Skip to content

Converting HTML to markdown doesn't appear to preserve HTML entities #431

@sebpowell

Description

@sebpowell

Consider the following HTML example:

<p>I think &amp;</p>

When I try converting this to Markdown using Turndown, I get the following output:

I think &

I guess I would expect Turndown to preserve HTML entities and to output something like this instead:

I think &amp;

I couldn't see an option to turn this on, so unless I'm missing something, I assume I need to use something like https://www.npmjs.com/package/html-entities. But I just wanted to check I'm not missing anything obvious?

Here's the config I'm using:

const INITIAL_TURNDOWN_OPTIONS: Turndown.Options = {
  headingStyle: "atx",
  hr: "---",
  bulletListMarker: "-",
  codeBlockStyle: "fenced",
  fence: "```",
  emDelimiter: "_",
  strongDelimiter: "**",
  linkStyle: "inlined",
};

Any help much appreciated!

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