DasRed / js-bbcode-parser

24 stars 7 forks source link

Code parsing doesn't work across multiple lines #10

Closed JL102 closed 3 years ago

JL102 commented 3 years ago

If you put code like this:

[list]
[*]item 1[/*]
[*]item 2[/*]
[/list]

[b]
multi line
bold text
[/b]

the output will be as follows:

[list]

[/list] [b] multi line bold text [/b]

It can be solved by adding an "s" to the regex flags on lines 41 and 59: new RegExp(regex, 'igms'). The "s" flag lets the regex search across multiple lines (see https://stackoverflow.com/questions/159118/how-do-i-match-any-character-across-multiple-lines-in-a-regular-expression)