Replies: 15 comments 2 replies
-
We are trying to follow the common mark spec. We are focusing marked on creating html from markdown according to the spec and using extensions instead of options to change the behavior. |
Beta Was this translation helpful? Give feedback.
-
that's very disappointing, given how much bloat "extension" installs tend to carry. It's 2020, html entities for things like apostrophes make literally no sense (unlike the HTML4.01 era, where they kind of did, until UTF8 won). Right now, I'm stuck having to use the following code, which I can guarantee you is less bloat than an extension:
This should not be necessary, and should not be necessary out of the box. As such, I strongly object to the label added to this issue: this should absolutely not be an extension. Instead,
At the spec level, the word "can" does not mean "should" in the slightest. It means any parser may or may not do this and both options are spec-compliant. Forcing that option without user choice is not "following the spec", it's making the decision for your users, and this should absolutely be an option people should be able to set for |
Beta Was this translation helpful? Give feedback.
-
what should the following code display? document.body.innerHTML = marked("`&`"); if you think it should be |
Beta Was this translation helpful? Give feedback.
-
removing html entities doesn't make sense if the goal is to output html. |
Beta Was this translation helpful? Give feedback.
-
I didn't say to remove entities, I said that If the original code literally contains But if the original code does not already have html entities, such as To wit:
That really should be |
Beta Was this translation helpful? Give feedback.
-
That is the problem the amount of code that would be required to accurately only replace the ones that are needed would be huge and changing. Since |
Beta Was this translation helpful? Give feedback.
-
Creating an option that would accurately only replace the html entities that are needed would bloat the marked codebase which is why it would be better as an extension so most people who don't need that functionality would not need the extra code. |
Beta Was this translation helpful? Give feedback.
-
Except that it needlessly grows the content by quite a lot of bytes. That's not super important for short content, but I have two websites that are 120 and 400 page books, respectively: it makes a huge difference not turning relatively frequently used single letters into five or more letters. As for the code needing lots of changes, I'm not sure it does? There are only two characters that must be converted to html entities in order not to invalid HTML, namely (e.g. it feels like this would a matter of |
Beta Was this translation helpful? Give feedback.
-
marked does not convert Consider writing markdown that contains any html entity inside a code block: `©` marked converts this markdown to the html: If marked didn't convert Which is not the correct way to display that markdown. There are similar examples of how not converting This is just one example of many situations where marked would need to use html entities in order to display the correct output in a browser. The code required to 100% accurately only replace the ones that are needed would be incredibly complex, definitely not as easy as The decision to move to extensions instead of options was so that marked doesn't become a massive library catering to everyone's individual situations. With extensions there can be an millions of ways to change marked without the library becoming bloated for the majority of users who just need markdown turned into html. |
Beta Was this translation helpful? Give feedback.
-
If you would like to research the code needed to only convert html entities when needed I would be happy to help you develop an extension for marked. |
Beta Was this translation helpful? Give feedback.
-
I might, I'm in the process of completely rewriting https://pomax.github.io/bezierinfo atm anyway, which relies on |
Beta Was this translation helpful? Give feedback.
-
HTML entities are no longer needed in unicode right? This should be an option. We're having to replace them too... |
Beta Was this translation helpful? Give feedback.
-
I will be useful when markedjs is used as a library. like in vue or react. |
Beta Was this translation helpful? Give feedback.
-
Hello ! It is a bit late, but as an easy workaround, it is possible to use the package html-entities to replace entities to their equivalent HTML5 characters, with the |
Beta Was this translation helpful? Give feedback.
-
What I consider an architectural/design flaw is that HTML encoding happens during parse i.e. the CST already contains different text nodes. IMHO this should be part of the renderer, potentially with an option to turn off. I'm writing my own renderer and not interested in HTML at all - just using the CST and have to decode to original - but only if the original ( Please allow to disable this encoding. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
Marked currently turns things like single quotes, double quotes, ampersands, etc. into their html entity equivalent, and this has by and large not been necessary for a long time. Could an option please be added to turn this off, so that code that relies on
marked
doesn't need a long list of post-processing replacements to turn all those entities back into the real letters/characters/codepoints?Beta Was this translation helpful? Give feedback.
All reactions