[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Warn that @indent and @noindent are useless insid
From: |
Patrice Dumas |
Subject: |
branch master updated: Warn that @indent and @noindent are useless inside paragraphs |
Date: |
Sat, 24 Dec 2022 18:06:27 -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 f1d65c9fae Warn that @indent and @noindent are useless inside
paragraphs
f1d65c9fae is described below
commit f1d65c9fae88b67de4d3f804aee951433c2bb8b8
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 25 00:06:16 2022 +0100
Warn that @indent and @noindent are useless inside paragraphs
* tp/Texinfo/ParserNonXS.pm (_in_paragraph)
(_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/handle_commands.c (in_paragraph)
(handle_other_command): add in_paragraph that returns true if
in a paragraph, including in a brace @-command except for a context
brace command. Use that function to warn if @indent or @noindent
are in a pragraph.
---
ChangeLog | 12 ++++++++
tp/TODO | 28 ++++++++---------
tp/Texinfo/ParserNonXS.pm | 31 ++++++++++++++++---
tp/Texinfo/XS/parsetexi/handle_commands.c | 21 +++++++++++++
tp/t/results/macro/macro_in_misc_commands.pl | 36 ++++++++++++++++++++++
tp/t/results/misc_commands/also_not_line.pl | 36 ++++++++++++++++++++++
.../results/misc_commands/noindent_in_paragraph.pl | 21 ++++++++++++-
.../at_commands_glued_in_paragraph.pl | 9 ++++++
tp/t/results/value/value_in_misc_commands.pl | 18 +++++++++++
9 files changed, 192 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1786756c21..895f76eb89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2022-12-24 Patrice Dumas <pertusus@free.fr>
+
+ Warn that @indent and @noindent are useless inside paragraphs
+
+ * tp/Texinfo/ParserNonXS.pm (_in_paragraph)
+ (_process_remaining_on_line),
+ tp/Texinfo/XS/parsetexi/handle_commands.c (in_paragraph)
+ (handle_other_command): add in_paragraph that returns true if
+ in a paragraph, including in a brace @-command except for a context
+ brace command. Use that function to warn if @indent or @noindent
+ are in a pragraph.
+
2022-12-24 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm: cut at 80 columns, reindent.
diff --git a/tp/TODO b/tp/TODO
index 0695bdbe13..3a2913576d 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -118,24 +118,9 @@ the context command stack.
-Punctuation and spaces before @image do not lead to a doubling of space.
-In fact @image is completly formatted outside of usual formatting containers.
-Not sure what should be the right way?
-test in info_test/image_and_punctuation
-
Image on sectioning command line haven't their length ignored correctly.
Not sure it is a big deal. An example in sectioning/at_commands_in_refs.
-warn when a @noindent/@indent appears within a paragraph.
-
-in info_tests/error_in_footnote there is an error message for each
-listoffloats; Line numbers are right, though, so maybe this is not
-an issue.
-
-converters_tests/things_before_setfilename there is no error
-for anchor and footnote before setfilename. It is not completly
-clear that there should be, though.
-
Recursive expansion of @value may lead to an infinite loop. Wait for
marksource to proceed.
https://bugzilla.redhat.com/show_bug.cgi?id=744878
@@ -242,6 +227,19 @@ Default is false.
In Plaintext, @quotation text could have the right margin narrowed to be more
in line with other output formats.
+Punctuation and spaces before @image do not lead to a doubling of space.
+In fact @image is completly formatted outside of usual formatting containers.
+Not sure what should be the right way?
+test in info_test/image_and_punctuation
+
+in info_tests/error_in_footnote there is an error message for each
+listoffloats; Line numbers are right, though, so maybe this is not
+an issue.
+
+converters_tests/things_before_setfilename there is no error
+for anchor and footnote before setfilename. It is not completly
+clear that there should be, though.
+
DocBook
-------
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 4922962f6d..731b319ca6 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1470,6 +1470,23 @@ sub _kbd_formatted_as_code($$)
return 0;
}
+sub _in_paragraph($$)
+{
+ my ($self, $current) = @_;
+ while ($current->{'parent'} and $current->{'parent'}->{'cmdname'}
+ and exists($self->{'brace_commands'}
+ ->{$current->{'parent'}->{'cmdname'}})
+ and $self->{'brace_commands'}
+ ->{$current->{'parent'}->{'cmdname'}} ne 'context')
{
+ $current = $current->{'parent'};
+ }
+ if ($current->{'type'} and $current->{'type'} eq 'paragraph') {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
# close brace commands, that don't set a new context (ie @caption, @footnote)
sub _close_all_style_commands($$$;$$)
{
@@ -3811,12 +3828,12 @@ sub _end_line($$$)
# check for infinite loop bugs...
if ($current eq $current_old) {
- my $indent = '- ';
- my $tree_msg = $indent . _print_current($current);
+ my $indent_str = '- ';
+ my $tree_msg = $indent_str . _print_current($current);
while ($current->{'parent'}) {
- $indent = '-'.$indent;
+ $indent_str = '-'.$indent_str;
$current = $current->{'parent'};
- $tree_msg .= $indent . _print_current($current);
+ $tree_msg .= $indent_str . _print_current($current);
}
$self->_bug_message("Nothing closed while a line context remains\n"
. $tree_msg,
@@ -4905,6 +4922,12 @@ sub _process_remaining_on_line($$$$)
$misc = { 'cmdname' => $command, 'parent' => $current,
'source_info' => $source_info };
push @{$current->{'contents'}}, $misc;
+ if (($command eq 'indent' or $command eq 'noindent')
+ and _in_paragraph($self, $current)) {
+ $self->_line_warn(sprintf(__("\@%s is useless inside of a
paragraph"),
+ $command),
+ $source_info);
+ }
}
$line = _start_empty_line_after_command($line, $current, undef);
}
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 0f108380e2..dd3130c4a4 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -77,6 +77,21 @@ check_no_text (ELEMENT *current)
return after_paragraph;
}
+int
+in_paragraph (ELEMENT *current)
+{
+ while (current->parent
+ && (command_flags(current->parent) & CF_brace)
+ && !(command_data(current->parent->cmd).data == BRACE_context))
+ {
+ current = current->parent;
+ }
+ if (current->type == ET_paragraph)
+ return 1;
+ else
+ return 0;
+}
+
/* symbol skipspace other */
ELEMENT *
handle_other_command (ELEMENT *current, char **line_inout,
@@ -257,6 +272,12 @@ handle_other_command (ELEMENT *current, char **line_inout,
misc->cmd = cmd;
misc->source_info = current_source_info;
add_to_element_contents (current, misc);
+ if ((cmd == CM_indent || cmd == CM_noindent)
+ && in_paragraph (current))
+ {
+ line_warn ("@%s is useless inside of a paragraph",
+ command_name(cmd));
+ }
}
start_empty_line_after_command (current, &line, 0);
}
diff --git a/tp/t/results/macro/macro_in_misc_commands.pl
b/tp/t/results/macro/macro_in_misc_commands.pl
index 5441760ba4..7261008976 100644
--- a/tp/t/results/macro/macro_in_misc_commands.pl
+++ b/tp/t/results/macro/macro_in_misc_commands.pl
@@ -4253,6 +4253,15 @@ $result_errors{'macro_in_misc_commands'} = [
'text' => '@page should only appear at the beginning of a line',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
(possibly involving @noindentmacro)
+',
+ 'file_name' => '',
+ 'line_nr' => 163,
+ 'macro' => 'noindentmacro',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @refill is obsolete (possibly involving
@refillmacro)
',
@@ -4262,6 +4271,24 @@ $result_errors{'macro_in_misc_commands'} = [
'text' => '@refill is obsolete',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
(possibly involving @noindentmacro)
+',
+ 'file_name' => '',
+ 'line_nr' => 166,
+ 'macro' => 'noindentmacro',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
(possibly involving @noindentmacro)
+',
+ 'file_name' => '',
+ 'line_nr' => 168,
+ 'macro' => 'noindentmacro',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @page should only appear at the beginning of a
line (possibly involving @pagemacro)
',
@@ -4271,6 +4298,15 @@ $result_errors{'macro_in_misc_commands'} = [
'text' => '@page should only appear at the beginning of a line',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
(possibly involving @noindentmacro)
+',
+ 'file_name' => '',
+ 'line_nr' => 174,
+ 'macro' => 'noindentmacro',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @refill is obsolete (possibly involving
@refillmacro)
',
diff --git a/tp/t/results/misc_commands/also_not_line.pl
b/tp/t/results/misc_commands/also_not_line.pl
index daa8ba166e..f49cb5e4a6 100644
--- a/tp/t/results/misc_commands/also_not_line.pl
+++ b/tp/t/results/misc_commands/also_not_line.pl
@@ -399,6 +399,15 @@ $result_errors{'also_not_line'} = [
'text' => '@page should only appear at the beginning of a line',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @refill is obsolete
',
@@ -408,6 +417,24 @@ $result_errors{'also_not_line'} = [
'text' => '@refill is obsolete',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 7,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 9,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @page should only appear at the beginning of a
line
',
@@ -417,6 +444,15 @@ $result_errors{'also_not_line'} = [
'text' => '@page should only appear at the beginning of a line',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 15,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @refill is obsolete
',
diff --git a/tp/t/results/misc_commands/noindent_in_paragraph.pl
b/tp/t/results/misc_commands/noindent_in_paragraph.pl
index 7d7fa2e367..e37d890698 100644
--- a/tp/t/results/misc_commands/noindent_in_paragraph.pl
+++ b/tp/t/results/misc_commands/noindent_in_paragraph.pl
@@ -90,7 +90,26 @@ Begin para2
after noindent2.
';
-$result_errors{'noindent_in_paragraph'} = [];
+$result_errors{'noindent_in_paragraph'} = [
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 2,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 6,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ }
+];
$result_floats{'noindent_in_paragraph'} = {};
diff --git a/tp/t/results/plaintext_tests/at_commands_glued_in_paragraph.pl
b/tp/t/results/plaintext_tests/at_commands_glued_in_paragraph.pl
index 5a9997670d..798994e2fa 100644
--- a/tp/t/results/plaintext_tests/at_commands_glued_in_paragraph.pl
+++ b/tp/t/results/plaintext_tests/at_commands_glued_in_paragraph.pl
@@ -458,6 +458,15 @@ anchoranchor
index';
$result_errors{'at_commands_glued_in_paragraph'} = [
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 11,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @cindex should only appear at the beginning of a
line
',
diff --git a/tp/t/results/value/value_in_misc_commands.pl
b/tp/t/results/value/value_in_misc_commands.pl
index c51f41dbaf..3213f72b73 100644
--- a/tp/t/results/value/value_in_misc_commands.pl
+++ b/tp/t/results/value/value_in_misc_commands.pl
@@ -2887,6 +2887,24 @@ $result_errors{'value_in_misc_commands'} = [
'text' => '@page should only appear at the beginning of a line',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 118,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: @noindent is useless inside of a paragraph
+',
+ 'file_name' => '',
+ 'line_nr' => 120,
+ 'macro' => '',
+ 'text' => '@noindent is useless inside of a paragraph',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @page should only appear at the beginning of a
line
',
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Warn that @indent and @noindent are useless inside paragraphs,
Patrice Dumas <=