pax_global_header 0000666 0000000 0000000 00000000064 13734573641 0014527 g ustar 00root root 0000000 0000000 52 comment=95039be25bf6ea7cc7545214e0f80e9c8f133a0e jupyterlab_pygments-0.1.2/ 0000775 0000000 0000000 00000000000 13734573641 0015636 5 ustar 00root root 0000000 0000000 jupyterlab_pygments-0.1.2/.gitignore 0000664 0000000 0000000 00000000101 13734573641 0017616 0 ustar 00root root 0000000 0000000 __pycache__/ dist/ build/ *.egg-info/ .ipynb_checkpoints/ .*.swp jupyterlab_pygments-0.1.2/LICENSE 0000664 0000000 0000000 00000003247 13734573641 0016651 0 ustar 00root root 0000000 0000000 Copyright (c) 2015 Project Jupyter Contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 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 HOLDER 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. Semver File License =================== The semver.py file is from https://github.com/podhmo/python-semver which is licensed under the "MIT" license. See the semver.py file for details. jupyterlab_pygments-0.1.2/README.md 0000664 0000000 0000000 00000002677 13734573641 0017131 0 ustar 00root root 0000000 0000000 # JupyterLab Pygments Theme This package contains a syntax coloring theme for [pygments](http://pygments.org/) making use of the JupyterLab CSS variables. The goal is to enable the use of JupyterLab's themes with pygments-generated HTML. ## Screencast In the following screencast, we demonstrate how Pygments-highlighted code can make use of the JupyterLab theme.  ## Installation `jupyterlab_pygments` can be installed with the conda package manager ``` conda install -c conda-forge jupyterlab_pygments ``` or from pypi ``` pip install jupyterlab_pygments ``` ## Dependencies - `jupyterlab_pygments` requires [pygments](http://pygments.org) version `2.4.1`. - The CSS variables used by the theme correspond to the CodeMirror syntex coloring theme defined in the NPM package [@jupyterlab/codemirror](https://www.npmjs.com/package/@jupyterlab/codemirror). Supported versions for `@jupyterlab/codemirror`'s CSS include `0.19.1`, `^1.0`, and, `^2.0`. ## Limitations Pygments-generated HTML and CSS classes are not granular enough to reproduce all of the details of codemirror (the JavaScript text editor used by JupyterLab). This includes the ability to differentiate properties from general names. ## License `jupyterlab_pygments` uses a shared copyright model that enables all contributors to maintain the copyright on their contributions. All code is licensed under the terms of the revised [BSD license](LICENSE). jupyterlab_pygments-0.1.2/jupyterlab_pygments/ 0000775 0000000 0000000 00000000000 13734573641 0021745 5 ustar 00root root 0000000 0000000 jupyterlab_pygments-0.1.2/jupyterlab_pygments/__init__.py 0000664 0000000 0000000 00000000251 13734573641 0024054 0 ustar 00root root 0000000 0000000 # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from .style import JupyterStyle from ._version import __version__ jupyterlab_pygments-0.1.2/jupyterlab_pygments/_version.py 0000664 0000000 0000000 00000000256 13734573641 0024146 0 ustar 00root root 0000000 0000000 # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. version_info = (0, 1, 2) __version__ = '.'.join(map(str, version_info)) jupyterlab_pygments-0.1.2/jupyterlab_pygments/style.py 0000664 0000000 0000000 00000020455 13734573641 0023465 0 ustar 00root root 0000000 0000000 # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from pygments.style import Style from pygments.token import ( Comment, Error, Generic, Keyword, Literal, Name, Number, Operator, Other, Punctuation, String, Text, Whitespace) class JupyterStyle(Style): """ A pygments style using JupyterLab CSS variables. The goal is to mimick JupyterLab's codemirror theme. Known impossibilities: - With pygments, the dot in `foo.bar` is considered an Operator (class: 'o'), while in codemirror, it is bare text. - With pygments, in both `from foo import bar`, and `foo.bar`, "bar" is considered a Name (class: 'n'), while in coremirror, the latter is a property. Available CSS variables are --jp-mirror-editor-keyword-color --jp-mirror-editor-atom-color --jp-mirror-editor-number-color --jp-mirror-editor-def-color --jp-mirror-editor-variable-color --jp-mirror-editor-variable-2-color --jp-mirror-editor-variable-3-color --jp-mirror-editor-punctuation-color --jp-mirror-editor-property-color --jp-mirror-editor-operator-color --jp-mirror-editor-comment-color --jp-mirror-editor-string-color --jp-mirror-editor-string-2-color --jp-mirror-editor-meta-color --jp-mirror-editor-qualifier-color --jp-mirror-editor-builtin-color --jp-mirror-editor-bracket-color --jp-mirror-editor-tag-color --jp-mirror-editor-attribute-color --jp-mirror-editor-header-color --jp-mirror-editor-quote-color --jp-mirror-editor-link-color --jp-mirror-editor-error-color """ default_style = '' background_color = 'var(--jp-cell-editor-background)' highlight_color = 'var(--jp-cell-editor-active-background)' styles = { Text: 'var(--jp-mirror-editor-variable-color)', # no class Whitespace: '', # class: 'w' Error: 'var(--jp-mirror-editor-error-color)', # class: 'err' Other: '', # class: 'x' Comment: 'italic var(--jp-mirror-editor-comment-color)', # class: 'c' #Comment.Multiline: '', # class: 'cm' #Comment.Preproc: '', # class: 'cp' #Comment.Single: '', # class: 'c1' #Comment.Special: '', # class: 'cs' Keyword: 'bold var(--jp-mirror-editor-keyword-color)', # class: 'k' #Keyword.Constant: '', # class: 'kc' #Keyword.Declaration: '', # class: 'kd' #Keyword.Namespace: '', # class: 'kn' #Keyword.Pseudo: '', # class: 'kp' #Keyword.Reserved: '', # class: 'kr' #Keyword.Type: '', # class: 'kt' Operator: 'bold var(--jp-mirror-editor-operator-color)', # class: 'o' Operator.Word: '', # class: 'ow' Literal: '', # class: 'l' Literal.Date: '', # class: 'ld' String: 'var(--jp-mirror-editor-string-color)', #String.Backtick: '', # class: 'sb' #String.Char: '', # class: 'sc' #String.Doc: '', # class: 'sd' #String.Double: '', # class: 's2' #String.Escape: '', # class: 'se' #String.Heredoc: '', # class: 'sh' #String.Interpol: '', # class: 'si' #String.Other: '', # class: 'sx' #String.Regex: '', # class: 'sr' #String.Single: '', # class: 's1' #String.Symbol: '', # class: 'ss' Number: 'var(--jp-mirror-editor-number-color)', # class: 'm' #Number.Float: '', # class: 'mf' #Number.Hex: '', # class: 'mh' #Number.Integer: '', # class: 'mi' #Number.Integer.Long: '', # class: 'il' #Number.Oct: '', # class: 'mo' Name: '', # class: 'n' #Name.Attribute: '', # class: 'na' #Name.Builtin: '', # class: 'nb' #Name.Builtin.Pseudo: '', # class: 'bp' #Name.Class: '', # class: 'nc' #Name.Constant: '', # class: 'no' #Name.Decorator: '', # class: 'nd' #Name.Entity: '', # class: 'ni' #Name.Exception: '', # class: 'ne' #Name.Function: '', # class: 'nf' #Name.Property: '', # class 'py' #Name.Label: '', # class: 'nl' #Name.Namespace: '', # class: 'nn' #Name.Other: '', # class: 'nx' #Name.Tag: '', # class: 'nt' #Name.Variable: '', # class: 'nv' #Name.Variable.Class: '', # class: 'vc' #Name.Variable.Global: '', # class: 'vg' #Name.Variable.Instance: '', # class: 'vi' Generic: '', # class: 'g' #Generic.Deleted: '', # class: 'gd', #Generic.Emph: 'italic', # class: 'ge' #Generic.Error: '', # class: 'gr' #Generic.Heading: '', # class: 'gh' #Generic.Inserted: '', # class: 'gi' #Generic.Output: '', # class: 'go' #Generic.Prompt: '', # class: 'gp' #Generic.Strong: '', # class: 'gs' #Generic.Subheading: '', # class: 'gu' #Generic.Traceback: '', # class: 'gt' Punctuation: 'var(--jp-mirror-editor-punctuation-color)' # class: 'p' } jupyterlab_pygments-0.1.2/notebooks/ 0000775 0000000 0000000 00000000000 13734573641 0017641 5 ustar 00root root 0000000 0000000 jupyterlab_pygments-0.1.2/notebooks/Example.ipynb 0000664 0000000 0000000 00000003332 13734573641 0022300 0 ustar 00root root 0000000 0000000 { "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pygments import highlight\n", "from pygments.lexers import PythonLexer\n", "from pygments.formatters import HtmlFormatter\n", "from jupyterlab_pygments import JupyterStyle" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "class PythonCode:\n", " def __init__(self, value):\n", " self.value = value\n", " \n", " def _repr_html_(self, **kwargs):\n", " formatter = HtmlFormatter(style=JupyterStyle)\n", " html = highlight(self.value, PythonLexer(), formatter)\n", " css = formatter.get_style_defs('.highlight')\n", " return f'