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
defer generating text nodes until necessary
12Me21
3 years ago
577a120b
19ac33f7
+12
-15
2 changed files
expand all
collapse all
unified
split
parse.js
testing
index.html
+3
-6
parse.js
···
50
50
ARGTYPES.push(Object.values(g)[0])
51
51
}
52
52
}
53
53
-
// style start:
54
54
-
// (?<![^ \t\n({'"])([*][*]|[_][_]|[~][~]|[/])(?=[^ \t\n,'"])
55
55
-
// style end:
56
56
-
// (?<=[^ \t\n,'"])([*][*]|[_][_]|[~][~]|[/])(?![^- \t\n.,:;!?'")}])
57
53
58
54
// ArgPattern
59
55
const ARGS_NORMAL = // /[...]?{?/
···
470
466
let match
471
467
function nevermind() {
472
468
REGEX.lastIndex = match.index+1
473
473
-
last = match.index
469
469
+
//last = match.index
474
470
}
475
471
function accept(i) {
472
472
+
TEXT(text.substring(last, match.index))
476
473
last = i
477
474
}
478
475
main: while (match = REGEX.exec(text)) {
···
482
479
prev = match.index
483
480
// 1: insert the text from after previous token
484
481
// idea: defer this until we actually KNOW we matched a token
485
485
-
TEXT(text.substring(last, match.index))
482
482
+
//TEXT(text.substring(last, match.index))
486
483
// 2: figure out which token type was matched
487
484
let token_text = match[0]
488
485
let group_num = match.indexOf("", 1)-1
+9
-9
testing/index.html
···
81
81
82
82
๐ฉ not table
83
83
a |table|
84
84
-
๐ฉ {"type":"ROOT","content":["a"," ","|table","|"]}
84
84
+
๐ฉ {"type":"ROOT","content":["a |table|"]}
85
85
86
86
๐ฉ single bar
87
87
|
88
88
a|
89
89
-
๐ฉ {"type":"ROOT","content":["|","\n","a","|"]}
89
89
+
๐ฉ {"type":"ROOT","content":["|","\n","a|"]}
90
90
91
91
๐ฉ single backslash
92
92
\
···
100
100
๐ฉ esc newline no table
101
101
\
102
102
|table|
103
103
-
๐ฉ {"type":"ROOT","content":["\n","|table","|"]}
103
103
+
๐ฉ {"type":"ROOT","content":["\n","|table|"]}
104
104
105
105
๐ฉ random escapes
106
106
\\ \@ \~
···
247
247
`abc
248
248
def`
249
249
250
250
-
๐ฉ {"type":"ROOT","content":["\n","\n",{"type":"table","args":null,"content":[{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{"color":"gray"},"content":["abc"]},{"type":"table_cell","args":{"color":"blue"},"content":["abc"]},{"type":"table_cell","args":{},"content":[{"type":"icode","args":{"text":"test"}}," "]}]}]},{"type":"image","args":{"url":"https://qcs.shsbs.xyz/api/file/raw/31760?size=30&crop=true"}},"the sand can be eatena","\n","\tabc","\n",{"type":"spoiler","args":{"label":"spoiler"},"content":["abc defaaaa ",{"type":"spoiler","args":{"label":"spoiler"},"content":["a"]}]},"aaaaaa","\n",{"type":"align","args":{"align":"right"},"content":["heck"]},{"type":"align","args":{"align":"center"},"content":["| table"," ","|"]},{"type":"divider"},{"type":"key","args":null,"content":[{"type":"key","args":null,"content":["a"]},{"type":"key","args":null,"content":["b"]},"\n",{"type":"key","args":null,"content":["ctrl"]},{"type":"invalid","args":{"text":"\\abcdef[aaa]{","reason":"invalid tag"},"content":[" ha","}"]},"\n",{"type":"key","args":null,"content":["shift"]},"\n",{"type":"key","args":null,"content":["ctrl"]},"+",{"type":"key","args":null,"content":["shift"]},"+",{"type":"key","args":null,"content":["M"]}]},"\n",{"type":"spoiler","args":{"label":"spoiler"},"content":["abc"]},"/","test","\n","a","/","\n",{"type":"icode","args":{"text":"abc"}},"\n","def",{"type":"icode","args":{"text":""}},"\n","\n"],"prev":"newline"}
250
250
+
๐ฉ {"type":"ROOT","content":["\n","\n",{"type":"table","args":null,"content":[{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{"color":"gray"},"content":["abc"]},{"type":"table_cell","args":{"color":"blue"},"content":["abc"]},{"type":"table_cell","args":{},"content":[{"type":"icode","args":{"text":"test"}}," "]}]}]},{"type":"image","args":{"url":"https://qcs.shsbs.xyz/api/file/raw/31760?size=30&crop=true"}},"the sand can be eatena","\n","\tabc","\n",{"type":"spoiler","args":{"label":"spoiler"},"content":["abc defaaaa ",{"type":"spoiler","args":{"label":"spoiler"},"content":["a"]}]},"aaaaaa","\n",{"type":"align","args":{"align":"right"},"content":["heck"]},{"type":"align","args":{"align":"center"},"content":["| table |"]},{"type":"divider"},{"type":"key","args":null,"content":[{"type":"key","args":null,"content":["a"]},{"type":"key","args":null,"content":["b"]},"\n",{"type":"key","args":null,"content":["ctrl"]},{"type":"invalid","args":{"text":"\\abcdef[aaa]{","reason":"invalid tag"},"content":[" ha","}"]},"\n",{"type":"key","args":null,"content":["shift"]},"\n",{"type":"key","args":null,"content":["ctrl"]},"+",{"type":"key","args":null,"content":["shift"]},"+",{"type":"key","args":null,"content":["M"]}]},"\n",{"type":"spoiler","args":{"label":"spoiler"},"content":["abc"]},"/","test","\n","a/","\n",{"type":"icode","args":{"text":"abc"}},"\n","def",{"type":"icode","args":{"text":""}},"\n","\n"],"prev":"newline"}
251
251
252
252
๐ฉ idk..env close
253
253
>{
···
257
257
๐ฉ spit it out
258
258
/abc
259
259
}def/
260
260
-
๐ฉ {"type":"ROOT","content":["/","abc","\n","}","def","/"]}
260
260
+
๐ฉ {"type":"ROOT","content":["/","abc","\n","}","def/"]}
261
261
262
262
๐ฉ null escape
263
263
test\b 123\.aaaaa
···
268
268
>{\.}
269
269
|\.|
270
270
| |
271
271
-
๐ฉ {"type":"ROOT","content":["test",{"type":"bold","content":["123"]},"aaaaa","\n","test",{"type":"bold","content":["123"]}," aaaaa","\n","test",{"type":"bold","content":["123"]},{"type":"italic","content":["aaaaa"]},"\n","heck","\\b","heck, heck",{"type":"bold","content":[]},"heck, heck",{"type":"bold","content":[]}," ","heck","\n",{"type":"simple_link","args":{"url":"https://example"}},"com","\n",{"type":"quote","args":{},"content":[]},{"type":"table","content":[{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":[]}]},{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":[]}]}]}]}
271
271
+
๐ฉ {"type":"ROOT","content":["test",{"type":"bold","content":["123"]},"aaaaa","\n","test",{"type":"bold","content":["123"]}," aaaaa","\n","test",{"type":"bold","content":["123"]},{"type":"italic","content":["aaaaa"]},"\n","heck\\b","heck, heck",{"type":"bold","content":[]},"heck, heck",{"type":"bold","content":[]}," ","heck","\n",{"type":"simple_link","args":{"url":"https://example"}},"com","\n",{"type":"quote","args":{},"content":[]},{"type":"table","content":[{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":[]}]},{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":[]}]}]}]}
272
272
273
273
๐ฉ styles closed by table cells
274
274
/italic | abc/
275
275
| table /test | /italic | abc/ |
276
276
abc /heck |
277
277
-
๐ฉ {"type":"ROOT","content":[{"type":"italic","content":["italic"," ","| abc"]},"\n",{"type":"table","args":null,"content":[{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":["table ","/","test"]},{"type":"table_cell","args":{},"content":["/","italic"]},{"type":"table_cell","args":{},"content":["abc","/"]}]}]},"abc ","/","heck"," ","|"],"prev":"text"}
277
277
+
๐ฉ {"type":"ROOT","content":[{"type":"italic","content":["italic | abc"]},"\n",{"type":"table","args":null,"content":[{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":["table ","/","test"]},{"type":"table_cell","args":{},"content":["/","italic"]},{"type":"table_cell","args":{},"content":["abc/"]}]}]},"abc ","/","heck |"],"prev":"text"}
278
278
279
279
๐ฉ list
280
280
- abc
···
331
331
|abc|abc
332
332
the sand | can be eaten |
333
333
heck |
334
334
-
๐ฉ {"type":"ROOT","content":["|","\n","wow"," ","|","\n",{"type":"table","args":null,"content":[{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":["abc"]}]},{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":["abc"]},{"type":"table_cell","args":{},"content":["abc"]}]}]},"the sand"," ","| can be eaten"," ","|","\n","heck"," ","|"],"prev":"text"}
334
334
+
๐ฉ {"type":"ROOT","content":["|","\n","wow |","\n",{"type":"table","args":null,"content":[{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":["abc"]}]},{"type":"table_row","args":{},"content":[{"type":"table_cell","args":{},"content":["abc"]},{"type":"table_cell","args":{},"content":["abc"]}]}]},"the sand | can be eaten |","\n","heck |"],"prev":"text"}
335
335
336
336
๐ฉ urls
337
337
aaahttp://example.com
···
340
340
(http://example.com/heck(123))
341
341
http://example.com/heck(123)abc;
342
342
343
343
-
๐ฉ {"type":"ROOT","content":["aaahttp:","/","/example.com","\n",{"type":"simple_link","args":{"url":"http://example.com"}},"?","\n","(",{"type":"simple_link","args":{"url":"http://example.com"}},")","\n","(",{"type":"simple_link","args":{"url":"http://example.com/heck(123)"}},")","\n",{"type":"simple_link","args":{"url":"http://example.com/heck(123)abc"}},";","\n","\n"]}
343
343
+
๐ฉ {"type":"ROOT","content":["aaahttp://example.com","\n",{"type":"simple_link","args":{"url":"http://example.com"}},"?","\n","(",{"type":"simple_link","args":{"url":"http://example.com"}},")","\n","(",{"type":"simple_link","args":{"url":"http://example.com/heck(123)"}},")","\n",{"type":"simple_link","args":{"url":"http://example.com/heck(123)abc"}},";","\n","\n"]}