summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/generate.py92
-rw-r--r--docs/src/lexerdevelopment.txt31
2 files changed, 77 insertions, 46 deletions
diff --git a/docs/generate.py b/docs/generate.py
index abdc6316..8759042b 100644
--- a/docs/generate.py
+++ b/docs/generate.py
@@ -27,7 +27,7 @@ from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
-PYGMENTS_FORMATTER = HtmlFormatter(style='friendly', cssclass='syntax')
+PYGMENTS_FORMATTER = HtmlFormatter(style='pastie', cssclass='syntax')
USAGE = '''\
Usage: %s <mode> <destination> [<source.txt> ...]
@@ -91,15 +91,15 @@ body {
}
h1 {
- font-weight: normal;
- font-size: 40px;
- color: #09839A;
+ font-weight: normal;
+ font-size: 40px;
+ color: #09839A;
}
h2 {
- font-weight: normal;
- font-size: 30px;
- color: #C73F00;
+ font-weight: normal;
+ font-size: 30px;
+ color: #C73F00;
}
h1.heading {
@@ -111,87 +111,87 @@ h2.subheading {
}
h3 {
- margin-top: 30px;
+ margin-top: 30px;
}
table.docutils {
- border-collapse: collapse;
- border: 2px solid #aaa;
- margin: 0.5em 1.5em 0.5em 1.5em;
+ border-collapse: collapse;
+ border: 2px solid #aaa;
+ margin: 0.5em 1.5em 0.5em 1.5em;
}
table.docutils td {
- padding: 2px;
- border: 1px solid #ddd;
+ padding: 2px;
+ border: 1px solid #ddd;
}
p, li, dd, dt, blockquote {
- font-size: 15px;
- color: #333;
+ font-size: 15px;
+ color: #333;
}
p {
- line-height: 150%;
- margin-bottom: 0;
- margin-top: 10px;
+ line-height: 150%;
+ margin-bottom: 0;
+ margin-top: 10px;
}
hr {
- border-top: 1px solid #ccc;
- border-bottom: 0;
- border-right: 0;
- border-left: 0;
- margin-bottom: 10px;
- margin-top: 20px;
+ border-top: 1px solid #ccc;
+ border-bottom: 0;
+ border-right: 0;
+ border-left: 0;
+ margin-bottom: 10px;
+ margin-top: 20px;
}
dl {
- margin-left: 10px;
+ margin-left: 10px;
}
li, dt {
- margin-top: 5px;
+ margin-top: 5px;
}
dt {
- font-weight: bold;
+ font-weight: bold;
}
th {
- text-align: left;
+ text-align: left;
}
a {
- color: #990000;
+ color: #990000;
}
a:hover {
- color: #c73f00;
+ color: #c73f00;
}
pre {
- background-color: #f0f0f0;
- border-top: 1px solid #ccc;
- border-bottom: 1px solid #ccc;
- padding: 5px;
- font-size: 13px;
- font-family: Bitstream Vera Sans Mono,monospace;
+ background-color: #f9f9f9;
+ border-top: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
+ padding: 5px;
+ font-size: 13px;
+ font-family: Bitstream Vera Sans Mono,monospace;
}
tt {
- font-size: 13px;
- font-family: Bitstream Vera Sans Mono,monospace;
- color: black;
- padding: 1px 2px 1px 2px;
- background-color: #f0f0f0;
+ font-size: 13px;
+ font-family: Bitstream Vera Sans Mono,monospace;
+ color: black;
+ padding: 1px 2px 1px 2px;
+ background-color: #f0f0f0;
}
cite {
- /* abusing <cite>, it's generated by ReST for `x` */
- font-size: 13px;
- font-family: Bitstream Vera Sans Mono,monospace;
- font-weight: bold;
- font-style: normal;
+ /* abusing <cite>, it's generated by ReST for `x` */
+ font-size: 13px;
+ font-family: Bitstream Vera Sans Mono,monospace;
+ font-weight: bold;
+ font-style: normal;
}
#backlink {
diff --git a/docs/src/lexerdevelopment.txt b/docs/src/lexerdevelopment.txt
index c5d2921b..80822e1d 100644
--- a/docs/src/lexerdevelopment.txt
+++ b/docs/src/lexerdevelopment.txt
@@ -480,3 +480,34 @@ This might sound confusing (and it can really be). But it is needed, and for an
example look at the Ruby lexer in `agile.py`_.
.. _agile.py: http://trac.pocoo.org/repos/pygments/trunk/pygments/lexers/agile.py
+
+
+Filtering Token Streams
+=======================
+
+Some languages ship a lot of builtin functions (for example PHP). The total
+amount of those functions differs from system to system because not everybody
+has every extension installed. In the case of PHP there are over 3000 builtin
+functions. That's an incredible huge amount of functions, much more than you
+can put into a regular expression.
+
+But because only `Name` tokens can be function names it's solvable by overriding
+the ``get_tokens_unprocessed`` method. The following lexer subclasses the
+`PythonLexer` so that it highlights some additional names as pseudo keywords:
+
+.. sourcecode:: python
+
+ from pykleur.lexers.agile import PythonLexer
+ from pykleur.token import Name, Keyword
+
+ class MyPythonLexer(PythonLexer):
+ EXTRA_KEYWORDS = ['foo', 'bar', 'foobar', 'barfoo', 'spam', 'eggs']
+
+ def get_tokens_unprocessed(self, text):
+ for index, token, value in PythonLexer.get_tokens_unprocessed(self, text):
+ if token is Name and value in self.EXTRA_KEYWORDS:
+ yield index, Keyword.Pseudo, value
+ else:
+ yield index, token, value
+
+The `PhpLexer` and `LuaLexer` use this method to resolve builtin functions.