How do I get my parser to work by matching this very particular MarkDown? #1028
-
Hi! I need some help with this one, and don't really know how to continue. I would greatly appreciate any help. 😄 I have started creating an extension for some really specific Markdown that I have used at work. It isn't non-disclosable, as this is my personal extension that I plan on making fully public and open source plugin for my own markdown "static" site thing. Here is the gist of what I have plotted together for the time being: I have created a regex that matches with markdown that looks like this: [![latest release](https://gitlab.com/path/to/latest/release/badge.svg)](https://gitlab.com/path/to/download/link) As per regex101.com it seems like it would match that just fine: https://regex101.com/r/K93jNP/1 But once that regex goes through the InlineParserEngine, it's as if it gets lost in there somewhere. I don't really know why, but my conclusion is, since it doesn't run the
Don't mind the further methods in the DownloadLastTagParser.php in the gist, my goal is currently only to make it run the Again, I would be very grateful for any help on this matter. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi there! 👋 It looks like your Markdown syntax is already recognized and easily parsed by this library - it's just an image inside of a link. Instead of trying to write your own parser (that needs to compete with the built-in ones), it would be much easier to find and modify the parsed elements. See these docs on how to iterate and modify the parsed elements and this example of how to hook that logic up to the engine. In your case, it looks like you'll want to find any Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks @colinodell ! I haven't tried it yet, but reading through it, it seems to make sense, and should be somewhat easy to implement. 😄 Update: I completely forgot about this one, and found it in my old notifications. What was suggested worked like a dream. Listening for the DocumentParsed event, and finding the particular part I needed was much easier, and somewhat straight forward to implement. It worked, and there is no competing with parsers. 😄 |
Beta Was this translation helpful? Give feedback.
Hi there! 👋
It looks like your Markdown syntax is already recognized and easily parsed by this library - it's just an image inside of a link. Instead of trying to write your own parser (that needs to compete with the built-in ones), it would be much easier to find and modify the parsed elements.
See these docs on how to iterate and modify the parsed elements and this example of how to hook that logic up to the engine.
In your case, it looks like you'll want to find any
Link
containing a singleImage
child whoseText
is one of those four strings. You can then choose to modify or completely replace any/all of those elements as needed.Hope that helps!