diff options
author | gbrandl <devnull@localhost> | 2009-11-23 21:28:49 +0100 |
---|---|---|
committer | gbrandl <devnull@localhost> | 2009-11-23 21:28:49 +0100 |
commit | 95e7412f294269c52e2b35b834ba5428c2aa645a (patch) | |
tree | 8b23c4c3d5d57b5e1ea0e3ac3b4eb24576dee559 | |
parent | fad460859d1c50e5a825bcf968e5162805d82146 (diff) | |
parent | d221e997f60f129498838340d49f45ce566cd5b1 (diff) | |
download | pygments-95e7412f294269c52e2b35b834ba5428c2aa645a.tar.gz |
merge with http://bitbucket.org/aslakhellesoy/pygments-main/ (adding Gherkin lexer).
-rw-r--r-- | AUTHORS | 2 | ||||
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
-rw-r--r-- | pygments/lexers/other.py | 85 |
4 files changed, 88 insertions, 1 deletions
@@ -25,12 +25,14 @@ Other contributors, listed alphabetically, are: * Matt Good -- Genshi, Cheetah lexers * Matthew Harrison -- SVG formatter * Steven Hazel -- Tcl lexer +* Aslak Hellesøy -- Gherkin lexer * Varun Hiremath -- Debian control lexer * Dennis Kaarsemaker -- sources.list lexer * Marek Kubica -- Scheme lexer * Jochen Kupperschmidt -- Markdown processor * Gerd Kurzbach -- Modelica lexer * Mark Lee -- Vala lexer +* Ben Mabey -- Gherkin lexer * Kirk McDonald -- D lexer * Lukas Meuser -- BBCode formatter, Lua lexer * Paulo Moura -- Logtalk lexer @@ -12,6 +12,7 @@ Version 1.2 - Lexers added: * Go + * Gherkin (Cucumber) * CMake * OOC diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 2f2ddad0..073565e0 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -76,6 +76,7 @@ LEXERS = { 'GenshiLexer': ('pygments.lexers.templates', 'Genshi', ('genshi', 'kid', 'xml+genshi', 'xml+kid'), ('*.kid',), ('application/x-genshi', 'application/x-kid')), 'GenshiTextLexer': ('pygments.lexers.templates', 'Genshi Text', ('genshitext',), (), ('application/x-genshi-text', 'text/x-genshi')), 'GettextLexer': ('pygments.lexers.text', 'Gettext Catalog', ('pot', 'po'), ('*.pot', '*.po'), ('application/x-gettext', 'text/x-gettext', 'text/gettext')), + 'GherkinLexer': ('pygments.lexers.other', 'Gherkin', ('Cucumber', 'cucumber', 'Gherkin', 'gherkin'), ('*.feature',), ('text/x-gherkin',)), 'GnuplotLexer': ('pygments.lexers.other', 'Gnuplot', ('gnuplot',), ('*.plot', '*.plt'), ('text/x-gnuplot',)), 'GoLexer': ('pygments.lexers.compiled', 'Go', ('go',), ('*.go',), ('text/x-gosrc',)), 'GroffLexer': ('pygments.lexers.text', 'Groff', ('groff', 'nroff', 'man'), ('*.[1234567]', '*.man'), ('application/x-troff', 'text/troff')), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 042a3313..ca8304e8 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -24,7 +24,7 @@ __all__ = ['SqlLexer', 'MySqlLexer', 'SqliteConsoleLexer', 'BrainfuckLexer', 'MOOCodeLexer', 'SmalltalkLexer', 'TcshLexer', 'LogtalkLexer', 'GnuplotLexer', 'PovrayLexer', 'AppleScriptLexer', 'BashSessionLexer', 'ModelicaLexer', 'RebolLexer', 'ABAPLexer', - 'NewspeakLexer'] + 'NewspeakLexer', 'GherkinLexer'] line_re = re.compile('.*?\n') @@ -2093,3 +2093,86 @@ class NewspeakLexer(RegexLexer): ] } +class GherkinLexer(RegexLexer): + """ + For `Gherkin <http://cukes.info/>` syntax. + + *New in Pygments 1.2.* + """ + name = 'Gherkin' + aliases = ['Cucumber', 'cucumber', 'Gherkin', 'gherkin'] + filenames = ['*.feature'] + mimetypes = ['text/x-gherkin'] + + feature_keywords_regexp = ur'^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функционалност|Функционал|Особина|Могућност|Özellik|Właściwość|Tính năng|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$' + scenario_keywords_regexp = ur'^(\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарио|Сценарий структураси|Сценарий|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Основа|Концепт|Контекст|Założenia|Tình huống|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y\'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$' + examples_regexp = ur'^(\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$' + step_keywords_regexp = ur'^(\s*)(하지만|조건|만일|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假如|但是|但し|並且|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Унда |То |Онда |Но |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Агар |А |Și |És |anrhegedig a |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Yna |Ya know how |Ya gotta |Y |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Soit |Siis |Si |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Donat |Donada |Diyelim ki |Dengan |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |But y\'all |But |Biết |Bet |BUT |Atunci |And y\'all |And |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A )' + + tokens = { + 'comments': [ + (r'#.*$', Comment), + ], + 'multiline_descriptions' : [ + (step_keywords_regexp, Keyword, "#pop"), + include('comments'), + (r"(\s|.)", Name.Constant), + ], + 'multiline_descriptions_on_stack' : [ + (step_keywords_regexp, Keyword, "#pop:2"), + include('comments'), + (r"(\s|.)", Name.Constant), + ], + 'scenario_table_description': [ + (r"\s+\|", Text, 'scenario_table_header'), + include('comments'), + (r"(\s|.)", Name.Constant), + ], + 'scenario_table_header': [ + (r"\s+\|\s*$", Text, "#pop:2"), + (r"(\s+\|\s*)(#.*)$", bygroups(Text, Comment), "#pop:2"), + include('comments'), + (r"\s+\|", Text), + (r"[^\|]", Name.Variable), + ], + 'scenario_sections_on_stack': [ + (scenario_keywords_regexp, bygroups(Text, Name.Class, Name.Class, Name.Constant), "multiline_descriptions_on_stack"), + ], + 'narrative': [ + include('scenario_sections_on_stack'), + (r"(\s|.)", Name.Builtin), + ], + 'table_vars': [ + (r'(<[^>]*>)', bygroups(Name.Variable)), + ], + 'string': [ + include('table_vars'), + (r'(\s|.)', String), + ], + 'py_string': [ + (r'"""', String, "#pop"), + include('string'), + ], + 'double_string': [ + (r'"', String, "#pop"), + include('string'), + ], + 'single_string': [ + (r"'", String, "#pop"), + include('string'), + ], + 'root': [ + (r'\n', Text), + include('comments'), + (r'"""', String, "py_string"), + (r'"', String, "double_string"), + (r"'", String, "single_string"), + include('table_vars'), + (r'@[^@\s]+', Name.Namespace), + (step_keywords_regexp, bygroups(Text, Keyword)), + (feature_keywords_regexp, bygroups(Name.Class, Name.Class, Name.Constant), 'narrative'), + (scenario_keywords_regexp, bygroups(Text, Name.Class, Name.Class, Name.Constant), "multiline_descriptions"), + (examples_regexp, bygroups(Text, Name.Class, Name.Class, Name.Constant), "scenario_table_description"), + (r'(\s|.)', Text), + ] + } |