reStructuredText 中的颜色文本 - 文件 (.rst) 在 :color:`text` 前面没有前导空格字符 [英] Color text in reStructuredText - files (.rst) without leading space character in front of :color:`text`

查看:65
本文介绍了reStructuredText 中的颜色文本 - 文件 (.rst) 在 :color:`text` 前面没有前导空格字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文本/代码片段如下:

时间戳-----------...1) UTC+2: 2021-06-10T09:00:42:red:`+02:00`2) UTC: 2021-06-10T09:00:42:red:`Z`

不想要的结果(没有彩色文本):

它在 :red: 前面插入空格时有效,但这不是可接受的解决方法,因为

如何在彩色块前实现彩色文本,而没有不需要的空格?

解决方案

正如您所意识到的,您的角色之前必须有一个空格.接下来,您可以使用反斜杠 (\) 转义空格.

.. raw:: html<风格>.red {color:red} </style>..角色::红色1) UTC+2: 2021-06-10T09:00:42\ :red:`+02:00`2) UTC: 2021-06-10T09:00:42\ :red:`Z`

查看类似问题和答案.

The text/code piece is the following:

Timestamps
-----------

...

1) UTC+2: 2021-06-10T09:00:42:red:`+02:00`
2) UTC: 2021-06-10T09:00:42:red:`Z`

Undesired result (no colored text achieved):

It works when inserting a space in front of :red:, but this is not an acceptable workaround as the ISO-8601-format does not allow for spaces.

Undesired result of workaround (colored text achieved, but with spaces):

How can I achieve colored text without undesired spaces in front of the colored piece?

解决方案

As you realized, you must have a space before your role. Next you can escape the space with a backslash (\).

.. raw:: html

    <style> .red {color:red} </style>

.. role:: red

1) UTC+2: 2021-06-10T09:00:42\ :red:`+02:00`
2) UTC: 2021-06-10T09:00:42\ :red:`Z`

See a similar question and answer.

这篇关于reStructuredText 中的颜色文本 - 文件 (.rst) 在 :color:`text` 前面没有前导空格字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