Infinity-For-Reddit icon indicating copy to clipboard operation
Infinity-For-Reddit copied to clipboard

Rewrite spoiler parsing

Open tabasavr opened this issue 3 years ago • 0 comments

Fixes #1099

Basically there were four cases that broke the code:

>! `one` `two` `three` !< - crashes
>! >! one !< >! two !< >! three !< !< - crashes
>! one `two !<` three !< - doesn't show any spoilers, should be one big spoiler
>! one >! two !< three !< - doesn't remove >! !< around two

I've left comments in this PR about specific places that broke the code, but I can also break up the commits if you want.

Also tested on
text
>! spoiler !<
>! start
end !<

```
code
>! block !<
```

>! because `code !<`

>!multi
line!<

>!new

line!<

>! not >! matched !<

>!
```
around block
```
!<

>!`code`!<

>!```not block
```!<

>`!` quote !<
code >`!` bracket !<
empty >!!<
>! self >!< intersection !<
>! other >!< way

Known problems:

  • #1102 Cannot escape spoiler using backslash - backslashes are removed somewhere before afterSetText, so fixing it will require a different approach
  • #1103 Leading and trailing spaces are not removed - fixable with current parser. But Reddit has some weird whitespace processing, so perfectly matching the behavior will be tricky

@scria1000 fyi

tabasavr avatar Sep 17 '22 08:09 tabasavr