All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jean-Noel Avila <jn.avila@free.fr>, git@vger.kernel.org
Subject: Re: [PATCH] doc: fix unmatched code fences
Date: Tue, 12 May 2015 22:15:56 -0400	[thread overview]
Message-ID: <20150513021556.GA4160@peff.net> (raw)
In-Reply-To: <xmqqfv71zlaz.fsf@gitster.dls.corp.google.com>

On Tue, May 12, 2015 at 11:45:56AM -0700, Junio C Hamano wrote:

> 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

  reply	other threads:[~2015-05-13  2:16 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 17:23 [PATCH] doc: fix unmatched code fences Jean-Noel Avila
2015-05-12 18:45 ` Junio C Hamano
2015-05-13  2:15   ` Jeff King [this message]
2015-05-13  3:43     ` Junio C Hamano
2015-05-13  3:45       ` Jeff King
2015-05-13  4:32         ` Junio C Hamano
2015-05-13  4:36           ` Jeff King
2015-05-13 22:22             ` brian m. carlson
2015-05-13  4:56     ` [PATCH 0/8] asciidoc fixups Jeff King
2015-05-13  4:57       ` [PATCH 1/8] doc: fix misrendering due to `single quote' Jeff King
2015-05-13  4:58       ` [PATCH 2/8] doc: fix unquoted use of "{type}" Jeff King
2015-05-13  4:58       ` [PATCH 3/8] doc: fix hanging "+"-continuation Jeff King
2015-05-13  4:58       ` [PATCH 4/8] doc: fix length of underlined section-title Jeff King
2015-05-13  4:58       ` [PATCH 5/8] doc/add: reformat `--edit` option Jeff King
2015-05-13  5:01       ` [PATCH 6/8] doc: convert \--option to --option Jeff King
2015-05-13  9:48         ` John Keeping
2015-05-14  4:32           ` Jeff King
2015-05-17 18:34             ` Junio C Hamano
2015-05-13  5:02       ` [PATCH 7/8] doc: drop backslash quoting of some curly braces Jeff King
2015-05-13  5:06       ` [PATCH 8/8] doc: put example URLs and emails inside literal backticks Jeff King
2015-05-13  5:09       ` [PATCH 0/8] asciidoc fixups Jeff King
2015-05-13  5:23       ` Junio C Hamano
2015-05-13  5:37         ` Jeff King
2015-05-13  7:43           ` Johannes Schindelin
2015-05-14  4:29             ` Jeff King
2015-05-13 22:41       ` brian m. carlson
2015-05-14  4:25         ` Jeff King
2015-05-14  4:34           ` [PATCH 9/8] doc: convert AsciiDoc {?foo} to ifdef::foo[] Jeff King
2015-05-14  7:43           ` [PATCH 0/8] asciidoc fixups Johannes Schindelin
2015-05-14 17:38             ` Jeff King
2015-05-14 18:20               ` Johannes Schindelin
2015-05-14 21:10                 ` Junio C Hamano
2015-05-14 21:17                   ` Jeff King
2015-05-14 21:40                     ` Junio C Hamano
2015-05-14 21:56                       ` David Turner
2015-05-15  2:52           ` brian m. carlson
2015-05-15  4:01             ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150513021556.GA4160@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jn.avila@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.