Skip to contentSkip to conversation

gitglossary: fix indentation of sub-lists

PATCH Superseded Jeff King 2 participants 7 messages Apr 11 – Apr 12 Documentation

lore
Share & tools
lore

Jeff King

author
#0 lore raw

PATCH 1/1 gitglossary: fix indentation of sub-lists

The glossary entry is a list of terms and their definitions, so multi-paragraph definitions need "+" continuation lines to indicate that they are part of a single entry.

When an entry contains a sub-list (say, a bulleted list), the final "+" may become ambiguous: is it connecting the next paragraph to the final entry of the sub-list, or to the original list of definition paragraphs?

Asciidoc generally connects it to the former, even when we mean the latter, and you end up with the next paragraph indented incorrectly, like this:

glob
...defines glob...

Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

- ...some special meaning of **...

- ...another special meaning of **...

- Other consecutive asterisks are considered invalid.

Glob magic is incompatible with literal magic.

That final "Glob magic is incompatible" paragraph is in the wrong spot. It should be at the same level as "Two consecutive asterisks", as it is not part of the final "Other consecutive asterisks" bullet point.

The same problem appears in several other spots in the glossary.

We can fix this by using "--" markers, which put the sub-list into its own block. This should catch all of the unordered lists in the glossary, which I found by grepping for " -" list markers.

---
Just happened to notice this while looking at the "ref" entry.

 Documentation/glossary-content.adoc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Documentation/glossary-content.adoc +10 -2
index 20ba121314..8967e89ece 100644
@@ -415,7 +415,8 @@ glob;;
 +
 Two consecutive asterisks ("`**`") in patterns matched against
 full pathname may have special meaning:
-
++
+--
  - A leading "`**`" followed by a slash means match in all
    directories. For example, "`**/foo`" matches file or directory
    "`foo`" anywhere. "`**/foo/bar`" matches file or directory "`bar`"
@@ -430,6 +431,7 @@ full pathname may have special meaning:
    matches "`a/b`", "`a/x/b`", "`a/x/y/b`" and so on.
 
  - Other consecutive asterisks are considered invalid.
+--
 +
 Glob magic is incompatible with literal magic.
 
@@ -442,7 +444,8 @@ See linkgit:gitattributes[5].
 +
 Each of the attribute requirements for the path takes one of
 these forms:
-
++
+--
 - "`ATTR`" requires that the attribute `ATTR` be set.
 
 - "`-ATTR`" requires that the attribute `ATTR` be unset.
@@ -452,6 +455,7 @@ these forms:
 
 - "`!ATTR`" requires that the attribute `ATTR` be
   unspecified.
+--
 +
 Note that when matching against a tree object, attributes are still
 obtained from working tree, not from the given tree object.
@@ -560,14 +564,17 @@ The ref namespace is hierarchical.
 Ref names must either start with `refs/` or be located in the root of
 the hierarchy. For the latter, their name must follow these rules:
 +
+--
  - The name consists of only upper-case characters or underscores.
 
  - The name ends with "`_HEAD`" or is equal to "`HEAD`".
+--
 +
 There are some irregular refs in the root of the hierarchy that do not
 match these rules. The following list is exhaustive and shall not be
 extended in the future:
 +
+--
  - `AUTO_MERGE`
 
  - `BISECT_EXPECTED_REV`
@@ -577,6 +584,7 @@ extended in the future:
  - `NOTES_MERGE_REF`
 
  - `MERGE_AUTOSTASH`
+--
 +
 Different subhierarchies are used for different purposes. For example,
 the `refs/heads/` hierarchy is used to represent local branches whereas
Signature · 1 line
2.54.0.rc1.279.g55df28c202
#1 lore raw
Quoted 22 lines · Jeff King

The glossary entry is a list of terms and their definitions, so multi-paragraph definitions need "+" continuation lines to indicate that they are part of a single entry.

When an entry contains a sub-list (say, a bulleted list), the final "+" may become ambiguous: is it connecting the next paragraph to the final entry of the sub-list, or to the original list of definition paragraphs?

Asciidoc generally connects it to the former, even when we mean the latter, and you end up with the next paragraph indented incorrectly, like this:

glob
...defines glob...

Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

- ...some special meaning of **...

- ...another special meaning of **...

Quoted 7 lines

- Other consecutive asterisks are considered invalid.

Glob magic is incompatible with literal magic.

