rouge 1.10.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge/cli.rb +1 -1
  3. data/lib/rouge/demos/actionscript +4 -0
  4. data/lib/rouge/demos/apiblueprint +33 -0
  5. data/lib/rouge/demos/biml +38 -0
  6. data/lib/rouge/demos/ceylon +7 -0
  7. data/lib/rouge/demos/cmake +7 -0
  8. data/lib/rouge/demos/coq +11 -0
  9. data/lib/rouge/demos/d +16 -0
  10. data/lib/rouge/demos/eiffel +30 -0
  11. data/lib/rouge/demos/fortran +22 -0
  12. data/lib/rouge/demos/gradle +10 -0
  13. data/lib/rouge/demos/jinja +9 -0
  14. data/lib/rouge/demos/jsonnet +28 -0
  15. data/lib/rouge/demos/julia +11 -0
  16. data/lib/rouge/demos/nasm +26 -0
  17. data/lib/rouge/demos/objective_c +4 -0
  18. data/lib/rouge/demos/protobuf +5 -0
  19. data/lib/rouge/demos/shell_session +10 -0
  20. data/lib/rouge/demos/smarty +12 -0
  21. data/lib/rouge/demos/tap +5 -0
  22. data/lib/rouge/demos/twig +9 -0
  23. data/lib/rouge/demos/typescript +1 -0
  24. data/lib/rouge/demos/verilog +27 -0
  25. data/lib/rouge/demos/viml +14 -5
  26. data/lib/rouge/formatters/html_wrapper.rb +11 -0
  27. data/lib/rouge/formatters/terminal256.rb +1 -1
  28. data/lib/rouge/lexer.rb +4 -2
  29. data/lib/rouge/lexers/actionscript.rb +195 -0
  30. data/lib/rouge/lexers/apache.rb +23 -20
  31. data/lib/rouge/lexers/apache/keywords.yml +721 -410
  32. data/lib/rouge/lexers/apiblueprint.rb +51 -0
  33. data/lib/rouge/lexers/biml.rb +41 -0
  34. data/lib/rouge/lexers/c.rb +7 -2
  35. data/lib/rouge/lexers/ceylon.rb +123 -0
  36. data/lib/rouge/lexers/clojure.rb +1 -1
  37. data/lib/rouge/lexers/cmake.rb +206 -0
  38. data/lib/rouge/lexers/coffeescript.rb +1 -1
  39. data/lib/rouge/lexers/coq.rb +187 -0
  40. data/lib/rouge/lexers/cpp.rb +12 -1
  41. data/lib/rouge/lexers/csharp.rb +12 -5
  42. data/lib/rouge/lexers/css.rb +2 -0
  43. data/lib/rouge/lexers/d.rb +176 -0
  44. data/lib/rouge/lexers/diff.rb +9 -9
  45. data/lib/rouge/lexers/eiffel.rb +65 -0
  46. data/lib/rouge/lexers/fortran.rb +142 -0
  47. data/lib/rouge/lexers/gradle.rb +37 -0
  48. data/lib/rouge/lexers/groovy.rb +2 -2
  49. data/lib/rouge/lexers/ini.rb +2 -2
  50. data/lib/rouge/lexers/java.rb +11 -8
  51. data/lib/rouge/lexers/javascript.rb +2 -1
  52. data/lib/rouge/lexers/jinja.rb +137 -0
  53. data/lib/rouge/lexers/jsonnet.rb +151 -0
  54. data/lib/rouge/lexers/julia.rb +172 -0
  55. data/lib/rouge/lexers/markdown.rb +1 -0
  56. data/lib/rouge/lexers/nasm.rb +203 -0
  57. data/lib/rouge/lexers/objective_c.rb +11 -0
  58. data/lib/rouge/lexers/php.rb +1 -1
  59. data/lib/rouge/lexers/powershell.rb +1 -1
  60. data/lib/rouge/lexers/protobuf.rb +70 -0
  61. data/lib/rouge/lexers/python.rb +23 -0
  62. data/lib/rouge/lexers/r.rb +53 -20
  63. data/lib/rouge/lexers/ruby.rb +4 -4
  64. data/lib/rouge/lexers/rust.rb +2 -2
  65. data/lib/rouge/lexers/shell_session.rb +29 -0
  66. data/lib/rouge/lexers/smarty.rb +91 -0
  67. data/lib/rouge/lexers/sql.rb +1 -1
  68. data/lib/rouge/lexers/swift.rb +20 -5
  69. data/lib/rouge/lexers/tap.rb +91 -0
  70. data/lib/rouge/lexers/twig.rb +37 -0
  71. data/lib/rouge/lexers/typescript.rb +46 -0
  72. data/lib/rouge/lexers/verilog.rb +164 -0
  73. data/lib/rouge/regex_lexer.rb +1 -1
  74. data/lib/rouge/version.rb +1 -1
  75. data/rouge.gemspec +1 -1
  76. metadata +47 -6
  77. data/lib/rouge/formatters/html_inline.rb +0 -20
  78. data/lib/rouge/formatters/html_linewise.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97effe9cafa1378b8091163a176fabb3a0157c9e
