git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] revisions.txt: expand tabs to spaces in diagram
@ 2018-04-30 21:04 Martin Ågren
  2018-05-02  4:50 ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Ågren @ 2018-04-30 21:04 UTC (permalink / raw)
  To: git

The diagram renders fine in AsciiDoc before and after this patch.
Asciidoctor, on the other hand, ignores the tabs entirely, which results
in different indentation for different lines. The graph illustration
earlier in the document already uses spaces instead of a tab.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
Can be seen at the end of https://git-scm.com/docs/gitrevisions

 Documentation/revisions.txt | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index dfcc49c72c..011746b74f 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -355,15 +355,15 @@ spelt out:
    B..C   = ^B C                C
    B...C  = B ^F C              G H D E B C
    B^-    = B^..B
-	  = ^B^1 B              E I J F B
+          = ^B^1 B              E I J F B
    C^@    = C^1
-	  = F                   I J F
+          = F                   I J F
    B^@    = B^1 B^2 B^3
-	  = D E F               D G H E F I J
+          = D E F               D G H E F I J
    C^!    = C ^C^@
-	  = C ^C^1
-	  = C ^F                C
+          = C ^C^1
+          = C ^F                C
    B^!    = B ^B^@
-	  = B ^B^1 ^B^2 ^B^3
-	  = B ^D ^E ^F          B
+          = B ^B^1 ^B^2 ^B^3
+          = B ^D ^E ^F          B
    F^! D  = F ^I ^J D           G H D F
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] revisions.txt: expand tabs to spaces in diagram
  2018-04-30 21:04 [PATCH] revisions.txt: expand tabs to spaces in diagram Martin Ågren
@ 2018-05-02  4:50 ` Junio C Hamano
  2018-05-02  6:20   ` Martin Ågren
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2018-05-02  4:50 UTC (permalink / raw)
  To: Martin Ågren; +Cc: git

Martin Ågren <martin.agren@gmail.com> writes:

> The diagram renders fine in AsciiDoc before and after this patch.
> Asciidoctor, on the other hand, ignores the tabs entirely, which results
> in different indentation for different lines. The graph illustration
> earlier in the document already uses spaces instead of a tab.

Ouch.  We might want to teach Documentation/.gitattributes that
indent-with-tab is unwelcome in that directory, after making this
fix (and possibly similar ones to other files).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] revisions.txt: expand tabs to spaces in diagram
  2018-05-02  4:50 ` Junio C Hamano
@ 2018-05-02  6:20   ` Martin Ågren
  2018-05-04  1:52     ` brian m. carlson
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Ågren @ 2018-05-02  6:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

On 2 May 2018 at 06:50, Junio C Hamano <gitster@pobox.com> wrote:
> Martin Ågren <martin.agren@gmail.com> writes:
>
>> The diagram renders fine in AsciiDoc before and after this patch.
>> Asciidoctor, on the other hand, ignores the tabs entirely, which results
>> in different indentation for different lines. The graph illustration
>> earlier in the document already uses spaces instead of a tab.
>
> Ouch.  We might want to teach Documentation/.gitattributes that
> indent-with-tab is unwelcome in that directory, after making this
> fix (and possibly similar ones to other files).

I actually grepped around a little for a leading tab, to see if I could
immediately spot any similar issues. But there are tons of tabs here
(about 13000). Most of them work out just fine, e.g., in the OPTIONS,
where we tab-indent the descriptions.

So while we could try to move away from leading tabs in Documentation/,
it would be a huge undertaking. Any kind of "do it while we're nearby"
approach would take a long time to complete. And a one-off conversion
would probably be a horrible idea. ;-)

I just noticed another difference in how the tabs are handled. In
git-add.txt, which I just picked at random, the three continuation lines
in the synopsis indent differently in AsciiDoc (which indents them more
than in the .txt) and Asciidoctor (which indents them less than in the
.txt). To me, this is more of a "if I didn't sit down and compare the
two outputs, I would never think about these indentations -- they're
both fine".

So it might be that the only places where leading tabs really matter is
this kind of diagrams. Maybe we have a handful such bugs lingering among
the 13000 tab-indented lines...

Martin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] revisions.txt: expand tabs to spaces in diagram
  2018-05-02  6:20   ` Martin Ågren
