this repo has no description

style boundary checks

12Me21 cc98194e 349b9fd6

+25 -11
+25 -11
parse.js
··· 265 265 // parsing // 266 266 267 267 const STYLE_START 268 - = /^[ \s.'"}{(> ][^ \s,'" ]|^\s["']/ // START 269 - const STYLE_END = /^[^ \s, ][-\s.,:;!?'"}{)<\\ ]/ 268 + = /^[\s][^\s,]|^['"}{(>][^\s,'"]/ 269 + const STYLE_END 270 + = /^[^\s,][-\s.,:;!?'"}{)<\\]/ 271 + const ITALIC_START 272 + = /^[\s][^\s,/]|^['"}{(>][^\s,'"/]/ 273 + const ITALIC_END 274 + = /^[^\s,/][-\s.,:;!?'"}{)<\\]/ 270 275 271 - const check_style=(token_text, before, after)=>{ 272 - // END 276 + const find_style=(token)=>{ 273 277 for (let c=current; 'style'===c.type; c=c.parent) 274 - if (c.args===token_text) { 275 - if (STYLE_END.test(before+after)) 276 - return c 277 - break 278 - } 279 - // START 280 - if (STYLE_START.test(before+after)) 278 + if (c.args===token) 279 + return c 280 + } 281 + 282 + const check_style=(token, before, after)=>{ 283 + let ital = "/"===token 284 + let c = find_style(token) 285 + if (c && (ital ? ITALIC_END : STYLE_END).test(before+after)) 286 + return c 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 + 637 + // idea: 638 + // compare ast formats: 639 + // memory, speed, etc. 640 + // {type, args, content} 641 + // [type, args, content] 642 + // [type, args, ...content]