Is there a (preferably light-weight way) to include the raw contents of a markdown file in HTML?
I'm using remark.js to create a slideshow and I'd like to keep the markdown file separate from the HTML, so that the HTML is very simple (and does not change):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test</title>
<link rel="stylesheet" href="style.css">
<script src="https://gnab.github.io/remark/downloads/remark-latest.min.js"></script>
</head>
<body>
<textarea id="source">
>>'paste' markdown file test.md<<
</textarea>
<script>
var slideshow = remark.create({
highlightStyle: 'darkula',
highlightLines: true
});
</script>
</body>
</html>
Ideally this runs offline and on a local machine (without running a web server). The bit with 'paste' markdown file test.md' obviously does not work (hence my question). I've tried:
object data="test.md"
but that generates an ugly iframeAccording to remarkjs wiki you need to add below lines to include your markdown file
var slideshow = remark.create({
sourceUrl: 'markdown.md'
});
Below is a complete example
<!DOCTYPE html>
<html>
<head>
<title>A title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<script src="https://remarkjs.com/downloads/remark-latest.min.js" type="text/javascript">
</script>
<script type="text/javascript">
var slideshow = remark.create({
sourceUrl: 'your_file.md'
});
</script>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With