logseq / mldoc

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

Feat/unordered list as headings #27

Closed tiensonqin closed 3 years ago

tiensonqin commented 3 years ago

Some questions:

  1. should we support this for org mode too?
  2. the current implementation count tabs as spaces, is it problematic?
  3. should we support ordered lists as bullets too?
RCmerci commented 3 years ago

should we support this for org-mode too?

Yes, I think.

the current implementation count tabs as spaces, is it problematic?

Maybe treat 1 \<space> as 1 level and 1 \<tab> as 4 levels ?

should we support ordered lists as bullets too?

I think it's not necessary yet? not sure.

tiensonqin commented 3 years ago

Ok, let's ignore the ordered list and enable this for org mode too.

Maybe treat 1 as 1 level and 1 as 4 levels ?

How about ignoring whether it's a space or a tab? After all, we need to recalculate the levels because the user's input might have discontinuous levels, for example:

- level 1
        - level 2 

Level 2 here should be treated as level 3 because it has 8 spaces before the -, and 4 spaces as a tab are very common. Ideally, the parser should walk through the ast and recalculate the levels, and then logseq doesn't need to care about whether it's a tab or spaces.

RCmerci commented 3 years ago

Level 2 here should be treated as level 3 because it has 8 spaces before the -

according to this PR, it will be level 9? level = length(spaces)+1. But I think 'ignoring whether it's a space or a tab' makes sense, users should only use spaces(or tabs) on one single page.

By the way, it looks like this PR is not formatted. ( make fmt )

tiensonqin commented 3 years ago

@RCmerci There's one problem if we support ordered lists as bullets in org mode, because we extended the list with heading's features like priorities, properties, keywords, scheduled/deadlines, etc. It'll be hard to use for existing org mode users especially when they need to use Emacs too.

tiensonqin commented 3 years ago

according to this PR, it will be level 9? level = length(spaces)+1.

Yes, this PR doesn't recalculate the levels yet, I'm doing some experiments with this and logseq's frontend :smile:

By the way, it looks like this PR is not formatted. ( make fmt )

Is it possible to make this automatically?

RCmerci commented 3 years ago

Is it possible to make this automatically?

yes, adding 'dune build @fmt --auto-promote' before 'dune build' will be fine. And for emacs config : (add-hook 'before-save-hook #'ocamlformat-before-save nil t)

RCmerci commented 3 years ago

@RCmerci There's one problem if we support ordered lists as bullets in org mode, because we extended the list with heading's features like priorities, properties, keywords, scheduled/deadlines, etc. It'll be hard to use for existing org mode users especially when they need to use Emacs too.

Oh, I forgot this ... it looks like we'd better ignore org-mode currently..

RCmerci commented 3 years ago

Is this PR ready to be merged?

tiensonqin commented 3 years ago

@RCmerci Let's fix the conflicts and merge this PR!