logseq/mldoc

mldoc's astExportMarkdown loses property information

cldwalker opened this issue · 2 comments

Hi @tiensonqin. When I use Mldoc's astExportMarkdown from js (via nbb), I noticed that blocks with only one property do not export their property drawer. Blocks with 2 or more properties export their property drawer fine. I think this is a bug as export should not lose property information. To reproduce, you can use the logseq-roundtrip script which converts markdown file to ast and then exports ast to markdown file. Steps to reproduce

  • git clone https://github.com/cldwalker/nbb-clis && cd nbb-clis
  • curl https://raw.githubusercontent.com/cldwalker/nbb-clis/main/test/resources/advanced.md -o advanced.md
  • bin/logseq-roundtrip advanced.md advanced-roundtrip.md
  • Observe that the fig node doesn't export collapsed:: true while the banana node exports its properties

I suspect 9aed290#r63959759 is the source of the bug but I don't know ocaml

@RCmerci Thanks for the fix! Confirmed this works with a local build of master

Fyi, I did a roundtrip on 300+ pages and now I only see one minor data loss bug and the rest are just changes in syntax with functionality preserved. Here are the changes in syntax in case it's interesting:

  • :PROPERTIES:
    :todo: 1606318630224
    :END:
    becomes
    :todo: 1606318630224
  • markdown tables have a header row added if the table doesn't have one e.g. |---|---|
  • SCHEDULED: <2021-05-13 Thu 06:00pm> becomes SCHEDULED: <2021-05-13 Thu 06:00>
    • I'm not worried about this as I can just manually change my few old timestamps to use 24 hours
  • :LOGBOOK: becomes :logbook: