rouge 3.11.1 → 3.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge/demos/minizinc +23 -0
- data/lib/rouge/lexer.rb +3 -0
- data/lib/rouge/lexers/eex.rb +2 -1
- data/lib/rouge/lexers/markdown.rb +7 -1
- data/lib/rouge/lexers/mason.rb +0 -5
- data/lib/rouge/lexers/minizinc.rb +87 -0
- data/lib/rouge/plugins/redcarpet.rb +7 -1
- data/lib/rouge/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 627bdb5578c0590a77e598473fcbe69330f21066cb87bd3463c2acabf31ac950
|
4
|
+
data.tar.gz: d28c6ae9d3a94d4cd81e1e7cd4ba883aa6a41d011569cd3051f140288bed70d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27fc73f1c40e471cb1120f6dab17700fb8155b1a4518c783374088725d35afe896a382e2ec2dd8690505bbe8eaf519396a4e5b4b6154816455b5865be7275244
|
7
|
+
data.tar.gz: 46e1d31f4df9486d498b8bc91b9fee28bfac7681b4acd276bbd084baf5a186ee2324c3fe16626f59df054e43e332b4fbb865115e7fb440b3acb4b3a6a0c0465e
|
@@ -0,0 +1,23 @@
|
|
1
|
+
% from MiniZinc Handbook:
|
2
|
+
% https://www.minizinc.org/doc-latest/en/modelling.html
|
3
|
+
|
4
|
+
% Colouring Australia using nc colours
|
5
|
+
int: nc = 3;
|
6
|
+
|
7
|
+
var 1..nc: wa; var 1..nc: nt; var 1..nc: sa; var 1..nc: q;
|
8
|
+
var 1..nc: nsw; var 1..nc: v; var 1..nc: t;
|
9
|
+
|
10
|
+
constraint wa != nt;
|
11
|
+
constraint wa != sa;
|
12
|
+
constraint nt != sa;
|
13
|
+
constraint nt != q;
|
14
|
+
constraint sa != q;
|
15
|
+
constraint sa != nsw;
|
16
|
+
constraint sa != v;
|
17
|
+
constraint q != nsw;
|
18
|
+
constraint nsw != v;
|
19
|
+
solve satisfy;
|
20
|
+
|
21
|
+
output ["wa=\(wa)\t nt=\(nt)\t sa=\(sa)\n",
|
22
|
+
"q=\(q)\t nsw=\(nsw)\t v=\(v)\n",
|
23
|
+
"t=", show(t), "\n"];
|
data/lib/rouge/lexer.rb
CHANGED
@@ -49,6 +49,9 @@ module Rouge
|
|
49
49
|
#
|
50
50
|
# Lexer.find_fancy('guess', "#!/bin/bash\necho Hello, world")
|
51
51
|
#
|
52
|
+
# If the code matches more than one lexer then Guesser::Ambiguous
|
53
|
+
# is raised.
|
54
|
+
#
|
52
55
|
# This is used in the Redcarpet plugin as well as Rouge's own
|
53
56
|
# markdown lexer for highlighting internal code blocks.
|
54
57
|
#
|
data/lib/rouge/lexers/eex.rb
CHANGED
@@ -34,7 +34,13 @@ module Rouge
|
|
34
34
|
|
35
35
|
rule %r/^([ \t]*)(```|~~~)([^\n]*\n)((.*?)(\2))?/m do |m|
|
36
36
|
name = m[3].strip
|
37
|
-
sublexer =
|
37
|
+
sublexer =
|
38
|
+
begin
|
39
|
+
Lexer.find_fancy(name.empty? ? "guess" : name, m[5], @options)
|
40
|
+
rescue Guesser::Ambiguous => e
|
41
|
+
e.alternatives.first.new(@options)
|
42
|
+
end
|
43
|
+
|
38
44
|
sublexer ||= PlainText.new(@options.merge(:token => Str::Backtick))
|
39
45
|
sublexer.reset!
|
40
46
|
|
data/lib/rouge/lexers/mason.rb
CHANGED
@@ -15,11 +15,6 @@ module Rouge
|
|
15
15
|
@perl = Perl.new
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.detect?(text)
|
19
|
-
return false if text.doctype?(/((?:ht|x)ml)/)
|
20
|
-
return true if text.doctype?
|
21
|
-
end
|
22
|
-
|
23
18
|
# Note: If you add a tag in the lines below, you also need to modify "disambiguate '*.m'" in file disambiguation.rb
|
24
19
|
TEXT_BLOCKS = %w(text doc)
|
25
20
|
PERL_BLOCKS = %w(args flags attr init once shared perl cleanup filter)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Based on Chroma's MiniZinc lexer:
|
5
|
+
# https://github.com/alecthomas/chroma/blob/5152194c717b394686d3d7a7e1946a360ec0728f/lexers/m/minizinc.go
|
6
|
+
|
7
|
+
module Rouge
|
8
|
+
module Lexers
|
9
|
+
class MiniZinc < RegexLexer
|
10
|
+
title "MiniZinc"
|
11
|
+
desc "MiniZinc is a free and open-source constraint modeling language (minizinc.org)"
|
12
|
+
tag 'minizinc'
|
13
|
+
filenames '*.mzn', '*.fzn', '*.dzn'
|
14
|
+
mimetypes 'text/minizinc'
|
15
|
+
|
16
|
+
def self.builtins
|
17
|
+
@builtins = Set.new %w[
|
18
|
+
abort abs acosh array_intersect array_union array1d array2d array3d
|
19
|
+
array4d array5d array6d asin assert atan bool2int card ceil concat
|
20
|
+
cos cosh dom dom_array dom_size fix exp floor index_set
|
21
|
+
index_set_1of2 index_set_2of2 index_set_1of3 index_set_2of3
|
22
|
+
index_set_3of3 int2float is_fixed join lb lb_array length ln log log2
|
23
|
+
log10 min max pow product round set2array show show_int show_float
|
24
|
+
sin sinh sqrt sum tan tanh trace ub ub_array
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.keywords
|
29
|
+
@keywords = Set.new %w[
|
30
|
+
ann annotation any constraint else endif function for forall if
|
31
|
+
include list of op output minimize maximize par predicate record
|
32
|
+
satisfy solve test then type var where
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.keywords_type
|
37
|
+
@keywords_type ||= Set.new %w(
|
38
|
+
array set bool enum float int string tuple
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.operators
|
43
|
+
@operators ||= Set.new %w(
|
44
|
+
in subset superset union diff symdiff intersect
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
id = /[$a-zA-Z_]\w*/
|
49
|
+
|
50
|
+
state :root do
|
51
|
+
rule %r(\s+)m, Text::Whitespace
|
52
|
+
rule %r(\\\n)m, Text::Whitespace
|
53
|
+
rule %r(%.*), Comment::Single
|
54
|
+
rule %r(/(\\\n)?[*](.|\n)*?[*](\\\n)?/)m, Comment::Multiline
|
55
|
+
rule %r/"(\\\\|\\"|[^"])*"/, Literal::String
|
56
|
+
|
57
|
+
rule %r(not|<->|->|<-|\\/|xor|/\\), Operator
|
58
|
+
rule %r(<|>|<=|>=|==|=|!=), Operator
|
59
|
+
rule %r(\+|-|\*|/|div|mod), Operator
|
60
|
+
rule %r(\\|\.\.|\+\+), Operator
|
61
|
+
rule %r([|()\[\]{},:;]), Punctuation
|
62
|
+
rule %r((true|false)\b), Keyword::Constant
|
63
|
+
rule %r(([+-]?)\d+(\.(?!\.)\d*)?([eE][-+]?\d+)?), Literal::Number
|
64
|
+
|
65
|
+
rule id do |m|
|
66
|
+
if self.class.keywords.include? m[0]
|
67
|
+
token Keyword
|
68
|
+
elsif self.class.keywords_type.include? m[0]
|
69
|
+
token Keyword::Type
|
70
|
+
elsif self.class.builtins.include? m[0]
|
71
|
+
token Name::Builtin
|
72
|
+
elsif self.class.operators.include? m[0]
|
73
|
+
token Operator
|
74
|
+
else
|
75
|
+
token Name::Other
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
rule %r(::\s*([^\W\d]\w*)(\s*\([^\)]*\))?), Name::Decorator
|
80
|
+
rule %r(\b([^\W\d]\w*)\b(\()) do
|
81
|
+
groups Name::Function, Punctuation
|
82
|
+
end
|
83
|
+
rule %r([^\W\d]\w*), Name::Other
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -9,7 +9,13 @@ module Rouge
|
|
9
9
|
module Plugins
|
10
10
|
module Redcarpet
|
11
11
|
def block_code(code, language)
|
12
|
-
lexer =
|
12
|
+
lexer =
|
13
|
+
begin
|
14
|
+
Lexer.find_fancy(language, code)
|
15
|
+
rescue Guesser::Ambiguous => e
|
16
|
+
e.alternatives.first
|
17
|
+
end
|
18
|
+
lexer ||= Lexers::PlainText
|
13
19
|
|
14
20
|
# XXX HACK: Redcarpet strips hard tabs out of code blocks,
|
15
21
|
# so we assume you're not using leading spaces that aren't tabs,
|
data/lib/rouge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rouge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeanine Adkisson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
|
14
14
|
email:
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/rouge/demos/mason
|
125
125
|
- lib/rouge/demos/mathematica
|
126
126
|
- lib/rouge/demos/matlab
|
127
|
+
- lib/rouge/demos/minizinc
|
127
128
|
- lib/rouge/demos/moonscript
|
128
129
|
- lib/rouge/demos/mosel
|
129
130
|
- lib/rouge/demos/msgtrans
|
@@ -323,6 +324,7 @@ files:
|
|
323
324
|
- lib/rouge/lexers/mathematica/builtins.rb
|
324
325
|
- lib/rouge/lexers/matlab.rb
|
325
326
|
- lib/rouge/lexers/matlab/builtins.yml
|
327
|
+
- lib/rouge/lexers/minizinc.rb
|
326
328
|
- lib/rouge/lexers/moonscript.rb
|
327
329
|
- lib/rouge/lexers/mosel.rb
|
328
330
|
- lib/rouge/lexers/msgtrans.rb
|