Skip to content

Commit

Permalink
introduce post-processing option --mathstylize=mo_implied_space
Browse files Browse the repository at this point in the history
  • Loading branch information
dginev committed Jan 24, 2024
1 parent 6ee12be commit 2327bf8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
10 changes: 6 additions & 4 deletions bin/latexmlpost
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ my ($format, $extension, $is_html, $urlstyle) = (undef, undef, undef, 'server');
my ($numbersections) = (1);
my ($stylesheet, $defaultresources, $icon, @css, @javascript, @xsltparameters);
my ($mathimagemag) = (1.75);
my ($linelength, $plane1, $hackplane1) = (undef, undef, undef);
my ($dographics, $svg, $picimages) = (undef, undef, undef);
my ($linelength, $plane1, $hackplane1, $mathstylize) = (undef, undef, undef, undef);
my ($dographics, $svg, $picimages) = (undef, undef, undef);
my @graphicsmaps = ();
my ($split, $splitat, $splitpath, $splitnaming) = (undef, 'section', undef, 'id');
my ($navtoc) = (undef);
Expand Down Expand Up @@ -123,6 +123,7 @@ GetOptions("quiet" => sub { $verbosity--; },
"mathsvg" => sub { addMathFormat('svg'); },
"nomathsvg" => sub { removeMathFormat('svg'); },
"linelength=i" => \$linelength,
"mathstylize=s" => \$mathstylize,
"plane1!" => \$plane1,
"hackplane1!" => \$hackplane1,
"presentationmathml|pmml" => sub { addMathFormat('pmml'); },
Expand Down Expand Up @@ -472,8 +473,9 @@ sub assemble_postprocessors {
require LaTeXML::Post::MathML::Presentation;
push(@mprocs, LaTeXML::Post::MathML::Presentation->new(
linelength => $linelength,
(defined $plane1 ? (plane1 => $plane1) : (plane1 => 1)),
($hackplane1 ? (hackplane1 => 1) : ()),
(defined $plane1 ? (plane1 => $plane1) : (plane1 => 1)),
($hackplane1 ? (hackplane1 => 1) : ()),
($mathstylize ? (mathstylize => $mathstylize) : ()),
%OPTIONS)); }
elsif ($fmt eq 'cmml') {
require LaTeXML::Post::MathML::Content;
Expand Down
5 changes: 3 additions & 2 deletions lib/LaTeXML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,9 @@ sub convert_post {
require LaTeXML::Post::MathML::Presentation;
push(@mprocs, LaTeXML::Post::MathML::Presentation->new(
linelength => $$opts{linelength},
(defined $$opts{plane1} ? (plane1 => $$opts{plane1}) : (plane1 => 1)),
($$opts{hackplane1} ? (hackplane1 => 1) : ()),
(defined $$opts{plane1} ? (plane1 => $$opts{plane1}) : (plane1 => 1)),
($$opts{hackplane1} ? (hackplane1 => 1) : ()),
($$opts{mathstylize} ? (mathstylize => $$opts{mathstylize}) : ()),
%PostOPS)); }
elsif ($fmt eq 'cmml') {
require LaTeXML::Post::MathML::Content;
Expand Down
1 change: 1 addition & 0 deletions lib/LaTeXML/Common/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ sub getopt_specification {
# However, IF combining, then will need to support a id/ref mechanism.
"mathimagemagnification=f" => \$$opts{mathimagemag},
"linelength=i" => \$$opts{linelength},
"mathstylize=s" => \$$opts{mathstylize},
"plane1!" => \$$opts{plane1},
"hackplane1!" => \$$opts{hackplane1},
"mathimages" => sub { addMathFormat($opts, 'images'); },
Expand Down
19 changes: 12 additions & 7 deletions lib/LaTeXML/Post/MathML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use LaTeXML::Util::Unicode;
use LaTeXML::Post;
use LaTeXML::Common::Font;
use List::Util qw(max);
use base qw(LaTeXML::Post::MathProcessor);
use base qw(Exporter);
use base qw(LaTeXML::Post::MathProcessor);
use base qw(Exporter);
our @EXPORT = (
qw( &DefMathML ),
qw( &pmml &pmml_scriptsize &pmml_smaller
Expand Down Expand Up @@ -710,9 +710,10 @@ sub stylizeContent {
# For each mathvariant, and for each of those 5 groups, there is a linear mapping,
# EXCEPT for chars defined before Plain 1, which already exist in lower blocks.
# Get desired mapping strategy
my $plane1 = $$LaTeXML::Post::MATHPROCESSOR{plane1};
my $plane1hack = $$LaTeXML::Post::MATHPROCESSOR{hackplane1};
my $u_variant = $variant
my $plane1 = $$LaTeXML::Post::MATHPROCESSOR{plane1};
my $plane1hack = $$LaTeXML::Post::MATHPROCESSOR{hackplane1};
my $mathstylize = $$LaTeXML::Post::MATHPROCESSOR{mathstylize} || '';
my $u_variant = $variant
&& ($plane1hack ? $plane1hackable{$variant}
: ($plane1 ? $variant : undef));
my $u_text = ($tag ne 'm:mtext') && $u_variant && unicode_convert($text, $u_variant);
Expand Down Expand Up @@ -749,7 +750,11 @@ sub stylizeContent {
$size = undef if $stretchy; # Ignore size, if we're stretching.
my $stretchyhack = undef;
if ($text =~ /^[\x{2061}\x{2062}\x{2063}]*$/) { # invisible get no size or stretchiness
$stretchy = $size = undef; }
$stretchy = $size = undef;
# If requested, switch implied mo to space
if ($text eq "\x{2062}" and $mathstylize eq 'mo_implied_space') {
$text = "\x{200B}";
} }
if ($size) {
if ($size eq ($LaTeXML::MathML::SIZE || 'text')) { # If default size, no need to mention.
$size = undef; }
Expand Down Expand Up @@ -1075,7 +1080,7 @@ sub space_walk {
space_walk($self, $prev);
while (my $next = shift(@nodes)) {
my $invisop; # Save Invisible operators as potential target for (l|r)space
if (($$next[0] eq 'm:mo') && $$next[2] && ($$next[2] =~ /^[\x{2061}\x{2062}\x{2063}]*$/)) {
if (($$next[0] eq 'm:mo') && $$next[2] && ($$next[2] =~ /^[\x{200B}\x{2061}\x{2062}\x{2063}]*$/)) {
$invisop = $next;
$next = shift(@nodes);
last unless $next; }
Expand Down

0 comments on commit 2327bf8

Please sign in to comment.