Commits

Pepijn de Vos committed 6629a12

multifile support

Example usage:

#!/bin/bash

for f in $@
do
mkdir -p `dirname "output/$f.html"`
./pygmentize -f html -O anchorlinenos,linenos,full,tagurlprefix=`pwd`/,singlepage=False,lineanchors=L,tagsfile=tags -o "output/$f.html" "$f"
done

Comments (0)

Files changed (1)

pygments/formatters/html.py

         self.cssfile = self._decodeifneeded(options.get('cssfile', ''))
         self.noclobber_cssfile = get_bool_opt(options, 'noclobber_cssfile', False)
         self.tagsfile = self._decodeifneeded(options.get('tagsfile', ''))
+        self.tagurlprefix = self._decodeifneeded(options.get('tagurlprefix', ''))
+        self.linkfext = self._decodeifneeded(options.get('linkfext', '.html'))
+        self.singlepage = get_bool_opt(options, 'singlepage', True)
 
         if self.tagsfile:
             try:
         # for <span style=""> lookup only
         getcls = self.ttype2class.get
         c2s = self.class2style
+        escape_table = _escape_html_table
+
         tagsfile = self.tagsfile
-        escape_table = _escape_html_table
+        singlepage = self.singlepage
+        if not singlepage:
+            tagurlprefix = self.tagurlprefix
+            linkfext = self.linkfext
 
         lspan = ''
         line = ''
             if tagsfile and ttype in Token.Name:
                 filename, lineNumber = self._lookup_ctag(value)
                 if filename:
-                    parts[0] = "<a href=\"#%s-%s\">%s" % (self.lineanchors, lineNumber, parts[0])
+                    if singlepage:
+                        parts[0] = "<a href=\"#%s-%s\">%s" % (self.lineanchors, lineNumber, parts[0])
+                    else:
+                        parts[0] = "<a href=\"%s%s%s#%s-%s\">%s" % (tagurlprefix, filename, linkfext, self.lineanchors, lineNumber, parts[0])
                     parts[-1] = "%s</a>" % parts[-1]
 
             # for all but the last line