docu-notion icon indicating copy to clipboard operation
docu-notion copied to clipboard

Numbered text in Notion is converted to bullet points in Markdown

Open hatton opened this issue 3 years ago • 2 comments

This in Notion:

image

Creates this markdown:

image

notion-to-md (which docu-notion uses) does support numbered lists, so I don't know what's going wrong.

hatton avatar Oct 07 '22 20:10 hatton

I did some research. There is code in a function modifyNumberedListObject which attempts to assign sequential numbers to block.numbered_list_item.number for each numbered_list_item; but the numbered-list blocks do not have this by the time I attempt to process them when writing a custom transformer. I did not determine whether the function is not called, called too late, or whether the number is being deleted somehow. Then, there is code in notion-to-md.ts which handles the numbered_list_item case which looks for that number, and not finding it, basically reverts to bulleted list. It's not clear why sequential numbering is even attempted. Markdown will handle that if the md file simply contains "1. " at the beginning of each numbered list item line. It's easy to make a custom transformer (or to change the numbered_list_item handler) to just do that. Possibly, the intent was just to make the input markdown more readable by using sequential numbers. However, one problem will remain: it is difficult to do a good job of making markdown restart numbering when desired. If notion-to-md simply puts a "1. " (or any other number) at the start of each numbered_list_item, markdown will number each series of such items starting at 1. This is often correct, but it's possible in Notion to continue a numbered-list number sequence after some intermediate material. Markdown can do this too, by indenting all the intermediate material by a tab (or four spaces). But I can discover no way for notion-to-md to know that it should do this. The block object received for a numbered_list_item, as far as I can tell, contains no indication of how it is numbered in Notion, (or which list it belongs to, or what preceding siblings it has, or anything similar that might help).

JohnThomson avatar Oct 11 '22 15:10 JohnThomson

So, we merged a patch that makes them come out as numbered lists, but each separate list will be numbered from 1. I think the next step would be to fork notion-to-md and make a patch that keeps the numbered-list numbers in some form. Possibly submit it as a PR. If it's not accepted soon, or if we decide it's not clean enough to submit, we might be able to use yarn patch to modify the version of notion-to-md that we use. Then we can output items with the right numbers, and I think we confirmed that our output stage will use them, at least for the first item in a list.

JohnThomson avatar Nov 11 '22 19:11 JohnThomson

The block object received for a numbered_list_item, as far as I can tell, contains no indication of how it is numbered in Notion

Right, see #35

hatton avatar Jan 27 '23 23:01 hatton

Closing as this is fixed.

hatton avatar Jan 27 '23 23:01 hatton