git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] doc: fix unmatched code fences

From
Jeff King <peff@peff.net>
Date
May 13, 2015, 02:15 UTC
Message-ID
<20150513021556.GA4160@peff.net>
In-Reply-To
<xmqqfv71zlaz.fsf@gitster.dls.corp.google.com>
On Tue, May 12, 2015 at 11:45:56AM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> Jean-Noel Avila <jn.avila@free.fr> writes:
> 
> > This mismatch upsets the renderer on git-scm.com.
> 
> Thanks.
> 
> I do not think this is the first time AsciiDoc(or) rendering glitch
> was reported.  GitHub folks, can you guys think of an automated way
> to spot these?  Relying on site visitors to eyeball and hoping them
> to report is not an ideal approach.

Here's a patch to fix the remaining cases of this particular problem, at least.

You can build with asciidoctor on the command-line. I don't know if it would be feasible to diff the asciidoc and asciidoctor output to look for gratuitous differences (or if the output is so different due to trivial stuff that the diff is unreadable).

-- >8 --
Subject: doc: fix unmatched code fences in git-stripspace

The asciidoctor renderer is more picky than classic asciidoc, and insists that the start and end of a code fence be the same size.

Found with this hacky perl script:
    foreach my $fn (@ARGV) {
      open(my $fh, '<', $fn);
      my ($fence, $fence_lineno, $prev);
      while (<$fh>) {
        chomp;
        if (/^----+$/) {
          if ($fence_lineno) {
            if ($_ ne $fence) {
              print "$fn:$fence_lineno:mismatched fence: ",
                    length($fence), " != ", length($_), "\n";
            }
            $fence_lineno = undef;
          }
	  # hacky check to avoid title-underlining
          elsif ($prev eq '' || $prev eq '+') {
            $fence = $_;
            $fence_lineno = $.;
          }
        }
        $prev = $_;
      }
    }
Signed-off-by: Jeff King <peff@peff.net>
---
With this patch and the one from Jean-Noel, the script above finds only
one hit, which is a false positive. It's at git-commit.txt:233, and it
looks like:
    It is a rough equivalent for:
    ------
            $ git reset --soft HEAD^
            $ ... do something else to come up with the right tree ...
            $ git commit -c ORIG_HEAD
    ------

I have no idea how asciidoc knows that this is a code block and not a title called "It is a rough...". So probably in addition to this false positive, we may be missing some other cases. Doing it right would probably involve just reusing asciidoc's parser.

 Documentation/git-stripspace.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-stripspace.txt b/Documentation/git-stripspace.txt
index 6c6e989..60328d5 100644
--- a/Documentation/git-stripspace.txt
+++ b/Documentation/git-stripspace.txt
@@ -49,7 +49,7 @@ EXAMPLES
 
 Given the following noisy input with '$' indicating the end of a line:
 
---------
+---------
 |A brief introduction   $
 |   $
 |$
@@ -65,7 +65,7 @@ Given the following noisy input with '$' indicating the end of a line:
 
 Use 'git stripspace' with no arguments to obtain:
 
---------
+---------
 |A brief introduction$
 |$
 |A new paragraph$
@@ -79,7 +79,7 @@ Use 'git stripspace' with no arguments to obtain:
 
 Use 'git stripspace --strip-comments' to obtain:
 
---------
+---------
 |A brief introduction$
 |$
 |A new paragraph$
-- 
2.4.0.192.g5f8138b
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 37 in “doc: fix unmatched code fences”
  1. doc: fix unmatched code fencesJean-Noel Avila, May 12, 2015
  2. Junio C HamanoMay 12, 2015
  3. Jeff KingMay 13, 2015
  4. Junio C HamanoMay 13, 2015
  5. Jeff KingMay 13, 2015
  6. Junio C HamanoMay 13, 2015
  7. Jeff KingMay 13, 2015
  8. brian m. carlsonMay 13, 2015
  9. 0/8 asciidoc fixupsJeff King, May 13, 2015
  10. 1/8 doc: fix misrendering due to `single quote'Jeff King, May 13, 2015
  11. 2/8 doc: fix unquoted use of "{type}"Jeff King, May 13, 2015
  12. 3/8 doc: fix hanging "+"-continuationJeff King, May 13, 2015
  13. 4/8 doc: fix length of underlined section-titleJeff King, May 13, 2015
  14. 5/8 doc/add: reformat `--edit` optionJeff King, May 13, 2015
  15. 6/8 doc: convert \--option to --optionJeff King, May 13, 2015
  16. John KeepingMay 13, 2015
  17. Jeff KingMay 14, 2015
  18. Junio C HamanoMay 17, 2015
  19. 7/8 doc: drop backslash quoting of some curly bracesJeff King, May 13, 2015
  20. 8/8 doc: put example URLs and emails inside literal backticksJeff King, May 13, 2015
  21. Jeff KingMay 13, 2015
  22. Junio C HamanoMay 13, 2015
  23. Jeff KingMay 13, 2015
  24. Johannes SchindelinMay 13, 2015
  25. Jeff KingMay 14, 2015
  26. brian m. carlsonMay 13, 2015
  27. Jeff KingMay 14, 2015
  28. 9/8 doc: convert AsciiDoc {?foo} to ifdef::foo[]Jeff King, May 14, 2015
  29. Johannes SchindelinMay 14, 2015
  30. Jeff KingMay 14, 2015
  31. Johannes SchindelinMay 14, 2015
  32. Junio C HamanoMay 14, 2015
  33. Jeff KingMay 14, 2015
  34. Junio C HamanoMay 14, 2015
  35. David TurnerMay 14, 2015
  36. brian m. carlsonMay 15, 2015
  37. Jeff KingMay 15, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.