Converting texinfo comments to HTML comments

View: New views
6 Messages — Rating Filter:   Alert me  

Converting texinfo comments to HTML comments

by Reinhold Kainhofer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Patrice,
In our lilypond docs, we have several texinfo comments, most notably the git
revision of the texinfo document, which would make sense to be converted into
html comments (so that we can e.g. determine from which revision a document
was compiled, which is particularly useful for translators).

I've taken a quick look at the texi2html code, but I couldn't find the spot
where @c lines are ignored.

Can you think of an easy way to convert texinfo comments into html comments?

Thanks,
Reinhold

PS: Sometimes it might even make sense to convert @ignore...@end ignore blocks
to html comments. Is there a way for this, too? (Actually, our git revisions
are currently inside an @ignore block, so if it's not possible to convert
ignore blocks to comments, then we'll have to change a lot of files...)
--
------------------------------------------------------------------
Reinhold Kainhofer, reinhold@..., http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org



Re: Converting texinfo comments to HTML comments

by Karl Berry :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Reinhold,

    are currently inside an @ignore block, so if it's not possible to convert
    ignore blocks to comments, then we'll have to change a lot of files...)

I suppose it could be an option that you could enable, but I don't
think it should be done by default.  Comments and @ignore blocks are
there to be ignored, not to be propagated, seems to me ...

Of course there is
@html
<!--
... git stuff ...
-->
@end html

I sympathize with your dilemma, but that would be the straightforward
way to do it, even though you have to "change a lot of files".

karl



Re: Converting texinfo comments to HTML comments

by Patrice Dumas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jul 20, 2009 at 02:38:13PM +0200, Reinhold Kainhofer wrote:

> Hi Patrice,
> In our lilypond docs, we have several texinfo comments, most notably the git
> revision of the texinfo document, which would make sense to be converted into
> html comments (so that we can e.g. determine from which revision a document
> was compiled, which is particularly useful for translators).
>
> I've taken a quick look at the texi2html code, but I couldn't find the spot
> where @c lines are ignored.
>
> Can you think of an easy way to convert texinfo comments into html comments?

First this recently changed in cvs, so you should use the cvs version.

Then I think you could redefine $misc_command_line to be like:

sub comments_misc_commands($$$$$)
{
   my $macro = shift;
   my $line = shift;
   my $args = shift;
   my $stack = shift;
   my $state = shift;

   return ($macro, $line, undef) unless ($macro eq 'comment' or $macro eq 'c');
   my $comment_line = $args->[0];
   chomp ($comment_line);
   $comment_line =~ s/^\s//;
   my $result_text = &$comment ($comment_line);
   return ($macro, $line, $result_text);
}



> PS: Sometimes it might even make sense to convert @ignore...@end ignore blocks
> to html comments. Is there a way for this, too? (Actually, our git revisions

I think you could try something along:

$texi_formats_map->{'ignore'} = 'raw';

And then modify $raw to use &$comments() when format is 'ignore'. I can
give more help if needed.

--
Pat



Re: Converting texinfo comments to HTML comments

by Patrice Dumas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jul 20, 2009 at 05:37:33PM -0500, Karl Berry wrote:
>
> I suppose it could be an option that you could enable, but I don't
> think it should be done by default.  Comments and @ignore blocks are

Not an option, a function to be redefined. I think this is special enough
that we should not care about it, just have an API that allows to change
it.

> there to be ignored, not to be propagated, seems to me ...

@c and @comment are already output as xml comments in --xml (makeinfo
do that too). But in the default case and for most formats, sure they
should simply be ignored.

--
Pat



Re: Converting texinfo comments to HTML comments

by Graham Percival-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jul 20, 2009 at 02:38:13PM +0200, Reinhold Kainhofer wrote:
> In our lilypond docs, we have several texinfo comments, most notably the git
> revision of the texinfo document, which would make sense to be converted into
> html comments (so that we can e.g. determine from which revision a document
> was compiled, which is particularly useful for translators).

Sorry, I just noticed this message as well.  I think this would be
better done as a macro; that way, we can retain our
non-git-revision-number comments as "private" in the documentation
source.

It's easily done with:
  @macro htmlcomment{TEXT}
  @html
  <!-- extra text: \TEXT\ -->
  @end html

Cheers,
- Graha



Re: Converting texinfo comments to HTML comments

by Jan Nieuwenhuizen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On ma, 2009-07-20 at 21:04 -0700, Graham Percival wrote:
> On Mon, Jul 20, 2009 at 02:38:13PM +0200, Reinhold Kainhofer wrote:
> > In our lilypond docs, we have several texinfo comments, most notably the git
> > revision of the texinfo document

> better done as a macro; that way, we can retain our
> non-git-revision-number comments as "private"
>
> It's easily done with:
>   @macro htmlcomment{TEXT}
>   @html

Sweet and simple!  Just run

   pytt '(?ms)\n@ignore(.*?)\n@end ignore(.*?)(\n@include macros.itexi)' '\n@include macros.itexi\n@htmlComment\1\n@end htmlComment\2' $(find . -name '*texi' -o -name '*tely')

at your convenience.

Greetings,
Jan.

--
Jan Nieuwenhuizen <janneke@...> | GNU LilyPond - The music typesetter
AvatarĀ®: http://AvatarAcademy.nl    | http://lilypond.org