self.description += s
else:
self.write(s)
+ if 'lstlisting' in self.ee():
+ self.listing += s
def docmd(self, c):
if self.state == 'math':
self.state = None
self.write('\n\n')
else:
- if c.cmd == '[':
- meth = self.cmd_gomath
+ if c.cmd == '\n':
+ self.write('\\\n')
else:
- cname = "cmd_" + c.cmd
- meth = getattr(self, cname, self.unrecognized_cmd)
- meth(c)
+ if c.cmd == '[':
+ meth = self.cmd_gomath
+ else:
+ cname = "cmd_" + c.cmd
+ meth = getattr(self, cname, self.unrecognized_cmd)
+ meth(c)
def cmd_gomath(self, c):
self.state = 'math'
return
s = str(c.params[0]).replace('\\_', '_')
s = s.replace('\\par', '')
+ s = s.replace('\n', ' ')
s = s.replace(';', '')
self.indent = 0
for proto in s.split('\\newline'):
elif s == 'lstlisting':
print >>self, "\n::\n"
self.indent += 1
+ print >>self
+ self.listing = ""
elif s in ['itemize', 'enumerate']:
self.indent += 1
elif s == 'tabular':
self.indent -= 1
print >>self
print >>self, ".." # otherwise a following :param: gets treated as more listing
+ if '\\_' in self.listing:
+ self.report_error(c, "backslash _ in listing")
elif s == 'document':
pass
else:
def cmd_genc(self, c): pass
def cmd_genpy(self, c): pass
def cmd_author(self, c): pass
- def cmd_cite(self, c): pass
def cmd_date(self, c): pass
def cmd_def(self, c): pass
def cmd_documentclass(self, c): pass
def cmd_hline(self, c):
print >>self, "\\hline"
+ def cmd_cite(self, c):
+ self.write("[%s]_" % str(c.params[0]))
+
def cmd_href(self, c):
if len(c.params) == 2:
self.write("`%s <%s>`_" % (str(c.params[1]), str(c.params[0])))
self.write(repr(c))
def unrecognized_cmd(self, c):
- if self.f == self.f_section:
- self.write(repr(c))
- self.unhandled_commands.add(c.cmd)
+ if not self.f in [self.f_index, self.f_chapter]:
+ self.write(c.cmd)
+ self.unhandled_commands.add(c.cmd)
def doL(self, L, newlines = True):
for x in L:
+ pos0 = self.f.tell()
if isinstance(x, TexCmd):
self.docmd(x)
else:
self.doplain(x)
else:
self.doplain(x.lstrip())
- if self.state in ['math'] or not newlines:
- self.appendspace()
- else:
- self.write('\n')
+ pos1 = self.f.tell()
+ if pos0 != pos1:
+ if self.state in ['math'] or not newlines:
+ self.appendspace()
+ else:
+ if not 'lstlisting' in self.ee():
+ self.write('\n')
def handle_table(self, s):
oneline = s.replace('\n', ' ').strip()
if distutils.dep_util.newer_group(["latexparser.py"] + sources, "pickled"):
fulldoc = latexparser(sys.argv[1], 0)
pickle.dump(fulldoc, open("pickled", 'wb'))
- raw = open('fulldoc', 'w')
+ raw = open('raw.full', 'w')
for x in fulldoc:
print >>raw, repr(x)
raw.close()