Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newcommand gamma weirdness #130

Open
ricopicone opened this issue Sep 12, 2017 · 3 comments
Open

newcommand gamma weirdness #130

ricopicone opened this issue Sep 12, 2017 · 3 comments

Comments

@ricopicone
Copy link

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.

@KGHustad
Copy link
Collaborator

Thanks, will look into it. It seems to affect expressions starting with g. Need to investigate further.

@ricopicone
Copy link
Author

Interesting. I hadn't tried others starting with g. I'll let you know if I discover anything of relevance.

@utsekaj42
Copy link

utsekaj42 commented Nov 14, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants