| 1 |
|
| 2 |
|
| 3 |
e |
| 4 |
|
| 5 |
, |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
""" |
| 16 |
Miscellaneous XeTeX/LuaTeX writer tests. |
| 17 |
""" |
| 18 |
|
| 19 |
from pathlib import Path |
| 20 |
import sys |
| 21 |
import unittest |
| 22 |
|
| 23 |
|
| 24 |
if __name__ == '__main__': |
| 25 |
|
| 26 |
|
| 27 |
sys.path.insert(0, str(Path(__file__).resolve().parents[2])) |
| 28 |
|
| 29 |
from docutils import core |
| 30 |
from docutils.writers import xetex |
| 31 |
|
| 32 |
|
| 33 |
TEST_ROOT = Path(__file__).parents[1] |
| 34 |
DATA_ROOT = TEST_ROOT / 'data' |
| 35 |
|
| 36 |
px_sample = """\ |
| 37 |
.. image:: foo.pdf |
| 38 |
:width: 250 px |
| 39 |
:height: 50pt |
| 40 |
""" |
| 41 |
|
| 42 |
px_body = r""" |
| 43 |
\includegraphics[height=50bp,width=250\pdfpxdimen]{foo.pdf} |
| 44 |
""" |
| 45 |
|
| 46 |
px_fallback = r""" |
| 47 |
% Provide a length variable and set default, if it is new |
| 48 |
\providecommand*{\DUprovidelength}[2]{% |
| 49 |
\ifdefined#1 |
| 50 |
\else |
| 51 |
\newlength{#1}\setlength{#1}{#2}% |
| 52 |
\fi |
| 53 |
} |
| 54 |
|
| 55 |
\DUprovidelength{\pdfpxdimen}{1bp} |
| 56 |
""" |
| 57 |
|
| 58 |
|
| 59 |
class PublishTestCase(unittest.TestCase): |
| 60 |
maxDiff = None |
| 61 |
|
| 62 |
settings = {'_disable_config': True, |
| 63 |
|
| 64 |
'use_latex_citations': False, |
| 65 |
'legacy_column_widths': False, |
| 66 |
} |
| 67 |
|
| 68 |
def test_px_workaround(self): |
| 69 |
"""Check the workaround for length unit 'px' missing in XeTeX. |
| 70 |
""" |
| 71 |
parts = core.publish_parts(px_sample, |
| 72 |
writer=xetex.Writer(), |
| 73 |
settings_overrides=self.settings) |
| 74 |
self.assertEqual(px_body, parts['body']) |
| 75 |
self.assertEqual(px_fallback, parts['fallbacks']) |
| 76 |
|
| 77 |
|
| 78 |
if __name__ == '__main__': |
| 79 |
unittest.main() |