You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when no charset is given. With the <meta charset="UTF-8"> it is converted to:
<h1 id="-bung-1">Übung 1</h1>
where the id is wrong and should be übung-1 instead of -bung-1.
In any way, the Ü (German umlauts) break the conversion. They work out of the box in any standard HTML5 document when entered directly (with meta charset absent).
@juaron The default HTML5 charset is UTF-8. If I do not specify the meta tag at all and convert the markdown #Übung and add it to the body, the resulting string is <h1 id="-bung-1">Übung 1</h1>.
It should be <h1 id="übung-1">Übung 1</h1>.
The HTML is saved using UTF-8. If I add the meta tag with UTF-8 to the header, the resulting markdown is: <h1 id="-bung-1">Übung 1</h1>.
From my point of view, it should work without specifying an encoding tag at all, as the default HTML encoding is UTF-8.
This seems to be a broader issue with UTF-8 support. On github, my markdown documents render correctly, but using marked, ’, …, and other characters become mangled (becoming ’, and …, respectively).
Adding <meta charset="UTF-8"> into the <head> tag, as @aroneiermann suggested, does indeed result in correct interpretation on my end.
Since I can skip that declaration when the markdown is displayed on github, it suggests there a way that marked could make the output document be interpreted as UTF-8 automatically/by default. Does that seem feasible to you, @aroneiermann? Or do we cheat by being on github and having their document header?
@aroneiermann Yes, I get the same <h1 id="-bung">Übung</h1>. With UTF-8, I think the right result should be <h1 id="übung">Übung</h1>, as it works in URLs as well.
So I think this problem is part on the Browser end (you HAVE to declare UTF-8) which the specs say is standard with HTML5, part within the generation of the id tag which does not support UTF-8.
Do you think, the ID computation can be adapted to support UTF-8 easily?
I could give it a try, if you don't mind..
Multiple tests are failing after that 33e3980.
I think it prints valid HTML5 code (w3.org html5 documentation). But it is possible that the used markdown documentation says something other.
Activity
aroneiermann commentedon Mar 27, 2015
What do you mean with - when no charset is given?
How do you set a charset? Do you write the
<meta charset="UTF-8">directly in the markdown file?Which charset has the source file?
fanktom commentedon Mar 28, 2015
@juaron The default HTML5 charset is UTF-8. If I do not specify the meta tag at all and convert the markdown
#Übungand add it to the body, the resulting string is<h1 id="-bung-1">Übung 1</h1>.It should be
<h1 id="übung-1">Übung 1</h1>.The HTML is saved using UTF-8. If I add the meta tag with UTF-8 to the header, the resulting markdown is:
<h1 id="-bung-1">Übung 1</h1>.From my point of view, it should work without specifying an encoding tag at all, as the default HTML encoding is UTF-8.
aroneiermann commentedon Mar 28, 2015
On my System (Ubuntu 14.04, with marked 0.3.3, and node 0.12.0 )
markedreturn the expected result.sansumbrella commentedon Jul 9, 2015
This seems to be a broader issue with UTF-8 support. On github, my markdown documents render correctly, but using marked,
’,…, and other characters become mangled (becoming’, and…, respectively).Adding
<meta charset="UTF-8">into the<head>tag, as @aroneiermann suggested, does indeed result in correct interpretation on my end.Since I can skip that declaration when the markdown is displayed on github, it suggests there a way that marked could make the output document be interpreted as UTF-8 automatically/by default. Does that seem feasible to you, @aroneiermann? Or do we cheat by being on github and having their document header?
aroneiermann commentedon Jul 14, 2015
@sansumbrella The github header contains
<meta charset='utf-8'>.@southdesign The default HTML5 is UTF-8 and the default of HTML4 is ISO-8859-1 (also called Latin 1).
But I can still not reproduce this error.
Could you please run
console.log(marked("ä"))?When I run this I get that
<h1 id="-bung">Übung</h1>.A possible solution would be to use character entity. In special this mean replace
äwithÄ.fanktom commentedon Jul 20, 2015
@aroneiermann Yes, I get the same
<h1 id="-bung">Übung</h1>. With UTF-8, I think the right result should be<h1 id="übung">Übung</h1>, as it works in URLs as well.So I think this problem is part on the Browser end (you HAVE to declare UTF-8) which the specs say is standard with HTML5, part within the generation of the id tag which does not support UTF-8.
Do you think, the ID computation can be adapted to support UTF-8 easily?
I could give it a try, if you don't mind..
Replace only white spaces in heading id
aroneiermann commentedon Jul 23, 2015
Multiple tests are failing after that 33e3980.
I think it prints valid HTML5 code (w3.org html5 documentation). But it is possible that the used markdown documentation says something other.
sebastientromp commentedon Mar 8, 2018
I'm facing a similar issue at the moment. Running
console.log(marked("I'm happy"))in the console produces<p>I'm happy</p>UziTech commentedon Mar 8, 2018
@sebastientromp
'is the HTML entity for the'(single quote) character. That is the intended behavior since marked outputs HTML not text