[Pkg-javascript-commits] [ltx] 06/25: split STATE_IGNORE_TAG into proper STATE_IGNORE_COMMENT + STATE_IGNORE_INSTRUCTION
Jonas Smedegaard
dr at jones.dk
Tue Jan 10 18:21:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository ltx.
commit a501732daabd2bd8fb4f789bcd17ab3aa4615aa1
Author: Astro <astro at spaceboyz.net>
Date: Thu Nov 3 20:00:06 2016 +0100
split STATE_IGNORE_TAG into proper STATE_IGNORE_COMMENT + STATE_IGNORE_INSTRUCTION
Fixes #101
---
lib/parsers/ltx.js | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/lib/parsers/ltx.js b/lib/parsers/ltx.js
index fda9104..d264b66 100644
--- a/lib/parsers/ltx.js
+++ b/lib/parsers/ltx.js
@@ -5,13 +5,14 @@ var EventEmitter = require('events').EventEmitter
var unescapeXML = require('../escape').unescapeXML
var STATE_TEXT = 0
-var STATE_IGNORE_TAG = 1
-var STATE_TAG_NAME = 2
-var STATE_TAG = 3
-var STATE_ATTR_NAME = 4
-var STATE_ATTR_EQ = 5
-var STATE_ATTR_QUOT = 6
-var STATE_ATTR_VALUE = 7
+var STATE_IGNORE_COMMENT = 1
+var STATE_IGNORE_INSTRUCTION = 2
+var STATE_TAG_NAME = 3
+var STATE_TAG = 4
+var STATE_ATTR_NAME = 5
+var STATE_ATTR_EQ = 6
+var STATE_ATTR_QUOT = 7
+var STATE_ATTR_VALUE = 8
var SaxLtx = module.exports = function SaxLtx () {
EventEmitter.call(this)
@@ -60,7 +61,6 @@ var SaxLtx = module.exports = function SaxLtx () {
for (; pos < data.length; pos++) {
var c = data.charCodeAt(pos)
- console.log("state", state, "c", c, data[pos])
switch (state) {
case STATE_TEXT:
if (c === 60 /* < */) {
@@ -77,20 +77,32 @@ var SaxLtx = module.exports = function SaxLtx () {
if (c === 47 /* / */ && recordStart === pos) {
recordStart = pos + 1
endTag = true
- } else if (c === 33 /* ! */ || c === 63 /* ? */) {
+ } else if (c === 33 /* ! */) {
recordStart = undefined
- state = STATE_IGNORE_TAG
+ state = STATE_IGNORE_COMMENT
+ } else if (c === 63 /* ? */) {
+ console.log('?')
+ recordStart = undefined
+ state = STATE_IGNORE_INSTRUCTION
} else if (c <= 32 || c === 47 /* / */ || c === 62 /* > */) {
tagName = endRecording()
pos--
state = STATE_TAG
}
break
- case STATE_IGNORE_TAG:
+ case STATE_IGNORE_COMMENT:
if (c === 62 /* > */) {
var prev_first = data.charCodeAt(pos-1)
var prev_second = data.charCodeAt(pos-2)
- if( prev_first === 45 /* - */ && prev_second === 45 /* - */) {
+ if (prev_first === 45 /* - */ && prev_second === 45 /* - */) {
+ state = STATE_TEXT
+ }
+ }
+ break
+ case STATE_IGNORE_INSTRUCTION:
+ if (c === 62 /* > */) {
+ var prev = data.charCodeAt(pos-1)
+ if (prev === 63 /* ? */) {
state = STATE_TEXT
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git
More information about the Pkg-javascript-commits
mailing list