latex writer considers unitless dimensions as px based

This commit is contained in:
Takeshi KOMIYA 2016-06-26 13:56:19 +09:00
parent fe3f2a4a3f
commit cd093fb0ca
3 changed files with 5 additions and 5 deletions

View File

@ -15,6 +15,8 @@ Incompatible changes
sphinxVerbatimintable which handles captions and wraps lines(ref #2704).
* latex, replace ``pt`` by TeX equivalent ``bp`` if found in ``width`` or
``height`` attribute of an image.
* latex, if ``width`` or ``height`` attribute of an image is given with no unit,
use ``px`` rather than ignore it.
Features added

View File

@ -283,12 +283,10 @@ def rstdim_to_latexdim(width_str):
res = width_str
amount, unit = match.groups()[:2]
float(amount) # validate amount is float
if not unit:
return None
if unit in ('', "px"):
res = "%s\\sphinxpxdimen" % amount
elif unit == 'pt':
res = '%sbp' % amount # convert to 'bp'
elif unit == "px":
res = "%s\\sphinxpxdimen" % amount
elif unit == "%":
res = "%.3f\\linewidth" % (float(amount) / 100.0)
return res

View File

@ -25,7 +25,7 @@ def test_rstdim_to_latexdim():
assert rstdim_to_latexdim('160pt') == '160bp'
assert rstdim_to_latexdim('160pc') == '160pc'
assert rstdim_to_latexdim('30%') == '0.300\\linewidth'
assert rstdim_to_latexdim('160') is None
assert rstdim_to_latexdim('160') == '160\\sphinxpxdimen'
# flaot values
assert rstdim_to_latexdim('160.0em') == '160.0em'