weixin_39727976
weixin_39727976
2020-12-26 18:38

An initial idea

Hi folks! I took some time today to draft out an early early (really early) idea. It doesn’t really work, but it gives us a starting point. You can clone it and run node example, and try changing the given heading to something else, to see how it works.

This is mainly inspired by how HTML is parsed. How it’s specced, but also how parses5 implements that spec. HTML, even though it’s pretty structured, has the same problem as markdown: everything is valid. That’s why I thought we’d start with this.

With this concept, I tried to get something of an AST done. Some initial positional info. One initial node (ATX heading), and some ideas on what’s needed for the block and inline states.

This is not something that should be merged, it‘s the first thing we throw away to build something better!

该提问来源于开源项目:micromark/micromark

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39727976 weixin_39727976 4月前

    P.S. for everyone not on the review list reading this: please review the code and share initial ideas! I’d love to develop this transparently and in the open, we could use fresh ideas on this!

    点赞 评论 复制链接分享
  • weixin_39715907 weixin_39715907 4月前

    I'll pop in on this next week. Currently dealing the pre-holiday work pile up.

    点赞 评论 复制链接分享
  • weixin_39727976 weixin_39727976 4月前

    Syntax extensions should go to micromark, but they could have a more gnarly interface. And I think there should be nicer plugins on a remark level that then add the plugins to the used micromark parser

    点赞 评论 复制链接分享
  • weixin_39614276 weixin_39614276 4月前

    there should be nicer plugins on a remark level that then add the plugins to the used micromark parser

    So the flow for something like https://github.com/djm/remark-shortcodes would be to add a micromark lexing plugin, then use the micromark output to feed a custom remark parser?

    点赞 评论 复制链接分享
  • weixin_39727976 weixin_39727976 4月前

    Yep! Or, more like this: it’ll add a micromark plugin to the parser set-up on unified. So I’m thinking that this.Parser is a micromark parser!

    点赞 评论 复制链接分享

相关推荐