4
- data.tar.gz: a594ae8d0e46031aadea8ec3662b660310a4e0ff
3
+ metadata.gz: 0d52689800e9b41571b3c09b3412f672a0e96de8
4
+ data.tar.gz: f0b4629db72f7122e8ff0760487f9193edec8f9c
5
5
  SHA512:
6
- metadata.gz: fb0e3c6b15a4e79c6239b93a4d82ff46863aa2ce8c3e11c971358b908a80927209db3912d696c7786aabd2134bd8d2822fad774ca08e98eec21ac366f7120e53
7
- data.tar.gz: daca6241c49f157150f0cefcfaf201cd96bb4a510b3cc0bb2ff71653726216b142a5fb8b1c287e1af7efd46b93a214253fb8e818984c1c0a342e5d1400e5d3a6
6
+ metadata.gz: cf7d9859a295ad5e9e269eecf77e3477d3bf93b062f19e0095b81135e66265375ddbfb1c986a155a4ed84921366ce2914e0ee900040c24f58d488921417a8928
7
+ data.tar.gz: b4de6ef45285cf75dac6d9558341955e5c29b30f06ea6a7584c99b1febde9a63915fa2a5442839fa3c7cc51da57dd51a2152adcfb98f09e83abba0524e11c359
@@ -23,7 +23,7 @@ module Rouge
23
23
 
24
24
  def read
25
25
  @read ||= begin
26
- file.read
26
+ File.read(file, encoding: 'utf-8')
27
27
  rescue => e
28
28
  $stderr.puts "unable to open #{input}: #{e.message}"
29
29
  exit 1
