Include HTML markup file content for remark.js

Is there (preferably an easy way) to include the original contents of the markdown file in HTML?

I use remark.js to create a slide show, and I would like to leave the markup file separate from the HTML, so the HTML is very simple (and doesn't change):

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Test</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://gnab.imtqy.com/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 is done autonomously and on the local computer (without starting the web server). The “paste” markdown file test.md bit obviously doesn't work (hence my question). I tried:

  • object data="test.md"but generates an ugly iframe
  • This is a solution , but I just got a blank page (I used CDN for jQuery).
+4
source share
1 answer

remarkjs wiki ,

var slideshow = remark.create({
  sourceUrl: 'markdown.md'
});

<!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>
0

Source: https://habr.com/ru/post/1666582/


All Articles