Browse Source

Added link target attribute support for plugins

pull/24/head
Vitaly Puzrin 10 years ago
parent
commit
56001200c0
  1. 3
      lib/renderer.js
  2. 1
      lib/rules_core/linkify.js
  3. 2
      lib/rules_inline/autolink.js
  4. 1
      lib/rules_inline/links.js

3
lib/renderer.js

@ -143,7 +143,8 @@ rules.paragraph_close = function (tokens, idx /*, options, env */) {
rules.link_open = function (tokens, idx /*, options, env */) {
var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : '';
return '<a href="' + escapeHtml(tokens[idx].href) + '"' + title + '>';
var target = tokens[idx].target ? (' target="' + escapeHtml(tokens[idx].target) + '"') : '';
return '<a href="' + escapeHtml(tokens[idx].href) + '"' + title + target + '>';
};
rules.link_close = function (/* tokens, idx, options, env */) {
return '</a>';

1
lib/rules_core/linkify.js

@ -132,6 +132,7 @@ module.exports = function linkify(state) {
nodes.push({
type: 'link_open',
href: links[ln].url,
target: '',
title: '',
level: level++
});

2
lib/rules_inline/autolink.js

@ -33,6 +33,7 @@ module.exports = function autolink(state, silent) {
state.push({
type: 'link_open',
href: fullUrl,
target: '',
level: state.level
});
state.push({
@ -60,6 +61,7 @@ module.exports = function autolink(state, silent) {
state.push({
type: 'link_open',
href: fullUrl,
target: '',
level: state.level
});
state.push({

1
lib/rules_inline/links.js

@ -160,6 +160,7 @@ module.exports = function links(state, silent) {
state.push({
type: 'link_open',
href: href,
target: '',
title: title,
level: state.level++
});

Loading…
Cancel
Save