That final "Glob magic is incompatible" paragraph is in the wrong spot. It should be at the same level as "Two consecutive asterisks", as it is not part of the final "Other consecutive asterisks" bullet point.

Documentation/doc-diff confirms that this is the effect of this change.

Quoted 2 lines

The same problem appears in several other spots in the glossary.

And that it is the effect for all the other spots at as well: pull a paragraph out of a bullet list back to the previous block (or level).

Quoted 3 lines

We can fix this by using "--" markers, which put the sub-list into its own block. This should catch all of the unordered lists in the glossary, which I found by grepping for " -" list markers.

Yes, for what it’s worth I think open blocks (--) are a great cure for this when you are lucky enough to not already be in an open block.

AsciiDoc is certainly a format.

Quoted 8 lines

---
Just happened to notice this while looking at the "ref" entry.

 Documentation/glossary-content.adoc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

[snip]

#2 lore raw
Quoted 11 lines · Kristoffer Haugsbakk
Quoted 1 line · Jeff King

[snip]

Documentation/doc-diff confirms that this is the effect of this change.

Quoted 2 lines

The same problem appears in several other spots in the glossary.

And that it is the effect for all the other spots at as well: pull a paragraph out of a bullet list back to the previous block (or level).

But with make html there are some + artifacts:

+ Glob magic is incompatible with literal magic.
[...]
+ Note that when matching against a tree object, attributes are [...]

This is very off the cuff since I have to go now. So I might be missing something/made a mistake.

I think the first thing is caused by the context already being in an open block?

Quoted 1 line

[snip]

author
#3 lore raw
Quoted 8 lines · Kristoffer Haugsbakk

But with make html there are some + artifacts:

+ Glob magic is incompatible with literal magic.
[...]
+ Note that when matching against a tree object, attributes are [...]

This is very off the cuff since I have to go now. So I might be missing something/made a mistake.

Hmm, I don't see that in the HTML when I build with asciidoc. But if I build with asciidoctor, I see it both in the HTML and in the doc-diff output. Yuck.

Quoted 2 lines

I think the first thing is caused by the context already being in an open block?

Yes. Looks like asciidoc learned to handle nested entries better, but perhaps asciidoctor didn't.

I think I've found a workaround, which I'll post in a moment. Thanks for reporting.

-Peff

author
#4 lore raw

PATCH v2 1/1 gitglossary: fix indentation of sub-lists

Quoted 8 lines · Jeff King
Quoted 2 lines

I think the first thing is caused by the context already being in an open block?

Yes. Looks like asciidoc learned to handle nested entries better, but perhaps asciidoctor didn't.

I think I've found a workaround, which I'll post in a moment. Thanks for reporting.

Here it is.

-- >8 --
Subject: [PATCH] gitglossary: fix indentation of sub-lists

The glossary entry is a list of terms and their definitions, so multi-paragraph definitions need "+" continuation lines to indicate that they are part of a single entry.

When an entry contains a sub-list (say, a bulleted list), the final "+" may become ambiguous: is it connecting the next paragraph to the final entry of the sub-list, or to the original list of definition paragraphs?

Asciidoc generally connects it to the former, even when we mean the latter, and you end up with the next paragraph indented incorrectly, like this:

glob
...defines glob...

Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

- ...some special meaning of **...

- ...another special meaning of **...

- Other consecutive asterisks are considered invalid.

Glob magic is incompatible with literal magic.

That final "Glob magic is incompatible" paragraph is in the wrong spot. It should be at the same level as "Two consecutive asterisks", as it is not part of the final "Other consecutive asterisks" bullet point.

The same problem appears in several other spots in the glossary.

Usually we'd fix this by using "--" markers, which put the sub-list into its own block. But there's a catch: in some of these spots we are already in an open block, and nesting open blocks is a problem. It seems to work for me using Asciidoc 10.2.1, but Asciidoctor 2.0.26 makes a mess of it (our intent to open a new block seems to close the old one).

Fortunately there's a work-around: when using a "+" list-continuation, the number of empty lines above the continuation indicates which level of parent list to continue. So by adding an empty line after our unordered list (before the "+"), we should be able to continue the definition list item.

But asciidoc being asciidoc, of course that is not the end of the story. That technique works fine for the "glob" and "attr" lists in this patch, but under the "refs" item it works for only 1 of the 2 lists! I can't figure out why, and this may be an asciidoctor bug. But we can work around it by using "--" open-block markers here, since we're not already in an open block.

