Пример #1
0
 def read(self, f):
     tokenizer = TexTokenizer(f)
     while 1:
         t = tokenizer.get()
         #      print repr(t)
         if not t: break
         self.feed(t)
     self.close()
     return
Пример #2
0
 def read(self, f):
     tokenizer = TexTokenizer(f)
     while 1:
         t = tokenizer.get()
         #      print repr(t)
         if not t:
             break
         self.feed(t)
     self.close()
     return
Пример #3
0
        return


# main
if __name__ == "__main__":

    def usage():
        print "usage: latex2html.py [file.tex ...]"
        sys.exit(2)

    try:
        (opts, args) = getopt.getopt(sys.argv[1:], "")
    except getopt.GetoptError:
        usage()

    for n in (args or ["-"]):
        if n == "-":
            f = sys.stdin
        else:
            f = file(n)
        tokenizer = TexTokenizer(f)
        parser = ConvHTMLParser()
        print "<html>"
        while 1:
            t = tokenizer.get()
            if not t: break
            parser.feed(t)
        parser.close()
        print "</html>"
        f.close()
Пример #4
0
    sys.exit(2)
  try:
    (opts, args) = getopt.getopt(sys.argv[1:], "w")
  except getopt.GetoptError:
    usage()

  wc = 0
  for (k, v) in opts:
    if k == "-w":
      wc = 1

  for n in (args or ["-"]):
    if n == "-":
      f = sys.stdin
    else:
      f = file(n)
    tokenizer = TexTokenizer(f)
    if wc:
      parser = DeTeXParser(None)
    else:
      parser = DeTeXParser()
    while 1:
      t = tokenizer.get()
      if not t: break
      parser.feed(t)
    parser.close()
    f.close()
    if wc:
      print "%s: words %d, lines %d" % \
            (n, parser.words, parser.lines)