I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 9e543cbd authored by str4d's avatar str4d
Browse files

Added support for links to structure specs in dataspec blocks

The HtmlFormatter class from Pygments was duplicated and modified,
instead of patching upstream.
parent 8dd96c81
No related branches found
No related tags found
No related merge requests found
......@@ -4,5 +4,6 @@ Flask-Babel==0.9
Flask-Cache==0.12
Jinja2==2.7.2
Pygments==1.6
python-ctags
docutils==0.11
gunicorn==0.17.2
......@@ -9,6 +9,14 @@ from pygments.lexers import get_lexer_by_name, guess_lexer
from pygments.formatters import HtmlFormatter
from pygments.util import ClassNotFound
try:
import ctags
except ImportError:
ctags = None
from flask import g
from i2p2www.formatters import I2PHtmlFormatter
from i2p2www.lexers import DataSpecLexer
class HighlightExtension(Extension):
......@@ -76,7 +84,16 @@ class HighlightExtension(Extension):
print(e)
sys.exit(1)
formatter = HtmlFormatter(**parameters)
if ctags:
if 'tagsfile' not in parameters:
parameters['tagsfile'] = 'i2p2www/pages/site/spectags'
if 'tagurlformat' not in parameters:
lang = 'en'
if hasattr(g, 'lang') and g.lang:
lang = g.lang
parameters['tagurlformat'] = '/' + lang + '/%(path)s%(fname)s'
formatter = I2PHtmlFormatter(**parameters)
code = highlight(Markup(body).unescape(), lexer, formatter)
return code
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment