Pepijn de Vos committed 6629a12

multifile support

Example usage:


for f in $@
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"

Comments (0)

Files changed (1)


         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:
         # 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.