<script src="/markdown-it.min.js"></script>
<script src="/jquery-3.5.1.min.js"></script>
<script>
$(function() {
var mdit = window.markdownit();
mdit.options.html=true;
// Process all div elements of class include. Follow up with custom callback
$('div.include').each( function() {
var inc = $(this);
// Use contents between div tag as the file to be included from server
var filename = inc.html();
// Unable to intercept load() contents. post-process markdown rendering with callback
inc.load(filename, function () {
inc.html( mdit.render(this.innerHTML) );
});
});
})
</script>
</head>
<body>
<h1>Master Document </h1>
<h1>Section 1</h1>
<div class="include">sec_1.md</div>
<hr/>
<h1>Section 2</h1>
<div class="include">sec_2.md</div>
This is the content of the main Markdown file `main.md`.
Below this line, the content of the file `chapter01.md` is included:
```{.python .cb.run}
with open('chapter01.md') as fp:
print(fp.read())
```
This line is printed below the external content.