# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1236169551 -3600 # Node ID be21d3d31ecfe513e0f4e0eb2c28ef5f16228771 # Parent 9a8db0c599717913f0a842401e3fcf3660801107# Parent 9495a0594b95a29beff0040ea2bd5a59cb6a7500 merge diff -r 9a8db0c59971 -r be21d3d31ecf common/rest.py --- a/common/rest.py Tue Mar 03 18:44:19 2009 +0100 +++ b/common/rest.py Wed Mar 04 13:25:51 2009 +0100 @@ -1,9 +1,19 @@ """rest publishing functions -contains some functions and setup of docutils for cubicweb +contains some functions and setup of docutils for cubicweb. Provides the +following ReST directives: + +* `eid`, create link to entity in the repository by their eid + +* `card`, create link to card entity in the repository by their wikiid + (proposing to create it when the refered card doesn't exist yet) + +* `winclude`, reference to a web documentation file (in wdoc/ directories) + +* `sourcecode` (if pygments is installed), source code colorization :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -156,6 +166,36 @@ 'encoding': directives.encoding} directives.register_directive('winclude', winclude_directive) +try: + from pygments import highlight + from pygments.lexers import get_lexer_by_name, LEXERS + from pygments.formatters import HtmlFormatter +except ImportError: + pass +else: + _PYGMENTS_FORMATTER = HtmlFormatter() + + def pygments_directive(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + try: + lexer = get_lexer_by_name(arguments[0]) + except ValueError: + import traceback + traceback.print_exc() + print sorted(aliases for module_name, name, aliases, _, _ in LEXERS.itervalues()) + # no lexer found + lexer = get_lexer_by_name('text') + print 'LEXER', lexer + parsed = highlight(u'\n'.join(content), lexer, _PYGMENTS_FORMATTER) + context = state.document.settings.context + context.req.add_css('pygments.css') + return [nodes.raw('', parsed, format='html')] + + pygments_directive.arguments = (1, 0, 1) + pygments_directive.content = 1 + directives.register_directive('sourcecode', pygments_directive) + + class CubicWebReSTParser(Parser): """The (customized) reStructuredText parser.""" diff -r 9a8db0c59971 -r be21d3d31ecf i18n/es.po --- a/i18n/es.po Tue Mar 03 18:44:19 2009 +0100 +++ b/i18n/es.po Wed Mar 04 13:25:51 2009 +0100 @@ -76,8 +76,8 @@ msgstr "%d semanas" #, python-format -msgid "%d years" -msgstr "%d años" +msgid "%d years" +msgstr "%d años" #, python-format msgid "%d days"