Search code examples
python-sphinxrestructuredtextdocutils

Security portion marking with Sphinx/rst


How can I successfully security portion mark paragraphs using Sphinx/rst?

(U) This is a portion marked heading
------------------------------------

(U) This is a portion marked sentence that renders not what I'd expect.

(U) This too is portion marked, and renders unexpectedly.

(U) This too is portion marked, but it does render fine when another sentence is placed directly below.
Next sentence.

When rendered (see below), the heading looks good, but the sentences look like a list. Using substitution/replace directives are not an acceptable solution due to strict requirements on portion marking information using ( and ) characters.

Rendered output:

(U) This is a portion marked heading

  U. This is a portion marked sentence that renders not what I'd expect.

  U. This too is portion marked, and renders unexpectedly.

(U) This too is portion marked, but it does render fine when another sentence is placed directly below. Next sentence.

Solution

  • This single line,

    (U) This is a portion marked sentence
    

    is interpreted as an item in an enumerated list, where (U) is the enumerator surrounded by parentheses.

    See http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#enumerated-lists. Here it says:

    If a single-line paragraph begins with text identical to an enumerator ("A.", "1.", "(b)", "I)", etc.), the first character will have to be escaped in order to have the line parsed as an ordinary paragraph:

    So a backslash in front of (U) will make the line display as an ordinary paragraph:

    \(U) This is a portion marked sentence