russross / blackfriday

Blackfriday: a markdown processor for Go
Other
5.41k stars 596 forks source link

code blocks break line has been deleted #697

Open ccpwcn opened 2 years ago

ccpwcn commented 2 years ago

my markdown:

```java
public interface List<E> extends Collection<E> {
    // 内容省略
}

my go code:
```golang
input := []byte(article.Content)
unsafe := blackfriday.Run(input, blackfriday.WithExtensions(blackfriday.CommonExtensions))
p := bluemonday.UGCPolicy()
p.AllowAttrs("class").Matching(regexp.MustCompile("^language-[a-zA-Z0-9]+$")).OnElements("code")
output := string(p.SanitizeBytes(unsafe))

my html text:

<code>java
public interface List&lt;E&gt; extends Collection&lt;E&gt; {
    // 内容省略
}
</code>

show in browser: code-block-one-line

all line and breaks has been deleted, expected, it will show look like this:

public interface List<E> extends Collection<E> {
    // 内容省略
}