嵌套/复合角色:将多个角色应用于重叠文本

Nested / Compounded roles: apply multiple roles to overlapping text

在我的 custom.css 文件中,

.bold {
    font-weight: bold;
}

.red {
    color:red;
}

在我的 _.rst 文件中,

.. role:: bold

.. role:: red

但是如果我尝试 nest/compound 它们,只有最外层的角色才会生效,例如


:bold:`:red:`This is only bold``

这只是粗体


有没有办法在不定义新(组合)角色的情况下组合这些效果?

角色定义为不能嵌套。

HTML 和作为后端的 LaTeX 都不支持样式重叠。

您可以使用自定义 css class 指令:

.. cssclass:: boldred

  bold red text

并更新 css 以格式化粗体 class