@ 2018-05-04  1:52     ` brian m. carlson
  2018-05-04  2:32       ` Junio C Hamano
  2018-05-06 20:42       ` [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor brian m. carlson
  0 siblings, 2 replies; 12+ messages in thread
From: brian m. carlson @ 2018-05-04  1:52 UTC (permalink / raw)
  To: Martin Ågren; +Cc: Junio C Hamano, Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 3349 bytes --]

On Wed, May 02, 2018 at 08:20:54AM +0200, Martin Ågren wrote:
> On 2 May 2018 at 06:50, Junio C Hamano <gitster@pobox.com> wrote:
> > Martin Ågren <martin.agren@gmail.com> writes:
> >
> >> The diagram renders fine in AsciiDoc before and after this patch.
> >> Asciidoctor, on the other hand, ignores the tabs entirely, which results
> >> in different indentation for different lines. The graph illustration
> >> earlier in the document already uses spaces instead of a tab.
> >
> > Ouch.  We might want to teach Documentation/.gitattributes that
> > indent-with-tab is unwelcome in that directory, after making this
> > fix (and possibly similar ones to other files).
> 
> I actually grepped around a little for a leading tab, to see if I could
> immediately spot any similar issues. But there are tons of tabs here
> (about 13000). Most of them work out just fine, e.g., in the OPTIONS,
> where we tab-indent the descriptions.
> 
> So while we could try to move away from leading tabs in Documentation/,
> it would be a huge undertaking. Any kind of "do it while we're nearby"
> approach would take a long time to complete. And a one-off conversion
> would probably be a horrible idea. ;-)
> 
> I just noticed another difference in how the tabs are handled. In
> git-add.txt, which I just picked at random, the three continuation lines
> in the synopsis indent differently in AsciiDoc (which indents them more
> than in the .txt) and Asciidoctor (which indents them less than in the
> .txt). To me, this is more of a "if I didn't sit down and compare the
> two outputs, I would never think about these indentations -- they're
> both fine".
> 
> So it might be that the only places where leading tabs really matter is
> this kind of diagrams. Maybe we have a handful such bugs lingering among
> the 13000 tab-indented lines...

I took a look at this.  Asciidoctor does seem to have some weird ideas
about tabs, but I think how it's handling this is converting them to
spaces, which makes sense if you're working with HTML or XML (which do
some bizarre things with tabs).

However, it's not converting them to 8 spaces, which is really what we
want here.  We can help both AsciiDoc and Asciidoctor do the right thing
here (and keep our 8-space tabs) by enclosing the diagram in a block
like so:

[literal]
--
   Args   Expanded arguments    Selected commits
   D                            G H D
   D F                          G H I J D F
   ^G D                         H D
   ^D B                         E I J F B
   ^D B C                       E I J F B C
   C                            I J F C
   B..C   = ^B C                C
   B...C  = B ^F C              G H D E B C
   B^-    = B^..B
	  = ^B^1 B              E I J F B
   C^@    = C^1
	  = F                   I J F
   B^@    = B^1 B^2 B^3
	  = D E F               D G H E F I J
   C^!    = C ^C^@
	  = C ^C^1
	  = C ^F                C
   B^!    = B ^B^@
	  = B ^B^1 ^B^2 ^B^3
	  = B ^D ^E ^F          B
   F^! D  = F ^I ^J D           G H D F
--

and using the tabsize=8 attribute when invoking Asciidoctor.  I can send
a patch tomorrow which does this, which I think may be a bit nicer than
having to give up tabs.

Thoughts?
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 867 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] revisions.txt: expand tabs to spaces in diagram
  2018-05-04  1:52     ` brian m. carlson