@@ -0,0 +1,4 @@
1
+ function hello(name:String):void
2
+ {
3
+ trace("hello " + name);
4
+ }
@@ -0,0 +1,33 @@
1
+ FORMAT: 1A
2
+ HOST: http://polls.apiblueprint.org/
3
+
4
+ # Polls
5
+
6
+ Polls is a simple API allowing consumers to view polls and vote in them.
7
+
8
+ # Polls API Root [/]
9
+
10
+ ## Group Question
11
+
12
+ Resources related to questions in the API.
13
+
14
+ ## Question [/questions/{question_id}]
15
+
16
+ + Parameters
17
+ + question_id: 1 (number, required) - ID of the Question in form of an integer
18
+
19
+ + Attributes
20
+ + question: `Favourite programming language?` (required)
21
+ + published_at: `2014-11-11T08:40:51.620Z` - An ISO8601 date when the question was published
22
+ + choices (array[Choice], required) - An array of Choice objects
23
+ + url: /questions/1
24
+
25
+ ### View a Questions Detail [GET]
26
+
27
+ + Response 200 (application/json)
28
+ + Attributes (Question)
29
+
30
+ ### Delete a Question [DELETE]
31
+
32
+ + Relation: delete
33
+ + Response 204
@@ -0,0 +1,38 @@
1
+ <#@ template language="C#" #>
2
+ <#@ import namespace="System.Data" #>
3
+ <Biml xmlns="http://schemas.varigence.com/biml.xsd">
4
+ <Connections>
5
+ <!-- Creates a connection to the Adventure Works database -->
6
+ <Connection
7
+ Name="AdventureWorks"
8
+ ConnectionString="Provider=SQLNCLI10.1;Data Source=Localhost;Persist Security Info=False;Integrated Security=SSPI;Initial Catalog=AdventureWorksDW"
9
+ />
10
+ </Connections>
11
+ <!-- Packages Collection -->
12
+ <Packages>
13
+ <!-- A Package -->
14
+ <Package
15
+ Name="MyFirstPackage"
16
+ ConstraintMode="Linear"
17
+ >
18
+ <!-- A Package's Tasks -->
19
+ <Tasks>
20
+ <ExecuteSQL Name="ExecuteStoredProc" ConnectionName="AdventureWorks">
21
+ <DirectInput>EXEC usp_StoredProc</DirectInput>
22
+ </ExecuteSQL>
23
+ <# foreach (var table in RootNode.Tables) { #>
24
+ <Dataflow Name="Duplicate <#=table.Name#> Data">
25
+ <Transformations>
26
+ <OleDbSource Name="Retrieve Data" ConnectionName="AdventureWorks">
27
+ <DirectInput>SELECT * FROM <#=table.Name#></DirectInput>
28
+ </OleDbSource>
29
+ <OleDbDestination Name="Insert Data" ConnectionName="AdventureWorks">
30
+ <ExternalTableOutput Table="<#=table.Name#>" />
31
+ </OleDbDestination>
32
+ </Transformations>
33
+ </Dataflow>
34
+ <# } #>
35
+ </Tasks>
36
+ </Package>
37
+ </Packages>
38
+ </Biml>
@@ -0,0 +1,7 @@
1
+ shared class CeylonClass<Parameter>()
2
+ given Parameter satisfies Object {
3
+
4
+ shared String name => "CeylonClass";
5
+ }
6
+
7
+ shared void run() => CeylonClass();
@@ -0,0 +1,7 @@
1
+ cmake_minimum_required(VERSION 2.8.3)
2
+
3
+ project(foo C)
4
+
5
+ # some note
6
+ add_executable(foo utils.c "foo.c")
7
+ target_link_libraries(foo ${LIBRARIES})
@@ -0,0 +1,11 @@
1
+ Require Import Coq.Lists.List.
2
+
3
+ Section with_T.
4
+ Context {T : Type}.
5
+
6
+ Fixpoint length (ls : list T) : nat :=
7
+ match ls with
8
+ | nil => 0
9
+ | _ :: ls => S (length ls)
10
+ end.
11
+ End with_T.
@@ -0,0 +1,16 @@
1
+ import std.algorithm, std.conv, std.functional,
2
+ std.math, std.regex, std.stdio;
3
+
4
+ alias round = pipe!(to!real, std.math.round, to!string);
5
+ static reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`;
6
+
7
+ void main()
8
+ {
9
+ // Replace anything that looks like a real
10
+ // number with the rounded equivalent.
11
+ stdin
12
+ .byLine
13
+ .map!(l => l.replaceAll!(c => c.hit.round)
14
+ (reFloatingPoint))
15
+ .each!writeln;
16
+ }
@@ -0,0 +1,30 @@
1
+ note
2
+ description: "Represents a person."
3
+
4
+ class
5
+ PERSON
6
+
7
+ create
8
+ make, make_unknown
9
+
10
+ feature {NONE} -- Creation
11
+
12
+ make (a_name: like name)
13
+ -- Create a person with `a_name' as `name'.
14
+ do
15
+ name := a_name
16
+ ensure
17
+ name = a_name
18
+ end
19
+
20
+ make_unknown
21
+ do ensure
22
+ name = Void
23
+ end
24
+
25
+ feature -- Access
26
+
27
+ name: detachable STRING
28
+ -- Full name or Void if unknown.
29
+
30
+ end
@@ -0,0 +1,22 @@
1
+ program bottles
2
+
3
+ implicit none
4
+ integer :: nbottles
5
+
6
+ do nbottles = 99, 1, -1
7
+ call print_bottles(nbottles)
8
+ end do
9
+
10
+ contains
11
+
12
+ subroutine print_bottles(n)
13
+ implicit none
14
+ integer, intent(in) :: n
15
+
16
+ write(*, "(I0, 1X, 'bottles of beer on the wall,')") n
17
+ write(*, "(I0, 1X, 'bottles of beer.')") n
18
+ write(*, "('Take one down, pass it around,')")
19
+ write(*, "(I0, 1X, 'bottles of beer on the wall.', /)") n - 1
20
+ end subroutine print_bottles
21
+
22
+ end program bottles
@@ -0,0 +1,10 @@
1
+ apply plugin: 'java'
2
+
3
+ repositories {
4
+ jcenter()
5
+ }
6
+
7
+ dependencies {
8
+ compile 'org.openjdk.jmh:jmh-core:1.12'
9
+ compile 'org.openjdk.jmh:jmh-generator-annprocess:1.12'
10
+ }
@@ -0,0 +1,9 @@
1
+ {% extends "layout.html" %}
2
+
3
+ {% block body %}
4
+ <ul>
5
+ {% for user in users %}
6
+ <li><a href="{{ user.url }}">{{ user.username }}</a></li>
7
+ {% endfor %}
8
+ </ul>
9
+ {% endblock %}
@@ -0,0 +1,28 @@
1
+ // Compiler template
2
+ local CCompiler = {
3
+ cFlags: [],
4
+ out: "a.out",
5
+ local flags_str = std.join(" ", self.cFlags),
6
+ local files_str = std.join(" ", self.files),
7
+ cmd: "%s %s %s -o %s" % [self.compiler, flags_str, files_str, self.out],
8
+ };
9
+
10
+ // GCC specialization
11
+ local Gcc = CCompiler { compiler: "gcc" };
12
+
13
+ // Another specialization
14
+ local Clang = CCompiler { compiler: "clang" };
15
+
16
+ // Mixins - append flags
17
+ local Opt = { cFlags: super.cFlags + ["-O3", "-DNDEBUG"] };
18
+ local Dbg = { cFlags: super.cFlags + ["-g"] };
19
+
20
+ // Output:
21
+ {
22
+ targets: [
23
+ Gcc { files: ["a.c", "b.c"] },
24
+ Clang { files: ["test.c"], out: "test" },
25
+ Clang + Opt { files: ["test2.c"], out: "test2" },
26
+ Gcc + Opt + Dbg { files: ["foo.c", "bar.c"], out: "baz" },
27
+ ]
28
+ }
@@ -0,0 +1,11 @@
1
+ function mandel(z)
2
+ c = z
3
+ maxiter = 80
4
+ for n = 1:maxiter
5
+ if abs(z) > 2
6
+ return n-1
7
+ end
8
+ z = z^2 + c
9
+ end
10
+ return maxiter
11
+ end
@@ -0,0 +1,26 @@
1
+ %macro IRQ 2
2
+ global irq%1
3
+ irq%1:
4
+ cli
5
+ push byte 0 ; push a dummy error code
6
+ push byte %2 ; push the IRQ number
7
+ jmp irq_common_stub
8
+ %endmacro
9
+
10
+ extern irq_handler
11
+
12
+ irq_common_stub:
13
+ pusha ; Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax
14
+ mov ax, ds ; Lower 16-bits of eax = ds.
15
+ push eax ; save the data segment descriptor
16
+ mov ax, 0x10 ; load the kernel data segment descriptor
17
+ mov edx, eax
18
+ call irq_handler
19
+
20
+ %assign i 0
21
+ %rep 8
22
+ ISR_NOERRCODE i
23
+ %assign i i+1
24
+ %endrep
25
+
26
+ ISR_NOERRCODE 9
@@ -12,3 +12,7 @@
12
12
  @end
