Render Markdown in Emacs buffer

前端 未结 8 608
一个人的身影
一个人的身影 2021-01-30 06:27

Is it possible to present Markdown rendered in an Emacs buffer using Emacs\' own buffer text formatting capabilities? Emacs in graphical environments has rich text presentation

相关标签:
8条回答
  • 2021-01-30 07:30

    As I don't know about any emacs-based Markdown parser, I'd have to say that you have to code one from scratch. Maybe this SO question can throw some pointers at you.

    If you opt to go through the Emacs-only road, then Semantic is an excellent API for that job (it offers you a lexer, parser-generator, and parser; it's been around for more than a decade, and it has documentation!). After having the language parser, you'll have to make some rendering functions for each token type. And this way you can customize everything.

    Although this would be an enlightening trip, for sure, I'd still opt for using an existing Markdown->html converter on a separate background process and then use w3(m) for emacs preview (as Bozhidar suggested). It gets the job done and it's much simpler to do. No major performance issues, neither - you should run this tool rather scarcely, so you can easily spare some extra milliseconds).

    A mixed solution would be to make the Markdown parser generate HTML directly, and preview it on a w3(m) buffer (it takes away the rendering weight from your shoulders, you only need to transliterate the markdown into html, and that seems pretty straight forward with Semantic).

    0 讨论(0)
  • 2021-01-30 07:31

    Apart from pretty-lambda (which has already been suggested multiple times), you could look into org-mode and its syntax highliting rules. In particular, the org-hide-emphasis-markers variable does more or less what you want (see e.g. how org-do-emphasis-faces hide markup characters).

    0 讨论(0)
提交回复
热议问题