-
Notifications
You must be signed in to change notification settings - Fork 12
/
xspace.py
40 lines (26 loc) · 967 Bytes
/
xspace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#
# YaLafi module for LaTeX package xspace
#
from yalafi import defs
from yalafi.defs import Macro, InitModule
require_packages = []
def init_module(parser, options, position):
parms = parser.parms
macros_latex = ""
macros_python = [
Macro(parms, '\\xspace', args='', repl=h_xspace),
]
environments = []
return InitModule(macros_latex=macros_latex, macros_python=macros_python,
environments=environments)
# see http://mirrors.ctan.org/macros/latex/required/tools/xspace.dtx
# line 243: \def\@xspace@exceptions@tlp{%
#
xspace_excl = ['.', ',', "'", "''", '/', '?', ';', ':', '!', '~',
'-', '--', '---', ')', '{', '}',
'\\footnote', '\\footnotemark']
def h_xspace(parser, buf, mac, args, delim, pos):
tok = buf.cur()
if tok and tok.txt not in xspace_excl:
return [defs.SpaceToken(pos, ' ')]
return []