cqroot / joplin-outline

A markdown outline (TOC) sidebar plugin for Joplin.
MIT License
218 stars 17 forks source link

Headings with html tags and maths are incorrectly displayed and don't work as liks #35

Closed ken1kob closed 2 years ago

ken1kob commented 3 years ago

As follows, headings with html tags and headings with math expressions are incorrectly displayed. Besides, they do not work as clickable internal links.

jopline-outline-bug2

They should be displayed as follows in the OUTLINE panel. Html tags should be removed, but their contents should be remained. Math expressions and their contents should be removed.

Heading1
Heading2 with html
Heading3 with math
ken1kob commented 3 years ago

The following is an example code fixing this bug.

        // check header
        line = line.replace(/\s+#+\s*$/, '');

        // START OF EXAMPLE
        // remove HTML elements
        while (true) {
            let x = line.replace(/<.*?>([^<>]*?)<\/.*?>/, '$1');
            if (x == line) break
            line = x
        }
        // remove math
        while (true) {
            let x = line.replace(/\$[^\$]+\$/, '');
            if (x == line) break
            line = x
        }
        // END OF EXAMPLE

        const match = line.match(/^(#+)\s(?:\[(.*)\]|(.*))/);
Edwardlin-zlt commented 3 years ago

@ken1kob How did you put the outline to the left side?~~

cqroot commented 3 years ago

@ken1kob How did you put the outline to the left side?~~

Menu: View -> Change application layout