-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
open links in new tab #79
Comments
Quickly there is two options that comes to my mind... 1. Use HTML directlySince Markdown support HTML you could use HTML for the links you want to open with <a href="http://example.com/" target="_blank">Hello, world!</a> 2. Extend
|
thanks @jfcere . it did work for me. |
thanks to @jfcere, I got an idea as how to approach this problem in In
|
Why not rewrite the renderer straight away?
Hm. How to escape backticks? |
I was able to make this work, but had to change the import as shown here: https://github.com/jfcere/ngx-markdown#markedoptionsrenderer
|
Today, this works
with
|
For anyone finding this looking for a solution like I did, this is what works when using marked v15 (which I suppose isn't really supported by ngx-markdown, but I haven't had any problems using it so far). export const markedOptionsFactory = (): MarkedOptions => {
const renderer = new MarkedRenderer();
renderer.link = ({href, text}): string => {
return `<a target="_blank" href="${href}">${text}</a>`;
};
return {
renderer: renderer,
gfm: true,
breaks: true,
pedantic: false
};
} And of course, use it in the providers-array in app.config.ts (or I guess in app.module.ts if you're using modules): export const appConfig: ApplicationConfig = {
providers: [
provideMarkdown({ markedOptions: { provide: MARKED_OPTIONS, useFactory: markedOptionsFactory } }),
]
} |
When embedding a link using markdown it opens in the same tab. Is there any way through which we can open the link in a new tab ?
The text was updated successfully, but these errors were encountered: