-
Notifications
You must be signed in to change notification settings - Fork 18
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
Links default to target="_blank" ? #13
Comments
You can override the rules (i use typescript). I took this function from "src/rules/link.js" in this project. <vue-simple-markdown :source="component" :postrender="postRender" /> methods: {
postRender(source: string) {
const LINK_REGEX = /\[(.+?)\]\(((?:(http[s]?|ftp):\/{2})?[\w\/\-+?#=.:!%&]+)\)/g;
return source.replace(LINK_REGEX, "<a href="$2">$1</a>");
}
} |
@Spanri postrender happens after the links have already been converted to the target blank links |
Has anyone solved this issue? I've tried writing a regex in the |
I think it's a better idea to parse and edit the HTML with the DOM API. E.g. function removeTargetBlank(htmldata) {
var container = document.createElement('div');
container.innerHTML = htmldata;
Array.from(container.querySelectorAll('a[target="_blank"]')).forEach(link => link.removeAttribute('target'));
return container.innerHTML;
} |
All links (even internal) seem to default to target="_blank", which is not nice for internal links.
I do not see any option to configure that
The text was updated successfully, but these errors were encountered: