diff options
-rw-r--r-- | pygments/formatters/html.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index 2a5454b2..6b308d59 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -356,6 +356,9 @@ class HtmlFormatter(Formatter): 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: @@ -653,9 +656,14 @@ class HtmlFormatter(Formatter): # for <span style=""> lookup only getcls = self.ttype2class.get c2s = self.class2style - tagsfile = self.tagsfile escape_table = _escape_html_table + tagsfile = self.tagsfile + singlepage = self.singlepage + if not singlepage: + tagurlprefix = self.tagurlprefix + linkfext = self.linkfext + lspan = '' line = '' for ttype, value in tokensource: @@ -674,7 +682,10 @@ class HtmlFormatter(Formatter): 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 |