metanorma / asciidoctor-rfc

AsciiRFC: an AsciiDoc/asciidoctor backend to produce RFC XML v3 (RFC 7991) and v2 (RFC 7749)
BSD 2-Clause "Simplified" License
15 stars 7 forks source link

Creating a table with row headers? #77

Closed ronaldtse closed 6 years ago

ronaldtse commented 6 years ago

So I'm trying to re-create this table using our gem. Right now it's just ASCII-art.

(actually you can see it here: https://tools.ietf.org/html/draft-ribose-cfrg-sm4-02#section-6.2.3)

   |  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
---|-------------------------------------------------
 0 | D6 90 E9 FE CC E1 3D B7 16 B6 14 C2 28 FB 2C 05
 1 | 2B 67 9A 76 2A BE 04 C3 AA 44 13 26 49 86 06 99
 2 | 9C 42 50 F4 91 EF 98 7A 33 54 0B 43 ED CF AC 62
 3 | E4 B3 1C A9 C9 08 E8 95 80 DF 94 FA 75 8F 3F A6
 4 | 47 07 A7 FC F3 73 17 BA 83 59 3C 19 E6 85 4F A8
 5 | 68 6B 81 B2 71 64 DA 8B F8 EB 0F 4B 70 56 9D 35
 6 | 1E 24 0E 5E 63 58 D1 A2 25 22 7C 3B 01 21 78 87
 7 | D4 00 46 57 9F D3 27 52 4C 36 02 E7 A0 C4 C8 9E
 8 | EA BF 8A D2 40 C7 38 B5 A3 F7 F2 CE F9 61 15 A1
 9 | E0 AE 5D A4 9B 34 1A 55 AD 93 32 30 F5 8C B1 E3
 A | 1D F6 E2 2E 82 66 CA 60 C0 29 23 AB 0D 53 4E 6F
 B | D5 DB 37 45 DE FD 8E 2F 03 FF 6A 72 6D 6C 5B 51
 C | 8D 1B AF 92 BB DD BC 7F 11 D9 5C 41 1F 10 5A D8
 D | 0A C1 31 88 A5 CD 7B BD 2D 74 D0 12 B8 E5 B4 B0
 E | 89 69 97 4A 0C 96 77 7E 65 B9 F1 09 C5 6E C6 84
 F | 18 F0 7D EC 3A DC 4D 20 79 EE 5F 3E D7 CB 39 48

This table is slightly different because it has a column header and also a row header. This is my attempt to create it in asciidoc:

[#table-sm4-sbox]
.SM4 S-box Values
[grid=none,align=center]
|===
h|   | 0  | 1  | 2  | 3  | 4  | 5  | 6  | 7  | 8  | 9  | A  | B  | C  | D  | E  | F

h| 0 | D6 | 90 | E9 | FE | CC | E1 | 3D | B7 | 16 | B6 | 14 | C2 | 28 | FB | 2C | 05
h| 1 | 2B | 67 | 9A | 76 | 2A | BE | 04 | C3 | AA | 44 | 13 | 26 | 49 | 86 | 06 | 99
h| 2 | 9C | 42 | 50 | F4 | 91 | EF | 98 | 7A | 33 | 54 | 0B | 43 | ED | CF | AC | 62
h| 3 | E4 | B3 | 1C | A9 | C9 | 08 | E8 | 95 | 80 | DF | 94 | FA | 75 | 8F | 3F | A6
h| 4 | 47 | 07 | A7 | FC | F3 | 73 | 17 | BA | 83 | 59 | 3C | 19 | E6 | 85 | 4F | A8
h| 5 | 68 | 6B | 81 | B2 | 71 | 64 | DA | 8B | F8 | EB | 0F | 4B | 70 | 56 | 9D | 35
h| 6 | 1E | 24 | 0E | 5E | 63 | 58 | D1 | A2 | 25 | 22 | 7C | 3B | 01 | 21 | 78 | 87
h| 7 | D4 | 00 | 46 | 57 | 9F | D3 | 27 | 52 | 4C | 36 | 02 | E7 | A0 | C4 | C8 | 9E
h| 8 | EA | BF | 8A | D2 | 40 | C7 | 38 | B5 | A3 | F7 | F2 | CE | F9 | 61 | 15 | A1
h| 9 | E0 | AE | 5D | A4 | 9B | 34 | 1A | 55 | AD | 93 | 32 | 30 | F5 | 8C | B1 | E3
h| A | 1D | F6 | E2 | 2E | 82 | 66 | CA | 60 | C0 | 29 | 23 | AB | 0D | 53 | 4E | 6F
h| B | D5 | DB | 37 | 45 | DE | FD | 8E | 2F | 03 | FF | 6A | 72 | 6D | 6C | 5B | 51
h| C | 8D | 1B | AF | 92 | BB | DD | BC | 7F | 11 | D9 | 5C | 41 | 1F | 10 | 5A | D8
h| D | 0A | C1 | 31 | 88 | A5 | CD | 7B | BD | 2D | 74 | D0 | 12 | B8 | E5 | B4 | B0
h| E | 89 | 69 | 97 | 4A | 0C | 96 | 77 | 7E | 65 | B9 | F1 | 09 | C5 | 6E | C6 | 84
h| F | 18 | F0 | 7D | EC | 3A | DC | 4D | 20 | 79 | EE | 5F | 3E | D7 | CB | 39 | 48
|===

Unfortunately this gives me the below without any header lines.

               0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
             0 D6 90 E9 FE CC E1 3D B7 16 B6 14 C2 28 FB 2C 05
             1 2B 67 9A 76 2A BE 04 C3 AA 44 13 26 49 86 06 99
             2 9C 42 50 F4 91 EF 98 7A 33 54 0B 43 ED CF AC 62
             3 E4 B3 1C A9 C9 08 E8 95 80 DF 94 FA 75 8F 3F A6
             4 47 07 A7 FC F3 73 17 BA 83 59 3C 19 E6 85 4F A8
             5 68 6B 81 B2 71 64 DA 8B F8 EB 0F 4B 70 56 9D 35
             6 1E 24 0E 5E 63 58 D1 A2 25 22 7C 3B 01 21 78 87
             7 D4 00 46 57 9F D3 27 52 4C 36 02 E7 A0 C4 C8 9E
             8 EA BF 8A D2 40 C7 38 B5 A3 F7 F2 CE F9 61 15 A1
             9 E0 AE 5D A4 9B 34 1A 55 AD 93 32 30 F5 8C B1 E3
             A 1D F6 E2 2E 82 66 CA 60 C0 29 23 AB 0D 53 4E 6F
             B D5 DB 37 45 DE FD 8E 2F 03 FF 6A 72 6D 6C 5B 51
             C 8D 1B AF 92 BB DD BC 7F 11 D9 5C 41 1F 10 5A D8
             D 0A C1 31 88 A5 CD 7B BD 2D 74 D0 12 B8 E5 B4 B0
             E 89 69 97 4A 0C 96 77 7E 65 B9 F1 09 C5 6E C6 84
             F 18 F0 7D EC 3A DC 4D 20 79 EE 5F 3E D7 CB 39 48

Without the "grid" option I get this:

   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   | 0 | D | 9 | E | F | C | E | 3 | B | 1 | B | 1 | C | 2 | F | 2 | 0 |
   |   | 6 | 0 | 9 | E | C | 1 | D | 7 | 6 | 6 | 4 | 2 | 8 | B | C | 5 |
   | 1 | 2 | 6 | 9 | 7 | 2 | B | 0 | C | A | 4 | 1 | 2 | 4 | 8 | 0 | 9 |
   |   | B | 7 | A | 6 | A | E | 4 | 3 | A | 4 | 3 | 6 | 9 | 6 | 6 | 9 |
   | 2 | 9 | 4 | 5 | F | 9 | E | 9 | 7 | 3 | 5 | 0 | 4 | E | C | A | 6 |
   |   | C | 2 | 0 | 4 | 1 | F | 8 | A | 3 | 4 | B | 3 | D | F | C | 2 |
   | 3 | E | B | 1 | A | C | 0 | E | 9 | 8 | D | 9 | F | 7 | 8 | 3 | A |
   |   | 4 | 3 | C | 9 | 9 | 8 | 8 | 5 | 0 | F | 4 | A | 5 | F | F | 6 |
   | 4 | 4 | 0 | A | F | F | 7 | 1 | B | 8 | 5 | 3 | 1 | E | 8 | 4 | A |
   |   | 7 | 7 | 7 | C | 3 | 3 | 7 | A | 3 | 9 | C | 9 | 6 | 5 | F | 8 |
   | 5 | 6 | 6 | 8 | B | 7 | 6 | D | 8 | F | E | 0 | 4 | 7 | 5 | 9 | 3 |
   |   | 8 | B | 1 | 2 | 1 | 4 | A | B | 8 | B | F | B | 0 | 6 | D | 5 |
   | 6 | 1 | 2 | 0 | 5 | 6 | 5 | D | A | 2 | 2 | 7 | 3 | 0 | 2 | 7 | 8 |
   |   | E | 4 | E | E | 3 | 8 | 1 | 2 | 5 | 2 | C | B | 1 | 1 | 8 | 7 |
   | 7 | D | 0 | 4 | 5 | 9 | D | 2 | 5 | 4 | 3 | 0 | E | A | C | C | 9 |
   |   | 4 | 0 | 6 | 7 | F | 3 | 7 | 2 | C | 6 | 2 | 7 | 0 | 4 | 8 | E |
   | 8 | E | B | 8 | D | 4 | C | 3 | B | A | F | F | C | F | 6 | 1 | A |
   |   | A | F | A | 2 | 0 | 7 | 8 | 5 | 3 | 7 | 2 | E | 9 | 1 | 5 | 1 |
   | 9 | E | A | 5 | A | 9 | 3 | 1 | 5 | A | 9 | 3 | 3 | F | 8 | B | E |
   |   | 0 | E | D | 4 | B | 4 | A | 5 | D | 3 | 2 | 0 | 5 | C | 1 | 3 |
   | A | 1 | F | E | 2 | 8 | 6 | C | 6 | C | 2 | 2 | A | 0 | 5 | 4 | 6 |
   |   | D | 6 | 2 | E | 2 | 6 | A | 0 | 0 | 9 | 3 | B | D | 3 | E | F |
   | B | D | D | 3 | 4 | D | F | 8 | 2 | 0 | F | 6 | 7 | 6 | 6 | 5 | 5 |
   |   | 5 | B | 7 | 5 | E | D | E | F | 3 | F | A | 2 | D | C | B | 1 |
   | C | 8 | 1 | A | 9 | B | D | B | 7 | 1 | D | 5 | 4 | 1 | 1 | 5 | D |
   |   | D | B | F | 2 | B | D | C | F | 1 | 9 | C | 1 | F | 0 | A | 8 |
   | D | 0 | C | 3 | 8 | A | C | 7 | B | 2 | 7 | D | 1 | B | E | B | B |
   |   | A | 1 | 1 | 8 | 5 | D | B | D | D | 4 | 0 | 2 | 8 | 5 | 4 | 0 |
   | E | 8 | 6 | 9 | 4 | 0 | 9 | 7 | 7 | 6 | B | F | 0 | C | 6 | C | 8 |
   |   | 9 | 9 | 7 | A | C | 6 | 7 | E | 5 | 9 | 1 | 9 | 5 | E | 6 | 4 |
   | F | 1 | F | 7 | E | 3 | D | 4 | 2 | 7 | E | 5 | 3 | D | C | 3 | 4 |
   |   | 8 | 0 | D | C | A | C | D | 0 | 9 | E | F | E | 7 | B | 9 | 8 |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

@opoudjis any idea how to make it work? Thanks!

opoudjis commented 6 years ago

There are only four styles of table supported in RFC XML v2. Because I tried to stick close to Asciidoc's native treatment of style, I did not support RFC XML v2's "headers" or Asciidoc's "rows", but neither of them give you what you want.

                              +---+----+----+
                              |   | 0  | 1  |
                              +---+----+----+
                              | 0 | D6 | 90 |
                              +---+----+----+
                              | 0 | D6 | 90 |
                              +---+----+----+

                                    All

                              +---+----+----+
                              |   | 0  | 1  |
                              +---+----+----+
                              | 0 | D6 | 90 |
                              | 0 | D6 | 90 |
                              +---+----+----+

                                Cols = Full

                                    0  1
                                  0 D6 90
                                  0 D6 90

                                   None

                                    0  1
                                  - -- --
                                  0 D6 90
                                  0 D6 90

                                  Headers

I will make Asciidoc's "rows" map to XML RFC's "headers", though that's strictly speaking misleading. As you can see, xml2rfc does not give special treatment to header cells at the start of rows; in fact, RFC XML v2 does not have a notion of header cells in the table body at all (though v3 does).

ronaldtse commented 6 years ago

That's true. I suppose this usage is outside of the typical functionality with RFC XML. Using "rows" to map to "headers" is a welcome change though -- at least there is a mapping!