【问题标题】:How can I highlight diff output text in restructuredtext in sphinx?如何在 sphinx 的 restructuredtext 中突出显示差异输出文本?
【发布时间】:2020-01-17 09:19:51
【问题描述】:

我试图找到但失败了。

我认为以红色“+”开头的线条着色

... 以及以蓝色“-”开头的线条着色

...就足够了。

hello.c::

    +#else                                 <<<<< want this line in red
     ISR_RESULT ISRs(U32 Interrupt, U32 Vector)
    +#endif                                <<<<< want this line in red
     {
    -//     printf ("Get IRQs \r\n");      <<<<< want this line in blue
    -       switch (Interrupt)             <<<<< want this line in blue
    -       {                              <<<<< want this line in blue
    -         case ISR_MBOX0:              <<<<< want this line in blue

【问题讨论】:

  • 请附上代码示例。另请参阅 Sphinx 用作语言的diff lexers for pygments 列表。
  • 我按照史蒂夫的建议重写了代码示例。但史蒂夫指出的文件对我没有帮助。我从那里找不到任何提示...
  • 第一个demo the code that you want to diff。你的本地测试看起来像演示吗?如果是这样,那么要更改默认突出显示的样式,您需要在主题的 CSS 文件中应用自定义样式。
  • 谢谢史蒂夫!但是,对我来说并不是那么简单......但是感谢您提供演示服务网址。
  • @Jeonghum 你的*.rst 文件实际上是什么样子的?

标签: diff highlight restructuredtext


【解决方案1】:

您可能应该使用code-block directivePygment's diff lexer。您的*.rst 文件应该如下所示:

.. code-block:: diff

    +#else
     ISR_RESULT ISRs(U32 Interrupt, U32 Vector)
    +#endif
     {
    -//     printf ("Get IRQs \r\n");
    -       switch (Interrupt)
    -       {
    -         case ISR_MBOX0:

【讨论】:

  • 我错过了说谢谢!这是一个 100% 完美的答案!
猜你喜欢
  • 1970-01-01
  • 2017-05-02
  • 1970-01-01
  • 1970-01-01
  • 2015-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多