remark-comments
Advanced tools
Comparing version 1.0.11 to 1.1.0
@@ -14,6 +14,10 @@ 'use strict'; | ||
function plugin() { | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref$beginMarker = _ref.beginMarker, | ||
beginMarker = _ref$beginMarker === undefined ? 'COMMENTS' : _ref$beginMarker, | ||
_ref$endMarker = _ref.endMarker, | ||
endMarker = _ref$endMarker === undefined ? 'COMMENTS' : _ref$endMarker; | ||
var beginMarker = beginMarkerFactory(opts.beginMarker); | ||
var endMarker = endMarkerFactory(opts.endMarker); | ||
beginMarker = beginMarkerFactory(beginMarker); | ||
endMarker = endMarkerFactory(endMarker); | ||
@@ -25,3 +29,2 @@ function locator(value, fromIndex) { | ||
function inlineTokenizer(eat, value, silent) { | ||
var keepBegin = value.indexOf(beginMarker); | ||
@@ -35,3 +38,7 @@ var keepEnd = value.indexOf(endMarker); | ||
var comment = value.substring(beginMarker.length + 1, keepEnd - 1); | ||
return eat(beginMarker + SPACE + comment + SPACE + endMarker); | ||
return eat(beginMarker + SPACE + comment + SPACE + endMarker)({ | ||
type: 'comments', | ||
data: { comment: comment }, | ||
value: '' | ||
}); | ||
} | ||
@@ -47,4 +54,13 @@ inlineTokenizer.locator = locator; | ||
inlineMethods.splice(inlineMethods.indexOf('text'), 0, 'comments'); | ||
var Compiler = this.Compiler; | ||
if (Compiler) { | ||
var visitors = Compiler.prototype.visitors; | ||
if (!visitors) return; | ||
visitors.comments = function (node) { | ||
return beginMarker + SPACE + node.data.comment + SPACE + endMarker; | ||
}; | ||
} | ||
} | ||
module.exports = plugin; |
{ | ||
"name": "remark-comments", | ||
"version": "1.0.11", | ||
"version": "1.1.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "url": "https://github.com/zestedesavoir/zmarkdown/tree/master/packages/remark-comments", |
@@ -7,3 +7,3 @@ # remark-comments [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] | ||
You can write comments in the Markdown source this way: | ||
You can insert comments in the Markdown source this way: | ||
@@ -14,3 +14,3 @@ ```markdown | ||
Everything between `<--COMMENTS` and `COMMENTS-->` will be absent from the output. | ||
Everything between `<--COMMENTS` and `COMMENTS-->` will be absent from the HTML output. Compiling to Markdown will preserve all comments. | ||
@@ -17,0 +17,0 @@ ## Installation |
@@ -5,5 +5,5 @@ const beginMarkerFactory = (marker = 'COMMENTS') => `<--${marker}` | ||
function plugin (opts = {}) { | ||
const beginMarker = beginMarkerFactory(opts.beginMarker) | ||
const endMarker = endMarkerFactory(opts.endMarker) | ||
function plugin ({beginMarker = 'COMMENTS', endMarker = 'COMMENTS'} = {}) { | ||
beginMarker = beginMarkerFactory(beginMarker) | ||
endMarker = endMarkerFactory(endMarker) | ||
@@ -15,3 +15,2 @@ function locator (value, fromIndex) { | ||
function inlineTokenizer (eat, value, silent) { | ||
const keepBegin = value.indexOf(beginMarker) | ||
@@ -25,3 +24,7 @@ const keepEnd = value.indexOf(endMarker) | ||
const comment = value.substring(beginMarker.length + 1, keepEnd - 1) | ||
return eat(beginMarker + SPACE + comment + SPACE + endMarker) | ||
return eat(beginMarker + SPACE + comment + SPACE + endMarker)({ | ||
type: 'comments', | ||
data: {comment}, | ||
value: '', | ||
}) | ||
} | ||
@@ -37,4 +40,13 @@ inlineTokenizer.locator = locator | ||
inlineMethods.splice(inlineMethods.indexOf('text'), 0, 'comments') | ||
const Compiler = this.Compiler | ||
if (Compiler) { | ||
const visitors = Compiler.prototype.visitors | ||
if (!visitors) return | ||
visitors.comments = (node) => { | ||
return beginMarker + SPACE + node.data.comment + SPACE + endMarker | ||
} | ||
} | ||
} | ||
module.exports = plugin |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7616
89