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

Skip to content
Snippets Groups Projects
Commit 40fc4650 authored by str4d's avatar str4d
Browse files

Re-enabled ctags with path discovery

parent 6bf8d82b
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
import os
import sys import sys
from jinja2 import nodes from jinja2 import nodes
from jinja2.ext import Extension, Markup from jinja2.ext import Extension, Markup
...@@ -19,6 +20,19 @@ from flask import g ...@@ -19,6 +20,19 @@ from flask import g
from i2p2www.formatters import I2PHtmlFormatter from i2p2www.formatters import I2PHtmlFormatter
from i2p2www.lexers import DataSpecLexer from i2p2www.lexers import DataSpecLexer
# https://stackoverflow.com/questions/2632199/how-do-i-get-the-path-of-the-current-executed-file-in-python?lq=1
def we_are_frozen():
# All of the modules are built-in to the interpreter, e.g., by py2exe
return hasattr(sys, "frozen")
def module_path():
encoding = sys.getfilesystemencoding()
if we_are_frozen():
return os.path.dirname(unicode(sys.executable, encoding))
return os.path.dirname(unicode(__file__, encoding))
class HighlightExtension(Extension): class HighlightExtension(Extension):
"""Highlight code blocks using Pygments """Highlight code blocks using Pygments
...@@ -84,16 +98,15 @@ class HighlightExtension(Extension): ...@@ -84,16 +98,15 @@ class HighlightExtension(Extension):
print(e) print(e)
sys.exit(1) sys.exit(1)
# TODO: Fix working directory issue if ctags:
#if ctags: if 'tagsfile' not in parameters:
# if 'tagsfile' not in parameters: parameters['tagsfile'] = module_path() + '/pages/site/spectags'
# parameters['tagsfile'] = 'i2p2www/pages/site/spectags'
# if 'tagurlformat' not in parameters: if 'tagurlformat' not in parameters:
# lang = 'en' lang = 'en'
# if hasattr(g, 'lang') and g.lang: if hasattr(g, 'lang') and g.lang:
# lang = g.lang lang = g.lang
# parameters['tagurlformat'] = '/' + lang + '/%(path)s%(fname)s' parameters['tagurlformat'] = '/' + lang + '/%(path)s%(fname)s'
formatter = I2PHtmlFormatter(**parameters) formatter = I2PHtmlFormatter(**parameters)
code = highlight(Markup(body).unescape(), lexer, formatter) code = highlight(Markup(body).unescape(), lexer, formatter)
......
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