So using the extra blank line for the first two instances, and "--" markers for the second two, this patch produces identical output from "doc-diff HEAD^ HEAD" for both --asciidoctor and --ascii modes.

---
 Documentation/glossary-content.adoc | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/glossary-content.adoc +6 -0
index 20ba121314..8c4e9dd3be 100644
@@ -430,6 +430,7 @@ full pathname may have special meaning:
    matches "`a/b`", "`a/x/b`", "`a/x/y/b`" and so on.
 
  - Other consecutive asterisks are considered invalid.
+
 +
 Glob magic is incompatible with literal magic.
 
@@ -452,6 +453,7 @@ these forms:
 
 - "`!ATTR`" requires that the attribute `ATTR` be
   unspecified.
+
 +
 Note that when matching against a tree object, attributes are still
 obtained from working tree, not from the given tree object.
@@ -560,14 +562,17 @@ The ref namespace is hierarchical.
 Ref names must either start with `refs/` or be located in the root of
 the hierarchy. For the latter, their name must follow these rules:
 +
+--
  - The name consists of only upper-case characters or underscores.
 
  - The name ends with "`_HEAD`" or is equal to "`HEAD`".
+--
 +
 There are some irregular refs in the root of the hierarchy that do not
 match these rules. The following list is exhaustive and shall not be
 extended in the future:
 +
+--
  - `AUTO_MERGE`
 
  - `BISECT_EXPECTED_REV`
@@ -577,6 +582,7 @@ extended in the future:
  - `NOTES_MERGE_REF`
 
  - `MERGE_AUTOSTASH`
+--
 +
 Different subhierarchies are used for different purposes. For example,
 the `refs/heads/` hierarchy is used to represent local branches whereas
Signature · 1 line
2.54.0.rc1.336.g4588871dc4
#5 lore raw
Quoted 24 lines · Jeff King
Quoted 8 lines · Jeff King
Quoted 2 lines

I think the first thing is caused by the context already being in an open block?

Yes. Looks like asciidoc learned to handle nested entries better, but perhaps asciidoctor didn't.

I think I've found a workaround, which I'll post in a moment. Thanks for reporting.

Here it is.

-- >8 --
Subject: [PATCH] gitglossary: fix indentation of sub-lists

[snip]

Usually we'd fix this by using "--" markers, which put the sub-list into its own block. But there's a catch: in some of these spots we are already in an open block, and nesting open blocks is a problem. It seems to work for me using Asciidoc 10.2.1, but Asciidoctor 2.0.26 makes a mess of it (our intent to open a new block seems to close the old one).

Quoted 5 lines

Fortunately there's a work-around: when using a "+" list-continuation, the number of empty lines above the continuation indicates which level of parent list to continue. So by adding an empty line after our unordered list (before the "+"), we should be able to continue the definition list item.

Nice.

Quoted 2 lines

But asciidoc being asciidoc, of course that is not the end of the story.

Ouch.

Quoted 3 lines

That technique works fine for the "glob" and "attr" lists in this patch, but under the "refs" item it works for only 1 of the 2 lists! I can't figure out why, and this may be an asciidoctor bug. But we can work

You mention “asciidoc being asciidoc” but here it seems to be about Asciidoctor?

Quoted 6 lines

around it by using "--" open-block markers here, since we're not already in an open block.

So using the extra blank line for the first two instances, and "--" markers for the second two, this patch produces identical output from "doc-diff HEAD^ HEAD" for both --asciidoctor and --ascii modes.

Nit: s/--ascii/--asciidoc/

Quoted 4 lines

---
[snip]

author
#6 lore raw
Quoted 10 lines · Kristoffer Haugsbakk
Quoted 1 line

But asciidoc being asciidoc, of course that is not the end of the story.

Ouch.

Quoted 3 lines

That technique works fine for the "glob" and "attr" lists in this patch, but under the "refs" item it works for only 1 of the 2 lists! I can't figure out why, and this may be an asciidoctor bug. But we can work

You mention “asciidoc being asciidoc” but here it seems to be about Asciidoctor?

It is. I meant "asciidoc the language", not "asciidoc the tool". I didn't want to be too harsh on asciidoctor specifically. I think in aggregate the pain comes equally from both tools. ;)

Quoted 5 lines
Quoted 3 lines

So using the extra blank line for the first two instances, and "--" markers for the second two, this patch produces identical output from "doc-diff HEAD^ HEAD" for both --asciidoctor and --ascii modes.

Nit: s/--ascii/--asciidoc/

Oops, yes.

-Peff