strapdown
strapdown copied to clipboard
Load from text file using jquery
Hey guys. Is there a way to load markdown plain text from a text file using jquery .get?
Here's my code for reference:
<!doctype html>
<html>
<div id="article"></div>
<script src="http://strapdownjs.com/v/0.2/strapdown.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.get("mytextfile.txt", function(data) {
var markdown = "<xmp theme=\"readable\" style=\"display:none;\">";
markdown += data;
markdown += "</xmp>";
$("#article").html(markdown);
});
});
</script>
</html>
This doesn't seem to work. Console log returns TypeError: markdownEl is undefined. Any idea how to fix this?
strapdown.js must run after. :/
Hi. I had a similar issue. So I wrapped strapdown.js into a function that I can call when it is convenient. Here is my fork https://github.com/dmelo/strapdown/tree/dmelo .
Now, you have to call window.strapdown() to make it parse the markdown. I will make a PR as soon as I implement it on a backward compatible way.