Comparing version 0.0.2 to 0.1.1
@@ -40,19 +40,32 @@ module.exports = (function() { | ||
peg$c0 = function(lines) { | ||
if(lines == null) { | ||
return ''; | ||
} | ||
lines.push(m.closeOpenTags(null)); | ||
lines = lines.filter(function(e) { return e !== null; }).join('\n'); | ||
return ( | ||
'<!DOCTYPE html>\n' + | ||
'<html lang="en">\n' + | ||
lines + | ||
'</html>\n' | ||
); | ||
if(m.partial()) { | ||
return lines; | ||
} else { | ||
return ( | ||
'<!DOCTYPE html>\n' + | ||
'<html lang="en">\n' + | ||
lines + | ||
'</html>\n' | ||
); | ||
} | ||
}, | ||
peg$c1 = function(line) { | ||
peg$c1 = "partial", | ||
peg$c2 = { type: "literal", value: "partial", description: "\"partial\"" }, | ||
peg$c3 = function() { | ||
m.setIsPartial(); | ||
}, | ||
peg$c4 = function(line) { | ||
return line; | ||
}, | ||
peg$c2 = function() { | ||
peg$c5 = function() { | ||
return null; | ||
}, | ||
peg$c3 = function(ident, name, id, cb, prop, mut, il) { | ||
peg$c6 = function(ident, name, id, cb, prop, mut, il) { | ||
var tag = m.buildTag(ident, name, id, cb, prop, mut, il); | ||
@@ -67,60 +80,75 @@ var content = m.closeOpenTags(ident) + tag; | ||
}, | ||
peg$c4 = function() { | ||
peg$c7 = function() { | ||
// Simply eats the comment. | ||
return null; | ||
}, | ||
peg$c5 = function(ident, val) { | ||
peg$c8 = function(ident, val) { | ||
return m.buildContent(ident, val); | ||
}, | ||
peg$c6 = function(ident, val) { | ||
peg$c9 = function(ident, val) { | ||
return m.buildRawContent(ident, val); | ||
}, | ||
peg$c7 = function(val) { | ||
peg$c10 = function(val) { | ||
return val; | ||
}, | ||
peg$c8 = function(name, val) { | ||
peg$c11 = function(name, val) { | ||
return [name, val]; | ||
}, | ||
peg$c9 = { type: "other", description: "Letter A-Z" }, | ||
peg$c10 = /^[a-zA-Z]/, | ||
peg$c11 = { type: "class", value: "[a-zA-Z]", description: "[a-zA-Z]" }, | ||
peg$c12 = { type: "other", description: "Letter A-Z or - _" }, | ||
peg$c13 = /^[a-zA-Z0-9\-_]/, | ||
peg$c14 = { type: "class", value: "[a-zA-Z0-9-_]", description: "[a-zA-Z0-9-_]" }, | ||
peg$c15 = /^[ -~]/, | ||
peg$c16 = { type: "class", value: "[ -~]", description: "[ -~]" }, | ||
peg$c17 = /^[!-&(-<>-~]/, | ||
peg$c18 = { type: "class", value: "[!-&(-<>-~]", description: "[!-&(-<>-~]" }, | ||
peg$c19 = /^[ -&(-~]/, | ||
peg$c20 = { type: "class", value: "[ -&(-~]", description: "[ -&(-~]" }, | ||
peg$c21 = { type: "other", description: "Whitespace" }, | ||
peg$c22 = { type: "other", description: "Extended whitespace" }, | ||
peg$c23 = /^[ \t]/, | ||
peg$c24 = { type: "class", value: "[ \\t]", description: "[ \\t]" }, | ||
peg$c25 = { type: "other", description: "Line feed" }, | ||
peg$c26 = /^[\n]/, | ||
peg$c27 = { type: "class", value: "[\\n]", description: "[\\n]" }, | ||
peg$c28 = { type: "other", description: "Carriage return" }, | ||
peg$c29 = /^[\r]/, | ||
peg$c30 = { type: "class", value: "[\\r]", description: "[\\r]" }, | ||
peg$c31 = { type: "other", description: "Newline either windows or *nix" }, | ||
peg$c32 = { type: "other", description: "#" }, | ||
peg$c33 = "#", | ||
peg$c34 = { type: "literal", value: "#", description: "\"#\"" }, | ||
peg$c35 = { type: "other", description: "Backtick character" }, | ||
peg$c36 = "`", | ||
peg$c37 = { type: "literal", value: "`", description: "\"`\"" }, | ||
peg$c38 = "+", | ||
peg$c39 = { type: "literal", value: "+", description: "\"+\"" }, | ||
peg$c40 = { type: "other", description: "Equals sign" }, | ||
peg$c41 = "=", | ||
peg$c42 = { type: "literal", value: "=", description: "\"=\"" }, | ||
peg$c43 = { type: "other", description: "Single quote character" }, | ||
peg$c44 = "'", | ||
peg$c45 = { type: "literal", value: "'", description: "\"'\"" }, | ||
peg$c46 = { type: "other", description: "Question mark" }, | ||
peg$c47 = "?", | ||
peg$c48 = { type: "literal", value: "?", description: "\"?\"" }, | ||
peg$c49 = "-", | ||
peg$c50 = { type: "literal", value: "-", description: "\"-\"" }, | ||
peg$c12 = { type: "other", description: "string" }, | ||
peg$c13 = "'", | ||
peg$c14 = { type: "literal", value: "'", description: "\"'\"" }, | ||
peg$c15 = "\\", | ||
peg$c16 = { type: "literal", value: "\\", description: "\"\\\\\"" }, | ||
peg$c17 = function(seq) { | ||
return seq; | ||
}, | ||
peg$c18 = /^[ -&(-[\]-\u10FFFF]/, | ||
peg$c19 = { type: "class", value: "[\\x20-\\x26\\x28-\\x5B\\x5D-\\u10FFFF]", description: "[\\x20-\\x26\\x28-\\x5B\\x5D-\\u10FFFF]" }, | ||
peg$c20 = /^[ -\u10FFFF]/, | ||
peg$c21 = { type: "class", value: "[\\x20-\\u10FFFF]", description: "[\\x20-\\u10FFFF]" }, | ||
peg$c22 = { type: "other", description: "Letter A-Z" }, | ||
peg$c23 = /^[a-zA-Z]/, | ||
peg$c24 = { type: "class", value: "[a-zA-Z]", description: "[a-zA-Z]" }, | ||
peg$c25 = { type: "other", description: "Letter A-Z or - _" }, | ||
peg$c26 = /^[a-zA-Z0-9\-_]/, | ||
peg$c27 = { type: "class", value: "[a-zA-Z0-9-_]", description: "[a-zA-Z0-9-_]" }, | ||
peg$c28 = /^[ -~]/, | ||
peg$c29 = { type: "class", value: "[ -~]", description: "[ -~]" }, | ||
peg$c30 = /^[!-&(-<>-~]/, | ||
peg$c31 = { type: "class", value: "[!-&(-<>-~]", description: "[!-&(-<>-~]" }, | ||
peg$c32 = /^[ -&(-~]/, | ||
peg$c33 = { type: "class", value: "[ -&(-~]", description: "[ -&(-~]" }, | ||
peg$c34 = { type: "other", description: "Whitespace" }, | ||
peg$c35 = { type: "other", description: "Extended whitespace" }, | ||
peg$c36 = /^[ \t]/, | ||
peg$c37 = { type: "class", value: "[ \\t]", description: "[ \\t]" }, | ||
peg$c38 = { type: "other", description: "Line feed" }, | ||
peg$c39 = /^[\n]/, | ||
peg$c40 = { type: "class", value: "[\\n]", description: "[\\n]" }, | ||
peg$c41 = { type: "other", description: "Carriage return" }, | ||
peg$c42 = /^[\r]/, | ||
peg$c43 = { type: "class", value: "[\\r]", description: "[\\r]" }, | ||
peg$c44 = { type: "other", description: "Newline either windows or *nix" }, | ||
peg$c45 = { type: "other", description: "#" }, | ||
peg$c46 = "#", | ||
peg$c47 = { type: "literal", value: "#", description: "\"#\"" }, | ||
peg$c48 = { type: "other", description: "Backtick character" }, | ||
peg$c49 = "`", | ||
peg$c50 = { type: "literal", value: "`", description: "\"`\"" }, | ||
peg$c51 = "+", | ||
peg$c52 = { type: "literal", value: "+", description: "\"+\"" }, | ||
peg$c53 = { type: "other", description: "Equals sign" }, | ||
peg$c54 = "=", | ||
peg$c55 = { type: "literal", value: "=", description: "\"=\"" }, | ||
peg$c56 = { type: "other", description: "Single quote character" }, | ||
peg$c57 = { type: "other", description: "Question mark" }, | ||
peg$c58 = "?", | ||
peg$c59 = { type: "literal", value: "?", description: "\"?\"" }, | ||
peg$c60 = "-", | ||
peg$c61 = { type: "literal", value: "-", description: "\"-\"" }, | ||
peg$c62 = { type: "other", description: "Exclamation mark." }, | ||
peg$c63 = "!", | ||
peg$c64 = { type: "literal", value: "!", description: "\"!\"" }, | ||
peg$c65 = ".", | ||
peg$c66 = { type: "literal", value: ".", description: "\".\"" }, | ||
@@ -313,20 +341,70 @@ peg$currPos = 0, | ||
function peg$parseSTART() { | ||
var s0, s1, s2; | ||
var s0, s1, s2, s3; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
s2 = peg$parseLINE(); | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
s2 = peg$parseLINE(); | ||
s1 = peg$parseDEF_PARTIAL(); | ||
if (s1 === peg$FAILED) { | ||
s1 = null; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parseLINE(); | ||
if (s3 !== peg$FAILED) { | ||
while (s3 !== peg$FAILED) { | ||
s2.push(s3); | ||
s3 = peg$parseLINE(); | ||
} | ||
} else { | ||
s2 = peg$FAILED; | ||
} | ||
if (s2 === peg$FAILED) { | ||
s2 = null; | ||
} | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c0(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
s1 = peg$FAILED; | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
return s0; | ||
} | ||
function peg$parseDEF_PARTIAL() { | ||
var s0, s1, s2, s3; | ||
s0 = peg$currPos; | ||
s1 = peg$parseCHAR_EM(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c0(s1); | ||
if (input.substr(peg$currPos, 7) === peg$c1) { | ||
s2 = peg$c1; | ||
peg$currPos += 7; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c2); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseNL(); | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c3(); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
s0 = s1; | ||
@@ -359,3 +437,3 @@ return s0; | ||
peg$savedPos = s0; | ||
s1 = peg$c1(s1); | ||
s1 = peg$c4(s1); | ||
s0 = s1; | ||
@@ -375,3 +453,3 @@ } else { | ||
peg$savedPos = s0; | ||
s1 = peg$c2(); | ||
s1 = peg$c5(); | ||
} | ||
@@ -440,3 +518,3 @@ s0 = s1; | ||
peg$savedPos = s0; | ||
s1 = peg$c3(s1, s2, s3, s4, s5, s6, s7); | ||
s1 = peg$c6(s1, s2, s3, s4, s5, s6, s7); | ||
s0 = s1; | ||
@@ -498,10 +576,10 @@ } else { | ||
s4 = []; | ||
s5 = peg$parseASCII(); | ||
s5 = peg$parseUNICODE(); | ||
while (s5 !== peg$FAILED) { | ||
s4.push(s5); | ||
s5 = peg$parseASCII(); | ||
s5 = peg$parseUNICODE(); | ||
} | ||
if (s4 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c4(); | ||
s1 = peg$c7(); | ||
s0 = s1; | ||
@@ -529,3 +607,3 @@ } else { | ||
function peg$parseCONTENT() { | ||
var s0, s1, s2, s3, s4, s5; | ||
var s0, s1, s2, s3, s4; | ||
@@ -549,8 +627,3 @@ s0 = peg$currPos; | ||
s3 = peg$currPos; | ||
s4 = []; | ||
s5 = peg$parsePROP_ASCII_INNER(); | ||
while (s5 !== peg$FAILED) { | ||
s4.push(s5); | ||
s5 = peg$parsePROP_ASCII_INNER(); | ||
} | ||
s4 = peg$parseSTRING(); | ||
if (s4 !== peg$FAILED) { | ||
@@ -565,3 +638,3 @@ s3 = input.substring(s3, peg$currPos); | ||
peg$savedPos = s0; | ||
s1 = peg$c5(s1, s3); | ||
s1 = peg$c8(s1, s3); | ||
s0 = s1; | ||
@@ -616,6 +689,6 @@ } else { | ||
s6 = []; | ||
s7 = peg$parseASCII(); | ||
s7 = peg$parseUNICODE(); | ||
while (s7 !== peg$FAILED) { | ||
s6.push(s7); | ||
s7 = peg$parseASCII(); | ||
s7 = peg$parseUNICODE(); | ||
} | ||
@@ -629,3 +702,3 @@ if (s6 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c6(s1, s5); | ||
s1 = peg$c9(s1, s5); | ||
s0 = s1; | ||
@@ -669,3 +742,3 @@ } else { | ||
peg$savedPos = s0; | ||
s1 = peg$c7(s1); | ||
s1 = peg$c10(s1); | ||
} | ||
@@ -678,3 +751,3 @@ s0 = s1; | ||
function peg$parseTAG_ID() { | ||
var s0, s1, s2, s3, s4; | ||
var s0, s1, s2, s3, s4, s5; | ||
@@ -686,13 +759,25 @@ s0 = peg$currPos; | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$currPos; | ||
s4 = peg$parseID(); | ||
if (s4 !== peg$FAILED) { | ||
s3 = input.substring(s3, peg$currPos); | ||
} else { | ||
s3 = s4; | ||
} | ||
s3 = peg$parseCHAR_SQ(); | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c7(s3); | ||
s0 = s1; | ||
s4 = peg$currPos; | ||
s5 = peg$parseSTRING(); | ||
if (s5 !== peg$FAILED) { | ||
s4 = input.substring(s4, peg$currPos); | ||
} else { | ||
s4 = s5; | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parseCHAR_SQ(); | ||
if (s5 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c10(s4); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
@@ -720,26 +805,23 @@ peg$currPos = s0; | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseCHAR_BT(); | ||
s2 = peg$parseCHAR_DOT(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$currPos; | ||
s4 = []; | ||
s5 = peg$parseTAG_CLASS(); | ||
if (s5 !== peg$FAILED) { | ||
while (s5 !== peg$FAILED) { | ||
s4.push(s5); | ||
s5 = peg$parseTAG_CLASS(); | ||
s3 = peg$parseCHAR_SQ(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$currPos; | ||
s5 = peg$parseSTRING(); | ||
if (s5 !== peg$FAILED) { | ||
s4 = input.substring(s4, peg$currPos); | ||
} else { | ||
s4 = s5; | ||
} | ||
} else { | ||
s4 = peg$FAILED; | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s3 = input.substring(s3, peg$currPos); | ||
} else { | ||
s3 = s4; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parseCHAR_BT(); | ||
if (s4 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c7(s3); | ||
s0 = s1; | ||
s5 = peg$parseCHAR_SQ(); | ||
if (s5 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c10(s4); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
@@ -765,34 +847,2 @@ peg$currPos = s0; | ||
function peg$parseTAG_CLASS() { | ||
var s0, s1, s2, s3; | ||
s0 = peg$currPos; | ||
s1 = peg$parse_(); | ||
if (s1 === peg$FAILED) { | ||
s1 = null; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$currPos; | ||
s3 = peg$parseID(); | ||
if (s3 !== peg$FAILED) { | ||
s2 = input.substring(s2, peg$currPos); | ||
} else { | ||
s2 = s3; | ||
} | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c7(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
return s0; | ||
} | ||
function peg$parseTAG_MUTATOR() { | ||
@@ -815,3 +865,3 @@ var s0, s1, s2, s3, s4; | ||
peg$savedPos = s0; | ||
s1 = peg$c7(s3); | ||
s1 = peg$c10(s3); | ||
s0 = s1; | ||
@@ -835,3 +885,3 @@ } else { | ||
function peg$parseTAG_PROP() { | ||
var s0, s1, s2, s3, s4, s5, s6; | ||
var s0, s1, s2, s3, s4, s5; | ||
@@ -861,8 +911,3 @@ s0 = peg$currPos; | ||
s4 = peg$currPos; | ||
s5 = []; | ||
s6 = peg$parsePROP_ASCII_INNER(); | ||
while (s6 !== peg$FAILED) { | ||
s5.push(s6); | ||
s6 = peg$parsePROP_ASCII_INNER(); | ||
} | ||
s5 = peg$parseSTRING(); | ||
if (s5 !== peg$FAILED) { | ||
@@ -877,3 +922,3 @@ s4 = input.substring(s4, peg$currPos); | ||
peg$savedPos = s0; | ||
s1 = peg$c8(s2, s4); | ||
s1 = peg$c11(s2, s4); | ||
s0 = s1; | ||
@@ -905,3 +950,3 @@ } else { | ||
function peg$parseTAG_INLINED_CONTENT() { | ||
var s0, s1, s2, s3, s4, s5, s6, s7; | ||
var s0, s1, s2, s3, s4, s5, s6; | ||
@@ -918,8 +963,3 @@ s0 = peg$currPos; | ||
s5 = peg$currPos; | ||
s6 = []; | ||
s7 = peg$parsePROP_ASCII_INNER(); | ||
while (s7 !== peg$FAILED) { | ||
s6.push(s7); | ||
s7 = peg$parsePROP_ASCII_INNER(); | ||
} | ||
s6 = peg$parseSTRING(); | ||
if (s6 !== peg$FAILED) { | ||
@@ -934,3 +974,3 @@ s5 = input.substring(s5, peg$currPos); | ||
peg$savedPos = s0; | ||
s1 = peg$c7(s5); | ||
s1 = peg$c10(s5); | ||
s0 = s1; | ||
@@ -965,2 +1005,116 @@ } else { | ||
function peg$parseSTRING() { | ||
var s0, s1, s2, s3; | ||
peg$silentFails++; | ||
s0 = peg$currPos; | ||
s1 = peg$currPos; | ||
s2 = []; | ||
s3 = peg$parseCHAR(); | ||
while (s3 !== peg$FAILED) { | ||
s2.push(s3); | ||
s3 = peg$parseCHAR(); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s1 = input.substring(s1, peg$currPos); | ||
} else { | ||
s1 = s2; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c10(s1); | ||
} | ||
s0 = s1; | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c12); } | ||
} | ||
return s0; | ||
} | ||
function peg$parseCHAR() { | ||
var s0, s1, s2; | ||
s0 = peg$parseUNESCAPED(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parseESCAPE(); | ||
if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s2 = peg$c13; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c14); } | ||
} | ||
if (s2 === peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 92) { | ||
s2 = peg$c15; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c16); } | ||
} | ||
} | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c17(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} | ||
return s0; | ||
} | ||
function peg$parseESCAPE() { | ||
var s0; | ||
if (input.charCodeAt(peg$currPos) === 92) { | ||
s0 = peg$c15; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c16); } | ||
} | ||
return s0; | ||
} | ||
function peg$parseUNESCAPED() { | ||
var s0; | ||
if (peg$c18.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c19); } | ||
} | ||
return s0; | ||
} | ||
function peg$parseUNICODE() { | ||
var s0; | ||
if (peg$c20.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c21); } | ||
} | ||
return s0; | ||
} | ||
function peg$parseID() { | ||
@@ -1006,3 +1160,3 @@ var s0, s1, s2, s3; | ||
peg$silentFails++; | ||
if (peg$c10.test(input.charAt(peg$currPos))) { | ||
if (peg$c23.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1012,3 +1166,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c11); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -1018,3 +1172,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c9); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c22); } | ||
} | ||
@@ -1029,3 +1183,3 @@ | ||
peg$silentFails++; | ||
if (peg$c13.test(input.charAt(peg$currPos))) { | ||
if (peg$c26.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1035,3 +1189,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c14); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c27); } | ||
} | ||
@@ -1041,3 +1195,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c12); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c25); } | ||
} | ||
@@ -1051,3 +1205,3 @@ | ||
if (peg$c15.test(input.charAt(peg$currPos))) { | ||
if (peg$c28.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1057,3 +1211,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c16); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c29); } | ||
} | ||
@@ -1067,3 +1221,3 @@ | ||
if (peg$c17.test(input.charAt(peg$currPos))) { | ||
if (peg$c30.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1073,3 +1227,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c18); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c31); } | ||
} | ||
@@ -1083,3 +1237,3 @@ | ||
if (peg$c19.test(input.charAt(peg$currPos))) { | ||
if (peg$c32.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1089,3 +1243,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c20); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c33); } | ||
} | ||
@@ -1104,3 +1258,3 @@ | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c21); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c34); } | ||
} | ||
@@ -1141,3 +1295,3 @@ | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c22); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c35); } | ||
} | ||
@@ -1152,3 +1306,3 @@ | ||
peg$silentFails++; | ||
if (peg$c23.test(input.charAt(peg$currPos))) { | ||
if (peg$c36.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1158,3 +1312,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c37); } | ||
} | ||
@@ -1164,3 +1318,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c21); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c34); } | ||
} | ||
@@ -1175,3 +1329,3 @@ | ||
peg$silentFails++; | ||
if (peg$c26.test(input.charAt(peg$currPos))) { | ||
if (peg$c39.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1181,3 +1335,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c27); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c40); } | ||
} | ||
@@ -1187,3 +1341,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c25); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c38); } | ||
} | ||
@@ -1198,3 +1352,3 @@ | ||
peg$silentFails++; | ||
if (peg$c29.test(input.charAt(peg$currPos))) { | ||
if (peg$c42.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1204,3 +1358,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c30); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c43); } | ||
} | ||
@@ -1210,3 +1364,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c28); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c41); } | ||
} | ||
@@ -1242,3 +1396,3 @@ | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c31); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c44); } | ||
} | ||
@@ -1254,7 +1408,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 35) { | ||
s0 = peg$c33; | ||
s0 = peg$c46; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c34); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c47); } | ||
} | ||
@@ -1264,3 +1418,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c32); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c45); } | ||
} | ||
@@ -1276,7 +1430,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 96) { | ||
s0 = peg$c36; | ||
s0 = peg$c49; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c37); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
} | ||
@@ -1286,3 +1440,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c35); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c48); } | ||
} | ||
@@ -1297,7 +1451,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 43) { | ||
s0 = peg$c38; | ||
s0 = peg$c51; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c39); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c52); } | ||
} | ||
@@ -1313,7 +1467,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 61) { | ||
s0 = peg$c41; | ||
s0 = peg$c54; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c42); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
@@ -1323,3 +1477,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c40); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c53); } | ||
} | ||
@@ -1335,7 +1489,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s0 = peg$c44; | ||
s0 = peg$c13; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c45); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c14); } | ||
} | ||
@@ -1345,3 +1499,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c43); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
} | ||
@@ -1357,7 +1511,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 63) { | ||
s0 = peg$c47; | ||
s0 = peg$c58; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c48); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c59); } | ||
} | ||
@@ -1367,3 +1521,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c46); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c57); } | ||
} | ||
@@ -1378,7 +1532,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 45) { | ||
s0 = peg$c49; | ||
s0 = peg$c60; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c61); } | ||
} | ||
@@ -1389,3 +1543,37 @@ | ||
function peg$parseCHAR_EM() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.charCodeAt(peg$currPos) === 33) { | ||
s0 = peg$c63; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c62); } | ||
} | ||
return s0; | ||
} | ||
function peg$parseCHAR_DOT() { | ||
var s0; | ||
if (input.charCodeAt(peg$currPos) === 46) { | ||
s0 = peg$c65; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c66); } | ||
} | ||
return s0; | ||
} | ||
function Manager() { | ||
@@ -1395,2 +1583,3 @@ this.openTags = []; | ||
this.identSize = 4; // How many spaces count as an ident. | ||
this.isPartial = false; | ||
@@ -1406,2 +1595,10 @@ this.voidTags = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; | ||
Manager.prototype.setIsPartial = function(ident) { | ||
this.isPartial = true; | ||
} | ||
Manager.prototype.partial = function(ident) { | ||
return this.isPartial === true; | ||
} | ||
Manager.prototype.genIdent = function(level) { | ||
@@ -1408,0 +1605,0 @@ var space = ''; |
{ | ||
"name": "candor", | ||
"version": "0.0.2", | ||
"version": "0.1.1", | ||
"description": "A new way to write HTML, elegantly.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Candor | ||
A new way to write HTML, elegantly. | ||
[![Build Status](https://travis-ci.org/r3oath/Candor.svg?branch=master)](https://travis-ci.org/r3oath/Candor) | ||
[![Build Status](https://travis-ci.org/r3oath/candor.svg?branch=master)](https://travis-ci.org/r3oath/candor) | ||
# The Mission | ||
There are many preprocessors that make web development easier, such as LESS, SASS, Stylus, CoffeeScript etc. But there isn't much out there that makes writing HTML any easier, at least not in a elegant, generic and non-restrictive form that will work for most project requirements, regardless of framework... well, to an extent. | ||
So, I decided to make **Candor**. | ||
# Example | ||
@@ -17,5 +12,5 @@ ``` | ||
body | ||
div #app `container` | ||
div `row` | ||
div `col-xs-12 text-center` | ||
div #'app' .'container' | ||
div .'row' | ||
div .'col-xs-12 text-center' | ||
img src'images/sick.png' | ||
@@ -62,19 +57,26 @@ p = 'This is pretty sick!' | ||
# Usage | ||
At the moment the parser is available under `x.parse(...)`. There will be gulp and Laravel elixir plugins soon, which will make development with Candor much easier. For the time being though, if you'd like to play around the syntax rules are as follows: | ||
#### HTML Tags | ||
``` | ||
name #id `classes` key'value' +mutator = 'Inline content' | ||
name #'id' .'classes' key'value' +mutator = 'Inline content' | ||
``` | ||
To generate an HTML tag, the only required section above is `name`. To give the tag an id, add `#id` where `id` is, well, the css id. Classes can be added inside a class block denoted between two back-tick characters as shown above. Tag properties are added as `key'value'`. Mutators, which are really just properties without values, such as `disabled` are denoted as `+disabled`. Inline content is again purely optional, but if needed, is simply specified as ` = 'content'` at the end of a tag. If this section is present, the opening and closing tags generated will be placed onto a single line, instead of separate lines. For a complete example, the following Candor syntax: | ||
The only required section above is `name`. | ||
Tag properties are added as `key'value'`. | ||
Mutators, which are really just properties without values, such as `disabled` are denoted as `+disabled`. | ||
Inline content is optional, but if needed is simply specified as ` = 'content'` at the end of a tag. If this section is present, the opening and closing tags generated will be placed onto a single line instead of separate lines. | ||
Eg: | ||
``` | ||
div #app `app app__dark` @click.stop'toggle()' +disabled = 'Uhmmm?' | ||
div #'app' .'app app__dark' @click.stop'toggle()' +disabled = 'Hello!' | ||
``` | ||
will produce the rendered HTML shown below: | ||
the above will produce the following rendered HTML: | ||
```html | ||
<div id="app" class="app app__dark" @click.stop="toggle()" disabled>Uhmmm?</div> | ||
<div id="app" class="app app__dark" @click.stop="toggle()" disabled>Hello!</div> | ||
``` | ||
@@ -87,3 +89,3 @@ | ||
Comments are just there as, well, comments. They will not be present in the rendered HTML. | ||
Comments will not be present in the rendered HTML. | ||
@@ -96,3 +98,3 @@ #### Raw Content | ||
If you require some non-Candor generated HTML, such as some JavaScript, PHP etc code, simply prepend the code with `--` and it will be rendered as is, as raw content. The above would produce: | ||
If you require some JavaScript, PHP etc, simply prepend the code with `--` and it will be rendered as is. The above would produce: | ||
@@ -107,23 +109,23 @@ ```html | ||
``` | ||
p | ||
div | ||
'This is a paragraph.' | ||
``` | ||
HTML content, aka the content that goes inside of a tag, is simply placed within single quotes. The content is not processed in any way, and currently only supports standard ASCII characters (Unicode support hopefully coming very soon!). The above example would produce: | ||
HTML content, aka the content that goes inside of a tag, is simply placed within single quotes. The above example would produce: | ||
```html | ||
<p> | ||
<div> | ||
This is a paragraph. | ||
</p> | ||
</div> | ||
``` | ||
# Roadmap | ||
- [x] Design an initial, clean, syntax that will describe a HTML document. | ||
- [x] Build a parser that ingests the new syntax and spits out the expected HTML. | ||
- [ ] Allow for the generation of HTML5 files and partials. | ||
- [ ] Allow for user defined indent sizes (Currently only supports 4 spaces to represent tabs) | ||
- [x] Design the syntax. | ||
- [x] Build a parser/generator. | ||
- [x] Allow for the generation of partials. | ||
- [ ] Allow for user defined indent sizes. | ||
- [ ] Allow for better customization of rendered HTML5. | ||
- [ ] Support for inline tags. | ||
- [ ] Support for Unicode (Currently limited to ASCII). | ||
- [ ] Create a gulp plugin. | ||
- [x] Support for Unicode (Currently limited to ASCII). | ||
- [ ] Create a gulp plugin. | ||
- [ ] Create a Laravel elixir plugin. |
@@ -13,5 +13,5 @@ var assert = require('assert'); | ||
'body\n' + | ||
' div #app `container`\n' + | ||
' div `row`\n' + | ||
' div `col-xs-12`\n' + | ||
' div #\'app\' .\'container\'\n' + | ||
' div .\'row\'\n' + | ||
' div .\'col-xs-12\'\n' + | ||
' p @click.stop\'toggleTitle()\' = \'Welcome!\'\n' | ||
@@ -18,0 +18,0 @@ ); |
@@ -8,3 +8,3 @@ var assert = require('assert'); | ||
it('Should add a class to a given tag.', function () { | ||
var actual = parser.parse('div `app`'); | ||
var actual = parser.parse('div .\'app\''); | ||
var expected = | ||
@@ -21,3 +21,3 @@ helper.html5( | ||
it('Should add multiple classes to a given tag.', function () { | ||
var actual = parser.parse('div `app app__dark`'); | ||
var actual = parser.parse('div .\'app app__dark\''); | ||
var expected = | ||
@@ -24,0 +24,0 @@ helper.html5( |
@@ -8,3 +8,3 @@ var assert = require('assert'); | ||
it('Should add an id to a given tag.', function () { | ||
var actual = parser.parse('div #app'); | ||
var actual = parser.parse('div #\'app\''); | ||
var expected = | ||
@@ -11,0 +11,0 @@ helper.html5( |
Sorry, the diff of this file is not supported yet
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
67827
21
1818
126