Closed MichaelMure closed 4 years ago
On the subject of links, it seems that there is no way in the AST to distinguish a complete link ([text](/url/)
) from a reference ([ref]
). Also a nice to have I think.
Another thing you might find interesting. I needed to visualize the possible cases in the AST, how node types relate to each other, so I generated this diagram from my test cases. It's not perfect, some cases are missing (notably how much garbage can be added in a link's text) but it's helpful. Might be handy for your documentation.
On the subject of links, it seems that there is no way in the AST to distinguish a complete link
[text](/url/)
from a reference ([ref]). Also a nice to have I think.
~Not the author but I'm currently digging through the source code to implement citations, e.g. [pg 3, @bibtex-key]
. I think the trouble is that link references are implemented as a paragraph transformer. I'm guessing that's probably the case because goldmark can't know if there's a corresponding definition for a short reference. The commonmark demo shows that for:~
[foo]
[bar]
[bar]: example.com
[foo] is the literal text [foo]
and [bar]
is a LinkReference.
After a bit more digging, I think what's actually happening for links is:
[foo]: http://example.com
in the parser context.[foo]
, by checking the parser context. If a link exists the short reference link is promoted to a full link.So, the request was instead of transforming a short reference link into a full link to differentiate with something like ShortRefLink
?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is more a FYI than a real issue.
I'm writing a Markdown renderer specialized for the terminal and I'm in the process of migrating to goldmark. If you are curious, you can have a look at https://github.com/MichaelMure/go-term-markdown/pull/20 (not merged yet).
First thing first, thanks for your work :)
I just wanted to document for you some of the struggle I had. Feel free to dismiss that entirely, it's just ideas throw over the fence:
parser
package would expose some helper to create a default parser or a GFM one.Blockquote
andList
would be convenient.TextBlock
with no lines, attached to the root. I'm able to detect that but a specific node type would make things much cleaner.RawHTML
nodes for each HTML tag. In my case it's a problem because I want to interpret some of that HTML (lists for example) to render them as well. This means that I would have to reconstruct first the HTML section before interpreting it. It'd be nice if the parser was able to distinguish those section and output a singleRawHTML
node. In the following example,item1
anditem2
would not beText
but be part of thisRawHTML
because the tags are unmatched at this point.Thank you!