Skip to content

Commit

Permalink
Replace NO_NESTING with IMAGE
Browse files Browse the repository at this point in the history
  • Loading branch information
thetarnav committed Mar 14, 2024
1 parent c35f9a4 commit 1e52dfa
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions smd.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const
LIST_ORDERED = 16777216, // 24
LIST_ITEM = 33554432, // 25
CHECKBOX = 67108864, // 26
MAYBE_URL = 134217728, // 27
MAYBE_TASK = 268435456, // 28
MAYBE_URL =134217728, // 27
MAYBE_TASK =268435456, // 28
/** `HEADING_1 | HEADING_2 | HEADING_3 | HEADING_4 | HEADING_5 | HEADING_6` */
ANY_HEADING = 252,
/** `CODE_BLOCK | CODE_FENCE | CODE_INLINE` */
Expand All @@ -48,8 +48,6 @@ export const
ANY_UND = 20480,
/** `LIST_UNORDERED | LIST_ORDERED` */
ANY_LIST = 25165824,
/** `ANY_CODE | IMAGE | HORIZONTAL_RULE` */
NO_NESTING = 4458240,
/** `DOCUMENT | BLOCKQUOTE` */
ANY_ROOT = 262145

Expand Down Expand Up @@ -902,7 +900,7 @@ export function parser_write(p, chunk) {
continue
/* `Code Inline` */
case '`':
if (p.token & NO_NESTING) break
if (p.token & IMAGE) break

if ('`' === char) {
p.backticks_count += 1
Expand All @@ -917,6 +915,8 @@ export function parser_write(p, chunk) {
continue
case '_':
case '*': {
if (p.token & IMAGE) break

/** @type {Token} */ let italic = ITALIC_AST
/** @type {Token} */ let strong = STRONG_AST
const symbol = p.pending[0]
Expand All @@ -925,8 +925,6 @@ export function parser_write(p, chunk) {
strong = STRONG_UND
}

if (p.token & NO_NESTING) break

if (p.pending.length === 1) {
/* **Strong**
^
Expand Down Expand Up @@ -969,7 +967,7 @@ export function parser_write(p, chunk) {
break
}
case '~':
if (p.token & (NO_NESTING | STRIKE)) break
if (p.token & (IMAGE | STRIKE)) break

if ("~" === p.pending) {
/* ~~Strike~~
Expand All @@ -994,7 +992,7 @@ export function parser_write(p, chunk) {
break
/* [Image](url) */
case '[':
if (!(p.token & (NO_NESTING | LINK)) &&
if (!(p.token & (IMAGE | LINK)) &&
']' !== char
) {
add_text(p)
Expand All @@ -1005,7 +1003,7 @@ export function parser_write(p, chunk) {
break
/* ![Image](url) */
case '!':
if (!(p.token & NO_NESTING) &&
if (!(p.token & IMAGE) &&
'[' === char
) {
add_text(p)
Expand All @@ -1025,7 +1023,7 @@ export function parser_write(p, chunk) {
/* foo http://...
^
*/
if (!(p.token & NO_NESTING) &&
if (!(p.token & (IMAGE | LINK)) &&
'h' === char &&
(" " === p.pending ||
"" === p.pending)
Expand Down

0 comments on commit 1e52dfa

Please sign in to comment.