texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Common.pm (@variable_string_settable


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (@variable_string_settables), tp/ext/highlight_syntax.pm (_get_language), tp/texi2any.pl, tp/Makefile.am (dist_extensions_DATA): load highlight_syntax.pm in main program if HIGHLIGHT_SYNTAX is set. Rename HIGHLIGHT_SYNTAX_DEFAULT as HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE. Setup highlight_syntax.pm as an internal extension.
Date: Sun, 19 Feb 2023 08:23:34 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 710f7fc1b8 * tp/Texinfo/Common.pm (@variable_string_settables), 
tp/ext/highlight_syntax.pm (_get_language), tp/texi2any.pl, tp/Makefile.am 
(dist_extensions_DATA): load highlight_syntax.pm in main program if 
HIGHLIGHT_SYNTAX is set.  Rename HIGHLIGHT_SYNTAX_DEFAULT as 
HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE.  Setup highlight_syntax.pm as an internal 
extension.
710f7fc1b8 is described below

commit 710f7fc1b86ec23b82651b335a4699d128b4062b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Feb 19 14:23:23 2023 +0100

    * tp/Texinfo/Common.pm (@variable_string_settables),
    tp/ext/highlight_syntax.pm (_get_language), tp/texi2any.pl,
    tp/Makefile.am (dist_extensions_DATA): load highlight_syntax.pm in
    main program if HIGHLIGHT_SYNTAX is set.  Rename
    HIGHLIGHT_SYNTAX_DEFAULT as HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE.  Setup
    highlight_syntax.pm as an internal extension.
    
    * doc/texinfo.texi (Other Customization Variables, Generating HTML)
    (Syntax Highlighting): document syntax highlighting support in
    texi2any for @example for HTML.
    
    * tp/tests/other/list-of-tests: use the HIGHLIGHT_SYNTAX to load
    syntax highlighting for one test case.
---
 ChangeLog                            | 16 ++++++++++
 doc/texinfo.texi                     | 58 +++++++++++++++++++++++++++++++-----
 tp/Makefile.am                       |  4 +--
 tp/Texinfo/Common.pm                 |  2 ++
 tp/{init => ext}/highlight_syntax.pm |  4 +--
 tp/tests/other/list-of-tests         |  2 +-
 tp/texi2any.pl                       |  6 ++++
 7 files changed, 78 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 00b688a32c..16ecdc4dd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2023-02-19  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (@variable_string_settables),
+       tp/ext/highlight_syntax.pm (_get_language), tp/texi2any.pl,
+       tp/Makefile.am (dist_extensions_DATA): load highlight_syntax.pm in
+       main program if HIGHLIGHT_SYNTAX is set.  Rename
+       HIGHLIGHT_SYNTAX_DEFAULT as HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE.  Setup
+       highlight_syntax.pm as an internal extension.
+
+       * doc/texinfo.texi (Other Customization Variables, Generating HTML)
+       (Syntax Highlighting): document syntax highlighting support in
+       texi2any for @example for HTML.
+
+       * tp/tests/other/list-of-tests: use the HIGHLIGHT_SYNTAX to load
+       syntax highlighting for one test case.
+
 2023-02-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (parser): remove a check and handling of
diff --git a/doc/texinfo.texi b/doc/texinfo.texi
index e4f7e2bce5..4d205d4e71 100644
--- a/doc/texinfo.texi
+++ b/doc/texinfo.texi
@@ -16910,6 +16910,25 @@ are considered to be fatal errors.  You should not 
need to change this
 value.  Default 100.
 @end ignore
 
+@item HIGHLIGHT_SYNTAX
+If set, @code{@@example} blocks with language information as first
+argument are highlighted in the HTML output.  It is also possible to
+specify a default for the language with
+@code{HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE}.  Syntax highlighting
+requires an external program to generate the highlighted HTML
+output (@pxref{Syntax Highlighting}).
+
+@cartouche
+@quotation warning
+The meaning of the value associated to @code{HIGHLIGHT_SYNTAX}
+is expected to evolve, be ready to change the value
+@end quotation
+@end cartouche
+
+@item HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE
+The default language used for syntax highlighting when there is no
+language information.
+
 @item IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME
 If set, spaces are ignored after an @@-command that takes braces.
 Default true, matching the @TeX{} behavior.
@@ -18144,18 +18163,16 @@ other programs.  This chapter gives some details on 
such HTML output.
 
 @command{texi2any} has many user-definable customization variables
 with which you can influence the HTML output.  @xref{Customization
-Variables}.  You can also write so-called @dfn{initialization files}, or
-@dfn{init files} for short, to modify almost every aspect of HTML output
-formatting.  Initialization files contain code and are loaded by
-@option{--init-file} (@pxref{Invoking @command{texi2any}}).
+Variables}.  In particular, there is support for syntax highlighting in
+@code{@@example} (@pxref{Syntax Highlighting}). You can also write so-called
+@dfn{initialization files}, or @dfn{init files} for short, to modify almost
+every aspect of HTML output formatting.  Initialization files contain code and
+are loaded by @option{--init-file} (@pxref{Invoking @command{texi2any}}).
 
 Some initialization files are maintained with Texinfo and installed
 in the default case.  For example, @file{chm.pm} produces the intermediate
 compressed HTML Help format files that can be subsequently converted to
