Skip to content

Commit 26453aa

Browse files
Improve test cases and doc for norm rules
Signed-off-by: James Ball <jameball@qti.qualcomm.com>
1 parent 07ae7be commit 26453aa

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

normative-rules.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ AsciiDoc supports several styles of anchors:
5151
Naming restrictions:
5252
* Start anchor names with a letter and use `:` to separate fields in the anchor name. No spaces allowed in name.
5353
* Use underscores to separate lists of items between colons (e.g., `:insts:add_sub`) since RISC-V
54-
uses `-` in some names (e.g., `R-type`).
55-
* Replace `.` in items with `-` (e.g., `fence.tso` becomes `fence-tso`) so all anchors types used
54+
uses hyphens in some names (e.g., `R-type`).
55+
* Replace `.` in items with a hyphen (e.g., `fence.tso` becomes `fence-tso`) so all anchors types used
5656
work properly (see https://docs.asciidoctor.org/asciidoc/latest/attributes/id/#block-assignment for details).
5757

5858
If you'd like to get more detailed AsciiDoc information on anchors, please read:
@@ -89,6 +89,12 @@ If you'd like to see detailed AsciiDoc examples of tagging cases, see https://gi
8989
>> `Bananas::`<br>
9090
>> `Typically yellow`<br>
9191
>> Tagged text: Entire description list
92+
>
93+
> Limitations:
94+
> * Only one paragraph tag per paragraph. Only the last tag is detected so you can't do:
95+
>>> `[norm:abc]`<br>
96+
>>> `[xyz]`<br>
97+
>>> `Here's my paragraph with 2 tags but we only get an anchor for xyz. However since it doesn't start with norm: we won't see any tag for this paragraph.`
9298
9399
2. Tagging part of a paragraph, table cells, unordered list items (AKA bullet list), or ordered list items (AKA numbered list)
94100

@@ -111,10 +117,12 @@ If you'd like to see detailed AsciiDoc examples of tagging cases, see https://gi
111117
>> Tagged text: `mango` and `apple`<br>
112118
>
113119
> Limitations:
114-
> * Can't anchor text across multiple paragraphs.
120+
> * Can't anchor text across multiple AsciiDoc blocks (any text separated by blank line) such as paragraphs.
121+
This also includes text followed by a list (ordered, unordered, description) since there has to be
122+
a blank line between the text the list.
115123
> * Must have text next to the 2nd hash symbol (i.e., can't have newline after `[#<anchor-name]#`).
116124
> * Can't put inside admonitions such as [NOTE] (see #4 below for solution).
117-
> * Can't have `.` in anchor-name (replace with `-`)
125+
> * Can't have `.` in anchor-name (replace with hyphen)
118126
119127
3. Tagging description lists
120128
* For description list terms (e.g., `Apples`, `Oranges`), put the anchor immediately after the term on its own line as follows:
0 Bytes
Binary file not shown.

tests/norm-rule/expected/test-norm-tags.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"norm:paragraph:inline-anchors:inline-anchor": "inline anchor",
66
"norm:paragraph:inline-anchors:entire": "Paragraph with inline anchor and something.",
77
"norm:paragraph:tag_with_newlines": "Here&#8217;s the first line. Here&#8217;s the second line.",
8+
"norm:def": "This paragraph has two tags but we only ever get a tag for norm:def.",
89
"norm:table:no-anchors-in-cells:entire-table": "Header 1|Header 2\n===\nCell in column 1, row 1|Cell in column 2, row 1\nCell in column 1, row 2|Cell in column 2, row 2\n===",
910
"norm:table:anchors-in-cells:cell": "cell with anchor",
1011
"norm:table:anchors-in-cells:entire-table": "===\ncell with anchor\ncell without anchor\n===",
@@ -53,7 +54,8 @@
5354
"norm:paragraph:no-inline-anchors",
5455
"norm:paragraph:inline-anchors:inline-anchor",
5556
"norm:paragraph:inline-anchors:entire",
56-
"norm:paragraph:tag_with_newlines"
57+
"norm:paragraph:tag_with_newlines",
58+
"norm:def"
5759
]
5860
},
5961
{

tests/norm-rule/test.adoc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
// PASSES
99
Before inline [#norm:inline]#inside inline# outside inline.
1010

11-
// SHOULD ALWAYS FAIL
12-
Before bad inline [#norm:bad-inline]#
11+
// SHOULD ALWAYS FAIL - Can't put inline tag at end of line.
12+
Before bad inline [#norm:bad-inline-1]#
1313
inside bad inline# outside bad inline.
1414

15+
// SHOULD ALWAYS FAIL - Can't span blocks (paragraphs in this case)
16+
Before bad inline [#norm:bad-inline-2]#inside bad inline.
17+
18+
Next paragraph# outside.
19+
20+
// SHOULD ALWAYS FAIL - Can't span blocks (list in this case)
21+
Before bad inline [#norm:bad-inline-3]#inside bad inline:
22+
23+
* Unordered list line 1#
24+
* Unordered list line 2
25+
1526
=== Chapter 1.2 - Paragraph Tagging
1627

1728
// PASSES
@@ -31,6 +42,15 @@ Next paragraph 2
3142
Here's the first line.
3243
Here's the second line.
3344

45+
// FAILS - Can't have multiple paragraph tags (only last works)
46+
[[norm:abc]]
47+
[[norm:def]]
48+
This paragraph has two tags but we only ever get a tag for norm:def.
49+
50+
[[norm:abc]]
51+
[[def]]
52+
This paragraph has two tags but we'll never see either since the 1st isn't picked up by the tags backend as a tag and the second doesn't start with norm:
53+
3454
=== Chapter 2 - Table Tagging
3555

3656
// FAILS - Tag includes entire table but has adoc === prefixes/suffixes.

0 commit comments

Comments
 (0)