mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 06:19:36 +00:00
When in doubt, do as LyX does
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6089 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b6f3c17004
commit
9a2c09c1ef
@ -1,3 +1,9 @@
|
|||||||
|
2003-02-11 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* reLyX/BasicLyX.pm: Do as LyX does: wrap the minipage width and
|
||||||
|
height output in inverted commas and strip the space from "4.5 cm".
|
||||||
|
Factorise the code by defining sub getAsLyXLength.
|
||||||
|
|
||||||
2003-02-11 Angus Leeming <leeming@lyx.org>
|
2003-02-11 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* reLyX/BasicLyX.pm: add support for minipages. The inner-pos optional
|
* reLyX/BasicLyX.pm: add support for minipages. The inner-pos optional
|
||||||
|
@ -218,14 +218,6 @@ my $MathEnvironments = "(math|displaymath|xxalignat|(equation|eqnarray|align|ali
|
|||||||
# ListLayouts may have standard paragraphs nested inside them.
|
# ListLayouts may have standard paragraphs nested inside them.
|
||||||
my $ListLayouts = "Itemize|Enumerate|Description";
|
my $ListLayouts = "Itemize|Enumerate|Description";
|
||||||
|
|
||||||
# Striaght translation of LaTeX lengths to LyX ones.
|
|
||||||
my %lengthAsLyXString = ('\textwidth' => 'text%',
|
|
||||||
'\columnwidth' => 'col%',
|
|
||||||
'\paperwidth' => 'page%',
|
|
||||||
'\linewidth' => 'line%',
|
|
||||||
'\paperheight' => 'pheight%',
|
|
||||||
'\textheight' => 'theight%');
|
|
||||||
|
|
||||||
# passed a string and an array
|
# passed a string and an array
|
||||||
# returns true if the string is an element of the array.
|
# returns true if the string is an element of the array.
|
||||||
sub foundIn {
|
sub foundIn {
|
||||||
@ -360,6 +352,34 @@ sub ending_math {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Straight translation of LaTeX lengths to LyX ones.
|
||||||
|
my %lengthAsLyXString = ('\textwidth' => 'text%',
|
||||||
|
'\columnwidth' => 'col%',
|
||||||
|
'\paperwidth' => 'page%',
|
||||||
|
'\linewidth' => 'line%',
|
||||||
|
'\paperheight' => 'pheight%',
|
||||||
|
'\textheight' => 'theight%');
|
||||||
|
|
||||||
|
sub getAsLyXLength {
|
||||||
|
my $LatexLength = shift;
|
||||||
|
|
||||||
|
my $LyXLength = '';
|
||||||
|
# If $LatexLength is something like '4.5\columnwidth', translate into
|
||||||
|
# LyXese.
|
||||||
|
if ($LatexLength =~ /([0-9]+\.?[0-9]*)\s*(\\[a-z]*)/) {
|
||||||
|
if (defined($lengthAsLyXString{$2})) {
|
||||||
|
$LyXLength = ($1 * 100) . $lengthAsLyXString{$2};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$LyXLength = $LatexLength;
|
||||||
|
# Remove any spaces from '4.5 cm'
|
||||||
|
$LyXLength =~ s/\s*//g;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $LyXLength;
|
||||||
|
}
|
||||||
|
|
||||||
########################## MAIN TRANSLATOR SUBROUTINE #####################
|
########################## MAIN TRANSLATOR SUBROUTINE #####################
|
||||||
sub basic_lyx {
|
sub basic_lyx {
|
||||||
# This subroutine is called by Text::TeX::process each time subroutine
|
# This subroutine is called by Text::TeX::process each time subroutine
|
||||||
@ -1046,14 +1066,7 @@ sub basic_lyx {
|
|||||||
my $height = '0pt';
|
my $height = '0pt';
|
||||||
$tok = $fileobject->eatOptionalArgument;
|
$tok = $fileobject->eatOptionalArgument;
|
||||||
if (defined($tok->print)) {
|
if (defined($tok->print)) {
|
||||||
$height = $tok->print;
|
$height = getAsLyXLength($tok->print);
|
||||||
# if something like '4.5\columnwidth', translate into
|
|
||||||
# LyXese.
|
|
||||||
if ($height =~ /([0-9.]*)\s*(\\[a-z]*)/) {
|
|
||||||
if (defined($lengthAsLyXString{$2})) {
|
|
||||||
$height = ($1 * 100) . $lengthAsLyXString{$2};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read the inner-pos optional argument, if it exists
|
# Read the inner-pos optional argument, if it exists
|
||||||
@ -1067,21 +1080,12 @@ sub basic_lyx {
|
|||||||
|
|
||||||
# Read the width as (a reference to) an array of tokens.
|
# Read the width as (a reference to) an array of tokens.
|
||||||
$tok = $fileobject->eatBalanced;
|
$tok = $fileobject->eatBalanced;
|
||||||
# $width is Something like either '4.5cm' or '\columnwidth'.
|
my $width = getAsLyXLength($tok->exact_print);
|
||||||
my $width = pop(@{$tok})->print;
|
|
||||||
# If $width is something like '\columnwidth', then manipulate
|
|
||||||
# it into LyX format and also extract the length itself.
|
|
||||||
if (defined($lengthAsLyXString{$width})) {
|
|
||||||
$width = $lengthAsLyXString{$width};
|
|
||||||
my $val = pop(@{$tok});
|
|
||||||
$val = (defined($val)) ? $val->print : '0';
|
|
||||||
$width = ($val * 100) . $width;
|
|
||||||
}
|
|
||||||
|
|
||||||
print OUTFILE "position $pos\n";
|
print OUTFILE "position $pos\n";
|
||||||
print OUTFILE "inner_position $innerpos\n";
|
print OUTFILE "inner_position $innerpos\n";
|
||||||
print OUTFILE "height $height\n";
|
print OUTFILE "height \"$height\"\n";
|
||||||
print OUTFILE "width $width\n";
|
print OUTFILE "width \"$width\"\n";
|
||||||
print OUTFILE "collapsed false\n";
|
print OUTFILE "collapsed false\n";
|
||||||
|
|
||||||
# \begin document
|
# \begin document
|
||||||
|
Loading…
Reference in New Issue
Block a user