Closed qwerty287 closed 2 years ago
Hello @qwerty287 ,
if you want to substitute some links with shorthand variants (like #123
on Github) pre-processing markdown input is a good idea. Creating an inline parser with h
as a special character is not though 😄 . You can run your code (with regex or anything else) before sending to Markwon
. Thus you can use markdown syntax and just create representation as you like.
For example, https://example.com/some_dude
can be replaced in your raw markdown with [@some_dude](https://example.com/some_dude)
. And Markwon
will take care of the rest (to display and handle clicks)
Thanks! Yes, that's my way currently too. My only concern with it is that this will also replace links in code blocks, which I would like to prevent. Is this possible, with regex or another solution? Unfortunately, regex does not allow signs like *
and +
in lookbehinds, so I would have to use some regex like (\S*)https://example.com/(\S+)(\S*)
with ``` lookbehinds/aheads) and substitute it by $1@$2$3
?
Yeah, exclude URLs from code blocks with regex might be almost impossible. Maybe you could use a similar to the autolink approach? It post-processes parsed markdown by inspecting Text
nodes and replaces found links with proper Link
s
This is working, thanks!
Thanks for the nice library! I habe a question, not necessarily related to only Markwon, but how can I short links/URLs? For example, GitHub is doing this with issue/PR links:
https://github.com/user/repo/issue/123
becomes#123
. Is there any way to do this? You could use an inline parser, but this requires a special char and giving ah
(fromhttps
) or using regex to replace the links before parsing, doesn't seem to be a good idea. Is there any other way?