[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Converter.pm (xml_format_tex
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/Converter.pm (xml_format_text_with_numeric_entities), tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/HTML.pm (_convert_text): add xml_format_text_with_numeric_entities() based on DocBook converter text, and use it in HTML if USE_NUMERIC_ENTITY is set. |
Date: |
Sun, 19 Dec 2021 09:34:40 -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 c8c62a8 * tp/Texinfo/Convert/Converter.pm
(xml_format_text_with_numeric_entities), tp/Texinfo/Convert/DocBook.pm
(_convert), tp/Texinfo/Convert/HTML.pm (_convert_text): add
xml_format_text_with_numeric_entities() based on DocBook converter text, and
use it in HTML if USE_NUMERIC_ENTITY is set.
c8c62a8 is described below
commit c8c62a8132a1a02c91a2de98d52b124bbc855b01
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 19 15:32:52 2021 +0100
* tp/Texinfo/Convert/Converter.pm
(xml_format_text_with_numeric_entities),
tp/Texinfo/Convert/DocBook.pm (_convert),
tp/Texinfo/Convert/HTML.pm (_convert_text): add
xml_format_text_with_numeric_entities() based on DocBook
converter text, and use it in HTML if USE_NUMERIC_ENTITY
is set.
---
ChangeLog | 10 ++++++++++
tp/Texinfo/Convert/Converter.pm | 28 ++++++++++++++++++++++++++++
tp/Texinfo/Convert/DocBook.pm | 17 +++--------------
tp/Texinfo/Convert/HTML.pm | 4 +++-
4 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7b301e0..9abc551 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,16 @@
2021-12-19 Patrice Dumas <pertusus@free.fr>
+ * tp/Texinfo/Convert/Converter.pm
+ (xml_format_text_with_numeric_entities),
+ tp/Texinfo/Convert/DocBook.pm (_convert),
+ tp/Texinfo/Convert/HTML.pm (_convert_text): add
+ xml_format_text_with_numeric_entities() based on DocBook
+ converter text, and use it in HTML if USE_NUMERIC_ENTITY
+ is set.
+
+2021-12-19 Patrice Dumas <pertusus@free.fr>
+
* tp/Texinfo/ParserNonXS.pm (_parse_macro_command_line)
(_lookup_macro_parameter, _expand_macro_body, _parse_texi):
Add _lookup_macro_parameter() to find the formal argument index
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 1a31e73..92575e6 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1364,6 +1364,29 @@ sub sort_element_counts($$;$$)
# XML related methods and variables that may be used in different
# XML Converters.
+
+my $xml_numeric_entity_mdash = '&#'.hex('2014').';';
+my $xml_numeric_entity_ndash = '&#'.hex('2013').';';
+my $xml_numeric_entity_ldquo = '&#'.hex('201C').';';
+my $xml_numeric_entity_rdquo = '&#'.hex('201D').';';
+my $xml_numeric_entity_lsquo = '&#'.hex('2018').';';
+my $xml_numeric_entity_rsquo = '&#'.hex('2019').';';
+
+sub xml_format_text_with_numeric_entities($$)
+{
+ my $self = shift;
+ my $text = shift;
+
+ $text =~ s/``/$xml_numeric_entity_ldquo/g;
+ $text =~ s/\'\'/$xml_numeric_entity_rdquo/g;
+ $text =~ s/`/$xml_numeric_entity_lsquo/g;
+ $text =~ s/\'/$xml_numeric_entity_rsquo/g;
+ $text =~ s/---/$xml_numeric_entity_mdash/g;
+ $text =~ s/--/$xml_numeric_entity_ndash/g;
+
+ return $text;
+}
+
sub xml_protect_text($$)
{
my $self = shift;
@@ -1835,6 +1858,11 @@ Other C<Texinfo::Convert::Converter> methods target
conversion to XML:
=over
+=item $formatted_text =
$converter->xml_format_text_with_numeric_entities($text)
+
+Replace quotation marks and hyphens used to represent dash in
+Texinfo text with numeric XML entities.
+
=item $protected_text = $converter->xml_protect_text($text)
Protect special XML characters (&, E<lt>, E<gt>, ") of I<$text>.
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 8b9f613..a1565d0 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -43,12 +43,6 @@ $VERSION = '6.8dev';
my $nbsp = '&#'.hex('00A0').';';
-my $mdash = '&#'.hex('2014').';';
-my $ndash = '&#'.hex('2013').';';
-my $ldquo = '&#'.hex('201C').';';
-my $rdquo = '&#'.hex('201D').';';
-my $lsquo = '&#'.hex('2018').';';
-my $rsquo = '&#'.hex('2019').';';
my %defaults = (
#'ENABLE_ENCODING' => 0,
@@ -60,8 +54,8 @@ my %defaults = (
'output_format' => 'docbook',
'SPLIT' => 0,
'documentlanguage' => undef,
- 'OPEN_QUOTE_SYMBOL' => $lsquo,
- 'CLOSE_QUOTE_SYMBOL' => $rsquo,
+ 'OPEN_QUOTE_SYMBOL' => '&#'.hex('2018').';',
+ 'CLOSE_QUOTE_SYMBOL' => '&#'.hex('2019').';',
'USE_NUMERIC_ENTITY' => 1,
);
@@ -523,12 +517,7 @@ sub _convert($$;$)
$result = $self->_protect_text($result);
if (! defined($element->{'type'}) or $element->{'type'} ne 'raw') {
if (!$self->{'document_context'}->[-1]->{'monospace'}->[-1]) {
- $result =~ s/``/$ldquo/g;
- $result =~ s/\'\'/$rdquo/g;
- $result =~ s/`/$lsquo/g;
- $result =~ s/\'/$rsquo/g;
- $result =~ s/---/$mdash/g;
- $result =~ s/--/$ndash/g;
+ $result = $self->xml_format_text_with_numeric_entities($result);
}
}
#warn "had text `$element->{'text'}', returning $result\n";
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index d5ed74d..6d2f127 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4276,7 +4276,9 @@ sub _convert_text($$$)
$text = Texinfo::Convert::Unicode::unicode_text($text,
($self->in_code() or
$self->in_math()));
} elsif (!$self->in_code() and !$self->in_math()) {
- if ($self->get_conf('USE_ISO')) {
+ if ($self->get_conf('USE_NUMERIC_ENTITY')) {
+ $text = $self->xml_format_text_with_numeric_entities($text);
+ } elsif ($self->get_conf('USE_ISO')) {
$text =~ s/---/\&mdash\;/g;
$text =~ s/--/\&ndash\;/g;
$text =~ s/``/\&ldquo\;/g;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Converter.pm (xml_format_text_with_numeric_entities), tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/HTML.pm (_convert_text): add xml_format_text_with_numeric_entities() based on DocBook converter text, and use it in HTML if USE_NUMERIC_ENTITY is set.,
Patrice Dumas <=
- Prev by Date:
branch master updated: Documentation of --OPT vs. --no-OPT
- Next by Date:
branch master updated: * doc/texinfo.texi (Other Customization Variables), tp/Texinfo/Convert/HTML.pm (non_breaking_space) (substitute_non_breaking_space, %BUTTONS_EXAMPLE) (%defaults, _indent_with_table, _set_non_breaking_space) (converter_initialize, _default_format_special_element_body): use numeric entities everywhere in HTML if USE_NUMERIC_ENTITY is set. Use functions to set and get the non breaking space entity. Set OPEN_QUOTE_SYMBOL CLOSE_QUOTE_SYMBOL and MENU_SYMBOL to undef in the default case, to set [...]
- Previous by thread:
branch master updated: Documentation of --OPT vs. --no-OPT
- Next by thread:
branch master updated: * doc/texinfo.texi (Other Customization Variables), tp/Texinfo/Convert/HTML.pm (non_breaking_space) (substitute_non_breaking_space, %BUTTONS_EXAMPLE) (%defaults, _indent_with_table, _set_non_breaking_space) (converter_initialize, _default_format_special_element_body): use numeric entities everywhere in HTML if USE_NUMERIC_ENTITY is set. Use functions to set and get the non breaking space entity. Set OPEN_QUOTE_SYMBOL CLOSE_QUOTE_SYMBOL and MENU_SYMBOL to undef in the default case, to set [...]
- Index(es):