rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust

Home Page:https://rust-lang.github.io/mdBook/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature request] support the rendering of adding parentheses

geometryolife opened this issue · comments

This case renders fine:

image
image

But after adding the parentheses it doesn't work:

image
image

I believe this is working as intended. mdBook uses CommonMark, and this seems to be related to a right-flanking delimiter run. The right emphasis cannot be preceded by a space or a punctuation character, unless it is followed by a space. Try removing the space before the *** and adding a space after.

Also, when reporting an issue, it can be helpful to include the actual text you are using instead of screenshots. I can't copy and paste your example to show you directly how to fix it.

@ehuss
Indeed, as you said, punctuation cannot be used before emphasis. If it is used, a space must be added after emphasis to render properly.
This may be the difference between Chinese and English. Chinese parentheses occupy the position of two English parentheses. If a space is added after the emphasis, the visual effect will not be so good.

Chinese:
***结构体(struct)***是包含类型字段的自定义数据结构。结构体可以存储任何非引用类型,包括其他结构。

English:
***结构体(struct)***是包含类型字段的自定义数据结构。结构体可以存储任何非引用类型,包括其他结构。

render result:
image

For this reason, I have chosen a compromise:

***结构体***(struct)是包含类型字段的自定义数据结构。结构体可以存储任何非引用类型,包括其他结构。

image

Thanks for your detailed reply.

OK, I'm going to go ahead and close since this is just the behavior of markdown. If you want to follow up, I recommend you check if there is already an issue about this on the commonmark spec, and maybe open a new one if not.

Oh, and I forgot to suggest that you can also just use HTML tags if the spacing is an issue.