[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 5 May 2024 06:49:35 -0400 (EDT) |
branch: master
commit 3c99e9719f1b65efe35f8e794f5bf080545ffef9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun May 5 12:49:18 2024 +0200
* tp/Texinfo/ParserNonXS.pm (_gather_def_item),
tp/Texinfo/XS/main/element_types.txt, tp/Texinfo/XS/parsetexi/def.c
(gather_def_item): put content before @defblock and first @def*line in
a before_defline container.
* tp/Texinfo/Convert/DocBook.pm (%type_elements),
tp/Texinfo/Convert/HTML.pm (%default_types_conversion),
tp/Texinfo/Convert/LaTeX.pm (_convert),
tp/Texinfo/Convert/TexinfoMarkup.pm (%type_elements),
tp/Texinfo/XS/convert/convert_html.c
(types_internal_conversion_table): update for before_defline.
* util/texinfo.dtd: update for beforefirstdefline.
---
ChangeLog | 16 +++++++++++++++
tp/Texinfo/Convert/DocBook.pm | 2 ++
tp/Texinfo/Convert/HTML.pm | 1 +
tp/Texinfo/Convert/LaTeX.pm | 6 ++++--
tp/Texinfo/Convert/TexinfoMarkup.pm | 1 +
tp/Texinfo/ParserNonXS.pm | 23 ++++++++++++++++------
tp/Texinfo/XS/convert/convert_html.c | 1 +
tp/Texinfo/XS/main/element_types.c | 1 +
tp/Texinfo/XS/main/element_types.h | 1 +
tp/Texinfo/XS/main/element_types.txt | 1 +
tp/Texinfo/XS/parsetexi/def.c | 10 +++++++++-
tp/t/results/def/comment_index_before_defline.pl | 6 +++---
tp/t/results/def/defblock_no_defline.pl | 6 +++---
tp/t/results/def/text_block_before_defline.pl | 6 +++---
tp/t/results/linemacro/api_doc_with_linemacro.pl | 2 +-
.../linemacro/block_begin_end_in_linemacro_call.pl | 2 +-
tp/t/results/linemacro/braces_after_text.pl | 2 +-
tp/t/results/linemacro/empty_last_argument.pl | 2 +-
.../results/linemacro/last_argument_with_braces.pl | 2 +-
tp/t/results/linemacro/nested_linemacro_calls.pl | 2 +-
.../linemacro/newline_and_continuation_in_brace.pl | 2 +-
.../linemacro/simple_nested_linemacro_calls.pl | 2 +-
tp/t/results/linemacro/verb_in_linemacro_call.pl | 2 +-
util/texinfo.dtd | 3 ++-
24 files changed, 74 insertions(+), 28 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 55e4755271..23800f1848 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-05-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_gather_def_item),
+ tp/Texinfo/XS/main/element_types.txt, tp/Texinfo/XS/parsetexi/def.c
+ (gather_def_item): put content before @defblock and first @def*line in
+ a before_defline container.
+
+ * tp/Texinfo/Convert/DocBook.pm (%type_elements),
+ tp/Texinfo/Convert/HTML.pm (%default_types_conversion),
+ tp/Texinfo/Convert/LaTeX.pm (_convert),
+ tp/Texinfo/Convert/TexinfoMarkup.pm (%type_elements),
+ tp/Texinfo/XS/convert/convert_html.c
+ (types_internal_conversion_table): update for before_defline.
+
+ * util/texinfo.dtd: update for beforefirstdefline.
+
2024-05-05 Patrice Dumas <pertusus@free.fr>
* tp/t/19def.t (@test_defblock): add full_document for LaTeX output
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 685f3aa8a2..26e10a8412 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -251,6 +251,8 @@ my %type_elements = (
'multitable_body' => 'tbody',
# Unfortunatly there does not seem to be anything better in DocBook.
'def_item' => 'blockquote',
+ # FIXME or nothing?
+ 'before_defline' => 'blockquote',
);
my %default_context_block_commands = (
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 4bc4ec295d..4e0337def1 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -7958,6 +7958,7 @@ sub _convert_def_item_type($$$$)
$default_types_conversion{'def_item'} = \&_convert_def_item_type;
$default_types_conversion{'inter_def_item'} = \&_convert_def_item_type;
+$default_types_conversion{'before_defline'} = \&_convert_def_item_type;
sub _convert_table_definition_type($$$$)
{
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 0f006832f3..c655787df6 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -4256,7 +4256,8 @@ sub _convert($$)
}
$result .= "\n";
$result .= _index_entry($self, $element);
- } elsif ($element->{'type'} eq 'def_item') {
+ } elsif ($element->{'type'} eq 'def_item'
+ or $element->{'type'} eq 'before_defline') {
$result .= "\\begin{quote}\n";
# Remove vertical space and start paragaph, avoiding adding
# more vertical space.
@@ -4337,7 +4338,8 @@ sub _convert($$)
if ($type) {
if ($type eq '_dot_not_end_sentence') {
$self->{'formatting_context'}->[-1]->{'dot_not_end_sentence'} -= 1;
- } elsif ($type eq 'def_item') {
+ } elsif ($type eq 'def_item'
+ or $element->{'type'} eq 'before_defline') {
$result .= "\\end{quote}\n";
} elsif ($type eq 'table_term') {
$result .= '}}]'."\n";
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index 3359f4c23d..74450a2bf1 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -257,6 +257,7 @@ my %type_elements = (
'multitable_body' => 'tbody',
'def_item' => 'definitionitem',
'before_item' => 'beforefirstitem',
+ 'before_defline' => 'beforefirstdefline',
);
my %default_context_block_commands = (
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 188618595b..946a84a105 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1884,7 +1884,7 @@ sub _gather_def_item($$;$)
my $type;
# means that we are between a @def*x and a @def
if ($next_command
- and $next_command ne 'defline' and $next_command ne 'deftypeline') {
+ and $next_command ne 'defline' and $next_command ne 'deftypeline') {
$type = 'inter_def_item';
} else {
$type = 'def_item';
@@ -1916,7 +1916,13 @@ sub _gather_def_item($$;$)
unshift @{$def_item->{'contents'}}, $item_content;
}
}
- if (scalar(@{$def_item->{'contents'}})) {
+ my $gathered_content_count = scalar(@{$def_item->{'contents'}});
+ if ($gathered_content_count) {
+ if ($current->{'cmdname'} eq 'defblock'
+ # all content between @defblock and first @def*line
+ and $gathered_content_count == $contents_count) {
+ $def_item->{'type'} = 'before_defline';
+ }
push @{$current->{'contents'}}, $def_item;
}
}
@@ -8331,10 +8337,10 @@ element:
=item def_line
-This type may be associated with a definition command with a x form,
-like C<@defunx>, C<@defvrx>. For the form without x, the associated
-I<def_line> is the first C<contents> element. It is described in more
-details below.
+This type is associated with a definition command with a x form,
+like C<@defunx>, C<@defvrx> and with C<@defline> and C<@deftypeline>.
+For the form without x, the associated I<def_line> is the first C<contents>
+element. It is described in more details below.
=item definfoenclose_command
@@ -8494,6 +8500,11 @@ be collected to know when a top-level brace command is
closed. In C<@math>,
in raw output format brace commands and within brace @-commands in raw output
format block commands.
+=item before_defline
+
+A container for content before the first C<@defline> or C<@deftypeline>
+in C<@defblock>.
+
=item before_item
A container for content before the first C<@item> of block @-commands
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 9345eb0047..0a85f8af2f 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -15203,6 +15203,7 @@ static const TYPE_INTERNAL_CONVERSION
types_internal_conversion_table[] = {
{ET_before_item, convert_before_item_type},
{ET_def_item, &convert_def_item_type},
{ET_inter_def_item, &convert_def_item_type},
+ {ET_before_defline, &convert_def_item_type},
{ET_def_line, &convert_def_line_type},
{ET_definfoenclose_command, &convert_definfoenclose_type},
{ET_index_entry_command, &convert_index_entry_command_type},
diff --git a/tp/Texinfo/XS/main/element_types.c
b/tp/Texinfo/XS/main/element_types.c
index 3554adbef1..eeddd181e8 100644
--- a/tp/Texinfo/XS/main/element_types.c
+++ b/tp/Texinfo/XS/main/element_types.c
@@ -55,6 +55,7 @@ char *element_type_names[] = {
"def_line",
"def_item",
"inter_def_item",
+"before_defline",
"multitable_head",
"multitable_body",
"row",
diff --git a/tp/Texinfo/XS/main/element_types.h
b/tp/Texinfo/XS/main/element_types.h
index 2dcfb0d682..34d664c4fa 100644
--- a/tp/Texinfo/XS/main/element_types.h
+++ b/tp/Texinfo/XS/main/element_types.h
@@ -58,6 +58,7 @@ ET_inter_item,
ET_def_line,
ET_def_item,
ET_inter_def_item,
+ET_before_defline,
ET_multitable_head,
ET_multitable_body,
ET_row,
diff --git a/tp/Texinfo/XS/main/element_types.txt
b/tp/Texinfo/XS/main/element_types.txt
index 0881399b82..4805e3edde 100644
--- a/tp/Texinfo/XS/main/element_types.txt
+++ b/tp/Texinfo/XS/main/element_types.txt
@@ -78,6 +78,7 @@ inter_item
def_line
def_item
inter_def_item
+before_defline
multitable_head
multitable_body
row
diff --git a/tp/Texinfo/XS/parsetexi/def.c b/tp/Texinfo/XS/parsetexi/def.c
index 5e21b52eda..bc4336fa13 100644
--- a/tp/Texinfo/XS/parsetexi/def.c
+++ b/tp/Texinfo/XS/parsetexi/def.c
@@ -76,7 +76,15 @@ gather_def_item (ELEMENT *current, enum command_id
next_command)
}
if (def_item->contents.number > 0)
- add_to_element_contents (current, def_item);
+ {
+ if (current->cmd == CM_defblock
+ /* all content between @defblock and first @def*line */
+ && def_item->contents.number == contents_count)
+ {
+ def_item->type = ET_before_defline;
+ }
+ add_to_element_contents (current, def_item);
+ }
else
destroy_element (def_item);
}
diff --git a/tp/t/results/def/comment_index_before_defline.pl
b/tp/t/results/def/comment_index_before_defline.pl
index bc4a2f8642..11dc746686 100644
--- a/tp/t/results/def/comment_index_before_defline.pl
+++ b/tp/t/results/def/comment_index_before_defline.pl
@@ -89,7 +89,7 @@ $result_trees{'comment_index_before_defline'} = {
'type' => 'empty_line'
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
@@ -375,11 +375,11 @@
$result_converted{'docbook'}->{'comment_index_before_defline'} = '<blockquote><!
$result_converted{'xml'}->{'comment_index_before_defline'} = '<defblock
endspaces=" ">
-<definitionitem><!-- c a comment -->
+<beforefirstdefline><!-- c a comment -->
<cindex index="cp" spaces=" "><indexterm index="cp"
number="1">entry</indexterm></cindex>
<!-- comment another -->
-</definitionitem><defline spaces="
"><definitionterm><defcategory>a</defcategory> <defsymbol>b</defsymbol>
<defparam>c</defparam> <defparam>d</defparam></definitionterm></defline>
+</beforefirstdefline><defline spaces="
"><definitionterm><defcategory>a</defcategory> <defsymbol>b</defsymbol>
<defparam>c</defparam> <defparam>d</defparam></definitionterm></defline>
</defblock>
';
diff --git a/tp/t/results/def/defblock_no_defline.pl
b/tp/t/results/def/defblock_no_defline.pl
index 5894d42a37..4456cf295c 100644
--- a/tp/t/results/def/defblock_no_defline.pl
+++ b/tp/t/results/def/defblock_no_defline.pl
@@ -38,7 +38,7 @@ $result_trees{'defblock_no_defline'} = {
'type' => 'paragraph'
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
@@ -198,8 +198,8 @@ $result_converted{'docbook'}->{'defblock_no_defline'} =
'<blockquote><para>misc
$result_converted{'xml'}->{'defblock_no_defline'} = '<defblock endspaces=" ">
-<definitionitem><para>misc text inside
-</para></definitionitem></defblock>
+<beforefirstdefline><para>misc text inside
+</para></beforefirstdefline></defblock>
';
1;
diff --git a/tp/t/results/def/text_block_before_defline.pl
b/tp/t/results/def/text_block_before_defline.pl
index 417b16d09a..db78e33a98 100644
--- a/tp/t/results/def/text_block_before_defline.pl
+++ b/tp/t/results/def/text_block_before_defline.pl
@@ -360,7 +360,7 @@ $result_trees{'text_block_before_defline'} = {
'type' => 'empty_line'
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
@@ -844,7 +844,7 @@ $result_converted{'xml'}->{'text_block_before_defline'} =
'<node name="Top" spac
<chapter spaces=" "><sectiontitle>Chap</sectiontitle>
<defblock endspaces=" ">
-<definitionitem><para>Some text<footnote><para>In footnote</para></footnote>.
+<beforefirstdefline><para>Some text<footnote><para>In
footnote</para></footnote>.
</para>
<example endspaces=" ">
<pre xml:space="preserve">an example
@@ -854,7 +854,7 @@ $result_converted{'xml'}->{'text_block_before_defline'} =
'<node name="Top" spac
<menuentry><menuleadingtext>*
</menuleadingtext><menunode>(other_manual)</menunode><menuseparator>::</menuseparator><menudescription><pre
xml:space="preserve">
</pre></menudescription></menuentry></menu>
-</definitionitem><defline spaces="
"><definitionterm><defcategory>a</defcategory> <defsymbol>b</defsymbol>
<defparam>c</defparam> <defparam>d</defparam></definitionterm></defline>
+</beforefirstdefline><defline spaces="
"><definitionterm><defcategory>a</defcategory> <defsymbol>b</defsymbol>
<defparam>c</defparam> <defparam>d</defparam></definitionterm></defline>
</defblock>
</chapter>
';
diff --git a/tp/t/results/linemacro/api_doc_with_linemacro.pl
b/tp/t/results/linemacro/api_doc_with_linemacro.pl
index 2a75ab5666..7eca5bbb5e 100644
--- a/tp/t/results/linemacro/api_doc_with_linemacro.pl
+++ b/tp/t/results/linemacro/api_doc_with_linemacro.pl
@@ -511,7 +511,7 @@ $result_trees{'api_doc_with_linemacro'} = {
'text' => ''
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/tp/t/results/linemacro/block_begin_end_in_linemacro_call.pl
b/tp/t/results/linemacro/block_begin_end_in_linemacro_call.pl
index 303ba21879..170498fd15 100644
--- a/tp/t/results/linemacro/block_begin_end_in_linemacro_call.pl
+++ b/tp/t/results/linemacro/block_begin_end_in_linemacro_call.pl
@@ -780,7 +780,7 @@ args \\e\\|\\f\\|
'type' => 'paragraph'
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/tp/t/results/linemacro/braces_after_text.pl
b/tp/t/results/linemacro/braces_after_text.pl
index 7174fad8ff..ea1aa80881 100644
--- a/tp/t/results/linemacro/braces_after_text.pl
+++ b/tp/t/results/linemacro/braces_after_text.pl
@@ -151,7 +151,7 @@ $result_trees{'braces_after_text'} = {
'text' => ''
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/tp/t/results/linemacro/empty_last_argument.pl
b/tp/t/results/linemacro/empty_last_argument.pl
index 737b386f10..8637560657 100644
--- a/tp/t/results/linemacro/empty_last_argument.pl
+++ b/tp/t/results/linemacro/empty_last_argument.pl
@@ -208,7 +208,7 @@ $result_trees{'empty_last_argument'} = {
'type' => 'index_entry_command'
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/tp/t/results/linemacro/last_argument_with_braces.pl
b/tp/t/results/linemacro/last_argument_with_braces.pl
index 7fc28843d8..ab6d579ae6 100644
--- a/tp/t/results/linemacro/last_argument_with_braces.pl
+++ b/tp/t/results/linemacro/last_argument_with_braces.pl
@@ -140,7 +140,7 @@ $result_trees{'last_argument_with_braces'} = {
'text' => ''
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/tp/t/results/linemacro/nested_linemacro_calls.pl
b/tp/t/results/linemacro/nested_linemacro_calls.pl
index daf4a5ba30..655f51bdb7 100644
--- a/tp/t/results/linemacro/nested_linemacro_calls.pl
+++ b/tp/t/results/linemacro/nested_linemacro_calls.pl
@@ -223,7 +223,7 @@ $result_trees{'nested_linemacro_calls'} = {
'text' => ''
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/tp/t/results/linemacro/newline_and_continuation_in_brace.pl
b/tp/t/results/linemacro/newline_and_continuation_in_brace.pl
index d71d89130a..d64d986710 100644
--- a/tp/t/results/linemacro/newline_and_continuation_in_brace.pl
+++ b/tp/t/results/linemacro/newline_and_continuation_in_brace.pl
@@ -158,7 +158,7 @@ $result_trees{'newline_and_continuation_in_brace'} = {
'text' => ''
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/tp/t/results/linemacro/simple_nested_linemacro_calls.pl
b/tp/t/results/linemacro/simple_nested_linemacro_calls.pl
index 3e8a08d537..72edc1636a 100644
--- a/tp/t/results/linemacro/simple_nested_linemacro_calls.pl
+++ b/tp/t/results/linemacro/simple_nested_linemacro_calls.pl
@@ -252,7 +252,7 @@ $result_trees{'simple_nested_linemacro_calls'} = {
'text' => ''
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/tp/t/results/linemacro/verb_in_linemacro_call.pl
b/tp/t/results/linemacro/verb_in_linemacro_call.pl
index d8a92f8b37..f1b19191df 100644
--- a/tp/t/results/linemacro/verb_in_linemacro_call.pl
+++ b/tp/t/results/linemacro/verb_in_linemacro_call.pl
@@ -248,7 +248,7 @@ $result_trees{'verb_in_linemacro_call'} = {
'type' => 'paragraph'
}
],
- 'type' => 'def_item'
+ 'type' => 'before_defline'
},
{
'args' => [
diff --git a/util/texinfo.dtd b/util/texinfo.dtd
index 91937dff1b..1681bf95d2 100644
--- a/util/texinfo.dtd
+++ b/util/texinfo.dtd
@@ -1043,7 +1043,7 @@
<!ATTLIST deftypemethodx
%spacesattr;>
-<!ELEMENT defblock (((defline | deftypeline), (%indexentry.cmds;)*,
definitionitem?)+)>
+<!ELEMENT defblock (beforefirstdefline?, ((defline | deftypeline),
(%indexentry.cmds;)*, definitionitem?)+)>
<!ATTLIST defblock
endspaces CDATA #IMPLIED>
<!ELEMENT defline (definitionterm)>
@@ -1055,6 +1055,7 @@
<!ELEMENT definitionterm (indexterm?, (%definition.args;)+)>
<!ELEMENT definitionitem (%block;)*>
+<!ELEMENT beforefirstdefline (%block;)*>
<!ENTITY % defargattr
"%bracketedattr; %spacestrailingspacesattr;">