@ 2018-05-04  2:32       ` Junio C Hamano
  2018-05-06 20:42       ` [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor brian m. carlson
  1 sibling, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2018-05-04  2:32 UTC (permalink / raw)
  To: brian m. carlson; +Cc: Martin Ågren, Git Mailing List

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> ...  We can help both AsciiDoc and Asciidoctor do the right thing
> here (and keep our 8-space tabs) by enclosing the diagram in a block
> like so:
>
> [literal]
> --
>    Args   Expanded arguments    Selected commits
>    D                            G H D
>    D F                          G H I J D F
>    ...
> 	  = B ^D ^E ^F          B
>    F^! D  = F ^I ^J D           G H D F
> --
>
> and using the tabsize=8 attribute when invoking Asciidoctor.  I can send
> a patch tomorrow which does this, which I think may be a bit nicer than
> having to give up tabs.

Yeah, trying to forbid indent-with-tab has been shown to be
unworkable so even if we tried to give up tabs, it is likely we
would break it by mistake.  Allowing indent-with-tab and ask the
tool to do the right thing is obviously the right direction.

Thanks.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor
  2018-05-04  1:52     ` brian m. carlson
  2018-05-04  2:32       ` Junio C Hamano
@ 2018-05-06 20:42       ` brian m. carlson
  2018-05-06 20:42         ` [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor brian m. carlson
  2018-05-07  3:04         ` [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor Junio C Hamano
  1 sibling, 2 replies; 12+ messages in thread
From: brian m. carlson @ 2018-05-06 20:42 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Martin Ågren

Asciidoctor expands tabs at the beginning of a line.  However, it does
not expand them into 8 spaces by default.  Since we use 8-space tabs,
tell Asciidoctor that we want 8 spaces by setting the tabsize attribute.
This ensures that our ASCII art renders properly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 6232143cb9..bcd216d96c 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -184,7 +184,7 @@ ASCIIDOC = asciidoctor
 ASCIIDOC_CONF =
 ASCIIDOC_HTML = xhtml5
 ASCIIDOC_DOCBOOK = docbook45
-ASCIIDOC_EXTRA += -acompat-mode
+ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
 ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
 DBLATEX_COMMON =

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor
  2018-05-06 20:42       ` [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor brian m. carlson
@ 2018-05-06 20:42         ` brian m. carlson
  2018-05-07  4:11           ` Martin Ågren
  2018-05-07  3:04         ` [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor Junio C Hamano
  1 sibling, 1 reply; 12+ messages in thread
From: brian m. carlson @ 2018-05-06 20:42 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Martin Ågren

When creating a literal block from an indented block without any sort of
delimiters, Asciidoctor strips off all leading whitespace, resulting in
a misrendered chart.  Use an explicit literal block to indicate to
Asciidoctor that we want to keep the leading whitespace.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
A future direction we could go here would actually be to turn this into
a table, which might render more acceptably in all forms.  But I think
this patch provides a useful improvement and we can switch to a table
later if desired.

 Documentation/revisions.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index dfcc49c72c..8f60c9f431 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -345,6 +345,7 @@ Here are a handful of examples using the Loeliger illustration above,
 with each step in the notation's expansion and selection carefully
 spelt out:
 
+....
    Args   Expanded arguments    Selected commits
    D                            G H D
    D F                          G H I J D F
@@ -367,3 +368,4 @@ spelt out:
 	  = B ^B^1 ^B^2 ^B^3
 	  = B ^D ^E ^F          B
    F^! D  = F ^I ^J D           G H D F
+....

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor
  2018-05-06 20:42       ` [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor brian m. carlson
  2018-05-06 20:42         ` [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor brian m. carlson
@ 2018-05-07  3:04         ` Junio C Hamano
  1 sibling, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2018-05-07  3:04 UTC (permalink / raw)
  To: brian m. carlson; +Cc: git, Martin Ågren

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> Asciidoctor expands tabs at the beginning of a line.  However, it does
> not expand them into 8 spaces by default.  Since we use 8-space tabs,
> tell Asciidoctor that we want 8 spaces by setting the tabsize attribute.
> This ensures that our ASCII art renders properly.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
>  Documentation/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Wonderful.  Thanks.

>
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index 6232143cb9..bcd216d96c 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -184,7 +184,7 @@ ASCIIDOC = asciidoctor
>  ASCIIDOC_CONF =
>  ASCIIDOC_HTML = xhtml5
>  ASCIIDOC_DOCBOOK = docbook45
> -ASCIIDOC_EXTRA += -acompat-mode
> +ASCIIDOC_EXTRA += -acompat-mode -atabsize=8
>  ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
>  ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
>  DBLATEX_COMMON =

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor
  2018-05-06 20:42         ` [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor brian m. carlson
@ 2018-05-07  4:11           ` Martin Ågren
  2018-05-08  1:13             ` brian m. carlson
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Ågren @ 2018-05-07  4:11 UTC (permalink / raw)
  To: brian m. carlson; +Cc: Git Mailing List, Junio C Hamano

On 6 May 2018 at 22:42, brian m. carlson <sandals@crustytoothpaste.net> wrote:
> When creating a literal block from an indented block without any sort of
> delimiters, Asciidoctor strips off all leading whitespace, resulting in
> a misrendered chart.  Use an explicit literal block to indicate to
> Asciidoctor that we want to keep the leading whitespace.

Excellent. These two patches fix my original problem and seem like the
obviously correct approach (in hindsight ;-) ). I wonder if the diagrams
earlier in the file should be tackled also. Right now, one has a huge
number of dots instead of the four you added; the other has none. They
do render fine though, so that'd only be about consistency in the
original .txt-file.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor
  2018-05-07  4:11           ` Martin Ågren
@ 2018-05-08  1:13             ` brian m. carlson
  2018-05-08 18:31               ` Martin Ågren
  0 siblings, 1 reply; 12+ messages in thread
From: brian m. carlson @ 2018-05-08  1:13 UTC (permalink / raw)
  To: Martin Ågren; +Cc: Git Mailing List, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 1222 bytes --]

On Mon, May 07, 2018 at 06:11:43AM +0200, Martin Ågren wrote:
> On 6 May 2018 at 22:42, brian m. carlson <sandals@crustytoothpaste.net> wrote:
> > When creating a literal block from an indented block without any sort of
> > delimiters, Asciidoctor strips off all leading whitespace, resulting in
> > a misrendered chart.  Use an explicit literal block to indicate to
> > Asciidoctor that we want to keep the leading whitespace.
> 
> Excellent. These two patches fix my original problem and seem like the
> obviously correct approach (in hindsight ;-) ). I wonder if the diagrams
> earlier in the file should be tackled also. Right now, one has a huge
> number of dots instead of the four you added; the other has none. They
> do render fine though, so that'd only be about consistency in the
> original .txt-file.

Yeah, the number of dots has to be at least four, but can be any
matching number.

Since this patch fixes the present issue, I'd like to leave it as it is
and run through a cleanup series a bit later that catches all the
literal indented blocks and marks them explicitly to avoid this issue in
the future.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 867 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor
  2018-05-08  1:13             ` brian m. carlson
@ 2018-05-08 18:31               ` Martin Ågren
  2018-05-09  0:24                 ` brian m. carlson
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Ågren @ 2018-05-08 18:31 UTC (permalink / raw)
  To: brian m. carlson, Martin Ågren, Git Mailing List,
	Junio C Hamano

On 8 May 2018 at 03:13, brian m. carlson <sandals@crustytoothpaste.net> wrote:
> On Mon, May 07, 2018 at 06:11:43AM +0200, Martin Ågren wrote:
>> Excellent. These two patches fix my original problem and seem like the
>> obviously correct approach (in hindsight ;-) ). I wonder if the diagrams
>> earlier in the file should be tackled also. Right now, one has a huge
>> number of dots instead of the four you added; the other has none. They
>> do render fine though, so that'd only be about consistency in the
>> original .txt-file.
>
> Yeah, the number of dots has to be at least four, but can be any
> matching number.
>
> Since this patch fixes the present issue, I'd like to leave it as it is
> and run through a cleanup series a bit later that catches all the
> literal indented blocks and marks them explicitly to avoid this issue in
> the future.

Sounds like a plan. :-) As noted elsewhere, I have no immediate idea how
to identify which of the 13000 tab-indented lines are really part of
diagrams and ascii-art. Counting the number of spaces? Anyway, thanks
for this mini-series.

Martin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor
  2018-05-08 18:31               ` Martin Ågren
@ 2018-05-09  0:24                 ` brian m. carlson
  0 siblings, 0 replies; 12+ messages in thread
From: brian m. carlson @ 2018-05-09  0:24 UTC (permalink / raw)
  To: Martin Ågren; +Cc: Git Mailing List, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 878 bytes --]

On Tue, May 08, 2018 at 08:31:10PM +0200, Martin Ågren wrote:
> On 8 May 2018 at 03:13, brian m. carlson <sandals@crustytoothpaste.net> wrote:
> > Since this patch fixes the present issue, I'd like to leave it as it is
> > and run through a cleanup series a bit later that catches all the
> > literal indented blocks and marks them explicitly to avoid this issue in
> > the future.
> 
> Sounds like a plan. :-) As noted elsewhere, I have no immediate idea how
> to identify which of the 13000 tab-indented lines are really part of
> diagrams and ascii-art. Counting the number of spaces? Anyway, thanks
> for this mini-series.

I have an utterly terrible Ruby one-liner which I wrote in a few
minutes.  It has some false positives, but not enough that I'd mind
sorting through them.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 867 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-05-09  0:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-30 21:04 [PATCH] revisions.txt: expand tabs to spaces in diagram Martin Ågren
2018-05-02  4:50 ` Junio C Hamano
2018-05-02  6:20   ` Martin Ågren
2018-05-04  1:52     ` brian m. carlson
2018-05-04  2:32       ` Junio C Hamano
2018-05-06 20:42       ` [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor brian m. carlson
2018-05-06 20:42         ` [PATCH 2/2] Documentation: render revisions correctly under Asciidoctor brian m. carlson
2018-05-07  4:11           ` Martin Ågren
2018-05-08  1:13             ` brian m. carlson
2018-05-08 18:31               ` Martin Ågren
2018-05-09  0:24                 ` brian m. carlson
2018-05-07  3:04         ` [PATCH 1/2] Documentation: use 8-space tabs with Asciidoctor Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).