miaolz123 / vue-markdown

A Powerful and Highspeed Markdown Parser for Vue
https://miaolz123.github.io/vue-markdown/
MIT License
1.91k stars 258 forks source link

Anchor tags options #35

Closed printscreen closed 7 years ago

printscreen commented 7 years ago

Purpose of this PR is to add in the ability to define attributes you want on anchor tags. The problem I am trying to solve is

  1. Open links in a new tab (Solved in version 2.1.4)
  2. Also protect against target="_blank" XSS attacks

To use this new attribute, it might look something like this

<template>
    <vue-markdown :anchorAttributes="anchorAttributes">{{ text }}</vue-markdown>
</template>
<script>
export default {
    data: () {
        anchorAttributes: {
            target: '_blank',
            rel: 'noopener noreferrer nofollow'
        }
    }
}
</script>

Please comment with any suggestions or improvements you would like to see.

printscreen commented 7 years ago

@miaolz123 @nikolasp This is what I was thinking in my last comment.

miaolz123 commented 7 years ago

@printscreen It look great !

Can I merge this PR into version 2.2.1 because this PR has a little break change ?

printscreen commented 7 years ago

Oh, that makes sense since i did replace a property, thus changing the API to the component. Yeah, it should have a minor version bump. You are right. You want me to make that change?

miaolz123 commented 7 years ago

@printscreen I just think it'll be better to add an example in ./example/simple/index.html.

printscreen commented 7 years ago

Ok, i will bump the version to 2.2.1 and update the ./example/simple/index.html file

miaolz123 commented 7 years ago

@printscreen yes, you can just change the version.

miaolz123 commented 7 years ago

@printscreen and add you name at Contributions in ./README.md.

printscreen commented 7 years ago

@miaolz123 Ok, updated

nikolasp commented 7 years ago

@printscreen This is great... Flexible and elegant solution.