2011-06-29 144 views
39

是否可以在重組文本中敲擊文本?ReST刪除線

東西例如當轉換成HTML,像呈現爲<strike>標籤: reStructuredText的

+0

當您使用獅身人面像時,這可能有所幫助:http://stackoverflow.com/a/24932178/2923406 – Rolf

回答

39

我查了文檔更好,由威樂Säävuori的建議,我決定加入這樣的刪除線:

.. role:: strike 
    :class: strike 

在該文件中,這可以應用如下:

:strike:`This text is crossed out` 

然後在我css文件我有一個條目:

.strike { 
    text-decoration: line-through; 
} 
10

According to the official spec在休息透溼標記沒有指令。

但是,如果環境允許:raw:角色或者您可以編寫自己的角色,則可以爲其編寫自定義插件。

11

有我在做它至少在三個方面:

.. role:: strike 

An example of :strike:`strike through text`. 

.. container:: strike 

    Here the full block of test is striked through. 

An undecorated paragraph. 

.. class:: strike 

This paragraph too is is striked through. 

.. admonition:: cancelled 
    :class: strike 

I strike through cancelled text. 

應用rst2html後您將獲得:

<p>An example of <span class="strike">strike through text</span>.</p> 
<div class="strike container"> 
Here the full block of test is striked through.</div> 
<p>An undecorated paragraph.</p> 
<p class="strike">This paragraph too is is striked through.</p> 
<div class="strike admonition"> 
<p class="first admonition-title">cancelled</p> 
<p class="last">I strike through cancelled text.</p> 

你有風格

.strike { 
    text-decoration: line-through; 
} 

在這裏,我已經採取了admonition使用它們指令作爲示例,但任何 指令允許:class:選項 會做。

由於它生成spanrole指令是 允許將您的樣式應用於段落的一部分的唯一指令。

它是多餘的一類strike添加到指令又稱 strike,如建議Gozzilli,因爲指令的名稱是默認 類HTML輸出。

我檢查了這些語法都與rest2html斯芬克斯。但 雖然一切如預期rest2htmlclass 指令失敗斯芬克斯。你有

.. rst-class:: strike 

This paragraph too is is striked through. 

這是在小 footnote of Sphinx reSt Primer說來取代它。

+0

您確定該鏈接。我看起來並不像你想要的那樣。 – Tshepang

+2

@Tshepang,我查了一下,鏈接最終在一個腳註中聲明:_當默認域包含一個類指令時,該指令將被遮蔽。因此,獅身人面像將其重新出口爲rst級._ – marcz

+0

沒有注意到。抱歉。 – Tshepang

4

我發現其他答案非常有幫助。 我對斯芬克斯不是很熟悉,但是我將它用於一個項目。我也希望獲得突破性的能力,並根據以前的答案進行工作。 爲了清楚起見,我在gozzilli中提到了刪除線的角色,但是我使用rst_prolog變量將其保存在conf.py中,如堆棧溢出線程here中所述。這意味着這個角色可用於所有的休息文件。

然後,我通過在我的源代碼目錄中的_templates內創建layout.html來擴展基本html模板。這個文件的內容是:

{% extends "!layout.html" %} 
{% set css_files = css_files + ["_static/myStyle.css"] %} 

這基本上包括一個自定義的css文件到所有內置的默認html文檔。

最後,在我的源目錄中我_static目錄我包括其中包含的文件myStyle.css:哪些其他的答案已經提供

.strike { 
    text-decoration: line-through; 
} 

我只是寫這個答案,因爲它對我來說不是顯而易見的,我用有限的獅身人面像經驗來編輯文件。