markdown-it-task-checkbox
Advanced tools
Comparing version 1.0.1 to 1.0.2
30
index.js
@@ -65,15 +65,11 @@ // Markdown-it plugin to render GitHub-style task lists; see | ||
id = options.idPrefix + lastId | ||
token.children.shift(); | ||
token.children.push(makeCheckbox(token, id, options, TokenConstructor)); | ||
// lable | ||
token.children.push(makeLable(id, TokenConstructor)); | ||
//text | ||
text = new TokenConstructor("text", "", 0); | ||
text.content = token.content.slice(3); | ||
token.children.push(text); | ||
token.content = ''; | ||
// token.children.push(new TokenConstructor("label_close", "label", -1)); | ||
token.children[0].content = token.children[0].content.slice(3); | ||
// label | ||
token.children.unshift(beginLabel(id, TokenConstructor)); | ||
token.children.push(endLabel(TokenConstructor)); | ||
// checkbox | ||
token.children.unshift(makeCheckbox(token, id, options, TokenConstructor)); | ||
if (options.divWrap) { | ||
token.children.unshift(beginLabel(options, TokenConstructor)); | ||
token.children.push(endLabel(TokenConstructor)); | ||
token.children.unshift(beginWrap(options, TokenConstructor)); | ||
token.children.push(endWrap(TokenConstructor)); | ||
} | ||
@@ -96,3 +92,3 @@ } | ||
function makeLable(id, TokenConstructor) { | ||
function beginLabel(id, TokenConstructor) { | ||
var label = new TokenConstructor('label_open', 'label', 1); | ||
@@ -103,5 +99,9 @@ label.attrs = [["for", id]]; | ||
function endLabel(TokenConstructor) { | ||
return new TokenConstructor("label_close", "label", -1); | ||
} | ||
// these next two functions are kind of hacky; probably should really be a | ||
// true block-level token with .tag=='label' | ||
function beginLabel(options, TokenConstructor) { | ||
function beginWrap(options, TokenConstructor) { | ||
var token = new TokenConstructor('checkbox_open', 'div', 0); | ||
@@ -112,3 +112,3 @@ token.attrs = [["class", options.divClass]]; | ||
function endLabel(TokenConstructor) { | ||
function endWrap(TokenConstructor) { | ||
var token = new TokenConstructor('checkbox_close', 'div', -1); | ||
@@ -115,0 +115,0 @@ // token.content = '</label>'; |
{ | ||
"name": "markdown-it-task-checkbox", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A markdown-it plugin to create GitHub-style task lists", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
75128
175