mixmark-io / turndown

🛏 An HTML to Markdown converter written in JavaScript
https://mixmark-io.github.io/turndown
MIT License
8.52k stars 864 forks source link

Nested Bullet Points and strikethrough not registering? #432

Closed r1shank closed 1 year ago

r1shank commented 1 year ago

I'm currently doing rich text -> markdown conversion using turndown and it seems like nested bullet points and strikethrough aren't registering in markdown. Is there any way to debug this/fix this?

const turndown = new TurndownService()
const toMarkdown = (value: string) => {
    // return marked.parse(value)
    return turndown.turndown(value)
}
    useEffect(() => {
        if (editorRef.current) {
            const editor = new Quill(editorRef.current, {
                theme: 'bubble',
                modules: {
                    toolbar: [
                        ["bold", "italic", "strike"],
                        ["blockquote", "code-block"],
                        [{ list: "ordered" }, { list: "bullet" }],
                    ],
                },
            });

            editor.on('text-change', () => {
                // eslint-disable-next-line @typescript-eslint/ban-ts-comment
                // @ts-ignore
                const html = editor.container.firstChild?.innerHTML;
                const markdown = toMarkdown(html);

                console.log(markdown)
            });
        }
    }, []);
image

nested (output on console)

image

strikethrough (output on console)

is there any way to debug or fix this?

r1shank commented 1 year ago

@martincizek do you know how to fix this/could you link someone who knows how I could go about fixing this?

r1shank commented 1 year ago

@domchristie any chance you know how to fix this?

domchristie commented 1 year ago

Strikethroughs are not part of the commonmark. You may wish to try the turndown gfm plugin