-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Inline HTML Code Blocks #50
Comments
Hello! It's probably worth clarifying what the My initial thought is that it could take in an explicit set of html handlers. Right now, it doesn't accept any HTML tags. But that's just that particular function, the library itself is fully extensible in you can handle HTML tags. Here's an example that builds off of the defaultHtmlRenderer and adds a https://ellie-app.com/9qnwgJFwWLha1 Does that do what you're looking for? Let me know how that goes. I think it's worth documenting which HTML tags (if any) are rendered in the default HTML renderer, and considering adding an explicit argument of HTML handlers, or perhaps accepted tags to render directly as HTML. |
Yes, that sample is similar to what I had been building, and my only real concern there is that it renders as Additionally, I think I surfaced another issue diagnosing this one. Specifically, if I wrap this https://ellie-app.com/9qpztJSgwhWa1 <section>
* 1
* 2<sup>2</sup>
* 2
</section> This unexpectedly renders to: <section>
<ul>
<li>1</li>
<li>2</li>
</ul>
<sup><p>2</p></sup>
<ul>
<li>2</li>
</ul>
</section> Notice the two By the way, thanks for your quick reply, and happy to help dive in to solve these issues! |
Digging into this a bit, when we parse a node like
Since that element breaks the unordered list when parsing blocks, whereas usually those elements would be a single unordered list and the html would be parsed as an inline. The solution would be to follow the GFM Spec 4.6 Subsection 6 "end condition" and break the HTML parsing after a blank line (as demonstrated in Example 118 which is failing in the current specs). That said, as you prefer good error handling instead of full correctness, I'm not sure if that approach is what you want (since we would do a worse job at explaining mismatched tags, etc). Or, alternatively, we could continue parsing full HTML but recombine the nodes back into larger text nodes after the HTML parse step. Or we could punt on this issue entirely. For what it's worth, this comes up in my project since I want to wrap large |
I've run into this same issue, in my case meaning I'm unable to use this package as I need lots of rich inline HTML. Example: Becomes Note the way |
Yeah, it's been on my radar that I'll need some way to take in raw text. Or at least that's one solution. Current BehaviorFor example, the current behavior is : Markdown.Html.tag "sup"
(\renderedChildren -> Html.sup [] renderedChildren)
] <p>2<sup><p>2</p></sup></p> Option 1We could add a function that gives you direct access to the raw text within the HTML, like this: Markdown.Html.tagWithRawText "sup"
(\rawText -> Html.sup [] [ Html.text rawText ])
] <p>2<sup>2</sup></p> Option 2I guess the other way to approach it could be to not wrap the rendered children in a paragraph tag. Markdown.Html.tag "sup"
(\renderedChildren -> Html.sup [] renderedChildren)
] <p>2<sup>2</sup></p> There are a lot of implications to think through for that case. It may turn out that the semantics are more intuitive and fit into the spec better. Or it may be that Option 2 isn't viable because it conflicts with the Markdown spec. I'd be curious to hear thoughts on that, though. Any other possibilities? Any initial impressions of those two options? |
@dillonkearns not sure if I'm just not understanding your proposed options, but it seems to me that nested tags should be parsed within their context, rather than always breaking out to the top level. I think @hayesgm articulated it nicely in his first post – it seems that any parsed Would it be possible to have it not do that, and nest just like Edit: re-reading the options you've proposed, it seems you're addressing the children of
Gets parsed as if you had typed
|
I believe there are actually two issues going on here: Issue 1 - Paragraph Wrapping
Example: The paragraph tag inside of Issue 2 - Invalid Parsing of Nested HTML TagsWhen nesting HTML tags, we parse HTML too early and significantly break rendering. Example: <section>
* 1
* 2<sup>2</sup>
* 3
</section> Renders to: <section>
<ul>
<li>1</li>
<li>2</li>
</ul>
<sup><p>2</p></sup>
<ul>
<li>3</li>
</ul>
</section> Notice the two |
I'm trying to use the extensible aspect of
elm-markdown
to add a<sup>
tag without forking the library.For example:
This is the standard GFM style, or so I've been told. I added a custom HTML extension as such:
However, this is being parsed and rendered as:
I am not sure this falls under standard GFM failures as it depends largely on the specifically extensibility features of this library. My expectation is that this would have been parsed and rendered as:
However, it appears in the current parsing data types (
Markdown.Block
), this data cannot be represented directly (e.g. we cannot nest anHtmlBlock
below aParagraph
). Would the right approach here be to fork and addsup
directly to the parser? At the end of the day, this limitation makes adding new extensible features a little difficult since they must always be top-level blocks.Thanks for making an awesome, pure Elm parser!
The text was updated successfully, but these errors were encountered: