[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Classify style brace commands as code/no_code/oth
From: |
Patrice Dumas |
Subject: |
branch master updated: Classify style brace commands as code/no_code/other directly |
Date: |
Tue, 23 Aug 2022 02:55:45 -0400 |
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 35ba0da816 Classify style brace commands as code/no_code/other directly
35ba0da816 is described below
commit 35ba0da81699c7dbca18f4f38c4d330ae1c19d3f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Aug 23 08:55:32 2022 +0200
Classify style brace commands as code/no_code/other directly
* tp/Texinfo/Common.pm (%brace_commands), tp/Texinfo/ParserNonXS.pm
(%full_text_commands, _in_code, _parse_line_command_args),
tp/Texinfo/XS/parsetexi/api.c (element_to_perl_hash),
tp/Texinfo/XS/parsetexi/command_data.txt,
tp/Texinfo/XS/parsetexi/commands.h, tp/Texinfo/XS/parsetexi/end_line.c
(parse_line_command_args), tp/Texinfo/XS/parsetexi/parser.c
(kbd_formatted_as_code, check_valid_nesting): classify style brace
commands as style_code, style_other and style_no_code directly in
%brace_commands in perl and as command data in C.
---
ChangeLog | 14 +++++++
tp/Texinfo/Common.pm | 6 +--
tp/Texinfo/Convert/DocBook.pm | 9 ++---
tp/Texinfo/Convert/HTML.pm | 5 +--
tp/Texinfo/ParserNonXS.pm | 12 ++++--
tp/Texinfo/XS/parsetexi/api.c | 4 +-
tp/Texinfo/XS/parsetexi/command_data.txt | 63 +++++++++++++++-----------------
tp/Texinfo/XS/parsetexi/commands.h | 10 +++--
tp/Texinfo/XS/parsetexi/end_line.c | 2 +-
tp/Texinfo/XS/parsetexi/parser.c | 10 +++--
10 files changed, 79 insertions(+), 56 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a33ce29867..c75e749a51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2022-08-23 Patrice Dumas <pertusus@free.fr>
+
+ Classify style brace commands as code/no_code/other directly
+
+ * tp/Texinfo/Common.pm (%brace_commands), tp/Texinfo/ParserNonXS.pm
+ (%full_text_commands, _in_code, _parse_line_command_args),
+ tp/Texinfo/XS/parsetexi/api.c (element_to_perl_hash),
+ tp/Texinfo/XS/parsetexi/command_data.txt,
+ tp/Texinfo/XS/parsetexi/commands.h, tp/Texinfo/XS/parsetexi/end_line.c
+ (parse_line_command_args), tp/Texinfo/XS/parsetexi/parser.c
+ (kbd_formatted_as_code, check_valid_nesting): classify style brace
+ commands as style_code, style_other and style_no_code directly in
+ %brace_commands in perl and as command data in C.
+
2022-08-22 Gavin Smith <gavinsmith0123@gmail.com>
* doc/texinfo.tex (\var): If 'txicodevaristt' is @set, then
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 7f933aa219..fbff78b5c7 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -710,14 +710,14 @@ our %style_commands;
foreach my $style_command ('asis', 'cite', 'clicksequence',
'dfn', 'emph', 'sc', 'var', 'headitemfont', 'strong', 'sub', 'sup',
'i', 'b', 'sansserif', 'slanted') {
- $brace_commands{$style_command} = 'style';
+ $brace_commands{$style_command} = 'style_other';
$style_commands{$style_command} = 1;
}
our %regular_font_style_commands;
foreach my $command ('r') {
$regular_font_style_commands{$command} = 1;
- $brace_commands{$command} = 'style';
+ $brace_commands{$command} = 'style_no_code';
$style_commands{$command} = 1;
}
@@ -725,7 +725,7 @@ our %code_style_commands;
foreach my $command ('code', 'command', 'env', 'file', 'kbd', 'option',
'samp', 't') {
$code_style_commands{$command} = 1;
- $brace_commands{$command} = 'style';
+ $brace_commands{$command} = 'style_code';
$style_commands{$command} = 1;
}
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index ce87fa994e..cf279cd606 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -120,13 +120,13 @@ my %style_attribute_commands;
'emph' => 'emphasis',
'env' => 'envar',
'file' => 'filename',
- 'footnote' => 'footnote',
+ 'footnote' => 'footnote', # not in %style_commands
'headitemfont' => 'emphasis role="bold"', # actually <th> instead of <td>
'i' => 'emphasis',
'indicateurl' => 'literal',
'kbd' => 'userinput',
'key' => 'keycap',
- 'math' => 'mathphrase',
+ 'math' => 'mathphrase', # not in %style_commands
'option' => 'option',
'r' => '',
'samp' => 'literal',
@@ -136,12 +136,11 @@ my %style_attribute_commands;
'sup' => 'superscript',
't' => 'literal',
'var' => 'replaceable',
- 'verb' => 'literal',
+ 'verb' => 'literal', # not in %style_commands
);
# this weird construct does like uniq, it avoids duplicates.
-# it may be required since math is not in the %style_commands as it is
-# in context command.
+# it may be required since some commands are not in %style_commands.
my @all_style_commands = keys %{{ map { $_ => 1 }
(keys(%Texinfo::Common::style_commands), keys(%style_attribute_commands),
'w', 'dmn', 'titlefont') }};
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 1e649e03f0..0933444a4d 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2497,14 +2497,13 @@ $style_commands_element{'normal'} = {
'sup' => 'sup',
't' => 'code',
'var' => 'var',
- 'verb' => 'code',
+ 'verb' => 'code', # not in %style_commands
};
my %style_commands_formatting;
# this weird construct does like uniq, it avoids duplicates.
-# it is required since math is not in the %style_commands as it is
-# in context command.
+# it may be required since some commands are not in %style_commands.
my @all_style_commands = keys %{{ map { $_ => 1 }
(keys(%style_commands), keys(%{$style_commands_element{'normal'}})) }};
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 3bbf045b80..af66680959 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -481,7 +481,9 @@ foreach my $command ('shortcaption', 'math') {
# commands that accept full text, but no block or top-level commands
my %full_text_commands;
foreach my $brace_command (keys (%brace_commands)) {
- if ($brace_commands{$brace_command} eq 'style') {
+ if ($brace_commands{$brace_command} eq 'style_code'
+ or $brace_commands{$brace_command} eq 'style_other'
+ or $brace_commands{$brace_command} eq 'style_no_code') {
$full_text_commands{$brace_command} = 1;
}
}
@@ -1402,7 +1404,8 @@ sub _in_code($$)
while ($current->{'parent'} and $current->{'parent'}->{'cmdname'}
and exists $brace_commands{$current->{'parent'}->{'cmdname'}}
and !exists
$context_brace_commands{$current->{'parent'}->{'cmdname'}}) {
- return 1 if ($code_style_commands{$current->{'parent'}->{'cmdname'}});
+ return 1
+ if ($brace_commands{$current->{'parent'}->{'cmdname'}} eq 'style_code');
$current = $current->{'parent'}->{'parent'};
}
return 0;
@@ -5891,7 +5894,10 @@ sub _parse_line_command_args($$$)
$self->{'definfoenclose'}->{$1} = [ $2, $3 ];
print STDERR "DEFINFOENCLOSE \@$1: $2, $3\n" if ($self->{'DEBUG'});
- $brace_commands{$1} = 'style';
+ # FIXME it is not propagated outside of the Parser. It is not
+ # reinitialized between calls of the converter. It is not
+ # put in %in_full_text_commands.
+ $brace_commands{$1} = 'style_other';
# Warning: there is a risk of mixing of data between a built-in
# command and a user command defined with @definfoenclose.
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 0cc2c127bb..be1c46284c 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -383,7 +383,9 @@ element_to_perl_hash (ELEMENT *e)
|| (command_flags(e) & CF_root)
|| (command_data(e->cmd).flags & CF_brace
&& (command_data(e->cmd).data >= 0
- || command_data(e->cmd).data == BRACE_style
+ || command_data(e->cmd).data == BRACE_style_other
+ || command_data(e->cmd).data == BRACE_style_code
+ || command_data(e->cmd).data == BRACE_style_no_code
|| command_data(e->cmd).data == BRACE_context
|| command_data(e->cmd).data == BRACE_other
|| command_data(e->cmd).data == BRACE_accent
diff --git a/tp/Texinfo/XS/parsetexi/command_data.txt
b/tp/Texinfo/XS/parsetexi/command_data.txt
index 0e0b46f62e..51fe804395 100644
--- a/tp/Texinfo/XS/parsetexi/command_data.txt
+++ b/tp/Texinfo/XS/parsetexi/command_data.txt
@@ -268,52 +268,49 @@ tieaccent brace,accent
BRACE_accent
dotless brace,accent BRACE_accent
# Style commands
-asis brace BRACE_style
-cite brace BRACE_style
-clicksequence brace BRACE_style
-dfn brace BRACE_style
-emph brace BRACE_style
-sc brace BRACE_style
-var brace BRACE_style
-headitemfont brace BRACE_style
-strong brace BRACE_style
-sub brace BRACE_style
-sup brace BRACE_style
+asis brace BRACE_style_other
+i brace BRACE_style_other
+b brace BRACE_style_other
+sansserif brace BRACE_style_other
+slanted brace BRACE_style_other
+cite brace BRACE_style_other
+clicksequence brace BRACE_style_other
+dfn brace BRACE_style_other
+emph brace BRACE_style_other
+sc brace BRACE_style_other
+var brace BRACE_style_other
+headitemfont brace BRACE_style_other
+strong brace BRACE_style_other
+sub brace BRACE_style_other
+sup brace BRACE_style_other
# code style commands
-code brace,code_style BRACE_style
-command brace,code_style BRACE_style
-env brace,code_style BRACE_style
-file brace,code_style BRACE_style
-kbd brace,code_style BRACE_style
-option brace,code_style BRACE_style
-samp brace,code_style BRACE_style
-t brace,code_style BRACE_style
-
-# Regular font style commands
-r brace BRACE_style
-i brace BRACE_style
-b brace BRACE_style
-sansserif brace BRACE_style
-slanted brace BRACE_style
+code brace BRACE_style_code
+command brace BRACE_style_code
+env brace BRACE_style_code
+file brace BRACE_style_code
+kbd brace BRACE_style_code
+option brace BRACE_style_code
+samp brace BRACE_style_code
+t brace BRACE_style_code
+
+# No code style commands
+r brace BRACE_style_no_code
U brace 1
dmn brace 1
titlefont brace,global 1
-
-w brace BRACE_other
-
hyphenation brace,global 1
anchor brace 1
errormsg brace 1
sortas brace 1
seeentry brace 1
seealso brace 1
+indicateurl brace 1
+key brace 1
-# more code style commands
-indicateurl brace,code_style 1
-key brace,code_style BRACE_other
-verb brace,code_style BRACE_other
+verb brace BRACE_other
+w brace BRACE_other
# context brace commands - commands that enclose full texts
footnote brace,global BRACE_context
diff --git a/tp/Texinfo/XS/parsetexi/commands.h
b/tp/Texinfo/XS/parsetexi/commands.h
index 0266b5feb8..1bea7ccbb2 100644
--- a/tp/Texinfo/XS/parsetexi/commands.h
+++ b/tp/Texinfo/XS/parsetexi/commands.h
@@ -54,8 +54,8 @@ void wipe_user_commands (void);
#define CF_brace 0x0010
#define CF_letter_no_arg 0x0020
#define CF_accent 0x0040
+/* CF_style and CF_code_style are not used */
#define CF_style 0x0080
-/* CF_code_style is set for brace commands only. */
#define CF_code_style 0x0100
#define CF_INFOENCLOSE 0x0200
#define CF_in_heading 0x0400
@@ -83,7 +83,7 @@ void wipe_user_commands (void);
/* NOTE: We've run out of spaces for flags, but some of these may not
be used, or may not be necessary.
- CF_code_style, CF_deprecated are hardly used.
+ CF_deprecated is hardly used.
Candidates for flags:
CF_close_paragraph, CF_heading_spec
@@ -116,7 +116,9 @@ void wipe_user_commands (void);
/* Types of brace command (CF_brace). */
#define BRACE_context -1 /* Can enclose paragraph breaks. */
#define BRACE_accent -2
-#define BRACE_style -3
-#define BRACE_other -4
+#define BRACE_style_other -3
+#define BRACE_style_code -5
+#define BRACE_style_no_code -6
+#define BRACE_other -7
#endif
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index c7f71cac90..4f5486c441 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -415,7 +415,7 @@ parse_line_command_args (ELEMENT *line_command)
user_defined_command_data[new_cmd].flags
|= (CF_INFOENCLOSE | CF_brace);
- user_defined_command_data[new_cmd].data = BRACE_style;
+ user_defined_command_data[new_cmd].data = BRACE_style_other;
ADD_ARG(new_command); free (new_command);
ADD_ARG(start); free (start);
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 7136035080..4e28fc8d31 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -807,7 +807,7 @@ kbd_formatted_as_code (ELEMENT *current)
&& (command_flags(tmp->parent) & CF_brace)
&& command_data(tmp->parent->cmd).data != BRACE_context)
{
- if (command_flags(tmp->parent) & CF_code_style)
+ if (command_data(tmp->parent->cmd).data == BRACE_style_code)
{
return 1;
}
@@ -938,7 +938,9 @@ check_valid_nesting (ELEMENT *current, enum command_id cmd)
else if (simple_text_command
/* "full text commands" */
|| (outer_flags & CF_brace)
- && command_data(outer).data == BRACE_style
+ && (command_data(outer).data == BRACE_style_other
+ || command_data(outer).data == BRACE_style_code
+ || command_data(outer).data == BRACE_style_no_code)
/* "full line commands" */
|| outer == CM_center
|| outer == CM_exdent
@@ -980,7 +982,9 @@ check_valid_nesting (ELEMENT *current, enum command_id cmd)
ok = 0;
if (command_data(outer).data == LINE_heading_spec
|| (outer_flags & CF_brace)
- && command_data(outer).data == BRACE_style)
+ && (command_data(outer).data == BRACE_style_other
+ || command_data(outer).data == BRACE_style_code
+ || command_data(outer).data == BRACE_style_no_code))
ok = 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Classify style brace commands as code/no_code/other directly,
Patrice Dumas <=