logseq / mldoc

Another Emacs Org-mode and Markdown parser.
GNU Affero General Public License v3.0
233 stars 20 forks source link

mldoc's astExportMarkdown loses backslash #116

Open cldwalker opened 2 years ago

cldwalker commented 2 years ago

Following up to #112, when I use Mldoc's astExportMarkdown from js (via nbb), I observe that backslashes are removed from the resulting export. Steps to reproduce:

# Build latest mldoc
$ cd /your/local/mldoc
$ make
$ cp _build/default/js/lib.bc.js js/package/index.js

$ git clone https://github.com/cldwalker/nbb-clis && cd nbb-clis
# Install local mldoc until a new one is published
$ cd clis/mldoc
$ npm i /your/local/mldoc/js/package
$ cd -

# Roundtrip example failure
$ echo "- example postgres cmd: \dt" > basic.md
$ logseq-roundtrip basic.md basic2.md
$ diff bas*
1c1
< - example postgres cmd: \dt
---
> - example postgres cmd: dt

You can see that the resulting export removes the backslash. However, it seems backslashes aren't removed if there is whitespace after the backslash. For example, - alias apm='/Applications/Atom\ Beta.app/Contents/Resources/app/apm/bin/apm' exports the same

tiensonqin commented 2 years ago

I suspect it's because \d is escaped https://github.com/logseq/mldoc/blob/master/lib/syntax/type_op.ml#L164 @RCmerci shall we add an Inline Escape type so that it can be preserved for later output?