arturadib / strapdown

Instant and elegant Markdown documents in the browser
http://strapdownjs.com
MIT License
2.48k stars 410 forks source link

Added possibility to put the markdown in a separate file #21

Closed didiercrunch closed 11 years ago

didiercrunch commented 11 years ago

Using the html5 data-* attributes, I added the possibility to put the markdown in a separate file.

For example, the two following snippets render the same thing. The only difference is that the markdown of the first snippet is in the file _hellostrapdown.js

<!DOCTYPE html>
<html>
<title>Hello Strapdown</title>

<body>
    <script src="v/0.3/strapdown.js" data-theme="simplex" data-style="display:none;" data-src="hello_strapdown.md"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<title>Hello Strapdown</title>

<xmp theme="united" style="display:none;">
# Markdown text goes in here

## Chapter 1

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. 

## Chapter 2

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</xmp>

<script src="http://strapdownjs.com/v/0.2/strapdown.js"></script>
</html>

The markdown source needs to be specified by a data-src attribute of the script tag. All other attributes of the script tag that starts with "data-" will be set to the xmp tag without the "data-".

I have not update the index.html. I am aware of cross origin problem when only using files.

arturadib commented 11 years ago

Hi thanks for the contribution. I think this is beyond the scope of what I was trying to do. The main reason is that it makes the page non-indexable by search engines (since the content is on a separate file) and slow to load.

A bit of feedback anyway:

Thanks again, I appreciate the effort!