segmentfault / HyperDown

一个结构清晰的,易于维护的,现代的PHP Markdown解析器
Other
1.2k stars 222 forks source link

希望四个 ```` 包裹 markdown 源码时,markdown 源码以代码段形式展示 ,不做转义 #39

Closed fenbox closed 3 years ago

fenbox commented 4 years ago

SF 社区用户反馈,github、stackoverflow 都实现了,比如想实现下面这样的 markdown 代码展示:

hell world

kecrily commented 4 years ago

@fenbox 刚刚看了一下你的回复内容,发现你使用是的 ``` ,而不是 ```` 。

我又在 GitHub 中尝试了一下该语法,该语法其实是与 ``` 相同的解析方式,也就是该效果原先就可以实现。```` 其实是一种错误的解析。

fenbox commented 4 years ago

@scvoet 你应该看下我的源码

image

kecrily commented 4 years ago
> SF 社区用户反馈,github、stackoverflow 都实现了
> 
> ```
> ```
> hell world
> ```
> ```

@fenbox 以上是我通过 GitHub 回复功能获取到的源码,这与你截图中的不同。`被转为,由此也可以判断这是一个错误解析

fenbox commented 4 years ago

@scvoet 根据 GitHub Flavored Markdown 的描述,这并不是错误解析。

A code fence is a sequence of at least three consecutive backtick characters (`) or tildes (~). (Tildes and backticks cannot be mixed.) A fenced code block begins with a code fence, indented no more than three spaces.

The closing code fence must use the same character as the opening fence

而你引用出现的三个 `,可能是 github 引用功能的 bug。

kecrily commented 4 years ago

@fenbox 根据该描述虽然这并不属于错误,但其实两者实际效果相同。故该需求意义不大,用```即可实现展示 Markdown 代码内容了。

fenbox commented 4 years ago

@scvoet 那你看下如何用 ``` 实现我下图这个一模一样的效果(包括里面的文本)

image

kecrily commented 4 years ago
```
hello,world
```

@fenbox 刚刚尝试了一下,发现确实是无法通过```来实现的,是我过于主观臆断了。

但可以采用四个 space 来替换 ``` 来实现