bug-texinfo
[Top][All Lists]
Advanced

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

Re: Suggestions for texi2any parsing


From: Frederico Muñoz
Subject: Re: Suggestions for texi2any parsing
Date: Sun, 22 Dec 2024 12:16:10 +0000
User-agent: Gnus/5.13 (Gnus v5.13)

Hello,

Apologies for the not getting back sooner - delayed, but not forgotten!
- and thank you for your help, including code diffs which were very
useful.

Patrice Dumas <pertusus@free.fr> writes:
>> ** Automatic creation of "extended" menus.
(...)
> The idea of the sectiontoc is to output sectioning commands, like a
> localized table of contents, therefore it seems to me that a description
> is not much in line with the sectiontoc.  In addition, it seems to me
> that a @menu fulfills well your purposse, since it shows a link and a
> description.  I do not really understand what you are missing from the
> sectiontoc that is not already in the @menu formatting?

I should've been clearer: with FORMAT_MENU="sectiontoc", I get this:

  * First article
  * Second article
  * Third article

With  FORMAT_MENU="menu", I get:

  * First article    2024-01-01
  * Second article   2024-02-02
  * Third article    2024-12-22

I do get everything I need from FORMAT_MENU="menu": the only issue is
that with "sectiontoc" I do not need to create the menu entry (just the
includes), while with "menu" I need to "manually" (actually, using M4) )
create the menu. If there was a way to use "sectiontoc" AND have add a
description, I wouldn't need to do it myself.

> We have added a new command @nodedescription in the upcoming release
> that contains the description that appears in @menus allowing to have an
> automatic generation of menus with descriptions.  For example:
>
> @node Copying Conditions
> @nodedescription Your rights.
> @unnumbered Texinfo Copying Conditions
>
> Maybe this is what you are looking for?

I tried it, and almost! Maybe there's an option somewhere that I'm not
setting correctly, but since using @nodedescription only works with
FORMAT_MENU="menu", it seems that it always uses the node name in the
menu (even with '-c NODE_NAME_IN_MENU=0'), so I get this:

  * FirstArticle    2024-12-21
  * SecondArticle   2024-12-22

That said, if it used the section title instead of the node name, this
would be exactly what I was asking: it would automatically build menus,
using a defined description field, and using section titles for the
entries.

(...)
> Another possibility would be to replace the default formatting for
> sectioning commands and nodes by a different formatting function (in
> Perl) that formats this part differently.  There is actually an example
> in Texinfo, see tp/init/book.pm, the book_convert_heading_command
> function and the called to texinfo_register_command_formatting right
> after.
>
> I do not think that it is such a good idea, however, as it requires good
> knowledge of Perl and texi2any customization API, and to sync with the
> corresponding default formatting function from time to time, which is a
> pain.

Understood, I'll either adjust to something related with the new option
above or just keep it like it is, I'm already using M4 to include all
the posts/*texi files in posts.texi , so building the menu is not adding
much more complexity.

>> == Adding a "Top" navigation entry
>>
>> For a web page I find it useful to be able to easily go to the
>> homepage. I'm manually changing the HTML to add a "Top" navigation entry
>> that points to the index page. I experimented with several options but
>> didn't get this effect. Is something like this possible, and if not,
>> would it be a useful addition?
>
> It is possible to modify the navigation header with Perl code using the
> texi2any customization API.  There are some explanations here:
> https://www.gnu.org/software/texinfo/manual/texi2any_api/html_node/Simple-headers-customizations.html
> and
> https://www.gnu.org/software/texinfo/manual/texi2any_api/html_node/Customizing-HTML-Footers_002c-Headers-and-Navigation-Panels.html
>
> However, to modify existing buttons, another approach seems to be better
> to me, call a user-defined function to modify the customization
> variables of the converter:
> https://www.gnu.org/software/texinfo/manual/texi2any_api/html_node/Init-File-Calling-at-Different-Stages.html
> and
> https://www.gnu.org/software/texinfo/manual/texi2any_api/html_node/Conversion-Customization-Variables.html
>
> In the attached initialization file, the add_top_button_setup function
> does that.  You can load it by adding --init-file=init_file.pm.
> I did a patch against your repository to show how it could be used too.

This works perfectly and I've adjusted my code to use it, thank you. The
diff was very useful, thank you for the additional work you've put on
it, much appreciated. I now understand the configuration API better as
well.

>> == Support for image URLs
>>
>> I use @image for the images, and this requires a local file. I can work
>> around this either by having the file, or doing some pre-processing, but
>> it would be easier to support image URLs. I understand that this is
>> something that is not simple since it wouldn't work in non HTML modes,
>> so I get why it is like it is.
>
> One possibility is to use IMAGE_LINK_PREFIX, like
>  -c IMAGE_LINK_PREFIX='https://interlaye.red/texiblog_images/'
> But this adds the same prefix to all the images.  I also added that to
> the customization file I attach.
>
> To add different prefixes for different images, the best would probably
> be to redefine the function formatting images, which is relatively
> simple, starting from the default one: tp/Texinfo/Convert/HTML.pm
> _convert_image_command.  This is somewhat described here:
> https://www.gnu.org/software/texinfo/manual/texi2any_api/html_node/Command-Tree-Element-Conversion-Functions.html
>

I'm taking a look there, thank -- although after thinking about it (and
reading Gavin's reply as well) I might just keep it as-is and require
all images to be present locally.

I have a couple of more ideas that I'll open as new threads, but all in
all I'm really enjoying using Texinfo for blogging, and the freedom of
knowing that I can automatically create a PDF, Info file, or plain text
version of everything is such a great bonus on top of being able to use
a simple yet expressive markdown.

Best regards,
--
Frederico




reply via email to

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