Conditions | 8 |
Total Lines | 26 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | #!/usr/bin/env python3 |
||
12 | def spaces(elem: Element, doc: Doc) -> RawInline | None: |
||
13 | """ |
||
14 | Add LaTeX spaces when needed. |
||
15 | |||
16 | Arguments |
||
17 | --------- |
||
18 | elem |
||
19 | A tree element. |
||
20 | doc |
||
21 | The pandoc document. |
||
22 | |||
23 | Returns |
||
24 | ------- |
||
25 | RawInline | None |
||
26 | A RawInLine or None. |
||
27 | """ |
||
28 | # Is it in the right format and is it a Space? |
||
29 | if doc.format in ("latex", "beamer") and isinstance(elem, Space): |
||
30 | if isinstance(elem.prev, Str) and elem.prev.text[-1] in ("«", "“", "‹"): |
||
31 | return RawInline("\\thinspace{}", "tex") |
||
32 | if isinstance(elem.next, Str): |
||
33 | if elem.next.text[0] == ":": |
||
34 | return RawInline("~", "tex") |
||
35 | if elem.next.text[0] in (";", "?", "!", "»", "”", "›"): |
||
36 | return RawInline("\\thinspace{}", "tex") |
||
37 | return None |
||
38 | |||
59 |