如何改变行内代码的背景色。
在重构文本中使用内联代码的一种方法是:
.. role::sql(code)
:language: sql
You can use the query :sql:`select * from table` to execute...当使用rst2pdf时,它输出漂亮的语法高亮和与代码块相同的背景色.我们如何使用rinohtype实现同样的目标?
理想的一些that looks like this in stackoverflow
这是我自己尝试过的
stylesheet:
[code-paragraph: Paragraph(has_class="coder")]
background_color = #fdffd6and rst:
.. role::sql(code)
:language: sql
:class: coder
You can use the query :sql:`select * from table` to execute...但这是行不通的,因为role可能是文本而不是段落。
发布于 2021-01-29 13:21:26
此时,请使用rinohtype 不支持为内联元素设置背景色(或边框)。在我们等待该功能实现时,我将讨论内联文本的一般样式。
下面是笔量用于reStructuredText片段的相关部分:
Paragraph('You can use the query select * f...') inline_code.rst:6 <paragraph>
> (0,0,0,0,2) body
MixedStyledText('You can use the query select * f...')
SingleStyledText('You can use the query ')
MixedStyledText('select * from table', style='monospaced') None:None <literal>
> (0,0,1,0,1) monospaced
MixedStyledText('select') None:None <inline>
SingleStyledText('select')
...要与选择器匹配的元素是具有单间隔样式的MixedStyledText。因为很难预测是否需要匹配SingleStyledText或MixedStyledText元素,所以应该始终使用更通用的 https://www.mos6581.org/rinohtype/master/api/paragraph.html#rinoh.text.StyledText 来表示选择器。
因此,对于您的示例,样式表中的代码段落定义如下所示:
[inline-code: StyledText('monospaced', has_class='coder')]
base = monospaced
background_color = #fdffd6关于这一点,有两点意见:
现在,rinohtype将使用TypeError: background_color is not a supported attribute for TextStyle中止。请参阅TextStyle的文档,查看支持哪种样式属性。
有关进一步的阅读,请参阅rinohtype手册中的元素造型。
https://stackoverflow.com/questions/65825828
复制相似问题