bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trying to wrap section number in span


From: Gavin Smith
Subject: Re: trying to wrap section number in span
Date: Sun, 20 Oct 2019 21:42:52 +0100
User-agent: Mutt/1.9.4 (2018-02-28)

On Sun, Oct 20, 2019 at 12:48:45PM -0700, Per Bothner wrote:
> I find chapter/section numbers in HTML to be useless clutter.
> One solution is to wrap each such number in a span, so one can easily use
> a CSS stylesheet to disable/enable/style it.
> 
> E.g. makeinfo woudl generate:
> 
>    <a href="Invocation.html"><span class="secnumber">2.1 </span>Invocation</a>
> 
> Then I could easily hide these using CSS:
> 
>    span.secnumber {display: none}
> 
> I tried this:
> 
> diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
> index 3467bb972..3fd9e741a 100644
> --- a/tp/Texinfo/Convert/HTML.pm
> +++ b/tp/Texinfo/Convert/HTML.pm
> @@ -563,7 +563,7 @@ sub command_text($$;$)
>                                  => {'contents'
>                                      => 
> $command->{'args'}->[0]->{'contents'}}});
>            } else {
> -            $tree = $self->gdt('{number} {section_title}',
> +            $tree = $self->gdt('<span class="secnumber">{number} 
> </span>{section_title}',
>                               {'number' => {'text' => $command->{'number'}},
>                                'section_title'
>                                  => {'contents'
> 
> However, that escapes the special characters '<' etc.
> Unfortunately, I'm not Perl fluent, and I haven't figured out how the
> gdt function works, nor the meaning of the trees it returns.
> This is presumably trivial for someone who understands the code.

gdt gets translations for strings that are going to go into the output 
documents.  The argument is usually plain text but can be Texinfo code.  
Hence, it has the same quoting conventions as Texinfo, where "<" stands 
for itself.  The tree returned is the same type as the parse tree for 
the whole Texinfo document.  It's not easy to add in a <span> here, as 
this tree is not specific to any output format.

The --no-number-sections option to texi2any should stop the section 
numbers being output.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]