mixmark-io / turndown

🛏 An HTML to Markdown converter written in JavaScript
https://mixmark-io.github.io/turndown
MIT License
8.88k stars 879 forks source link

Potential issues with other concatenated codes (must add "!" at start) #169

Closed n457 closed 6 years ago

n457 commented 8 years ago

to-markdown can trigger an issue with other concatenated codes :

image

Solution : adding ! before the first function, like other libs :

image

domchristie commented 8 years ago

Hmm. Does the code above end with a semi-colon?

n457 commented 8 years ago

Nope, the lib code above doesn't end with a ;, that's the problem. But as you can see in the screenshot below, it seems that beginning the first function of a library with a ! or a ; is some sort of convention, avoiding this kind of lib concatenation issues.

image

My project is using all of those following concatenated libs and after taking a look in all of them individually, most of them begin with a ! or ;. For the others, it's pure luck that the whole code works : the previous concatenated lib has an ending ;

PS : to-markdown.custom.js means that i had a ! myself

image

domchristie commented 8 years ago

Ah, OK. This library uses https://github.com/substack/node-browserify to build the browser version, which does not add a trailing ; or !. There may be an a way to customise this with the browserify JavaScript API (with wrap?) If you fancy looking into this, I'd welcome a pull request.

domchristie commented 6 years ago

Turndown v4 (an upcoming version of this library), uses rollup to build the browser version (https://unpkg.com/turndown/dist/turndown.js), and so should be fixed once released. Thanks for raising this.