Skip to content
This repository

Add syntax highlighting for Gherkin #202

Merged
merged 3 commits into from about 1 year ago

4 participants

Jonathan Hedstrom Ariel Gold Matthew McCullough Phil Webb
Jonathan Hedstrom

No description provided.

Ariel Gold

Have you seen [#46] where cucumber syntax highlighting was added?

I pulled your changes and the syntax highlighting looks better with your gherkin highlighting because quotes and everything inside quotes are highlighted, but it looks like the highlighting doesn't work properly if the string inside the quotes has line breaks.

Matthew McCullough matthewmccullough merged commit 7b7d9c0 into from January 20, 2013
Matthew McCullough matthewmccullough closed this January 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
4  bin/showoff
@@ -6,7 +6,7 @@ require 'showoff/version'
6 6
 require 'rubygems'
7 7
 require 'gli'
8 8
 
9  
-include GLI
  9
+include GLI::App
10 10
 
11 11
 version SHOWOFF_VERSION
12 12
 
@@ -186,4 +186,4 @@ on_error do |exception|
186 186
   true
187 187
 end
188 188
 
189  
-exit GLI.run(ARGV)
  189
+exit run(ARGV)
6  lib/showoff.rb
@@ -503,11 +503,7 @@ def pdf(static=true)
503 503
    def self.do_static(what)
504 504
       what = "index" if !what
505 505
 
506  
-      # Nasty hack to get the actual ShowOff module
507  
-      showoff = ShowOff.new
508  
-      while !showoff.is_a?(ShowOff)
509  
-        showoff = showoff.instance_variable_get(:@app)
510  
-      end
  506
+      showoff = ShowOff.new!
511 507
       name = showoff.instance_variable_get(:@pres_name)
512 508
       path = showoff.instance_variable_get(:@root_path)
513 509
       logger = showoff.instance_variable_get(:@logger)
112  public/js/sh_lang/sh_gherkin.js
... ...
@@ -0,0 +1,112 @@
  1
+if (! this.sh_languages) {
  2
+  this.sh_languages = {};
  3
+}
  4
+sh_languages['gherkin'] = [
  5
+  [
  6
+    [
  7
+      /#/g,
  8
+      'sh_comment',
  9
+      1
  10
+    ],
  11
+    [
  12
+      /\b[+-]?(?:(?:0x[A-Fa-f0-9]+)|(?:(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?))u?(?:(?:int(?:8|16|32|64))|L)?\b/g,
  13
+      'sh_number',
  14
+      -1
  15
+    ],
  16
+    [
  17
+      /^(?:[\s]*(?:But |And |Then |When |Given |\* |Scenarios|Examples|Scenario Template|Scenario Outline|Scenario|Background|Feature))/g,
  18
+      'sh_keyword',
  19
+      -1
  20
+    ],
  21
+    [
  22
+      /^(?:[\s]*'(?:[^\\']|\\.)*'[\s]*|[\s]*\"(?:[^\\\"]|\\.)*\"[\s]*)$/g,
  23
+      'sh_comment',
  24
+      -1
  25
+    ],
  26
+    [
  27
+      /(?:[\s]*'{3})/g,
  28
+      'sh_string',
  29
+      2
  30
+    ],
  31
+    [
  32
+      /(?:[\s]*\"{3})/g,
  33
+      'sh_string',
  34
+      3
  35
+    ],
  36
+    [
  37
+      /"/g,
  38
+      'sh_string',
  39
+      4
  40
+    ],
  41
+    [
  42
+      /'/g,
  43
+      'sh_string',
  44
+      5
  45
+    ],
  46
+    [
  47
+      /(?:@[^@\r\n\t ]+)/g,
  48
+      'sh_type',
  49
+      -1
  50
+    ],
  51
+    [
  52
+      /\|/g,
  53
+      'sh_specialchar',
  54
+      -1
  55
+    ]
  56
+  ],
  57
+  [
  58
+    [
  59
+      /$/g,
  60
+      null,
  61
+      -2
  62
+    ]
  63
+  ],
  64
+  [
  65
+    [
  66
+      /(?:'{3})/g,
  67
+      'sh_string',
  68
+      -2
  69
+    ]
  70
+  ],
  71
+  [
  72
+    [
  73
+      /(?:\"{3})/g,
  74
+      'sh_string',
  75
+      -2
  76
+    ]
  77
+  ],
  78
+  [
  79
+    [
  80
+      /$/g,
  81
+      null,
  82
+      -2
  83
+    ],
  84
+    [
  85
+      /\\(?:\\|")/g,
  86
+      null,
  87
+      -1
  88
+    ],
  89
+    [
  90
+      /"/g,
  91
+      'sh_string',
  92
+      -2
  93
+    ]
  94
+  ],
  95
+  [
  96
+    [
  97
+      /$/g,
  98
+      null,
  99
+      -2
  100
+    ],
  101
+    [
  102
+      /\\(?:\\|')/g,
  103
+      null,
  104
+      -1
  105
+    ],
  106
+    [
  107
+      /'/g,
  108
+      'sh_string',
  109
+      -2
  110
+    ]
  111
+  ]
  112
+];
1  public/js/sh_lang/sh_gherkin.min.js
... ...
@@ -0,0 +1 @@
  1
+if(!this.sh_languages){this.sh_languages={}}sh_languages.gherkin=[[[/#/g,"sh_comment",1],[/\b[+-]?(?:(?:0x[A-Fa-f0-9]+)|(?:(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?))u?(?:(?:int(?:8|16|32|64))|L)?\b/g,"sh_number",-1],[/^(?:[\s]*(?:But |And |Then |When |Given |\* |Scenarios|Examples|Scenario Template|Scenario Outline|Scenario|Background|Feature))/g,"sh_keyword",-1],[/^(?:[\s]*'(?:[^\\']|\\.)*'[\s]*|[\s]*\"(?:[^\\\"]|\\.)*\"[\s]*)$/g,"sh_comment",-1],[/(?:[\s]*'{3})/g,"sh_string",2],[/(?:[\s]*\"{3})/g,"sh_string",3],[/"/g,"sh_string",4],[/'/g,"sh_string",5],[/(?:@[^@\r\n\t ]+)/g,"sh_type",-1],[/\|/g,"sh_specialchar",-1]],[[/$/g,null,-2]],[[/(?:'{3})/g,"sh_string",-2]],[[/(?:\"{3})/g,"sh_string",-2]],[[/$/g,null,-2],[/\\(?:\\|")/g,null,-1],[/"/g,"sh_string",-2]],[[/$/g,null,-2],[/\\(?:\\|')/g,null,-1],[/'/g,"sh_string",-2]]];
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.