Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tab 相关 #7

Open
xovel opened this issue Jun 17, 2019 · 0 comments
Open

tab 相关 #7

xovel opened this issue Jun 17, 2019 · 0 comments

Comments

@xovel
Copy link
Owner

xovel commented Jun 17, 2019

\t,也就是 tab 制表符,在进行 zmd 进行解析的时候针对该符号的处理经过了一番短暂的探索,最终决定沿用 marked 的处理方式,即直接全局替换。

有尝试过只替换开头的一部分:

  src = src.replace(/^ {0,3}\t/gm, '    ')

然而却出现了更多令人难以捉摸的情况:

  • 多个连在一起(比如 \t\t)不方便进行处理,或者造成代码比较复杂。
  • 水平线中间是支持 \t 的,但只采用上面的替换方式,需要更新对应的正则判定规则。
  • setext heading 同上。
  • 各种带有代码块预判的情况都要发生变更。
  • 块引用和列表嵌套的情况更加模棱两可。
...
        text = cap[0].replace(/^ {0,4}/gm, '')
          // remove initial empty line
          .replace(/^(?: *\n)+/, '')
          // replace trailing empty lines to a sigle line break
          .replace(/(?: *\n)+$/, '\n')
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant