hplgit / doconce

Lightweight markup language - document once, include anywhere
http://hplgit.github.io/doconce/doc/web/index.html
Other
311 stars 60 forks source link

re problem with Python 3.6 #153

Closed mikaem closed 6 years ago

mikaem commented 6 years ago

Hi

I just installed doconce from conda-forge with Python 3.6 and I get this error on any attempt to create an html. A reproducible test is to run test/test_mintest.py, which results in the error message shown below. Some debugging and this comes down to

line 3384, in doconce_split_html
  m = re.search(r'\label\{(.+?)\}', line)

It seems that re no longer supports this regular expression 'r'\label{(.+?)}'. Not sure why, but I think the solution is to use the regex module instead of re. The regex module is backwards compatible with re. It fixes the problem for me, but

translating doconce text in _ref_mintest_bluegray.do.txt to html
figure file ../doc/src/manual/fig/wave1D:
    can use ../doc/src/manual/fig/wave1D.png for format html
output in _ref_mintest_bluegray.html
Traceback (most recent call last):
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/bin/doconce", line 4, in <module>
    __import__('pkg_resources').run_script('DocOnce==1.4.5', 'doconce')
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/site-packages/pkg_resources/__init__.py", line 739, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1494, in run_script
    exec(code, namespace, namespace)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/site-packages/DocOnce-1.4.5-py3.6.egg-info/scripts/doconce", line 1723, in <module>
    bg_session = main()
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/site-packages/DocOnce-1.4.5-py3.6.egg-info/scripts/doconce", line 1712, in main
    retval = eval(command + '()')
  File "<string>", line 1, in <module>
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/site-packages/doconce/misc.py", line 2782, in split_html
    files = doconce_split_html(header, parts, footer, basename, filename)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/site-packages/doconce/misc.py", line 3384, in doconce_split_html
    m = re.search(r'\label\{(.+?)\}', line)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/re.py", line 182, in search
    return _compile(pattern, flags).search(string)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/sre_parse.py", line 856, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, False)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/sre_parse.py", line 415, in _parse_sub
    itemsappend(_parse(source, state, verbose))
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/sre_parse.py", line 501, in _parse
    code = _escape(source, this, state)
  File "/Users/mikaelmortensen/anaconda2/envs/shenfun/lib/python3.6/sre_parse.py", line 401, in _escape
    raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \l at position 0
Traceback (most recent call last):
  File "test_mintest.py", line 131, in <module>
    test_mintest_html()
  File "test_mintest.py", line 85, in test_mintest_html
    assert False, 'Could not run %s' % cmd
AssertionError: Could not run doconce split_html _ref_mintest_bluegray.html
KGHustad commented 6 years ago

Thank you for reporting this bug! It's now resolved in master. I will try to get an update out soon.