Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkdownToHtml pipe shouldn't add additional HTML #15

Open
takahser opened this issue Nov 10, 2019 · 2 comments
Open

MarkdownToHtml pipe shouldn't add additional HTML #15

takahser opened this issue Nov 10, 2019 · 2 comments

Comments

@takahser
Copy link

Currently, when using the pipe the output HTML markup is wrapped in a <p> HTML paragraph.

Actual Output

<span>
    <p>
        foo <strong>bar</strong>
    </p>
</span>

Imho the expected behaviour is not to add any additional HTML.

Expected Output

<span>
    foo <strong>bar</strong>
</span>

In my case it made the layout change since I had some span text before which is now in a paragraph and became a block element.

Input

<span [innerHTML]="'foo **bar**' | MarkdownToHtml"></span>
@vknabel
Copy link
Contributor

vknabel commented Nov 11, 2019

Hi @takahser. Thanks for your report.

Unfortunetly the p-tag comes from marked and thus cannot be removed.

As a workaround you could set a class on your span to inline inner paragraphs.

.inline p {
  display: inline;
}

@larqitos
Copy link

@vknabel I took a look at the documentation for marked and noticed there is a way to output inline. They provide an inline lexer for this purpose. I am including the update in your code below, perhaps you can allow an option in your pipe to allow for inline output or with a wrapping p tag.

    MarkdownToHtmlPipe.prototype.transform = function (markdown, options) {
        if (markdown == null)
            return '';
        return marked.inlineLexer(markdown, [], options);
    };

Found the information here: markedjs/marked#395

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

No branches or pull requests

3 participants