diff options
author | Georg Brandl <georg@python.org> | 2015-03-08 07:32:43 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2015-03-08 07:32:43 +0100 |
commit | 0ed4dae05a85dd67e6190cc7027a830e89e7465d (patch) | |
tree | b490b8bdcde5b3d30000fe93a306d79c165e5e58 | |
parent | 48eb4ba2f472b5d3edaf8446f7bc127a5272c46f (diff) | |
download | pygments-0ed4dae05a85dd67e6190cc7027a830e89e7465d.tar.gz |
Added Algol and Algol_nu style (#1090).
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | pygments/lexers/modula2.py | 2 | ||||
-rw-r--r-- | pygments/styles/__init__.py | 2 | ||||
-rw-r--r-- | pygments/styles/algol.py | 63 | ||||
-rw-r--r-- | pygments/styles/algol_nu.py | 63 |
5 files changed, 130 insertions, 2 deletions
@@ -15,10 +15,12 @@ Version 2.1 * Emacs Lisp (PR#431) * Arduino (PR#442) + * Modula-2 with multi-dialect support (#1090) - Added styles: * Lovelace (PR#456) + * Algol and Algol-nu (#1090) Version 2.0.3 diff --git a/pygments/lexers/modula2.py b/pygments/lexers/modula2.py index eec913b6..d32bb5bb 100644 --- a/pygments/lexers/modula2.py +++ b/pygments/lexers/modula2.py @@ -1564,5 +1564,3 @@ class Modula2Lexer(RegexLexer): # return result yield index, token, value - -# end of modula2.py diff --git a/pygments/styles/__init__.py b/pygments/styles/__init__.py index 2c69714f..d7a0564a 100644 --- a/pygments/styles/__init__.py +++ b/pygments/styles/__init__.py @@ -39,6 +39,8 @@ STYLE_MAP = { 'paraiso-light': 'paraiso_light::ParaisoLightStyle', 'paraiso-dark': 'paraiso_dark::ParaisoDarkStyle', 'lovelace': 'lovelace::LovelaceStyle', + 'algol': 'algol::AlgolStyle', + 'algol_nu': 'algol_nu::Algol_NuStyle', } diff --git a/pygments/styles/algol.py b/pygments/styles/algol.py new file mode 100644 index 00000000..a8726009 --- /dev/null +++ b/pygments/styles/algol.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +""" + pygments.styles.algol + ~~~~~~~~~~~~~~~~~~~~~ + + Algol publication style. + + This style renders source code for publication of algorithms in + scientific papers and academic texts, where its format is frequently used. + + It is based on the style of the revised Algol-60 language report[1]. + + o No colours, only black, white and shades of grey are used. + o Keywords are rendered in lowercase underline boldface. + o Builtins are rendered in lowercase boldface italic. + o Docstrings and pragmas are rendered in dark grey boldface. + o Library identifiers are rendered in dark grey boldface italic. + o Comments are rendered in grey italic. + + To render keywords without underlining, refer to the `Algol_Nu` style. + + For lowercase conversion of keywords and builtins in languages where + these are not or might not be lowercase, a supporting lexer is required. + The Algol and Modula-2 lexers automatically convert to lowercase whenever + this style is selected. + + [1] `Revised Report on the Algorithmic Language Algol-60 <http://www.masswerk.at/algol60/report.htm>` + + :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.style import Style +from pygments.token import Keyword, Name, Comment, String, Error, Operator + + +class AlgolStyle(Style): + + background_color = "#ffffff" + default_style = "" + + styles = { + Comment: "italic #888", + Comment.Preproc: "bold noitalic #888", + Comment.Special: "bold noitalic #888", + + Keyword: "underline bold", + Keyword.Declaration: "italic", + + Name.Builtin: "bold italic", + Name.Builtin.Pseudo: "bold italic", + Name.Namespace: "bold italic #666", + Name.Class: "bold italic #666", + Name.Function: "bold italic #666", + Name.Variable: "bold italic #666", + Name.Constant: "bold italic #666", + + Operator.Word: "bold", + + String: "italic #666", + + Error: "border:#FF0000" + } diff --git a/pygments/styles/algol_nu.py b/pygments/styles/algol_nu.py new file mode 100644 index 00000000..392838f2 --- /dev/null +++ b/pygments/styles/algol_nu.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +""" + pygments.styles.algol_nu + ~~~~~~~~~~~~~~~~~~~~~~~~ + + Algol publication style without underlining of keywords. + + This style renders source code for publication of algorithms in + scientific papers and academic texts, where its format is frequently used. + + It is based on the style of the revised Algol-60 language report[1]. + + o No colours, only black, white and shades of grey are used. + o Keywords are rendered in lowercase boldface. + o Builtins are rendered in lowercase boldface italic. + o Docstrings and pragmas are rendered in dark grey boldface. + o Library identifiers are rendered in dark grey boldface italic. + o Comments are rendered in grey italic. + + To render keywords with underlining, refer to the `Algol` style. + + For lowercase conversion of keywords and builtins in languages where + these are not or might not be lowercase, a supporting lexer is required. + The Algol and Modula-2 lexers automatically convert to lowercase whenever + this style is selected. + + [1] `Revised Report on the Algorithmic Language Algol-60 <http://www.masswerk.at/algol60/report.htm>` + + :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.style import Style +from pygments.token import Keyword, Name, Comment, String, Error, Operator + + +class Algol_NuStyle(Style): + + background_color = "#ffffff" + default_style = "" + + styles = { + Comment: "italic #888", + Comment.Preproc: "bold noitalic #888", + Comment.Special: "bold noitalic #888", + + Keyword: "bold", + Keyword.Declaration: "italic", + + Name.Builtin: "bold italic", + Name.Builtin.Pseudo: "bold italic", + Name.Namespace: "bold italic #666", + Name.Class: "bold italic #666", + Name.Function: "bold italic #666", + Name.Variable: "bold italic #666", + Name.Constant: "bold italic #666", + + Operator.Word: "bold", + + String: "italic #666", + + Error: "border:#FF0000" + } |