-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add pygments lexer for TQL + Tuleap style
It allow to have syntax highlight for TQL code blocks Block code are now highlighted with Tuleap style
- Loading branch information
Showing
6 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
def setup(app): | ||
return | ||
|
||
from pygments.lexer import RegexLexer | ||
from pygments.token import * | ||
import re | ||
|
||
class TqlLexer(RegexLexer): | ||
""" | ||
A lexer for TQL (Tuleap Query Language) | ||
""" | ||
name = 'TQL' | ||
flags = re.MULTILINE + re.IGNORECASE | ||
|
||
tokens = { | ||
'root': [ | ||
(r'\s+', Whitespace), | ||
(r'\/{2}.*', Comment), | ||
|
||
(r"'(?:[^\\]|\\.)*?(?:'|$)", String), | ||
(r'"(?:[^\\]|\\.)*?(?:"|$)', String), | ||
|
||
(r'/\d+[dwmy]/i', Number), | ||
(r'\d+(?:\.\d+)?', Number), | ||
|
||
(r'linked\s*from\b', Name), | ||
(r'(?:and|from|or|select|where)\b', Keyword), | ||
(r'(?:artifact|between|by|child|children|covered|covering|from|in|is|linked|myself|not|now|open|parent|to|tracker|type|with|without)\b', Name), | ||
|
||
(r'[=<>!+-]+', Operator), | ||
(r'[()]', Operator), | ||
|
||
(r'@[.\w-]+', Name.Constant), | ||
(r'[.\w-]+', Literal), | ||
|
||
(r',', Punctuation) | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
def setup(app): | ||
return | ||
|
||
from pygments.style import Style | ||
from pygments.token import * | ||
|
||
class TuleapStyle(Style): | ||
styles = { | ||
Token: '#282621', # typo-default-text-color | ||
|
||
Keyword: '#005f90', # class:'k' deep-blue-text | ||
Name: '#6a14a7', # class:'n' plum-crazy-text | ||
Name.Constant: '#945600', # class:'no' clockwork-orange-text | ||
Name.Other: '#774a0a', # class:'nx' teddy-brown-text | ||
String: '#137900', # class:'s' neon-green-text | ||
Number: '#bf4747', # class:'m' coral-pink-text | ||
Literal: '#525252', # class:'l' inca-silver-text | ||
|
||
Comment: '#717171', # class:'c' dimmed-color | ||
Comment.Preproc: '#1b805e', # class:'cp' surf-green-text | ||
Punctuation: '#717171', # class:'p' dimmed-color | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters