On 2022-05-06, Guenter Milde via Docutils-users wrote:
> Testing with the minimal example (provided in private mail) revealed that
> a backslash must be quadrupled to appear in the output (rsp. the doctree).
> This is a common "feature" if the same escape character is used two times...
> (The first escape-round is the generic rST escape handling.)
Some more experiments showed, that the CSV escape handling is first and
rST escape handling second::
.. csv-table::
:header: "testa\" \\*testb*", "testa \*testb*", 2\\\\a, 3\\b
:stub-columns: 1
1,"(1\\2)","(2,\ *3*)","(3,4)"
2,"(1,3)","(2,4)","(3,5)"
3,"(1,4)","(2,5)","(3,6)"
> Looking at the definitions in docutils/parsers/rst/directives/tables.py
> reveals that headers from the argument list and table content are parsed
> using different "CSV dialects": HeaderDialect vs. DocutilsDialect.
> Only the first defines an escape character.
>> If so, it this intentional? (In the csv-table data,
>> they just need to be doubled.)
> Given that this two different csv dialects are defined in tables.py
> since at least 2004, it may be intentional or a side-effect of some
> intention.
> OTOH, the documentation
> https://docutils.sourceforge.io/docs/ref/rst/directives.html#csv-table-1
> says regarding the "header" option:
> Must use the same CSV format as the main CSV data.
> Either implementation or documentation should be changed. Now we need to
> find out / decide which.
I favour a common dialect for content and header, because
using "\" as escapechar means "\\\\" is required for a literal
backslash in the header (but not the content cells)
because "\" is also used by the rST escape mechanism :(.
However, I may be just missing the motivation for
a separate HeaderDialect since the initial implementation
(r2309 "table-related directives" goodger 2004-06-18).
Günter
|