Skip to content

HTML entities not generated properly in parsedown extensions #909

@toodlelew

Description

@toodlelew

Environment: Parsedown 1.7.4 in PHP 5.6.40.

Learning how to use Parsedown in order to use it into a PHP-based recipe program to manage recipe instructions.
I've used the example extension ("Add Inline Element") as a basis for a test to handle a markdown extension that will manage measurement unit conversions ("pounds" to "kilograms", "degrees Centigrade" to "degrees Fahrenheit", etc.). The initial test is to recognize a special markdown that indicates temperature in Fahrenheit, and expresses it as "° F".

The extension seems well-formed, properly recognizing the markdown, and (mostly) generating the expected HTML. However,
it does not properly generate the HTML for the ° entity,

Given the input
"Preheat the oven to {F}350{/F} and wait 10 minutes."
I expect the output HTML to be
<p>Preheat the oven to <em>350&deg; F</em> and wait 10 minutes.</p>

However, the invocation of the extension results in
<p>Preheat the oven to <em>350&amp;deg; F</em> and wait 10 minutes.</p>

See attached test php program

testparsedown.txt

It is worth noting that, If I enter the input
"Preheat the oven to 350&deg; F and wait 10 minutes."
directly into parsedown, I get the expected HTML output; parsedown does not convert the input ampersand to an entity

Note: 2024-03-01 edits to clarify expected, actual results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions