From f02f8252e8345320643eb1d1cace32c78715f376 Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Wed, 19 Oct 2022 11:44:20 +1300 Subject: [PATCH] fix: Expand table columns in text output --- tests/valid/draft-miek-test.pages.text | 26 ++-- tests/valid/draft-miek-test.text | 26 ++-- tests/valid/draft-miek-test.txt | 26 ++-- tests/valid/elements.bom.text | 162 ++++++++++++------------- tests/valid/elements.pages.text | 162 ++++++++++++------------- tests/valid/elements.text | 154 +++++++++++------------ tests/valid/elements.wip.text | 162 ++++++++++++------------- tests/valid/manpage.txt | 43 ++++--- xml2rfc/writers/text.py | 16 ++- 9 files changed, 388 insertions(+), 389 deletions(-) diff --git a/tests/valid/draft-miek-test.pages.text b/tests/valid/draft-miek-test.pages.text index 75904750b..89e973ad2 100644 --- a/tests/valid/draft-miek-test.pages.text +++ b/tests/valid/draft-miek-test.pages.text @@ -1029,19 +1029,19 @@ A.8. Table Tests Table 1: Demonstration of simple table syntax. - +==========+=========+=========+==============================+ - | Centered | Default | Right | Left Aligned | - | Header | Aligned | Aligned | | - +==========+=========+=========+==============================+ - | First | row | 12.0 | Example of a row that spans | - | | | | multiple lines. | - +----------+---------+---------+------------------------------+ - | Second | row | 5.0 | Here's another one. Note | - | | | | the blank line between rows. | - +----------+---------+---------+------------------------------+ - - Table 2: Here's the caption. It, too, may span multiple - lines. This is a multiline table. This is verbatim text. + +=================+=========+=========+==============================+ + | Centered Header | Default | Right | Left Aligned | + | | Aligned | Aligned | | + +=================+=========+=========+==============================+ + | First | row | 12.0 | Example of a row that spans | + | | | | multiple lines. | + +-----------------+---------+---------+------------------------------+ + | Second | row | 5.0 | Here's another one. Note | + | | | | the blank line between rows. | + +-----------------+---------+---------+------------------------------+ + + Table 2: Here's the caption. It, too, may span multiple lines. + This is a multiline table. This is verbatim text. +=========+=======+==================+ diff --git a/tests/valid/draft-miek-test.text b/tests/valid/draft-miek-test.text index efda0e633..a264cc41c 100644 --- a/tests/valid/draft-miek-test.text +++ b/tests/valid/draft-miek-test.text @@ -867,19 +867,19 @@ A.8. Table Tests Table 1: Demonstration of simple table syntax. - +==========+=========+=========+==============================+ - | Centered | Default | Right | Left Aligned | - | Header | Aligned | Aligned | | - +==========+=========+=========+==============================+ - | First | row | 12.0 | Example of a row that spans | - | | | | multiple lines. | - +----------+---------+---------+------------------------------+ - | Second | row | 5.0 | Here's another one. Note | - | | | | the blank line between rows. | - +----------+---------+---------+------------------------------+ - - Table 2: Here's the caption. It, too, may span multiple - lines. This is a multiline table. This is verbatim text. + +=================+=========+=========+==============================+ + | Centered Header | Default | Right | Left Aligned | + | | Aligned | Aligned | | + +=================+=========+=========+==============================+ + | First | row | 12.0 | Example of a row that spans | + | | | | multiple lines. | + +-----------------+---------+---------+------------------------------+ + | Second | row | 5.0 | Here's another one. Note | + | | | | the blank line between rows. | + +-----------------+---------+---------+------------------------------+ + + Table 2: Here's the caption. It, too, may span multiple lines. + This is a multiline table. This is verbatim text. +=========+=======+==================+ diff --git a/tests/valid/draft-miek-test.txt b/tests/valid/draft-miek-test.txt index 5e5d75201..e0fbe4327 100644 --- a/tests/valid/draft-miek-test.txt +++ b/tests/valid/draft-miek-test.txt @@ -1029,19 +1029,19 @@ A.8. Table Tests Table 1: Demonstration of simple table syntax. - +==========+=========+=========+==============================+ - | Centered | Default | Right | Left Aligned | - | Header | Aligned | Aligned | | - +==========+=========+=========+==============================+ - | First | row | 12.0 | Example of a row that spans | - | | | | multiple lines. | - +----------+---------+---------+------------------------------+ - | Second | row | 5.0 | Here's another one. Note | - | | | | the blank line between rows. | - +----------+---------+---------+------------------------------+ - - Table 2: Here's the caption. It, too, may span multiple - lines. This is a multiline table. This is verbatim text. + +=================+=========+=========+==============================+ + | Centered Header | Default | Right | Left Aligned | + | | Aligned | Aligned | | + +=================+=========+=========+==============================+ + | First | row | 12.0 | Example of a row that spans | + | | | | multiple lines. | + +-----------------+---------+---------+------------------------------+ + | Second | row | 5.0 | Here's another one. Note | + | | | | the blank line between rows. | + +-----------------+---------+---------+------------------------------+ + + Table 2: Here's the caption. It, too, may span multiple lines. + This is a multiline table. This is verbatim text. +=========+=======+==================+ diff --git a/tests/valid/elements.bom.text b/tests/valid/elements.bom.text index 11611ce86..0011f08fb 100644 --- a/tests/valid/elements.bom.text +++ b/tests/valid/elements.bom.text @@ -582,28 +582,27 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 | | | | | +-----+-----+-----+-----+ - +===============================+=====================+=========+ - | A | B | C D | - +===============================+=====================+====+====+ - | 1 | 2 | 3 | 4 | - +===============================+=====================+====+====+ - | Long text in a single cell | b1 | c1 | d1 | - +-------------------------------+---------------------+----+----+ - | Long text in a 3-cell column. | Long text in a 3-cell row. | - | Quid igitur est? Inquit; | Quid enim est a Cyrenaicisque | - | audire enim cupio, quid non | melius liberiusque | - | probes eius, a quo | defenditur, tamen eius modi | - | dissentias. | tempora incidunt, ut labore | - | | et dolore disputandum putant. | - | +---------------------+----+----+ - | | Another 3-cell | c3 | d3 | - | | column. +----+----+ - | | | x | - +-------------------------------+ +----+----+ - | a5 | | c5 | d5 | - +-------------------------------+---------------------+----+----+ - | aa | bb | cc | dd | - +-------------------------------+---------------------+----+----+ + +================================+============================+=========+ + | A | B | C D | + +================================+============================+====+====+ + | 1 | 2 | 3 | 4 | + +================================+============================+====+====+ + | Long text in a single cell | b1 | c1 | d1 | + +--------------------------------+----------------------------+----+----+ + | Long text in a 3-cell column. | Long text in a 3-cell row. | + | Quid igitur est? Inquit; | Quid enim est a Cyrenaicisque melius | + | audire enim cupio, quid non | liberiusque defenditur, tamen eius | + | probes eius, a quo dissentias. | modi tempora incidunt, ut labore et | + | | dolore disputandum putant. | + | +----------------------------+----+----+ + | | Another 3-cell column. | c3 | d3 | + | | +----+----+ + | | | x | + +--------------------------------+ +----+----+ + | a5 | | c5 | d5 | + +--------------------------------+----------------------------+----+----+ + | aa | bb | cc | dd | + +--------------------------------+----------------------------+----+----+ Table 1: Header, footer, colspan and rowspan Default alignment @@ -613,26 +612,23 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + Author, et al. Expires 13 January 2019 [Page 11] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +========+========+=================+=====+=====+=========+=========+ - |Column |Column |Column |TC |TC | TC | TC | - |Title 1 |Tilte 2 |Title |4 |5 | 6 | 7 | - | | |3 | | | | | - | | +==+==+==+==+==+==+==+==+==+==+====+====+====+====+ - | | |C1|C2|C3|C4|C5|C6|C1|C2|C1|C2| C1 | C2 | C1 | C2 | - +========+========+==+==+==+==+==+==+==+==+==+==+====+====+====+====+ - |Major |Minor |x |x |x |x |x |x |x |x |x |x | x | x | x | x | - |Row 1, |Row 1, | | | | | | | | | | | | | | | - |Column 1|Column 2| | | | | | | | | | | | | | | - | +--------+--+--+--+--+--+--+--+--+--+--+----+----+----+----+ - | |Minor |x |x |x |x |x |x |x |x |x |x | x | x | x | x | - | |Row 2, | | | | | | | | | | | | | | | - | |Column 2| | | | | | | | | | | | | | | - +--------+--------+--+--+--+--+--+--+--+--+--+--+----+----+----+----+ + +=============+=============+=================+=====+=======+=========+=========+ + | Column | Column |Column Title 3 |TC 4 |TC 5 | TC 6 | TC 7 | + | Title 1 | Tilte 2 +==+==+==+==+==+==+==+==+==+====+====+====+====+====+ + | | |C1|C2|C3|C4|C5|C6|C1|C2|C1| C2 | C1 | C2 | C1 | C2 | + +=============+=============+==+==+==+==+==+==+==+==+==+====+====+====+====+====+ + | Major Row | Minor Row |x |x |x |x |x |x |x |x |x | x | x | x | x | x | + | 1, Column 1 | 1, Column 2 | | | | | | | | | | | | | | | + | +-------------+--+--+--+--+--+--+--+--+--+----+----+----+----+----+ + | | Minor Row |x |x |x |x |x |x |x |x |x | x | x | x | x | x | + | | 2, Column 2 | | | | | | | | | | | | | | | + +-------------+-------------+--+--+--+--+--+--+--+--+--+----+----+----+----+----+ Table 2: Large colspan @@ -669,35 +665,40 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + + + Author, et al. Expires 13 January 2019 [Page 12] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +======+===========+======+========+=================+======+=======+ - |Method|Definition |ptype |property|Value |Status|Version| - +======+===========+======+========+=================+======+=======+ - |dnswl |RFC 8904 |dns |zone |DNSWL publicly |active|1 | - | | | | |accessible query | | | - | | | | |root domain | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |policy|ip |type A response |active|1 | - | | | | |received (or a | | | - | | | | |quoted, comma- | | | - | | | | |separated list | | | - | | | | |thereof) | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |policy|txt |type TXT query |active|1 | - | | | | |response | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |dns |sec |one of "yes" for |active|1 | - | | | | |DNSSEC | | | - | | | | |authenticated | | | - | | | | |data, "no" for | | | - | | | | |not signed, or | | | - | | | | |"na" for not | | | - | | | | |applicable | | | - +------+-----------+------+--------+-----------------+------+-------+ + +======+============+======+=========+====================+======+=======+ + |Method| Definition |ptype |property | Value |Status|Version| + +======+============+======+=========+====================+======+=======+ + |dnswl | RFC 8904 |dns |zone | DNSWL publicly |active|1 | + | | | | | accessible | | | + | | | | | query root | | | + | | | | | domain | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |policy|ip | type A response |active|1 | + | | | | | received (or a | | | + | | | | | quoted, comma- | | | + | | | | | separated list | | | + | | | | | thereof) | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |policy|txt | type TXT query |active|1 | + | | | | | response | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |dns |sec | one of "yes" |active|1 | + | | | | | for DNSSEC | | | + | | | | | authenticated | | | + | | | | | data, "no" for | | | + | | | | | not signed, or | | | + | | | | | "na" for not | | | + | | | | | applicable | | | + +------+------------+------+---------+--------------------+------+-------+ Table 6 @@ -724,7 +725,6 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - Author, et al. Expires 13 January 2019 [Page 13] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 @@ -1178,25 +1178,23 @@ Author, et al. Expires 13 January 2019 [Page 21] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +=====+=====+===================+====================+ - | SPI | SI | Next Hop(s) | Transport | - | | | | Encapsulation (TE) | - +=====+=====+===================+====================+ - | 10 | 255 | 192.0.2.1 | VXLAN-gpe | - +-----+-----+-------------------+--------------------+ - | 10 | 254 | 198.51.100.10 | GRE | - +-----+-----+-------------------+--------------------+ - | 10 | 253 | www.example.com | HTTP | - +-----+-----+-------------------+--------------------+ - | 10 | 252 | www.example2.com | HTTP | - +-----+-----+-------------------+--------------------+ - | 40 | 251 | 198.51.100.15 | GRE | - +-----+-----+-------------------+--------------------+ - | 50 | 200 | 01:23:45:67:89:ab | Ethernet | - +-----+-----+-------------------+--------------------+ - | 15 | 212 | Null (end of | None | - | | | path) | | - +-----+-----+-------------------+--------------------+ + +=====+=====+====================+==============================+ + | SPI | SI | Next Hop(s) | Transport Encapsulation (TE) | + +=====+=====+====================+==============================+ + | 10 | 255 | 192.0.2.1 | VXLAN-gpe | + +-----+-----+--------------------+------------------------------+ + | 10 | 254 | 198.51.100.10 | GRE | + +-----+-----+--------------------+------------------------------+ + | 10 | 253 | www.example.com | HTTP | + +-----+-----+--------------------+------------------------------+ + | 10 | 252 | www.example2.com | HTTP | + +-----+-----+--------------------+------------------------------+ + | 40 | 251 | 198.51.100.15 | GRE | + +-----+-----+--------------------+------------------------------+ + | 50 | 200 | 01:23:45:67:89:ab | Ethernet | + +-----+-----+--------------------+------------------------------+ + | 15 | 212 | Null (end of path) | None | + +-----+-----+--------------------+------------------------------+ Table 7: nNLM at nSFF1 @@ -1229,6 +1227,8 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + Author, et al. Expires 13 January 2019 [Page 22] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 diff --git a/tests/valid/elements.pages.text b/tests/valid/elements.pages.text index 88b8d5916..5bf686cbd 100644 --- a/tests/valid/elements.pages.text +++ b/tests/valid/elements.pages.text @@ -582,28 +582,27 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 | | | | | +-----+-----+-----+-----+ - +===============================+=====================+=========+ - | A | B | C D | - +===============================+=====================+====+====+ - | 1 | 2 | 3 | 4 | - +===============================+=====================+====+====+ - | Long text in a single cell | b1 | c1 | d1 | - +-------------------------------+---------------------+----+----+ - | Long text in a 3-cell column. | Long text in a 3-cell row. | - | Quid igitur est? Inquit; | Quid enim est a Cyrenaicisque | - | audire enim cupio, quid non | melius liberiusque | - | probes eius, a quo | defenditur, tamen eius modi | - | dissentias. | tempora incidunt, ut labore | - | | et dolore disputandum putant. | - | +---------------------+----+----+ - | | Another 3-cell | c3 | d3 | - | | column. +----+----+ - | | | x | - +-------------------------------+ +----+----+ - | a5 | | c5 | d5 | - +-------------------------------+---------------------+----+----+ - | aa | bb | cc | dd | - +-------------------------------+---------------------+----+----+ + +================================+============================+=========+ + | A | B | C D | + +================================+============================+====+====+ + | 1 | 2 | 3 | 4 | + +================================+============================+====+====+ + | Long text in a single cell | b1 | c1 | d1 | + +--------------------------------+----------------------------+----+----+ + | Long text in a 3-cell column. | Long text in a 3-cell row. | + | Quid igitur est? Inquit; | Quid enim est a Cyrenaicisque melius | + | audire enim cupio, quid non | liberiusque defenditur, tamen eius | + | probes eius, a quo dissentias. | modi tempora incidunt, ut labore et | + | | dolore disputandum putant. | + | +----------------------------+----+----+ + | | Another 3-cell column. | c3 | d3 | + | | +----+----+ + | | | x | + +--------------------------------+ +----+----+ + | a5 | | c5 | d5 | + +--------------------------------+----------------------------+----+----+ + | aa | bb | cc | dd | + +--------------------------------+----------------------------+----+----+ Table 1: Header, footer, colspan and rowspan Default alignment @@ -613,26 +612,23 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + Author, et al. Expires January 13, 2019 [Page 11] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +========+========+=================+=====+=====+=========+=========+ - |Column |Column |Column |TC |TC | TC | TC | - |Title 1 |Tilte 2 |Title |4 |5 | 6 | 7 | - | | |3 | | | | | - | | +==+==+==+==+==+==+==+==+==+==+====+====+====+====+ - | | |C1|C2|C3|C4|C5|C6|C1|C2|C1|C2| C1 | C2 | C1 | C2 | - +========+========+==+==+==+==+==+==+==+==+==+==+====+====+====+====+ - |Major |Minor |x |x |x |x |x |x |x |x |x |x | x | x | x | x | - |Row 1, |Row 1, | | | | | | | | | | | | | | | - |Column 1|Column 2| | | | | | | | | | | | | | | - | +--------+--+--+--+--+--+--+--+--+--+--+----+----+----+----+ - | |Minor |x |x |x |x |x |x |x |x |x |x | x | x | x | x | - | |Row 2, | | | | | | | | | | | | | | | - | |Column 2| | | | | | | | | | | | | | | - +--------+--------+--+--+--+--+--+--+--+--+--+--+----+----+----+----+ + +=============+=============+=================+=====+=======+=========+=========+ + | Column | Column |Column Title 3 |TC 4 |TC 5 | TC 6 | TC 7 | + | Title 1 | Tilte 2 +==+==+==+==+==+==+==+==+==+====+====+====+====+====+ + | | |C1|C2|C3|C4|C5|C6|C1|C2|C1| C2 | C1 | C2 | C1 | C2 | + +=============+=============+==+==+==+==+==+==+==+==+==+====+====+====+====+====+ + | Major Row | Minor Row |x |x |x |x |x |x |x |x |x | x | x | x | x | x | + | 1, Column 1 | 1, Column 2 | | | | | | | | | | | | | | | + | +-------------+--+--+--+--+--+--+--+--+--+----+----+----+----+----+ + | | Minor Row |x |x |x |x |x |x |x |x |x | x | x | x | x | x | + | | 2, Column 2 | | | | | | | | | | | | | | | + +-------------+-------------+--+--+--+--+--+--+--+--+--+----+----+----+----+----+ Table 2: Large colspan @@ -669,35 +665,40 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + + + Author, et al. Expires January 13, 2019 [Page 12] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +======+===========+======+========+=================+======+=======+ - |Method|Definition |ptype |property|Value |Status|Version| - +======+===========+======+========+=================+======+=======+ - |dnswl |RFC 8904 |dns |zone |DNSWL publicly |active|1 | - | | | | |accessible query | | | - | | | | |root domain | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |policy|ip |type A response |active|1 | - | | | | |received (or a | | | - | | | | |quoted, comma- | | | - | | | | |separated list | | | - | | | | |thereof) | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |policy|txt |type TXT query |active|1 | - | | | | |response | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |dns |sec |one of "yes" for |active|1 | - | | | | |DNSSEC | | | - | | | | |authenticated | | | - | | | | |data, "no" for | | | - | | | | |not signed, or | | | - | | | | |"na" for not | | | - | | | | |applicable | | | - +------+-----------+------+--------+-----------------+------+-------+ + +======+============+======+=========+====================+======+=======+ + |Method| Definition |ptype |property | Value |Status|Version| + +======+============+======+=========+====================+======+=======+ + |dnswl | RFC 8904 |dns |zone | DNSWL publicly |active|1 | + | | | | | accessible | | | + | | | | | query root | | | + | | | | | domain | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |policy|ip | type A response |active|1 | + | | | | | received (or a | | | + | | | | | quoted, comma- | | | + | | | | | separated list | | | + | | | | | thereof) | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |policy|txt | type TXT query |active|1 | + | | | | | response | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |dns |sec | one of "yes" |active|1 | + | | | | | for DNSSEC | | | + | | | | | authenticated | | | + | | | | | data, "no" for | | | + | | | | | not signed, or | | | + | | | | | "na" for not | | | + | | | | | applicable | | | + +------+------------+------+---------+--------------------+------+-------+ Table 6 @@ -724,7 +725,6 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - Author, et al. Expires January 13, 2019 [Page 13] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 @@ -1178,25 +1178,23 @@ Author, et al. Expires January 13, 2019 [Page 21] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +=====+=====+===================+====================+ - | SPI | SI | Next Hop(s) | Transport | - | | | | Encapsulation (TE) | - +=====+=====+===================+====================+ - | 10 | 255 | 192.0.2.1 | VXLAN-gpe | - +-----+-----+-------------------+--------------------+ - | 10 | 254 | 198.51.100.10 | GRE | - +-----+-----+-------------------+--------------------+ - | 10 | 253 | www.example.com | HTTP | - +-----+-----+-------------------+--------------------+ - | 10 | 252 | www.example2.com | HTTP | - +-----+-----+-------------------+--------------------+ - | 40 | 251 | 198.51.100.15 | GRE | - +-----+-----+-------------------+--------------------+ - | 50 | 200 | 01:23:45:67:89:ab | Ethernet | - +-----+-----+-------------------+--------------------+ - | 15 | 212 | Null (end of | None | - | | | path) | | - +-----+-----+-------------------+--------------------+ + +=====+=====+====================+==============================+ + | SPI | SI | Next Hop(s) | Transport Encapsulation (TE) | + +=====+=====+====================+==============================+ + | 10 | 255 | 192.0.2.1 | VXLAN-gpe | + +-----+-----+--------------------+------------------------------+ + | 10 | 254 | 198.51.100.10 | GRE | + +-----+-----+--------------------+------------------------------+ + | 10 | 253 | www.example.com | HTTP | + +-----+-----+--------------------+------------------------------+ + | 10 | 252 | www.example2.com | HTTP | + +-----+-----+--------------------+------------------------------+ + | 40 | 251 | 198.51.100.15 | GRE | + +-----+-----+--------------------+------------------------------+ + | 50 | 200 | 01:23:45:67:89:ab | Ethernet | + +-----+-----+--------------------+------------------------------+ + | 15 | 212 | Null (end of path) | None | + +-----+-----+--------------------+------------------------------+ Table 7: nNLM at nSFF1 @@ -1229,6 +1227,8 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + Author, et al. Expires January 13, 2019 [Page 22] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 diff --git a/tests/valid/elements.text b/tests/valid/elements.text index b71d95da0..b6892a9c3 100644 --- a/tests/valid/elements.text +++ b/tests/valid/elements.text @@ -492,47 +492,42 @@ Table of Contents | | | | | +-----+-----+-----+-----+ - +===============================+=====================+=========+ - | A | B | C D | - +===============================+=====================+====+====+ - | 1 | 2 | 3 | 4 | - +===============================+=====================+====+====+ - | Long text in a single cell | b1 | c1 | d1 | - +-------------------------------+---------------------+----+----+ - | Long text in a 3-cell column. | Long text in a 3-cell row. | - | Quid igitur est? Inquit; | Quid enim est a Cyrenaicisque | - | audire enim cupio, quid non | melius liberiusque | - | probes eius, a quo | defenditur, tamen eius modi | - | dissentias. | tempora incidunt, ut labore | - | | et dolore disputandum putant. | - | +---------------------+----+----+ - | | Another 3-cell | c3 | d3 | - | | column. +----+----+ - | | | x | - +-------------------------------+ +----+----+ - | a5 | | c5 | d5 | - +-------------------------------+---------------------+----+----+ - | aa | bb | cc | dd | - +-------------------------------+---------------------+----+----+ + +================================+============================+=========+ + | A | B | C D | + +================================+============================+====+====+ + | 1 | 2 | 3 | 4 | + +================================+============================+====+====+ + | Long text in a single cell | b1 | c1 | d1 | + +--------------------------------+----------------------------+----+----+ + | Long text in a 3-cell column. | Long text in a 3-cell row. | + | Quid igitur est? Inquit; | Quid enim est a Cyrenaicisque melius | + | audire enim cupio, quid non | liberiusque defenditur, tamen eius | + | probes eius, a quo dissentias. | modi tempora incidunt, ut labore et | + | | dolore disputandum putant. | + | +----------------------------+----+----+ + | | Another 3-cell column. | c3 | d3 | + | | +----+----+ + | | | x | + +--------------------------------+ +----+----+ + | a5 | | c5 | d5 | + +--------------------------------+----------------------------+----+----+ + | aa | bb | cc | dd | + +--------------------------------+----------------------------+----+----+ Table 1: Header, footer, colspan and rowspan Default alignment - +========+========+=================+=====+=====+=========+=========+ - |Column |Column |Column |TC |TC | TC | TC | - |Title 1 |Tilte 2 |Title |4 |5 | 6 | 7 | - | | |3 | | | | | - | | +==+==+==+==+==+==+==+==+==+==+====+====+====+====+ - | | |C1|C2|C3|C4|C5|C6|C1|C2|C1|C2| C1 | C2 | C1 | C2 | - +========+========+==+==+==+==+==+==+==+==+==+==+====+====+====+====+ - |Major |Minor |x |x |x |x |x |x |x |x |x |x | x | x | x | x | - |Row 1, |Row 1, | | | | | | | | | | | | | | | - |Column 1|Column 2| | | | | | | | | | | | | | | - | +--------+--+--+--+--+--+--+--+--+--+--+----+----+----+----+ - | |Minor |x |x |x |x |x |x |x |x |x |x | x | x | x | x | - | |Row 2, | | | | | | | | | | | | | | | - | |Column 2| | | | | | | | | | | | | | | - +--------+--------+--+--+--+--+--+--+--+--+--+--+----+----+----+----+ + +=============+=============+=================+=====+=======+=========+=========+ + | Column | Column |Column Title 3 |TC 4 |TC 5 | TC 6 | TC 7 | + | Title 1 | Tilte 2 +==+==+==+==+==+==+==+==+==+====+====+====+====+====+ + | | |C1|C2|C3|C4|C5|C6|C1|C2|C1| C2 | C1 | C2 | C1 | C2 | + +=============+=============+==+==+==+==+==+==+==+==+==+====+====+====+====+====+ + | Major Row | Minor Row |x |x |x |x |x |x |x |x |x | x | x | x | x | x | + | 1, Column 1 | 1, Column 2 | | | | | | | | | | | | | | | + | +-------------+--+--+--+--+--+--+--+--+--+----+----+----+----+----+ + | | Minor Row |x |x |x |x |x |x |x |x |x | x | x | x | x | x | + | | 2, Column 2 | | | | | | | | | | | | | | | + +-------------+-------------+--+--+--+--+--+--+--+--+--+----+----+----+----+----+ Table 2: Large colspan @@ -563,30 +558,31 @@ Table of Contents A really tight table where left padding cannot be applied as it would throw the left-alignment of the text off. - +======+===========+======+========+=================+======+=======+ - |Method|Definition |ptype |property|Value |Status|Version| - +======+===========+======+========+=================+======+=======+ - |dnswl |RFC 8904 |dns |zone |DNSWL publicly |active|1 | - | | | | |accessible query | | | - | | | | |root domain | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |policy|ip |type A response |active|1 | - | | | | |received (or a | | | - | | | | |quoted, comma- | | | - | | | | |separated list | | | - | | | | |thereof) | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |policy|txt |type TXT query |active|1 | - | | | | |response | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |dns |sec |one of "yes" for |active|1 | - | | | | |DNSSEC | | | - | | | | |authenticated | | | - | | | | |data, "no" for | | | - | | | | |not signed, or | | | - | | | | |"na" for not | | | - | | | | |applicable | | | - +------+-----------+------+--------+-----------------+------+-------+ + +======+============+======+=========+====================+======+=======+ + |Method| Definition |ptype |property | Value |Status|Version| + +======+============+======+=========+====================+======+=======+ + |dnswl | RFC 8904 |dns |zone | DNSWL publicly |active|1 | + | | | | | accessible | | | + | | | | | query root | | | + | | | | | domain | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |policy|ip | type A response |active|1 | + | | | | | received (or a | | | + | | | | | quoted, comma- | | | + | | | | | separated list | | | + | | | | | thereof) | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |policy|txt | type TXT query |active|1 | + | | | | | response | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |dns |sec | one of "yes" |active|1 | + | | | | | for DNSSEC | | | + | | | | | authenticated | | | + | | | | | data, "no" for | | | + | | | | | not signed, or | | | + | | | | | "na" for not | | | + | | | | | applicable | | | + +------+------------+------+---------+--------------------+------+-------+ Table 6 @@ -974,25 +970,23 @@ Table of Contents At nSFF1, the following nNLM is assumed: - +=====+=====+===================+====================+ - | SPI | SI | Next Hop(s) | Transport | - | | | | Encapsulation (TE) | - +=====+=====+===================+====================+ - | 10 | 255 | 192.0.2.1 | VXLAN-gpe | - +-----+-----+-------------------+--------------------+ - | 10 | 254 | 198.51.100.10 | GRE | - +-----+-----+-------------------+--------------------+ - | 10 | 253 | www.example.com | HTTP | - +-----+-----+-------------------+--------------------+ - | 10 | 252 | www.example2.com | HTTP | - +-----+-----+-------------------+--------------------+ - | 40 | 251 | 198.51.100.15 | GRE | - +-----+-----+-------------------+--------------------+ - | 50 | 200 | 01:23:45:67:89:ab | Ethernet | - +-----+-----+-------------------+--------------------+ - | 15 | 212 | Null (end of | None | - | | | path) | | - +-----+-----+-------------------+--------------------+ + +=====+=====+====================+==============================+ + | SPI | SI | Next Hop(s) | Transport Encapsulation (TE) | + +=====+=====+====================+==============================+ + | 10 | 255 | 192.0.2.1 | VXLAN-gpe | + +-----+-----+--------------------+------------------------------+ + | 10 | 254 | 198.51.100.10 | GRE | + +-----+-----+--------------------+------------------------------+ + | 10 | 253 | www.example.com | HTTP | + +-----+-----+--------------------+------------------------------+ + | 10 | 252 | www.example2.com | HTTP | + +-----+-----+--------------------+------------------------------+ + | 40 | 251 | 198.51.100.15 | GRE | + +-----+-----+--------------------+------------------------------+ + | 50 | 200 | 01:23:45:67:89:ab | Ethernet | + +-----+-----+--------------------+------------------------------+ + | 15 | 212 | Null (end of path) | None | + +-----+-----+--------------------+------------------------------+ Table 7: nNLM at nSFF1 diff --git a/tests/valid/elements.wip.text b/tests/valid/elements.wip.text index 452a6c9f0..34b490c9c 100644 --- a/tests/valid/elements.wip.text +++ b/tests/valid/elements.wip.text @@ -582,28 +582,27 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 | | | | | +-----+-----+-----+-----+ - +===============================+=====================+=========+ - | A | B | C D | - +===============================+=====================+====+====+ - | 1 | 2 | 3 | 4 | - +===============================+=====================+====+====+ - | Long text in a single cell | b1 | c1 | d1 | - +-------------------------------+---------------------+----+----+ - | Long text in a 3-cell column. | Long text in a 3-cell row. | - | Quid igitur est? Inquit; | Quid enim est a Cyrenaicisque | - | audire enim cupio, quid non | melius liberiusque | - | probes eius, a quo | defenditur, tamen eius modi | - | dissentias. | tempora incidunt, ut labore | - | | et dolore disputandum putant. | - | +---------------------+----+----+ - | | Another 3-cell | c3 | d3 | - | | column. +----+----+ - | | | x | - +-------------------------------+ +----+----+ - | a5 | | c5 | d5 | - +-------------------------------+---------------------+----+----+ - | aa | bb | cc | dd | - +-------------------------------+---------------------+----+----+ + +================================+============================+=========+ + | A | B | C D | + +================================+============================+====+====+ + | 1 | 2 | 3 | 4 | + +================================+============================+====+====+ + | Long text in a single cell | b1 | c1 | d1 | + +--------------------------------+----------------------------+----+----+ + | Long text in a 3-cell column. | Long text in a 3-cell row. | + | Quid igitur est? Inquit; | Quid enim est a Cyrenaicisque melius | + | audire enim cupio, quid non | liberiusque defenditur, tamen eius | + | probes eius, a quo dissentias. | modi tempora incidunt, ut labore et | + | | dolore disputandum putant. | + | +----------------------------+----+----+ + | | Another 3-cell column. | c3 | d3 | + | | +----+----+ + | | | x | + +--------------------------------+ +----+----+ + | a5 | | c5 | d5 | + +--------------------------------+----------------------------+----+----+ + | aa | bb | cc | dd | + +--------------------------------+----------------------------+----+----+ Table 1: Header, footer, colspan and rowspan Default alignment @@ -613,26 +612,23 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + Author, et al. Expires 13 January 2019 [Page 11] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +========+========+=================+=====+=====+=========+=========+ - |Column |Column |Column |TC |TC | TC | TC | - |Title 1 |Tilte 2 |Title |4 |5 | 6 | 7 | - | | |3 | | | | | - | | +==+==+==+==+==+==+==+==+==+==+====+====+====+====+ - | | |C1|C2|C3|C4|C5|C6|C1|C2|C1|C2| C1 | C2 | C1 | C2 | - +========+========+==+==+==+==+==+==+==+==+==+==+====+====+====+====+ - |Major |Minor |x |x |x |x |x |x |x |x |x |x | x | x | x | x | - |Row 1, |Row 1, | | | | | | | | | | | | | | | - |Column 1|Column 2| | | | | | | | | | | | | | | - | +--------+--+--+--+--+--+--+--+--+--+--+----+----+----+----+ - | |Minor |x |x |x |x |x |x |x |x |x |x | x | x | x | x | - | |Row 2, | | | | | | | | | | | | | | | - | |Column 2| | | | | | | | | | | | | | | - +--------+--------+--+--+--+--+--+--+--+--+--+--+----+----+----+----+ + +=============+=============+=================+=====+=======+=========+=========+ + | Column | Column |Column Title 3 |TC 4 |TC 5 | TC 6 | TC 7 | + | Title 1 | Tilte 2 +==+==+==+==+==+==+==+==+==+====+====+====+====+====+ + | | |C1|C2|C3|C4|C5|C6|C1|C2|C1| C2 | C1 | C2 | C1 | C2 | + +=============+=============+==+==+==+==+==+==+==+==+==+====+====+====+====+====+ + | Major Row | Minor Row |x |x |x |x |x |x |x |x |x | x | x | x | x | x | + | 1, Column 1 | 1, Column 2 | | | | | | | | | | | | | | | + | +-------------+--+--+--+--+--+--+--+--+--+----+----+----+----+----+ + | | Minor Row |x |x |x |x |x |x |x |x |x | x | x | x | x | x | + | | 2, Column 2 | | | | | | | | | | | | | | | + +-------------+-------------+--+--+--+--+--+--+--+--+--+----+----+----+----+----+ Table 2: Large colspan @@ -669,35 +665,40 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + + + Author, et al. Expires 13 January 2019 [Page 12] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +======+===========+======+========+=================+======+=======+ - |Method|Definition |ptype |property|Value |Status|Version| - +======+===========+======+========+=================+======+=======+ - |dnswl |RFC 8904 |dns |zone |DNSWL publicly |active|1 | - | | | | |accessible query | | | - | | | | |root domain | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |policy|ip |type A response |active|1 | - | | | | |received (or a | | | - | | | | |quoted, comma- | | | - | | | | |separated list | | | - | | | | |thereof) | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |policy|txt |type TXT query |active|1 | - | | | | |response | | | - +------+-----------+------+--------+-----------------+------+-------+ - |dnswl |RFC 8904 |dns |sec |one of "yes" for |active|1 | - | | | | |DNSSEC | | | - | | | | |authenticated | | | - | | | | |data, "no" for | | | - | | | | |not signed, or | | | - | | | | |"na" for not | | | - | | | | |applicable | | | - +------+-----------+------+--------+-----------------+------+-------+ + +======+============+======+=========+====================+======+=======+ + |Method| Definition |ptype |property | Value |Status|Version| + +======+============+======+=========+====================+======+=======+ + |dnswl | RFC 8904 |dns |zone | DNSWL publicly |active|1 | + | | | | | accessible | | | + | | | | | query root | | | + | | | | | domain | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |policy|ip | type A response |active|1 | + | | | | | received (or a | | | + | | | | | quoted, comma- | | | + | | | | | separated list | | | + | | | | | thereof) | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |policy|txt | type TXT query |active|1 | + | | | | | response | | | + +------+------------+------+---------+--------------------+------+-------+ + |dnswl | RFC 8904 |dns |sec | one of "yes" |active|1 | + | | | | | for DNSSEC | | | + | | | | | authenticated | | | + | | | | | data, "no" for | | | + | | | | | not signed, or | | | + | | | | | "na" for not | | | + | | | | | applicable | | | + +------+------------+------+---------+--------------------+------+-------+ Table 6 @@ -724,7 +725,6 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - Author, et al. Expires 13 January 2019 [Page 13] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 @@ -1178,25 +1178,23 @@ Author, et al. Expires 13 January 2019 [Page 21] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 - +=====+=====+===================+====================+ - | SPI | SI | Next Hop(s) | Transport | - | | | | Encapsulation (TE) | - +=====+=====+===================+====================+ - | 10 | 255 | 192.0.2.1 | VXLAN-gpe | - +-----+-----+-------------------+--------------------+ - | 10 | 254 | 198.51.100.10 | GRE | - +-----+-----+-------------------+--------------------+ - | 10 | 253 | www.example.com | HTTP | - +-----+-----+-------------------+--------------------+ - | 10 | 252 | www.example2.com | HTTP | - +-----+-----+-------------------+--------------------+ - | 40 | 251 | 198.51.100.15 | GRE | - +-----+-----+-------------------+--------------------+ - | 50 | 200 | 01:23:45:67:89:ab | Ethernet | - +-----+-----+-------------------+--------------------+ - | 15 | 212 | Null (end of | None | - | | | path) | | - +-----+-----+-------------------+--------------------+ + +=====+=====+====================+==============================+ + | SPI | SI | Next Hop(s) | Transport Encapsulation (TE) | + +=====+=====+====================+==============================+ + | 10 | 255 | 192.0.2.1 | VXLAN-gpe | + +-----+-----+--------------------+------------------------------+ + | 10 | 254 | 198.51.100.10 | GRE | + +-----+-----+--------------------+------------------------------+ + | 10 | 253 | www.example.com | HTTP | + +-----+-----+--------------------+------------------------------+ + | 10 | 252 | www.example2.com | HTTP | + +-----+-----+--------------------+------------------------------+ + | 40 | 251 | 198.51.100.15 | GRE | + +-----+-----+--------------------+------------------------------+ + | 50 | 200 | 01:23:45:67:89:ab | Ethernet | + +-----+-----+--------------------+------------------------------+ + | 15 | 212 | Null (end of path) | None | + +-----+-----+--------------------+------------------------------+ Table 7: nNLM at nSFF1 @@ -1229,6 +1227,8 @@ Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 + + Author, et al. Expires 13 January 2019 [Page 22] Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018 diff --git a/tests/valid/manpage.txt b/tests/valid/manpage.txt index 79e9fcb6d..f9272d306 100644 --- a/tests/valid/manpage.txt +++ b/tests/valid/manpage.txt @@ -2321,28 +2321,27 @@ Table of Contents comes out as shown below: - +===+=============+=========================================+ - | # | Nickname | Output for comparison | - +===+=============+=========================================+ - | 1 | | | - +---+-------------+-----------------------------------------+ - | 2 | | | - +---+-------------+-----------------------------------------+ - | 3 | | | - +---+-------------+-----------------------------------------+ - | 4 | | | - +---+-------------+-----------------------------------------+ - | 5 | <Σ> | GREEK CAPITAL LETTER SIGMA (U+03A3) | - +---+-------------+-----------------------------------------+ - | 6 | <σ> | GREEK SMALL LETTER SIGMA (U+03C3) | - +---+-------------+-----------------------------------------+ - | 7 | <ς> | GREEK SMALL LETTER FINAL SIGMA (U+03C2) | - +---+-------------+-----------------------------------------+ - | 8 | <♚> | BLACK CHESS KING (U+265A) | - +---+-------------+-----------------------------------------+ - | 9 | | | - | | (U+2163) | | - +---+-------------+-----------------------------------------+ + +===+======================+=========================================+ + | # | Nickname | Output for comparison | + +===+======================+=========================================+ + | 1 | | | + +---+----------------------+-----------------------------------------+ + | 2 | | | + +---+----------------------+-----------------------------------------+ + | 3 | | | + +---+----------------------+-----------------------------------------+ + | 4 | | | + +---+----------------------+-----------------------------------------+ + | 5 | <Σ> | GREEK CAPITAL LETTER SIGMA (U+03A3) | + +---+----------------------+-----------------------------------------+ + | 6 | <σ> | GREEK SMALL LETTER SIGMA (U+03C3) | + +---+----------------------+-----------------------------------------+ + | 7 | <ς> | GREEK SMALL LETTER FINAL SIGMA (U+03C2) | + +---+----------------------+-----------------------------------------+ + | 8 | <♚> | BLACK CHESS KING (U+265A) | + +---+----------------------+-----------------------------------------+ + | 9 | (U+2163) | | + +---+----------------------+-----------------------------------------+ Table 1: A Sample of Legal Nicknames diff --git a/xml2rfc/writers/text.py b/xml2rfc/writers/text.py index 30b2fe174..085555b96 100644 --- a/xml2rfc/writers/text.py +++ b/xml2rfc/writers/text.py @@ -4061,7 +4061,16 @@ def set_colwidths(cells, rows, cols): widths.reverse() for j in [ k for w, k in widths ]: pad = min(2, excess) - excess -= pad + _reqwidth = sum([ c.colwidth for c in cells[0] ]) + (cols + 1)*len(bchar['|']) + if _reqwidth > width: + # remove / decrease pad if table width exceeds avaiable width + _excess = _reqwidth - width + while _excess > 0: + pad -= 1 + _excess -= 1 + if pad < 0: + pad = 0 + break for i in range(rows): cells[i][j].colwidth += pad cells[i][j].padding = pad @@ -4074,10 +4083,7 @@ def set_colwidths(cells, rows, cols): cell = cells[i][j] if cell.text: if cell.foldable: - if cell.colspan > 1: - cell.wrapped = fill(cell.text, width=cell.minwidth, fix_sentence_endings=True).splitlines() - else: - cell.wrapped = fill(cell.text, width=cell.colwidth, fix_sentence_endings=True).splitlines() + cell.wrapped = fill(cell.text, width=cell.colwidth, fix_sentence_endings=True).splitlines() else: cell.wrapped = cell.text.splitlines()