Skip to content

Commit

Permalink
parse comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Apr 29, 2018
1 parent 6eb47d2 commit 0136716
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
19 changes: 19 additions & 0 deletions dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@
stack[stack.length - 1].children.push(child);
};

var parseComment = function (index, input, length, stack) {
for (; index < length;) {
var char0 = input[index];
var char1 = input[index + 1];
var char2 = input[index + 2];

if (char0 === "<" && char1 === "!" && char2 === "-" && input[index + 3] === "-") {
index = parseComment(index + 4, input, length, stack);
} else if (char0 === "-" && char1 === "-" && char2 === ">") {
index += 3;
break;
} else {
index += 1;
}
}

return index;
};

var parseOpeningTag = function (index, input, length, stack) {
var type = "";

Expand Down
2 changes: 1 addition & 1 deletion dist/moon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/compiler/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ const pushChild = (child, stack) => {
stack[stack.length - 1].children.push(child);
};

const parseComment = (index, input, length, stack) => {
for (; index < length;) {
const char0 = input[index];
const char1 = input[index + 1];
const char2 = input[index + 2];

if (char0 === "<" && char1 === "!" && char2 === "-" && input[index + 3] === "-") {
index = parseComment(index + 4, input, length, stack);
} else if (char0 === "-" && char1 === "-" && char2 === ">") {
index += 3;
break;
} else {
index += 1;
}
}

return index;
};

const parseOpeningTag = (index, input, length, stack) => {
let type = "";

Expand Down

0 comments on commit 0136716

Please sign in to comment.