Hide Details applies separately to each paragraph


#1

Description

Hi, there’s a bug with details-plugin: when selecting a big chunk of text separated in paragraphs, clicking the Hide Details -button causes the [details...] to be prefixed to each separate paragraph, not just the beginning (and end) of the selection.

The same bug applies to spoiler-plugin.

Location of bug

As far as I know, the problem is here (no idea how to fix):

So likely the culprit is applySurround and how it functions…

Reproduction

  1. Write several lines of text (separate with linebreak)
  2. Choose all the lines.
  3. Click Hide Details.
  4. PROFIT

Result

Summary

Lines with text

Summary

Lines with text

Summary

Lines with text

Summary

Lines with text

Summary

Lines with text

[details=Summary]Lines with text[/details]
[details=Summary]Lines with text[/details]
[details=Summary]Lines with text[/details]
[details=Summary]Lines with text[/details]
[details=Summary]Lines with text[/details]

Should result in:

[details=Summary]Lines with text
Lines with text
Lines with text
Lines with text
Lines with text[/details]

[details=Summary]Lines with text
Lines with text
Lines with text
Lines with text
Lines with text[/details]

Hide Details applies separately
(Joshua Rosenfeld) #2

For reference, this is the markdown that selecting multiple lines and clicking hide details generates.

[details=Summary]Lines with text[/details]
[details=Summary]Lines with text[/details]
[details=Summary]Lines with text[/details]
[details=Summary]Lines with text[/details]
[details=Summary]Lines with text[/details]

#3

Thanks, I edited this into the first message!


(Jeff Atwood) #4

Aha we should fix this @tgxworld


(Alan Tan) #5

PR in

Would love to get @eviltrout’s thoughts first before merging :slight_smile:


(Robin Ward) #6

I said it was cool via chat, and it looks like the PR was merged. Thanks @tgxworld!


(Robin Ward) #7