markdown-it-attrs
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -7,3 +7,3 @@ 'use strict'; | ||
var src = '# header {.style-me}\n' | ||
var src = '# header {.style-me}\n'; | ||
src += 'paragraph {data-toggle=modal}'; | ||
@@ -13,2 +13,2 @@ | ||
console.log(res); | ||
console.log(res); // eslint-disable-line |
@@ -55,9 +55,9 @@ 'use strict'; | ||
} | ||
var attrs = utils.getAttrs(inlineTokens[j].content, 1, endChar); | ||
if (attrs.length !== 0) { | ||
var inlineAttrs = utils.getAttrs(inlineTokens[j].content, 1, endChar); | ||
if (inlineAttrs.length !== 0) { | ||
// remove {} | ||
inlineTokens[j].content = inlineTokens[j].content.substr(endChar + 1); | ||
// add attributes | ||
attrToken.info = "b"; | ||
utils.addAttrs(attrs, attrToken); | ||
attrToken.info = 'b'; | ||
utils.addAttrs(inlineAttrs, attrToken); | ||
} | ||
@@ -64,0 +64,0 @@ } |
@@ -56,9 +56,9 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownItAttrs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
} | ||
var attrs = utils.getAttrs(inlineTokens[j].content, 1, endChar); | ||
if (attrs.length !== 0) { | ||
var inlineAttrs = utils.getAttrs(inlineTokens[j].content, 1, endChar); | ||
if (inlineAttrs.length !== 0) { | ||
// remove {} | ||
inlineTokens[j].content = inlineTokens[j].content.substr(endChar + 1); | ||
// add attributes | ||
attrToken.info = "b"; | ||
utils.addAttrs(attrs, attrToken); | ||
attrToken.info = 'b'; | ||
utils.addAttrs(inlineAttrs, attrToken); | ||
} | ||
@@ -174,2 +174,3 @@ } | ||
},{"./utils.js":2}],2:[function(require,module,exports){ | ||
'use strict'; | ||
/** | ||
@@ -198,6 +199,6 @@ * parse {.class #id key=val} strings | ||
for (var i=start; i <= end; ++i) { | ||
var char = str.charAt(i); | ||
var char_ = str.charAt(i); | ||
// switch to reading value if equal sign | ||
if (char === keySeparator) { | ||
if (char_ === keySeparator) { | ||
parsingKey = false; | ||
@@ -208,3 +209,3 @@ continue; | ||
// {.class} | ||
if (char === classChar && key === '') { | ||
if (char_ === classChar && key === '') { | ||
key = 'class'; | ||
@@ -216,3 +217,3 @@ parsingKey = false; | ||
// {#id} | ||
if (char === idChar && key === '') { | ||
if (char_ === idChar && key === '') { | ||
key = 'id'; | ||
@@ -224,7 +225,7 @@ parsingKey = false; | ||
// {value="inside quotes"} | ||
if (char === '"' && value === '') { | ||
if (char_ === '"' && value === '') { | ||
valueInsideQuotes = true; | ||
continue; | ||
} | ||
if (char === '"' && valueInsideQuotes) { | ||
if (char_ === '"' && valueInsideQuotes) { | ||
valueInsideQuotes = false; | ||
@@ -235,3 +236,3 @@ continue; | ||
// read next key/value pair | ||
if ((char === pairSeparator && !valueInsideQuotes) || i === end) { | ||
if ((char_ === pairSeparator && !valueInsideQuotes) || i === end) { | ||
if (key === '') { | ||
@@ -249,3 +250,3 @@ // beginning or ending space: { .red } vs {.red} | ||
// continue if character not allowed | ||
if (parsingKey && char.search(allowedKeyChars) === -1) { | ||
if (parsingKey && char_.search(allowedKeyChars) === -1) { | ||
continue; | ||
@@ -256,9 +257,9 @@ } | ||
if (parsingKey) { | ||
key += char; | ||
key += char_; | ||
continue; | ||
} | ||
value += char; | ||
value += char_; | ||
} | ||
return attrs; | ||
} | ||
}; | ||
@@ -283,3 +284,3 @@ /** | ||
return token; | ||
} | ||
}; | ||
@@ -307,5 +308,5 @@ /** | ||
return str; | ||
} | ||
}; | ||
},{}]},{},[1])(1) | ||
}); |
{ | ||
"name": "markdown-it-attrs", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Add classes, identifiers and attributes to your markdown with {} curly brackets, similar to pandoc's header attributes", | ||
@@ -17,5 +17,6 @@ "license": "MIT", | ||
"browser": "browserify index.js --standalone markdown-it-attrs -o markdown-it-attrs.browser.js", | ||
"test": "mocha", | ||
"lint": "eslint .", | ||
"preversion": "mocha && npm run browser && git add markdown-it-attrs.browser.js", | ||
"postpublish": "git push && git push --tags" | ||
"postpublish": "git push && git push --tags", | ||
"test": "npm run lint && mocha" | ||
}, | ||
@@ -37,2 +38,3 @@ "homepage": "https://github.com/arve0/markdown-it-attrs", | ||
"browserify": "^13.0.0", | ||
"eslint": "^3.3.0", | ||
"markdown-it": "^6.0.2", | ||
@@ -39,0 +41,0 @@ "mocha": "*" |
27
utils.js
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/** | ||
@@ -24,6 +25,6 @@ * parse {.class #id key=val} strings | ||
for (var i=start; i <= end; ++i) { | ||
var char = str.charAt(i); | ||
var char_ = str.charAt(i); | ||
// switch to reading value if equal sign | ||
if (char === keySeparator) { | ||
if (char_ === keySeparator) { | ||
parsingKey = false; | ||
@@ -34,3 +35,3 @@ continue; | ||
// {.class} | ||
if (char === classChar && key === '') { | ||
if (char_ === classChar && key === '') { | ||
key = 'class'; | ||
@@ -42,3 +43,3 @@ parsingKey = false; | ||
// {#id} | ||
if (char === idChar && key === '') { | ||
if (char_ === idChar && key === '') { | ||
key = 'id'; | ||
@@ -50,7 +51,7 @@ parsingKey = false; | ||
// {value="inside quotes"} | ||
if (char === '"' && value === '') { | ||
if (char_ === '"' && value === '') { | ||
valueInsideQuotes = true; | ||
continue; | ||
} | ||
if (char === '"' && valueInsideQuotes) { | ||
if (char_ === '"' && valueInsideQuotes) { | ||
valueInsideQuotes = false; | ||
@@ -61,3 +62,3 @@ continue; | ||
// read next key/value pair | ||
if ((char === pairSeparator && !valueInsideQuotes) || i === end) { | ||
if ((char_ === pairSeparator && !valueInsideQuotes) || i === end) { | ||
if (key === '') { | ||
@@ -75,3 +76,3 @@ // beginning or ending space: { .red } vs {.red} | ||
// continue if character not allowed | ||
if (parsingKey && char.search(allowedKeyChars) === -1) { | ||
if (parsingKey && char_.search(allowedKeyChars) === -1) { | ||
continue; | ||
@@ -82,9 +83,9 @@ } | ||
if (parsingKey) { | ||
key += char; | ||
key += char_; | ||
continue; | ||
} | ||
value += char; | ||
value += char_; | ||
} | ||
return attrs; | ||
} | ||
}; | ||
@@ -109,3 +110,3 @@ /** | ||
return token; | ||
} | ||
}; | ||
@@ -133,2 +134,2 @@ /** | ||
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
23759
13
580
4