Naereen / StrapDown.js

:sparkles: StrapDown.js is an awesome javascript tool to quickly publish nice-looking web-pages in pure Markdown :pencil:, with no server side compilation :sunglasses: →
https://naereen.github.io/StrapDown.js/
MIT License
108 stars 45 forks source link

xmp must be child of body #1

Closed steegness closed 7 years ago

steegness commented 8 years ago

As referenced here in the original project, it seems as though the xmp or textarea currently MUST be a direct child of the body tag to work. A change to the replaceChild() calls seems as though it can fix this.

Naereen commented 8 years ago

Hi, I never experienced the issue, but I usually use my StrapDown.js on a pure-Markdown page so I'm not surprised that it could need such a trick for a more general setting.

I will test and then merge your suggestion, thanks.

steegness commented 8 years ago

The change as written (changing the document.body.replaceChild) works: once. That's because of this line: var markdownEl = document.getElementsByTagName("xmp")[0] || (document.getElementsByTagName("pre")[0] || document.getElementsByTagName("textarea")[0]);

Likely a separate issue, but something I noticed while I was testing things out.

Naereen commented 8 years ago

Hi again, Thanks for your suggestion, the change has been done here, 04124c0.