-the CHM format.  As another example, @file{highlight_syntax.pm} uses
-@command{source-highlight} for syntax highlighting of @code{@@example}
-blocks using the first argument to specify the language of the code
-(@pxref{@code{@@example}}). @xref{,,,source-highlight, GNU Source-highlight}.
+the CHM format.
 
 The documentation of @command{texi2any} HTML output adaptation using
 customization files is in a separate manual.  @xref{,,, texi2any_api, GNU
@@ -18505,6 +18522,31 @@ customization set by the user.
 @xref{HTML Customization Variables}.
 
 
+@node Syntax Highlighting
+@section Code Examples Syntax Highlighting in HTML
+@cindex @command{source-highlight}
+
+@cartouche
+@quotation warning
+Source highlighting is experimental, feedback is welcomed.
+@end quotation
+@end cartouche
+
+Support for source code syntax highlighting is available in
+@command{texi2any} for the HTML output, with the help of external software.
+This feature is turned on by setting @code{HIGHLIGHT_SYNTAX}.  Source code
+highlighting is set up for @code{@@example} blocks.  The language
+specified for syntax highlighting is the first argument on the 
@code{@@example} line
+(@pxref{@code{@@example}}), or @code{HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE} if set
+and there is no first argument.
+
+Syntax highlighting is performed by the @command{source-highlight} command
+(@pxref{,,,source-highlight, GNU Source-highlight}).  In the future other
+possibilites could be added.
+
+@xref{Other Customization Variables}.
+
+
 @node HTML Xref
 @section HTML Cross-references
 @cindex HTML cross-references
diff --git a/tp/Makefile.am b/tp/Makefile.am
index 0a86f01221..91ba55701f 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -115,6 +115,7 @@ dist_debugmodules_DATA = \
 extensionsdir = $(datadir)/texinfo/ext
 dist_extensions_DATA = \
  ext/epub3.pm \
+ ext/highlight_syntax.pm \
  ext/tex4ht.pm \
  ext/latex2html.pm
 
@@ -123,8 +124,7 @@ dist_init_DATA = \
  init/book.pm \
  init/chm.pm \
  init/documentation_examples.pm \
- init/html32.pm \
- init/highlight_syntax.pm
+ init/html32.pm
 
 test_files = \
  t/README \
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 03fe663bd7..f3e2ae99cd 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -374,6 +374,8 @@ our @variable_string_settables = (
 'FRAMES',
 'FRAMESET_DOCTYPE',
 'HEADER_IN_TABLE',
+'HIGHLIGHT_SYNTAX', # for ext/highlight_syntax.pm
+'HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE', # for ext/highlight_syntax.pm
 'HTML_MATH',
 'HTML_ROOT_ELEMENT_ATTRIBUTES',
 'HTMLXREF_FILE',
diff --git a/tp/init/highlight_syntax.pm b/tp/ext/highlight_syntax.pm
similarity index 99%
rename from tp/init/highlight_syntax.pm
rename to tp/ext/highlight_syntax.pm
index 84c31ab619..a8bcf728aa 100644
--- a/tp/init/highlight_syntax.pm
+++ b/tp/ext/highlight_syntax.pm
@@ -39,8 +39,6 @@ my %languages_extensions = (
   'perl' => 'pl',
 );
 
-texinfo_add_valid_customization_option('HIGHLIGHT_SYNTAX_DEFAULT');
-
 # reference on a hash
 my $highlighted_languages_list;
 
@@ -110,7 +108,7 @@ sub _get_language($$$)
 
   if (not defined($converted_language) and defined($self)) {
     my $default_highlight_language
-      = $self->get_conf('HIGHLIGHT_SYNTAX_DEFAULT');
+      = $self->get_conf('HIGHLIGHT_SYNTAX_DEFAULT_LANGUAGE');
     if (defined($default_highlight_language)) {
       $converted_language = $default_highlight_language;
     }
diff --git a/tp/tests/other/list-of-tests b/tp/tests/other/list-of-tests
index e63b3b6d9e..ab86e93907 100644
--- a/tp/tests/other/list-of-tests
+++ b/tp/tests/other/list-of-tests
@@ -1,4 +1,4 @@
 
-highlight_syntax_example highlight_example.texi --html 
--init=highlight_syntax.pm
+highlight_syntax_example highlight_example.texi --html -c HIGHLIGHT_SYNTAX=1
 
 highlight_syntax_example_latin9 highlight_example.texi --html 
--init=highlight_syntax.pm -c 'OUTPUT_ENCODING_NAME=ISO-8859-15'
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 3169a2c9a5..409c953b58 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1147,6 +1147,12 @@ if (defined($cmdline_options->{'HTML_MATH'})
   locate_and_load_extension_file($tex4ht_file, $internal_extension_dirs);
 }
 
+my $highlight_syntax_file = 'highlight_syntax.pm';
+if ($cmdline_options->{'HIGHLIGHT_SYNTAX'}) {
+  locate_and_load_extension_file($highlight_syntax_file,
+                                 $internal_extension_dirs);
+}
+
 # For tests, set some strings to values not changing with releases
 my %test_conf = (
     'PACKAGE_VERSION' => '',



reply via email to

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