Skip to content

German umlauts break conversion #561

Closed

Description

@fanktom

The conversion of the german word for exercise:

# Übung

is converted to:

<h1 id="-bung-1">Übung 1</h1>

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).

Activity

  1. aroneiermann commented on Mar 27, 2015

    @aroneiermann

    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?

  2. fanktom commented on Mar 28, 2015

    @fanktom
    Author

    @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.

  3. aroneiermann commented on Mar 28, 2015

    @aroneiermann

    On my System (Ubuntu 14.04, with marked 0.3.3, and node 0.12.0 ) marked return the expected result.

  4. sansumbrella commented on Jul 9, 2015

    @sansumbrella

    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?

  5. aroneiermann commented on Jul 14, 2015

    @aroneiermann

    @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 &#196;.

  6. fanktom commented on Jul 20, 2015

    @fanktom
    Author

    @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..

  7. aroneiermann commented on Jul 23, 2015

    @aroneiermann

    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.

  8. sebastientromp commented on Mar 8, 2018

    @sebastientromp

    I'm facing a similar issue at the moment. Running console.log(marked("I'm happy")) in the console produces <p>I&#39;m happy</p>

  9. UziTech commented on Mar 8, 2018

    @UziTech
    Member

    @sebastientromp &#39; is the HTML entity for the ' (single quote) character. That is the intended behavior since marked outputs HTML not text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions