Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load from text file using jquery #67

Open
aemxn opened this issue Jun 4, 2016 · 2 comments
Open

Load from text file using jquery #67

aemxn opened this issue Jun 4, 2016 · 2 comments

Comments

@aemxn
Copy link

aemxn commented Jun 4, 2016

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?

@joedf
Copy link

joedf commented Jun 5, 2016

strapdown.js must run after. :/

@dmelo
Copy link

dmelo commented Jun 29, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants