Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions jemdoc
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,9 @@ def br(b, f, tableblock=False):
for m in r.findall(b):
repl = os.environ.get(m)
if repl == None:
b = re.sub("!\$%s\$!" % m, 'FAILED_MATCH_' + m, b)
b = re.sub(r"!\$%s\$!" % m, 'FAILED_MATCH_' + m, b)
else:
b = re.sub("!\$%s\$!" % m, repl, b)
b = re.sub(r"!\$%s\$!" % m, repl, b)

# Deal with literal backspaces.
if f.eqs and f.eqsupport:
Expand Down Expand Up @@ -892,7 +892,7 @@ def gethl(lang):
d['special'] = ['cols', 'optvar', 'param', 'problem', 'norm2', 'norm1',
'value', 'minimize', 'maximize', 'rows', 'rand',
'randn', 'printval', 'matrix']
d['error'] = ['\w*Error',]
d['error'] = [r'\w*Error',]
d['commentuntilend'] = '#'
d['strings'] = True
elif lang in ['c', 'c++', 'cpp']:
Expand All @@ -901,7 +901,7 @@ def gethl(lang):
'clock_t', 'struct', 'long', 'extern', 'char']
d['operator'] = ['#include.*', '#define', '@pyval{', '}@', '@pyif{',
'@py{']
d['error'] = ['\w*Error',]
d['error'] = [r'\w*Error',]
d['commentuntilend'] = ['//', '/*', ' * ', '*/']
elif lang in ('rb', 'ruby'):
d['statement'] = putbsbs(['while', 'until', 'unless', 'if', 'elsif',
Expand All @@ -910,7 +910,7 @@ def gethl(lang):
d['operator'] = putbsbs(['and', 'not', 'or'])
d['builtin'] = putbsbs(['true', 'false', 'require', 'warn'])
d['special'] = putbsbs(['IO'])
d['error'] = putbsbs(['\w*Error',])
d['error'] = putbsbs([r'\w*Error',])
d['commentuntilend'] = '#'
d['strings'] = True
d['strings'] = True
Expand All @@ -928,13 +928,13 @@ def gethl(lang):
d['builtin'] = putbsbs(['gem', 'gcc', 'python', 'curl', 'wget', 'ssh',
'latex', 'find', 'sed', 'gs', 'grep', 'tee',
'gzip', 'killall', 'echo', 'touch',
'ifconfig', 'git', '(?<!\.)tar(?!\.)'])
'ifconfig', 'git', r'(?<!\.)tar(?!\.)'])
d['commentuntilend'] = '#'
d['strings'] = True
elif lang == 'matlab':
d['statement'] = putbsbs(['max', 'min', 'find', 'rand', 'cumsum', 'randn', 'help',
'error', 'if', 'end', 'for'])
d['operator'] = ['&gt;', 'ans =', '>>', '~', '\.\.\.']
d['operator'] = ['&gt;', 'ans =', '>>', '~', r'\.\.\.']
d['builtin'] = putbsbs(['csolve'])
d['commentuntilend'] = '%'
d['strings'] = True
Expand Down Expand Up @@ -1026,14 +1026,14 @@ def geneq(f, eq, dpi, wl, outname):
basefile = texfile[:-4]
g = os.fdopen(fd, 'wb')

preamble = '\documentclass{article}\n'
preamble = '\\documentclass{article}\n'
for p in f.eqpackages:
preamble += '\\usepackage{%s}\n' % p
for p in f.texlines:
# Replace \{ and \} in p with { and }.
# XXX hack.
preamble += re.sub(r'\\(?=[{}])', '', p + '\n')
preamble += '\pagestyle{empty}\n\\begin{document}\n'
preamble += '\\pagestyle{empty}\n\\begin{document}\n'
g.write(preamble)

# Write the equation itself.
Expand All @@ -1043,7 +1043,7 @@ def geneq(f, eq, dpi, wl, outname):
g.write('$%s$' % eq)

# Finish off the tex file.
g.write('\n\\newpage\n\end{document}')
g.write('\n\\newpage\n\\end{document}')
g.close()

exts = ['.tex', '.aux', '.dvi', '.log']
Expand Down Expand Up @@ -1193,7 +1193,7 @@ def codeblock(f, g):
out(f.outf, l)
elif g[1] == 'jemdoc':
# doing this more nicely needs python 2.5.
for x in ('#', '~', '>>>', '\~', '{'):
for x in ('#', '~', '>>>', r'\~', '{'):
if str(l).lstrip().startswith(x):
out(f.outf, '</tt><pre class="tthl">')
out(f.outf, l + '</pre><tt class="tthl">')
Expand Down Expand Up @@ -1418,13 +1418,13 @@ def procfile(f):
# Quickly pull out the equation here:
# Check we don't already have the terminating character in a whole-line
# equation without linebreaks, eg \( Ax=b \):
if not s.strip().endswith('\)'):
if not s.strip().endswith(r'\)'):
while True:
l = nl(f, codemode=True)
if not l:
break
s += l
if l.strip() == '\)':
if l.strip() == r'\)':
break
r = br(s.strip(), f)
r = mathjaxeqresub(r)
Expand Down