markdown-it-attrs
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -51,2 +51,3 @@ 'use strict'; | ||
// add attributes | ||
attrToken.info = "b"; | ||
utils.addAttrs(attrs, attrToken); | ||
@@ -69,4 +70,12 @@ } | ||
md.core.ruler.push('curly_attributes', curlyAttrs); | ||
// render inline code blocks with attrs | ||
md.renderer.rules.code_inline = renderCodeInline; | ||
}; | ||
function renderCodeInline(tokens, idx, _, __, slf) { | ||
var token = tokens[idx]; | ||
return '<code'+ slf.renderAttrs(token) +'>' | ||
+ utils.escapeHtml(tokens[idx].content) | ||
+ '</code>'; | ||
} | ||
/** | ||
@@ -73,0 +82,0 @@ * test if inline token has proper formated curly end |
{ | ||
"name": "markdown-it-attrs", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Add classes, identifiers and attributes to your markdown with {} curly brackets, similar to pandoc's header attributes", | ||
@@ -17,4 +17,3 @@ "license": "MIT", | ||
"test": "mocha", | ||
"prepublish": "mocha", | ||
"postpublish": "git tag v$npm_package_version; git push --tags; git push" | ||
"prepublish": "mocha" | ||
}, | ||
@@ -21,0 +20,0 @@ "homepage": "https://github.com/arve0/markdown-it-attrs", |
23
utils.js
@@ -99,1 +99,24 @@ /** | ||
} | ||
/** | ||
* from https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js | ||
*/ | ||
var HTML_ESCAPE_TEST_RE = /[&<>"]/; | ||
var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g; | ||
var HTML_REPLACEMENTS = { | ||
'&': '&', | ||
'<': '<', | ||
'>': '>', | ||
'"': '"' | ||
}; | ||
function replaceUnsafeChar(ch) { | ||
return HTML_REPLACEMENTS[ch]; | ||
} | ||
exports.escapeHtml = function(str) { | ||
if (HTML_ESCAPE_TEST_RE.test(str)) { | ||
return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar); | ||
} | ||
return str; | ||
} |
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
11348
11
228