diff --git a/CHANGES.md b/CHANGES.md index ed3b11b3..9698fde3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ Changes in Markdown Preview =========================== +## 1.3.0 + +* Now supports any markdown parser through a generalized method. Now you can map a binary to parser name via `markdown_binary_map`. Then use the parser name in `enabled_parsers` to use it. +* Multimarkdown specific settings have been removed. Multimarkdown should now be configured via `markdown_binary_map` and `enabled_parsers`. +* Upgraded to Python Markdown 2.6.4. +* Removed internal PyYaml and Pygments. Markdown Preview now uses Package Control dependencies to obtain PyYaml and Pygments. +* Update kbd CSS for Github. ## 1.0.3 diff --git a/MarkdownPreview.py b/MarkdownPreview.py index 338cd010..51cc4b54 100644 --- a/MarkdownPreview.py +++ b/MarkdownPreview.py @@ -11,6 +11,12 @@ import time import codecs import cgi +import yaml + +pygments_local = { + 'github': 'pygments_css/github.css', + 'github2014': 'pygments_css/github2014.css' +} def is_ST3(): @@ -20,20 +26,14 @@ def is_ST3(): if is_ST3(): from . import desktop - from . import yaml from .markdown_settings import Settings from .markdown_wrapper import StMarkdown as Markdown - from .lib.markdown_preview_lib.pygments.formatters import get_formatter_by_name from .helper import INSTALLED_DIRECTORY from urllib.request import urlopen, url2pathname, pathname2url from urllib.parse import urlparse, urlunparse from urllib.error import HTTPError, URLError from urllib.parse import quote from .markdown.extensions import codehilite - try: - PYGMENTS_AVAILABLE = codehilite.pygments - except: - PYGMENTS_AVAILABLE = False def Request(url, data, headers): ''' Adapter for urllib2 used in ST2 ''' @@ -44,22 +44,22 @@ def Request(url, data, headers): else: import desktop - import yaml from markdown_settings import Settings from markdown_wrapper import StMarkdown as Markdown - from lib.markdown_preview_lib.pygments.formatters import get_formatter_by_name from helper import INSTALLED_DIRECTORY from urllib2 import Request, urlopen, HTTPError, URLError from urllib import quote, url2pathname, pathname2url from urlparse import urlparse, urlunparse import markdown.extensions.codehilite as codehilite - try: - PYGMENTS_AVAILABLE = codehilite.pygments - except: - PYGMENTS_AVAILABLE = False unicode_str = unicode +from pygments.formatters import get_formatter_by_name +try: + PYGMENTS_AVAILABLE = codehilite.pygments +except: + PYGMENTS_AVAILABLE = False + _CANNOT_CONVERT = u'cannot convert markdown' PATH_EXCLUDE = tuple( @@ -119,7 +119,7 @@ def load_resource(name): if is_ST3(): return sublime.load_resource('Packages/Markdown Preview/{0}'.format(name)) else: - filename = os.path.join(sublime.packages_path(), INSTALLED_DIRECTORY, name) + filename = os.path.join(sublime.packages_path(), INSTALLED_DIRECTORY, os.path.normpath(name)) return load_utf8(filename) except: print("Error while load_resource('%s')" % name) @@ -276,11 +276,14 @@ def repl_relative(m, base_path, relative_path): def repl_absolute(m, base_path): """ Replace path with absolute path """ link = m.group(0) - scheme, netloc, path, params, query, fragment, is_url, is_absolute = parse_url(m.group('path')[1:-1]) - path = url2pathname(path) + try: + scheme, netloc, path, params, query, fragment, is_url, is_absolute = parse_url(m.group('path')[1:-1]) + except Exception: + return link if (not is_absolute and not is_url): + path = url2pathname(path) temp = os.path.normpath(os.path.join(base_path, path)) if os.path.exists(temp): path = pathname2url(temp.replace("\\", "/")) @@ -925,18 +928,23 @@ def parser_specific_convert(self, markdown_text): return markdown_html -class MultiMarkdownCompiler(Compiler): +class ExternalMarkdownCompiler(Compiler): default_css = "markdown.css" + def __init__(self, parser): + """Initialize.""" + + self.parser = parser + super(ExternalMarkdownCompiler, self).__init__() + def parser_specific_convert(self, markdown_text): import subprocess - binary = self.settings.get("multimarkdown_binary", "") - if os.path.exists(binary): - cmd = [binary] - critic_mode = self.settings.get("strip_critic_marks", "accept") - if critic_mode in ("accept", "reject"): - cmd.append('-a' if critic_mode == "accept" else '-r') - sublime.status_message('converting markdown with multimarkdown...') + settings = sublime.load_settings("MarkdownPreview.sublime-settings") + binary = settings.get('markdown_binary_map', {})[self.parser] + + if len(binary) and os.path.exists(binary[0]): + cmd = binary + sublime.status_message('converting markdown with %s...' % self.parser) if sublime.platform() == "windows": startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW @@ -958,7 +966,7 @@ def parser_specific_convert(self, markdown_text): print(markdown_html) markdown_html = _CANNOT_CONVERT else: - sublime.error_message("Cannot find multimarkdown binary!") + sublime.error_message("Cannot find % binary!" % self.binary) markdown_html = _CANNOT_CONVERT return markdown_html @@ -966,14 +974,27 @@ def parser_specific_convert(self, markdown_text): class MarkdownCompiler(Compiler): default_css = "markdown.css" - def get_highlight(self): - ''' return the Pygments css if enabled ''' + def set_highlight(self, pygments_style, css_class): + ''' Set the Pygments css. ''' - highlight = '' - if self.pygments_style and not self.noclasses: - highlight += '' % get_formatter_by_name('html', style=self.pygments_style).get_style_defs('.codehilite pre') + if pygments_style and not self.noclasses: + style = None + if pygments_style not in pygments_local: + try: + style = get_formatter_by_name('html', style=pygments_style).get_style_defs('.codehilite pre') + except Exception: + pygments_style = 'github' + if style is None: + style = load_resource(pygments_local[pygments_style]) % { + 'css_class': ''.join(['.' + x for x in css_class.split(' ') if x]) + } - return highlight + self.pygments_style = '' % style + return pygments_style + + def get_highlight(self): + ''' return the Pygments css if enabled. ''' + return self.pygments_style if self.pygments_style else '' def preprocessor_critic(self, text): ''' Stip out multi-markdown critic marks. Accept changes by default ''' @@ -985,24 +1006,29 @@ def parser_specific_preprocess(self, text): return text def process_extensions(self, extensions): - re_pygments = re.compile(r"pygments_style\s*=\s*([a-zA-Z][a-zA-Z_\d]*)") + re_pygments = re.compile(r"(?:\s*,)?pygments_style\s*=\s*([a-zA-Z][a-zA-Z_\d]*)") + re_pygments_replace = re.compile(r"pygments_style\s*=\s*([a-zA-Z][a-zA-Z_\d]*)") re_use_pygments = re.compile(r"use_pygments\s*=\s*(True|False)") re_insert_pygment = re.compile(r"(?Pcodehilite\([^)]+?)(?P\s*\)$)|(?Pcodehilite)") - re_no_classes = re.compile(r"noclasses\s*=\s*(True|False)") + re_no_classes = re.compile(r"(?:\s*,)?noclasses\s*=\s*(True|False)") + re_css_class = re.compile(r"css_class\s*=\s*([\w\-]+)") # First search if pygments has manually been set, # and if so, read what the desired color scheme to use is self.pygments_style = None self.noclasses = False use_pygments = True + pygments_css = None count = 0 for e in extensions: if e.startswith("codehilite"): m = re_use_pygments.search(e) use_pygments = True if m is None else m.group(1) == 'True' + m = re_css_class.search(e) + css_class = m.group(1) if m else 'codehilite' pygments_style = re_pygments.search(e) if pygments_style is None: - self.pygments_style = "github" + pygments_css = "github" m = re_insert_pygment.match(e) if m is not None: if m.group('bracket_start'): @@ -1012,9 +1038,20 @@ def process_extensions(self, extensions): start = m.group('start') + "(pygments_style=" end = ')' - extensions[count] = start + self.pygments_style + end + extensions[count] = start + pygments_css + end else: - self.pygments_style = pygments_style.group(1) + pygments_css = pygments_style.group(1) + + # Set the style, but erase the setting if the CSS is pygments_local. + # Don't allow 'no_css' with non internal themes. + # Replace the setting with the correct name if the style was invalid. + original = pygments_css + pygments_css = self.set_highlight(pygments_css, css_class) + if pygments_css in pygments_local: + extensions[count] = re_no_classes.sub('', re_pygments.sub('', e)) + elif original != pygments_css: + extensions[count] = re_pygments_replace.sub('pygments_style=%s' % pygments_css, e) + noclasses = re_no_classes.search(e) if noclasses is not None and noclasses.group(1) == "True": self.noclasses = True @@ -1023,17 +1060,17 @@ def process_extensions(self, extensions): # Second, if nothing manual was set, see if "enable_highlight" is enabled with pygment support # If no style has been set, setup the default if ( - self.pygments_style is None and + pygments_css is None and self.settings.get("enable_highlight") is True ): + pygments_css = self.set_highlight('github', 'codehilite') guess_lang = str(bool(self.settings.get("guess_language", True))) use_pygments = bool(self.settings.get("enable_pygments", True)) extensions.append( - "codehilite(guess_lang=%s,pygments_style=github,use_pygments=%s)" % ( + "codehilite(guess_lang=%s,use_pygments=%s)" % ( guess_lang, str(use_pygments) ) ) - self.pygments_style = "github" if not use_pygments: self.pygments_style = None @@ -1067,15 +1104,20 @@ def parser_specific_convert(self, markdown_text): class MarkdownPreviewSelectCommand(sublime_plugin.TextCommand): def run(self, edit, target='browser'): + + settings = sublime.load_settings("MarkdownPreview.sublime-settings") + md_map = settings.get('markdown_binary_map', {}) parsers = [ "markdown", - "github", - "multimarkdown" + "github" ] + # Add external markdown binaries. + for k in md_map.keys(): + parsers.append(k) + self.target = target - settings = sublime.load_settings("MarkdownPreview.sublime-settings") enabled_parsers = set() for p in settings.get("enabled_parsers", ["markdown", "github"]): if p in parsers: @@ -1119,9 +1161,12 @@ def run(self, edit, parser='markdown', target='browser'): if parser == "github": compiler = GithubCompiler() - elif parser == "multimarkdown": - compiler = MultiMarkdownCompiler() + elif parser == 'markdown': + compiler = MarkdownCompiler() + elif parser in settings.get("enabled_parsers", ("markdown", "github")): + compiler = ExternalMarkdownCompiler(parser) else: + # Fallback to Python Markdown compiler = MarkdownCompiler() html, body = compiler.run(self.view, preview=(target in ['disk', 'browser'])) @@ -1259,8 +1304,10 @@ def run(self): if parser == "github": compiler = GithubCompiler() - elif parser == "multimarkdown": - compiler = MultiMarkdownCompiler() + elif parser == 'markdown': + compiler = MarkdownCompiler() + elif parser in settings.get("enabled_parsers", ("markdown", "github")): + compiler = ExternalMarkdownCompiler(parser) else: compiler = MarkdownCompiler() diff --git a/MarkdownPreview.sublime-settings b/MarkdownPreview.sublime-settings index 48cd2197..8527788b 100644 --- a/MarkdownPreview.sublime-settings +++ b/MarkdownPreview.sublime-settings @@ -113,6 +113,23 @@ */ "enabled_parsers": ["markdown", "github"], + /* + Custom external markdown parsers. + + "markdown_binary_map" contains key values pairs. The key + is name of the parser and what is used in "enabled_parsers" + to turn on the access to the parser. The value is an array + containing the path to the binary and all the parameters that + are desired. + + Multimarkdown is provided as an example below. It's path may differ + on your system. + */ + + "markdown_binary_map": { + "multimarkdown": ["/usr/local/bin/multimarkdown"] + }, + /* Default mode for the github Markdown parser : markdown (documents) or gfm (comments) see http://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document @@ -195,11 +212,6 @@ */ // "path_tempfile": "/tmp/my_notes", - /* - Absolute path to multimarkdown executable - */ - "multimarkdown_binary": "", - /* Sets HTML output to a simple form: - No head @@ -237,6 +249,8 @@ accept: Accepts the proposed inserts and deletions (comments etc. are discarded) reject: Rejects the proposed inserts and deletions (comments etc. are discarded) none: does nothing + + Critic marks only affects "github" and "markdown" (Python Markdown). */ "strip_critic_marks": "none", diff --git a/README.md b/README.md index fc3fa8d7..44da537e 100644 --- a/README.md +++ b/README.md @@ -22,20 +22,20 @@ You can use builtin [python-markdown][10] parser or use the [github markdown API - MathJax support : \\\\(\frac{\pi}{2}\\\\) thanks to @bps10 - HTML template customisation thanks to @hozaka - Embed images as base64 (see [settings][settings] file for more info) - - Strip out multimarkdown critic marks (see [settings][settings] file for more info) + - Strip out multimarkdown critic marks from either Githubs or Python Markdown input source (see [settings][settings] file for more info) - 3rd party extensions for the Python Markdown parser: | Extension | Documentation | |-----------|---------------| - | magiclink | Find and convert HTML links and email address to links ([MagicLink Documentation](http://facelessuser.github.io/PyMdown/extensions/magiclink/)). | - | delete | Surround inline text with `~~crossed out~~` to get del tags ~~crossed out~~. | + | magiclink | Find and convert HTML links and email address to links ([MagicLink Documentation](http://facelessuser.github.io/pymdown-extensions/extensions/magiclink/)). | + | delete | Surround inline text with `~~strike through~~` to get del tags ~~strike through~~. | | insert | Surround inline text with `^^underlined^^` to get ins tags underlined. | - | tasklist | Github Flavored Markdown tasklists ([Tasklist Documentation](http://facelessuser.github.io/PyMdown/extensions/tasklist/)). | - | githubemoji | Support for Github Flavored Markdown emojis ([GithubEmoji Documentation](http://facelessuser.github.io/PyMdown/extensions/githubemoji/)). | - | headeranchor | Github Flavored Markdown style header anchors ([HeaderAnchor Documentation](http://facelessuser.github.io/PyMdown/extensions/headeranchor/)). | + | tasklist | Github Flavored Markdown tasklists ([Tasklist Documentation](http://facelessuser.github.io/pymdown-extensions/extensions/tasklist/)). | + | githubemoji | Support for Github Flavored Markdown emojis ([GithubEmoji Documentation](http://facelessuser.github.io/pymdown-extensions/extensions/githubemoji/)). | + | headeranchor | Github Flavored Markdown style header anchors ([HeaderAnchor Documentation](http://facelessuser.github.io/pymdown-extensions/extensions/headeranchor/)). | | github | A convenience extension to add: `magiclink`, `delete`, `tasklist`, `githubemoji`, `headeranchor`, `superfences`, and `nl2br` to parse and display Markdown in a github-ish way. It is recommed to pair `github` with `extra` and `codehilite` (with language guessing off) to parse close to github's way. Be aware of what extensions `github` loads, because you should not load extensions more than once. | - | progressbar | Create progress bars ([ProgressBar Documentation](http://facelessuser.github.io/PyMdown/extensions/progressbar/)). | - | superfences | Allow fenced blocks to be nested under lists, blockquotes, etc. and add special UML diagram blocks ([SuperFences Documentation](http://facelessuser.github.io/PyMdown/extensions/superfences/)). | + | progressbar | Create progress bars ([ProgressBar Documentation](http://facelessuser.github.io/pymdown-extensions/extensions/progressbar/)). | + | superfences | Allow fenced blocks to be nested under lists, blockquotes, etc. and add special UML diagram blocks ([SuperFences Documentation](http://facelessuser.github.io/pymdown-extensions/extensions/superfences/)). | ## Installation : @@ -44,7 +44,7 @@ You can use builtin [python-markdown][10] parser or use the [github markdown API For all Sublime Text 2/3 users we recommend install via [Package Control][3]. 1. [Install][11] Package Control if you haven't yet. -2. Use `cmd+shift+P` then `Package Control: Install Package` +2. Use cmd+shift+P then `Package Control: Install Package` 3. Look for `Markdown Preview` and install it. ### Manual Install @@ -59,7 +59,7 @@ For all Sublime Text 2/3 users we recommend install via [Package Control][3]. ### To preview : - optionally select some of your markdown for conversion - - use `cmd+shift+P` then `Markdown Preview` to show the follow commands (you will be prompted to select which parser you prefer): + - use cmd+shift+P then `Markdown Preview` to show the follow commands (you will be prompted to select which parser you prefer): - Markdown Preview: Preview in Browser - Markdown Preview: Export HTML in Sublime Text - Markdown Preview: Copy to Clipboard @@ -68,9 +68,25 @@ For all Sublime Text 2/3 users we recommend install via [Package Control][3]. `{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} },` for a specific parser and target or `{ "keys": ["alt+m"], "command": "markdown_preview_select", "args": {"target": "browser"} },` to bring up the quick panel to select enabled parsers for a given target. - once converted a first time, the output HTML will be updated on each file save (with LiveReload plugin) +### Enabling Other External Markdown Parsers : + +External parser commands and arguments should first be mapped to a name. The path to the binary should be first, followed by flags etc. + +```js + "markdown_binary_map": { + "multimarkdown": ["/usr/local/bin/multimarkdown"] + }, +``` + +Then the name can be placed in `enabled_parsers` to enable use of the new parser. + +```js + "enabled_parsers": ["markdown", "github", "multimarkdown"], +``` + ### To build : - - Just use `Ctrl+B` (Windows/Linux) or `cmd+B` (Mac) to build current file. + - Just use ctrl+B (Windows/Linux) or cmd+B (Mac) to build current file. ### To config : diff --git a/dependencies.json b/dependencies.json new file mode 100644 index 00000000..ef31286f --- /dev/null +++ b/dependencies.json @@ -0,0 +1,8 @@ +{ + "*": { + "*": [ + "pygments", + "pyyaml" + ] + } +} diff --git a/lib/markdown_preview_lib/__init__.py b/lib/markdown_preview_lib/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/markdown_preview_lib/pygments/LICENSE b/lib/markdown_preview_lib/pygments/LICENSE deleted file mode 100755 index 641c8e8e..00000000 --- a/lib/markdown_preview_lib/pygments/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2006-2014 by the respective authors (see AUTHORS file). -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/markdown_preview_lib/pygments/__init__.py b/lib/markdown_preview_lib/pygments/__init__.py deleted file mode 100755 index be6db19f..00000000 --- a/lib/markdown_preview_lib/pygments/__init__.py +++ /dev/null @@ -1,91 +0,0 @@ -# -*- coding: utf-8 -*- -""" - Pygments - ~~~~~~~~ - - Pygments is a syntax highlighting package written in Python. - - It is a generic syntax highlighter for general use in all kinds of software - such as forum systems, wikis or other applications that need to prettify - source code. Highlights are: - - * a wide range of common languages and markup formats is supported - * special attention is paid to details, increasing quality by a fair amount - * support for new languages and formats are added easily - * a number of output formats, presently HTML, LaTeX, RTF, SVG, all image - formats that PIL supports, and ANSI sequences - * it is usable as a command-line tool and as a library - * ... and it highlights even Brainfuck! - - The `Pygments tip`_ is installable with ``easy_install Pygments==dev``. - - .. _Pygments tip: - http://bitbucket.org/birkenfeld/pygments-main/get/tip.zip#egg=Pygments-dev - - :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" -from __future__ import absolute_import - -__version__ = '2.0.1' -__docformat__ = 'restructuredtext' - -__all__ = ['lex', 'format', 'highlight'] - - -import sys -from .util import StringIO, BytesIO - - -def lex(code, lexer): - """ - Lex ``code`` with ``lexer`` and return an iterable of tokens. - """ - try: - return lexer.get_tokens(code) - except TypeError as err: - if isinstance(err.args[0], str) and \ - 'unbound method get_tokens' in err.args[0]: - raise TypeError('lex() argument must be a lexer instance, ' - 'not a class') - raise - - -def format(tokens, formatter, outfile=None): - """ - Format a tokenlist ``tokens`` with the formatter ``formatter``. - - If ``outfile`` is given and a valid file object (an object - with a ``write`` method), the result will be written to it, otherwise - it is returned as a string. - """ - try: - if not outfile: - #print formatter, 'using', formatter.encoding - realoutfile = formatter.encoding and BytesIO() or StringIO() - formatter.format(tokens, realoutfile) - return realoutfile.getvalue() - else: - formatter.format(tokens, outfile) - except TypeError as err: - if isinstance(err.args[0], str) and \ - 'unbound method format' in err.args[0]: - raise TypeError('format() argument must be a formatter instance, ' - 'not a class') - raise - - -def highlight(code, lexer, formatter, outfile=None): - """ - Lex ``code`` with ``lexer`` and format it with the formatter ``formatter``. - - If ``outfile`` is given and a valid file object (an object - with a ``write`` method), the result will be written to it, otherwise - it is returned as a string. - """ - return format(lex(code, lexer), formatter, outfile) - - -if __name__ == '__main__': - from .cmdline import main - sys.exit(main(sys.argv)) diff --git a/lib/markdown_preview_lib/pygments/cmdline.py b/lib/markdown_preview_lib/pygments/cmdline.py deleted file mode 100755 index d265e4a0..00000000 --- a/lib/markdown_preview_lib/pygments/cmdline.py +++ /dev/null @@ -1,508 +0,0 @@ -# -*- coding: utf-8 -*- -""" - pygments.cmdline - ~~~~~~~~~~~~~~~~ - - Command line interface. - - :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" - -from __future__ import print_function -from __future__ import absolute_import -import sys -import getopt -from textwrap import dedent - -from . import __version__, highlight -from .util import ClassNotFound, OptionError, docstring_headline -from .lexers import get_all_lexers, get_lexer_by_name, get_lexer_for_filename, \ - find_lexer_class, guess_lexer, TextLexer -from .formatters.latex import LatexEmbeddedLexer, LatexFormatter -from .formatters import get_all_formatters, get_formatter_by_name, \ - get_formatter_for_filename, find_formatter_class, \ - TerminalFormatter # pylint:disable-msg=E0611 -from .filters import get_all_filters, find_filter_class -from .styles import get_all_styles, get_style_by_name - - -USAGE = """\ -Usage: %s [-l | -g] [-F [:]] [-f ] - [-O ] [-P ] [-s] [-o ] [] - - %s -S - - -

%(title)s

- -''' - -DOC_HEADER_EXTERNALCSS = '''\ - - - - - %(title)s - - - - -

%(title)s

- -''' - -DOC_FOOTER = '''\ - - -''' - - -class HtmlFormatter(Formatter): - r""" - Format tokens as HTML 4 ```` tags within a ``
`` tag, wrapped
-    in a ``
`` tag. The ``
``'s CSS class can be set by the `cssclass` - option. - - If the `linenos` option is set to ``"table"``, the ``
`` is
-    additionally wrapped inside a ```` which has one row and two
-    cells: one containing the line numbers and one containing the code.
-    Example:
-
-    .. sourcecode:: html
-
-        
-
- - -
-
1
-            2
-
-
def foo(bar):
-              pass
-            
-
- - (whitespace added to improve clarity). - - Wrapping can be disabled using the `nowrap` option. - - A list of lines can be specified using the `hl_lines` option to make these - lines highlighted (as of Pygments 0.11). - - With the `full` option, a complete HTML 4 document is output, including - the style definitions inside a ``