doconce
doconce copied to clipboard
newcommand gamma weirdness
Using the newcommands_keep.tex
feature to define the command
\newcommand{\gammar}{\gamma{}}
gives a strange error when using the following.
doconce format ipynb index --no_abort
It returns the following.
running preprocess -DFORMAT=ipynb -DDEVICE=screen index.do.txt > tmp_preprocess__index.do.txt
translating doconce text in tmp_preprocess__index.do.txt to ipynb
Traceback (most recent call last):
File "/usr/local/bin/doconce", line 1721, in <module>
bg_session = main()
File "/usr/local/bin/doconce", line 1710, in main
retval = eval(command + '()')
File "<string>", line 1, in <module>
File "/usr/local/bin/doconce", line 103, in format
bg_session = doconce.doconce.format_driver()
File "/usr/local/lib/python2.7/site-packages/doconce/doconce.py", line 5470, in format_driver
out_filename, bg_session = file2file(filename_preprocessed, format, basename)
File "/usr/local/lib/python2.7/site-packages/doconce/doconce.py", line 4285, in file2file
filestr, bg_session = doconce2format(filestr, format)
File "/usr/local/lib/python2.7/site-packages/doconce/doconce.py", line 4589, in doconce2format
filestr = expand_newcommands(newcommand_files, filestr) # inline math
File "/usr/local/lib/python2.7/site-packages/doconce/expand_newcommands.py", line 126, in expand_newcommands
return substitute(source, newcommands)
File "/usr/local/lib/python2.7/site-packages/doconce/expand_newcommands.py", line 96, in substitute
text, n = re.subn(pattern, replacement, text)
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 166, in subn
return _compile(pattern, flags).subn(repl, string, count)
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 286, in _subx
template = _compile_repl(template, pattern)
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 273, in _compile_repl
raise error, v # invalid expression
sre_constants.error: missing group name
It only seems to have this problem when using \gamma
in a \newcommand
. I've tried placing it in extra braces {}
, but it doesn't help. Again, all other Greek symbols seem to be fine.
I think it's a bug.
Thanks, will look into it. It seems to affect expressions starting with g
. Need to investigate further.
Interesting. I hadn't tried others starting with g
. I'll let you know if I discover anything of relevance.
I'm not so familiar with regex's but perhaps the \g
in
replacement = replacement.replace('#%d' % i, r'\g<%d>' % i)
(from line 48 of lib/doconce/expand_newcommands.py
) could be related.
For a quick fix consider the embedding of newcommands in ipynb that I have pushed ipynb changes