[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 19 Feb 2023 17:11:22 -0500 (EST) |
branch: master
commit af3ed469d22dd109244d01aef3583907b3a28fa4
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Feb 19 23:00:22 2023 +0100
* tp/ext/highlight_syntax.pm (highlight_setup, highlight_process):
handle HIGHLIGHT_SYNTAX customization option being not defined. Can
happen if highlight_syntax.pm is loaded as an init file and not
as an extension.
* tp/tests/Makefile.onetst, tp/tests/other/list-of-tests: add syntax
highlighting tests with HIGHLIGHT_SYNTAX highlight and pygments.
---
ChangeLog | 10 +++
tp/ext/highlight_syntax.pm | 7 +-
tp/tests/Makefile.onetst | 2 +
tp/tests/other/list-of-tests | 2 +
.../chapter.html | 91 ++++++++++++++++++++
.../highlight_example.1 | 0
.../highlight_example.2 | 0
.../highlight_syntax_example_highlight/index.html | 49 +++++++++++
.../highlight_syntax_example_pygments/chapter.html | 99 ++++++++++++++++++++++
.../highlight_example.1 | 0
.../highlight_example.2 | 0
.../highlight_syntax_example_pygments/index.html | 49 +++++++++++
.../other_highlight_syntax_example_highlight.sh | 25 ++++++
.../other_highlight_syntax_example_pygments.sh | 25 ++++++
14 files changed, 356 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e4a395c3c3..818d8eb3ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-02-19 Patrice Dumas <pertusus@free.fr>
+
+ * tp/ext/highlight_syntax.pm (highlight_setup, highlight_process):
+ handle HIGHLIGHT_SYNTAX customization option being not defined. Can
+ happen if highlight_syntax.pm is loaded as an init file and not
+ as an extension.
+
+ * tp/tests/Makefile.onetst, tp/tests/other/list-of-tests: add syntax
+ highlighting tests with HIGHLIGHT_SYNTAX highlight and pygments.
+
2023-02-19 Patrice Dumas <pertusus@free.fr>
Add other commands for syntax highlighting
diff --git a/tp/ext/highlight_syntax.pm b/tp/ext/highlight_syntax.pm
index 174a7379c5..364fe3e4e5 100644
--- a/tp/ext/highlight_syntax.pm
+++ b/tp/ext/highlight_syntax.pm
@@ -73,9 +73,9 @@ sub highlight_setup($$)
my $highlight_type = $self->get_conf('HIGHLIGHT_SYNTAX');
my $cmd;
- if ($highlight_type eq 'highlight') {
+ if (defined($highlight_type) and $highlight_type eq 'highlight') {
$cmd = 'highlight --list-scripts=lang';
- } elsif ($highlight_type eq 'pygments') {
+ } elsif (defined($highlight_type) and $highlight_type eq 'pygments') {
$cmd = 'pygmentize -L lexers';
} else {
$highlight_type = 'source-highlight';
@@ -329,7 +329,8 @@ sub highlight_process($$)
# When there is no possibility to specify all the fragments to highlight
# in an input file, pass each fragment to a command.
- if ($highlight_type eq 'highlight' or $highlight_type eq 'pygments') {
+ if (defined($highlight_type)
+ and ($highlight_type eq 'highlight' or $highlight_type eq 'pygments')) {
foreach my $language (keys(%languages)) {
foreach my $element_command (@{$languages{$language}->{'commands'}}) {
my ($element, $cmdname) = @{$element_command};
diff --git a/tp/tests/Makefile.onetst b/tp/tests/Makefile.onetst
index 5223d8089f..d2e3f1f1a4 100644
--- a/tp/tests/Makefile.onetst
+++ b/tp/tests/Makefile.onetst
@@ -131,5 +131,7 @@ type_tex_html_one_test_files_generated_list = \
# list of type other test files
type_other_one_test_files_generated_list = \
test_scripts/other_highlight_syntax_example.sh \
+ test_scripts/other_highlight_syntax_example_pygments.sh \
+ test_scripts/other_highlight_syntax_example_highlight.sh \
test_scripts/other_highlight_syntax_example_latin9.sh
diff --git a/tp/tests/other/list-of-tests b/tp/tests/other/list-of-tests
index ab86e93907..3e2252a7aa 100644
--- a/tp/tests/other/list-of-tests
+++ b/tp/tests/other/list-of-tests
@@ -1,4 +1,6 @@
highlight_syntax_example highlight_example.texi --html -c HIGHLIGHT_SYNTAX=1
+highlight_syntax_example_pygments highlight_example.texi --html -c
HIGHLIGHT_SYNTAX=pygments
+highlight_syntax_example_highlight highlight_example.texi --html -c
HIGHLIGHT_SYNTAX=highlight
highlight_syntax_example_latin9 highlight_example.texi --html
--init=highlight_syntax.pm -c 'OUTPUT_ENCODING_NAME=ISO-8859-15'
diff --git
a/tp/tests/other/res_parser/highlight_syntax_example_highlight/chapter.html
b/tp/tests/other/res_parser/highlight_syntax_example_highlight/chapter.html
new file mode 100644
index 0000000000..0c43a02264
--- /dev/null
+++ b/tp/tests/other/res_parser/highlight_syntax_example_highlight/chapter.html
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>chapter (top)</title>
+
+<meta name="description" content="chapter (top)">
+<meta name="keywords" content="chapter (top)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2any">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="index.html" rel="start" title="Top">
+<link href="index.html" rel="up" title="Top">
+<link href="index.html" rel="prev" title="Top">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+div.example {margin-left: 3.2em}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="chapter-level-extent" id="chapter">
+<div class="nav-panel">
+<p>
+Previous: <a href="index.html" accesskey="p" rel="prev">top</a>, Up: <a
href="index.html" accesskey="u" rel="up">top</a> </p>
+</div>
+<hr>
+<h2 class="chapter" id="chap"><span>1 châp<a class="copiable-link"
href="#chap"> ¶</a></span></h2>
+
+<p>Texinfo
+</p><div class="example user-texinfo">
+<pre class="example-preformatted"><code class="code">texinfo</code>
+@code{protécted}
+</pre></div>
+
+<p>C++
+</p><div class="example user-C++">
+<pre class="example-preformatted"><span style="color:#838183;
font-style:italic">// Your First C++ Program</span>
+
+<span style="color:#008200">#include <iostream></span>
+
+<span style="color:#0057ae">int</span> <span
style="color:#010181">main</span><span style="color:#000000">() {</span>
+ <span style="color:#000000; font-weight:bold">std</span><span
style="color:#000000">::</span>cout <span style="color:#000000"><<</span>
<span style="color:#bf0303">"Hello Wörld!"</span><span
style="color:#000000">;</span>
+ <span style="color:#000000; font-weight:bold">return</span> <span
style="color:#b07e00">0</span><span style="color:#000000">;</span>
+<span style="color:#000000">}</span>
+</pre></div>
+
+<p>perl
+</p><div class="example user-perl">
+<pre class="example-preformatted"><span style="color:#000000;
font-weight:bold">my</span> <span style="color:#0057ae">$list</span> <span
style="color:#000000">= [</span><span
style="color:#bf0303">'ça'</span><span style="color:#000000">,</span>
<span style="color:#bf0303">'bôù'</span><span
style="color:#000000">,</span> <span
style="color:#bf0303">'é'</span><span style="color:#000000">,</span>
<span style="color:#bf0303">'é ą € ≡'</span><span style [...]
+<span style="color:#000000; font-weight:bold">sub do</span> <span
style="color:#000000">($) {</span>
+ <span style="color:#000000; font-weight:bold">my</span> <span
style="color:#0057ae">$arg</span> <span style="color:#000000">=</span> <span
style="color:#000000; font-weight:bold">shift</span><span
style="color:#000000">;</span>
+ <span style="color:#000000; font-weight:bold">return</span> <span
style="color:#0057ae">$arg</span> <span style="color:#000000">+</span> <span
style="color:#b07e00">4</span><span style="color:#000000">;</span>
+<span style="color:#000000">}</span>
+</pre></div>
+
+<div class="example user-perl">
+<pre class="example-preformatted"><span style="color:#000000;
font-weight:bold">my</span> <span
style="color:#0057ae">@SECTION_BUTTONS</span> <span
style="color:#000000">=</span>
+ <span style="color:#000000">(</span>
+ \<span style="color:#000000">&</span>singular_banner<span
style="color:#000000">,</span>
+ <span style="color:#bf0303">'Back'</span><span
style="color:#000000">,</span> <span
style="color:#bf0303">'Forward'</span><span
style="color:#000000">,</span> <span
style="color:#bf0303">'FastBack'</span><span
style="color:#000000">,</span> <span
style="color:#bf0303">'FastForward'</span><span
style="color:#000000">,</span>
+ <span style="color:#bf0303">'Up'</span><span
style="color:#000000">,</span> <span
style="color:#bf0303">'Top'</span><span
style="color:#000000">,</span> <span
style="color:#bf0303">'Contents'</span><span
style="color:#000000">,</span> <span
style="color:#bf0303">'Index'</span><span
style="color:#000000">,</span> <span
style="color:#bf0303">'About'</span>
+ <span style="color:#000000">);</span>
+
+texinfo_set_from_init_file <span style="color:#000000">(</span><span
style="color:#bf0303">'SECTION_BUTTONS'</span><span
style="color:#000000">,</span> \<span
style="color:#0057ae">@SECTION_BUTTONS</span><span
style="color:#000000">);</span>
+</pre></div>
+
+<p>No argument
+</p><div class="example">
+<pre class="example-preformatted">texinfo_set_from_init_file('NO_CSS', 1);
+</pre></div>
+
+<p>Unknown language
+</p><div class="example user-unknown">
+<pre class="example-preformatted">unknown language
+</pre></div>
+
+</div>
+
+
+
+</body>
+</html>
diff --git
a/tp/tests/other/res_parser/highlight_syntax_example_highlight/highlight_example.1
b/tp/tests/other/res_parser/highlight_syntax_example_highlight/highlight_example.1
new file mode 100644
index 0000000000..e69de29bb2
diff --git
a/tp/tests/other/res_parser/highlight_syntax_example_highlight/highlight_example.2
b/tp/tests/other/res_parser/highlight_syntax_example_highlight/highlight_example.2
new file mode 100644
index 0000000000..e69de29bb2
diff --git
a/tp/tests/other/res_parser/highlight_syntax_example_highlight/index.html
b/tp/tests/other/res_parser/highlight_syntax_example_highlight/index.html
new file mode 100644
index 0000000000..7595ca942b
--- /dev/null
+++ b/tp/tests/other/res_parser/highlight_syntax_example_highlight/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Top (top)</title>
+
+<meta name="description" content="Top (top)">
+<meta name="keywords" content="Top (top)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2any">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="#Top" rel="start" title="Top">
+<link href="chapter.html" rel="next" title="chapter">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="top-level-extent" id="Top">
+<div class="nav-panel">
+<p>
+Next: <a href="chapter.html" accesskey="n" rel="next">châp</a> </p>
+</div>
+<hr>
+<h1 class="top" id="top"><span>top<a class="copiable-link" href="#top">
¶</a></span></h1>
+
+<ul class="mini-toc">
+<li><a href="chapter.html" accesskey="1">châp</a></li>
+</ul>
+</div>
+<hr>
+<div class="nav-panel">
+<p>
+Next: <a href="chapter.html" accesskey="n" rel="next">châp</a> </p>
+</div>
+
+
+
+</body>
+</html>
diff --git
a/tp/tests/other/res_parser/highlight_syntax_example_pygments/chapter.html
b/tp/tests/other/res_parser/highlight_syntax_example_pygments/chapter.html
new file mode 100644
index 0000000000..dd864f906f
--- /dev/null
+++ b/tp/tests/other/res_parser/highlight_syntax_example_pygments/chapter.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>chapter (top)</title>
+
+<meta name="description" content="chapter (top)">
+<meta name="keywords" content="chapter (top)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2any">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="index.html" rel="start" title="Top">
+<link href="index.html" rel="up" title="Top">
+<link href="index.html" rel="prev" title="Top">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+div.example {margin-left: 3.2em}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="chapter-level-extent" id="chapter">
+<div class="nav-panel">
+<p>
+Previous: <a href="index.html" accesskey="p" rel="prev">top</a>, Up: <a
href="index.html" accesskey="u" rel="up">top</a> </p>
+</div>
+<hr>
+<h2 class="chapter" id="chap"><span>1 châp<a class="copiable-link"
href="#chap"> ¶</a></span></h2>
+
+<p>Texinfo
+</p><div class="example user-texinfo">
+<pre class="example-preformatted"><code class="code">texinfo</code>
+@code{protécted}
+</pre></div>
+
+<p>C++
+</p><div class="example user-C++">
+<pre class="example-preformatted"><div class="highlight" style="background:
#f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color:
#3D7B7B; font-style: italic">// Your First C++ Program</span>
+
+<span style="color: #9C6500">#include</span><span style="color: #bbbbbb">
</span><span style="color: #3D7B7B; font-style: italic"><iostream></span>
+
+<span style="color: #B00040">int</span><span style="color: #bbbbbb">
</span><span style="color: #0000FF">main</span>()<span style="color: #bbbbbb">
</span>{
+<span style="color: #bbbbbb"> </span>std<span style="color:
#666666">::</span>cout<span style="color: #bbbbbb"> </span><span style="color:
#666666"><<</span><span style="color: #bbbbbb"> </span><span
style="color: #BA2121">"Hello Wörld!"</span>;
+<span style="color: #bbbbbb"> </span><span style="color: #008000;
font-weight: bold">return</span><span style="color: #bbbbbb"> </span><span
style="color: #666666">0</span>;
+}
+</pre></div>
+</pre></div>
+
+<p>perl
+</p><div class="example user-perl">
+<pre class="example-preformatted"><div class="highlight" style="background:
#f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color:
#008000; font-weight: bold">my</span><span style="color: #bbbbbb"> </span><span
style="color: #19177C">$list</span><span style="color: #bbbbbb"> </span><span
style="color: #666666">=</span><span style="color: #bbbbbb"> </span>[<span
style="color: #BA2121">'ça'</span>,<span style="color: #bbbbbb">
</span><span style="color: #BA2121"> [...]
+<span style="color: #008000; font-weight: bold">sub</span><span style="color:
#bbbbbb"> </span><span style="color: #0000FF">do</span><span style="color:
#bbbbbb"> </span>($)<span style="color: #bbbbbb"> </span>{
+<span style="color: #bbbbbb"> </span><span style="color: #008000;
font-weight: bold">my</span><span style="color: #bbbbbb"> </span><span
style="color: #19177C">$arg</span><span style="color: #bbbbbb"> </span><span
style="color: #666666">=</span><span style="color: #bbbbbb"> </span><span
style="color: #008000">shift</span>;
+<span style="color: #bbbbbb"> </span><span style="color: #008000;
font-weight: bold">return</span><span style="color: #bbbbbb"> </span><span
style="color: #19177C">$arg</span><span style="color: #bbbbbb"> </span><span
style="color: #666666">+</span><span style="color: #bbbbbb"> </span><span
style="color: #666666">4</span>;
+}
+</pre></div>
+</pre></div>
+
+<div class="example user-perl">
+<pre class="example-preformatted"><div class="highlight" style="background:
#f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color:
#008000; font-weight: bold">my</span><span style="color: #bbbbbb"> </span><span
style="color: #19177C">@SECTION_BUTTONS</span><span style="color: #bbbbbb">
</span><span style="color: #666666">=</span>
+<span style="color: #bbbbbb"> </span>(
+<span style="color: #bbbbbb"> </span><span style="color:
#666666">\&</span>singular_banner,
+<span style="color: #bbbbbb"> </span><span style="color:
#BA2121">'Back'</span>,<span style="color: #bbbbbb"> </span><span
style="color: #BA2121">'Forward'</span>,<span style="color: #bbbbbb">
</span><span style="color: #BA2121">'FastBack'</span>,<span
style="color: #bbbbbb"> </span><span style="color:
#BA2121">'FastForward'</span>,
+<span style="color: #bbbbbb"> </span><span style="color:
#BA2121">'Up'</span>,<span style="color: #bbbbbb"> </span><span
style="color: #BA2121">'Top'</span>,<span style="color: #bbbbbb">
</span><span style="color: #BA2121">'Contents'</span>,<span
style="color: #bbbbbb"> </span><span style="color:
#BA2121">'Index'</span>,<span style="color: #bbbbbb"> </span><span
style="color: #BA2121">'About'</span>
+<span style="color: #bbbbbb"> </span>);
+
+texinfo_set_from_init_file<span style="color: #bbbbbb"> </span>(<span
style="color: #BA2121">'SECTION_BUTTONS'</span>,<span style="color:
#bbbbbb"> </span><span style="color: #666666">\</span><span style="color:
#19177C">@SECTION_BUTTONS</span>);
+</pre></div>
+</pre></div>
+
+<p>No argument
+</p><div class="example">
+<pre class="example-preformatted">texinfo_set_from_init_file('NO_CSS', 1);
+</pre></div>
+
+<p>Unknown language
+</p><div class="example user-unknown">
+<pre class="example-preformatted">unknown language
+</pre></div>
+
+</div>
+<hr>
+<div class="nav-panel">
+<p>
+Previous: <a href="index.html">top</a>, Up: <a href="index.html">top</a>
</p>
+</div>
+
+
+
+</body>
+</html>
diff --git
a/tp/tests/other/res_parser/highlight_syntax_example_pygments/highlight_example.1
b/tp/tests/other/res_parser/highlight_syntax_example_pygments/highlight_example.1
new file mode 100644
index 0000000000..e69de29bb2
diff --git
a/tp/tests/other/res_parser/highlight_syntax_example_pygments/highlight_example.2
b/tp/tests/other/res_parser/highlight_syntax_example_pygments/highlight_example.2
new file mode 100644
index 0000000000..e69de29bb2
diff --git
a/tp/tests/other/res_parser/highlight_syntax_example_pygments/index.html
b/tp/tests/other/res_parser/highlight_syntax_example_pygments/index.html
new file mode 100644
index 0000000000..7595ca942b
--- /dev/null
+++ b/tp/tests/other/res_parser/highlight_syntax_example_pygments/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Top (top)</title>
+
+<meta name="description" content="Top (top)">
+<meta name="keywords" content="Top (top)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2any">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="#Top" rel="start" title="Top">
+<link href="chapter.html" rel="next" title="chapter">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="top-level-extent" id="Top">
+<div class="nav-panel">
+<p>
+Next: <a href="chapter.html" accesskey="n" rel="next">châp</a> </p>
+</div>
+<hr>
+<h1 class="top" id="top"><span>top<a class="copiable-link" href="#top">
¶</a></span></h1>
+
+<ul class="mini-toc">
+<li><a href="chapter.html" accesskey="1">châp</a></li>
+</ul>
+</div>
+<hr>
+<div class="nav-panel">
+<p>
+Next: <a href="chapter.html" accesskey="n" rel="next">châp</a> </p>
+</div>
+
+
+
+</body>
+</html>
diff --git a/tp/tests/test_scripts/other_highlight_syntax_example_highlight.sh
b/tp/tests/test_scripts/other_highlight_syntax_example_highlight.sh
new file mode 100755
index 0000000000..041199e461
--- /dev/null
+++ b/tp/tests/test_scripts/other_highlight_syntax_example_highlight.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+# This file generated by maintain/regenerate_cmd_tests.sh
+
+if test z"$srcdir" = "z"; then
+ srcdir=.
+fi
+
+one_test_logs_dir=test_log
+
+
+
+if test "z$OTHER_TESTS" != z"yes"; then
+ echo "Skipping other tests that are not easily reproducible"
+ exit 77
+fi
+
+dir=other
+name='highlight_syntax_example_highlight'
+mkdir -p $dir
+
+"$srcdir"/run_parser_all.sh -dir $dir $name
+exit_status=$?
+cat $dir/$one_test_logs_dir/$name.log
+exit $exit_status
+
diff --git a/tp/tests/test_scripts/other_highlight_syntax_example_pygments.sh
b/tp/tests/test_scripts/other_highlight_syntax_example_pygments.sh
new file mode 100755
index 0000000000..4b0eef32c0
--- /dev/null
+++ b/tp/tests/test_scripts/other_highlight_syntax_example_pygments.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+# This file generated by maintain/regenerate_cmd_tests.sh
+
+if test z"$srcdir" = "z"; then
+ srcdir=.
+fi
+
+one_test_logs_dir=test_log
+
+
+
+if test "z$OTHER_TESTS" != z"yes"; then
+ echo "Skipping other tests that are not easily reproducible"
+ exit 77
+fi
+
+dir=other
+name='highlight_syntax_example_pygments'
+mkdir -p $dir
+
+"$srcdir"/run_parser_all.sh -dir $dir $name
+exit_status=$?
+cat $dir/$one_test_logs_dir/$name.log
+exit $exit_status
+