tangled
alpha
login
or
join now
ansxor.ca
/
markup2
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
1
pulls
pipelines
style boundary checks
12Me21
3 years ago
cc98194e
349b9fd6
+25
-11
1 changed file
expand all
collapse all
unified
split
parse.js
+25
-11
parse.js
···
265
265
// parsing //
266
266
267
267
const STYLE_START
268
268
-
= /^[ \s.'"}{(> ][^ \s,'" ]|^\s["']/ // START
269
269
-
const STYLE_END = /^[^ \s, ][-\s.,:;!?'"}{)<\\ ]/
268
268
+
= /^[\s][^\s,]|^['"}{(>][^\s,'"]/
269
269
+
const STYLE_END
270
270
+
= /^[^\s,][-\s.,:;!?'"}{)<\\]/
271
271
+
const ITALIC_START
272
272
+
= /^[\s][^\s,/]|^['"}{(>][^\s,'"/]/
273
273
+
const ITALIC_END
274
274
+
= /^[^\s,/][-\s.,:;!?'"}{)<\\]/
270
275
271
271
-
const check_style=(token_text, before, after)=>{
272
272
-
// END
276
276
+
const find_style=(token)=>{
273
277
for (let c=current; 'style'===c.type; c=c.parent)
274
274
-
if (c.args===token_text) {
275
275
-
if (STYLE_END.test(before+after))
276
276
-
return c
277
277
-
break
278
278
-
}
279
279
-
// START
280
280
-
if (STYLE_START.test(before+after))
278
278
+
if (c.args===token)
279
279
+
return c
280
280
+
}
281
281
+
282
282
+
const check_style=(token, before, after)=>{
283
283
+
let ital = "/"===token
284
284
+
let c = find_style(token)
285
285
+
if (c && (ital ? ITALIC_END : STYLE_END).test(before+after))
286
286
+
return c
287
287
+
if ((ital ? ITALIC_START : STYLE_START).test(before+after))
281
288
return true
282
289
}
283
290
const ARG_REGEX = /.*?(?=])/y
···
626
633
// \tag{ ... {heck} ... } <- closes here
627
634
628
635
// todo: after parsing a block element: eat the next newline directly
636
636
+
637
637
+
// idea:
638
638
+
// compare ast formats:
639
639
+
// memory, speed, etc.
640
640
+
// {type, args, content}
641
641
+
// [type, args, content]
642
642
+
// [type, args, ...content]