13
13
 
14
14
  NSArray *arrayLiteral = @[@"abc", @1];
15
+ NSDictionary *dictLiteral = @{
16
+ @"hello": @"world",
17
+ @"goodbye": @"cruel world"
18
+ };
@@ -0,0 +1,5 @@
1
+ message Person {
2
+ required string name = 1;
3
+ required int32 id = 2;
4
+ optional string email = 3;
5
+ }
@@ -0,0 +1,10 @@
1
+ $ ls /bin/bash
2
+ /bin/bash
3
+ $ sudo su -
4
+ [sudo] password for sio4:
5
+ # ls /bin/bash
6
+ /bin/bash
7
+ #
8
+ # exit
9
+ logout
10
+ $
@@ -0,0 +1,12 @@
1
+ {foo bar='single quotes' baz="double quotes" test3=$test3}
2
+
3
+ <ul>
4
+ {foreach from=$myvariable item=data}
5
+ <li>{$data.field}</li>
6
+ {foreachelse}
7
+ <li>No Data</li>
8
+ {/foreach}
9
+ </ul>
10
+
11
+ <div class="{if $foo}class1{else}class2{/if}">{$foo.bar.baz}</div>
12
+
@@ -0,0 +1,5 @@
1
+ ok 1 - Input file opened
2
+ not ok 2 - First line of the input valid
3
+ ok 3 - Read the rest of the file
4
+ not ok 4 - Summarized correctly # TODO Not written yet
5
+ 1..4
@@ -0,0 +1,9 @@
1
+ {% include 'header.html' %}
2
+
3
+ {% for user in users %}
4
+ * {{ user.name }}
5
+ {% else %}
6
+ No users have been found.
7
+ {% endfor %}
8
+
9
+ {% include 'footer.html' %}
@@ -0,0 +1 @@
1
+ $(document).ready(function() { alert('ready!'); });
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Verilog Lexer
3
+ */
4
+ module Foo(
5
+ input logic Clk_CI,
6
+ input logic Rst_RBI,
7
+ input logic A,
8
+ input logic B,
9
+ output logic C
10
+ );
11
+ logic C_DN, C_DP;
12
+
13
+ assign C = C_DP;
14
+
15
+ always_comb begin : proc_next_state
16
+ C_DN = A + B;
17
+ end
18
+
19
+ // Clocked process
20
+ always_ff @(posedge Clk_CI, negedge Rst_RBI) begin
21
+ if(~Rst_RBI) begin
22
+ C_DP <= 1'b0;
23
+ end else begin
24
+ C_DP <= C_DN;
25
+ end
26
+ end
27
+ endmodule
@@ -1,5 +1,14 @@
1
- set encoding=utf-8
2
-
3
- filetype off
4
- call pathogen#runtime_append_all_bundles()
5
- filetype plugin indent on
1
+ function! s:Make(dir, make, format, name) abort
2
+ let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
3
+ let cwd = getcwd()
4
+ let [mp, efm, cc] = [&l:mp, &l:efm, get(b:, 'current_compiler', '')]
5
+ try
6
+ execute cd fnameescape(dir)
7
+ let [&l:mp, &l:efm, b:current_compiler] = [a:make, a:format, a:compiler]
8
+ execute (exists(':Make') == 2 ? 'Make' : 'make')
9
+ finally
10
+ let [&l:mp, &l:efm, b:current_compiler] = [mp, efm, cc]
11
+ if empty(cc) | unlet! b:current_compiler | endif
12
+ execute cd fnameescape(cwd)
13
+ endtry
14
+ endfunction
@@ -0,0 +1,11 @@
1
+ module Rouge
2
+ module Formatters
3
+ class HTMLWrapper
4
+ def initialize(open, formatter, close)
5
+ @open = open
6
+ @formatter = formatter
7
+ @close = close
8
+ end
9
+ end
10
+ end
11
+ end
@@ -155,7 +155,7 @@ module Rouge
155
155
  # private
156
156
  def escape_sequence(token)
157
157
  @escape_sequences ||= {}
158
- @escape_sequences[token.name] ||=
158
+ @escape_sequences[token.qualname] ||=
159
159
  EscapeSequence.new(get_style(token))
160
160
  end
161
161
 
@@ -124,9 +124,11 @@ module Rouge
124
124
  # the analysis more.
125
125
  source_threshold = lexers.size < total_size ? 0 : 0.5
126
126
  return [best_by_source(lexers, source, source_threshold)].compact
127
+ elsif lexers.size < total_size
128
+ return lexers
129
+ else
130
+ return []
127
131
  end
128
-
129
- []
130
132
  end
131
133
 
132
134
  class AmbiguousGuess < StandardError