-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[markdown_to_html] option to open external links in another tab #4288
Comments
The conversion of markdown to HTML is not performed by Twig itself. The MarkdownExtension relies on an external markdown engine (see the MarkdownInterface and its different implementations for the supported engines). Some of those engines may be providing such extension points. |
If you use commonmark you can use the You have to create your own factory:
League\CommonMark\Extension\ExternalLink\ExternalLinkExtension:
tags:
- { name: 'twig.markdown.league_extension' }
twig.markdown.league_common_mark_converter_factory:
class: App\YourLeagueCommonMarkConverterFactory I haven't tried it, but the principle looks something like this. What I don't like about the solution is that you need your own factory to configure the CommonMark environment. This could be improved. The config argument should be a param to configure the environment. |
I found the PR that fixes the complicated setup: #3737 |
Thanks, @connorhu! |
Is there a way to add an option so that external link have a
target="blank"
added to the a tag?I know I can simply embed html instead, but this seems like a handy feature.
Extending that idea, is there a way I can intercept and render any link tag? For styling, adding an icon, etc.?
The text was updated successfully, but these errors were encountered: