rasendubi / uniorg

An accurate Org-mode parser for JavaScript/TypeScript

Home Page:https://oleksii.shmalko.com/uniorg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lost space symbol after checkbox values

Artawower opened this issue · comments

commented

Hello! I tried to parse structure like this:

console.log(
  stringify(
    parse(`
- [ ] checkbox 1
- [ ] checkbox 2`)
  ),
  null,
  2
);

And i see next output:

- [ ]checkbox 1
- [ ]checkbox 2

But I was expecting the original text, is this expected behavior? (Space symbol is lost at the moment of parsing)

Hey, thanks for the bug report!

It's more likely that space is lost in the uniorg-stringify rather than parser.

One option to fix that is to add trailing whitespace for checkboxes here:

org.checkbox === 'on'
? '[X]'
: org.checkbox === 'off'
? '[ ]'
: org.checkbox === 'trans'
? '[-]'
: null,

commented

That makes sense, I thought it was a parser, because I expected the space character to be inside the "value" property. And a structure like children: [ { { { type: 'text', value: 'checkbox 2' } ] was expected as children: [ { { { type: 'text', value: ' checkbox 2' } ]. But if it's a stringify thing, that's probably even easier to fix 🙂

This is fixed in uniorg-stringify@1.0.1