textpow1x 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- before_script:
1
+ before_install:
2
2
  - sudo apt-get install -y libonig-dev && bundle install
3
3
  script: "bundle exec rake"
4
4
  rvm:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- textpow1x (1.2.4)
4
+ textpow1x (1.2.5)
5
5
  plist (>= 3.0.1)
6
6
 
7
7
  GEM
@@ -76,6 +76,7 @@ having <tt>name="text.string", position=10</tt> and the second having
76
76
  <tt>"markup.string"</tt> tag is inside the <tt>"text.string"</tt> tag.
77
77
 
78
78
  == TODO
79
+ * smart + mel + applescript have some invalid utf8 characters that are currently ignored (search for INVALID_UTF8))
79
80
  * fix markdown and php syntax
80
81
  * parse text plist files {example}[https://raw.github.com/kangax/textmate-js-language-syntax-file/master/JavaScript.plist]
81
82
  * update more languages via github urls
@@ -90,17 +90,7 @@ module Textpow
90
90
  table.each do |key, value|
91
91
  case key
92
92
  when "firstLineMatch", "foldingStartMarker", "foldingStopMarker", "match", "begin"
93
- begin
94
- regex = if Textpow::RUBY_19
95
- value.force_encoding("ASCII-8BIT")
96
- Regexp.new(value)
97
- else
98
- Oniguruma::ORegexp.new(value, :options => Oniguruma::OPTION_CAPTURE_GROUP)
99
- end
100
- instance_variable_set("@#{key}", regex)
101
- rescue RegexpError, ArgumentError => e
102
- raise ParsingError, "Parsing error in #{value}: #{e.to_s}"
103
- end
93
+ instance_variable_set("@#{key}", parse_regex(value))
104
94
  when "content", "fileTypes", "name", "contentName", "end", "scopeName", "keyEquivalent"
105
95
  instance_variable_set("@#{key}", value)
106
96
  when "captures", "beginCaptures", "endCaptures"
@@ -116,6 +106,27 @@ module Textpow
116
106
  end
117
107
  end
118
108
 
109
+ def parse_regex(value)
110
+ if Textpow::RUBY_19
111
+ parse_regex_with_invalid_chars(value)
112
+ else
113
+ Oniguruma::ORegexp.new(value, :options => Oniguruma::OPTION_CAPTURE_GROUP)
114
+ end
115
+ rescue RegexpError, ArgumentError => e
116
+ raise ParsingError, "Parsing error in #{value}: #{e.to_s}"
117
+ end
118
+
119
+ def parse_regex_with_invalid_chars(value)
120
+ Regexp.new(value.force_encoding('UTF-8'))
121
+ rescue RegexpError => e
122
+ if e.message =~ /UTF-8/ or e.message =~ /invalid multibyte escape/
123
+ puts "Ignored utf8 regex error #{$!}"
124
+ /INVALID_UTF8/
125
+ else
126
+ raise e
127
+ end
128
+ end
129
+
119
130
  # register in global syntax list -> can be found by include
120
131
  def register_in_syntaxes(scope)
121
132
  @@syntaxes[@name_space] ||= {}
@@ -124,7 +135,6 @@ module Textpow
124
135
 
125
136
  def self.convert_file_to_table(file)
126
137
  raise "File not found: #{file}" unless File.exist?(file)
127
-
128
138
  case file
129
139
  when /(\.tmSyntax|\.plist)$/
130
140
  require 'plist'
@@ -1,3 +1,3 @@
1
1
  module Textpow
2
- VERSION = Version = "1.2.4"
2
+ VERSION = Version = "1.2.5"
3
3
  end
@@ -0,0 +1 @@
1
+ ü
@@ -10,9 +10,13 @@ describe "syntax files" do
10
10
  end
11
11
 
12
12
  Dir["#{Textpow.syntax_path}/*.syntax"].each do |syntax|
13
- it "#{syntax} can parse" do
13
+ it "can parse with #{syntax}" do
14
14
  Textpow.syntax(syntax).parse("xxx\n1 + 1\n### xxx")
15
15
  end
16
+
17
+ it "can parse UTF-8 with #{syntax}" do
18
+ Textpow.syntax(syntax).parse(File.read("spec/fixtures/utf8.txt"))
19
+ end
16
20
  end
17
21
 
18
22
  xit "parses markdown" do
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: textpow1x
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.5
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 4
10
- version: 1.2.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dizan Vasquez
14
9
  - Spox
15
10
  - Chris Hoffman
@@ -17,37 +12,33 @@ authors:
17
12
  autorequire:
18
13
  bindir: bin
19
14
  cert_chain: []
20
-
21
- date: 2011-11-02 00:00:00 -07:00
22
- default_executable:
23
- dependencies:
24
- - !ruby/object:Gem::Dependency
25
- type: :runtime
26
- requirement: &id001 !ruby/object:Gem::Requirement
15
+ date: 2012-05-05 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: plist
19
+ requirement: !ruby/object:Gem::Requirement
27
20
  none: false
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- hash: 5
32
- segments:
33
- - 3
34
- - 0
35
- - 1
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
36
24
  version: 3.0.1
37
- name: plist
38
- version_requirements: *id001
25
+ type: :runtime
39
26
  prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.1
40
33
  description: A library for parsing TextMate bundles on ruby 1.x
41
- email:
34
+ email:
42
35
  - michael@grosser.it
43
- executables:
36
+ executables:
44
37
  - plist2yaml
45
38
  - plist2syntax
46
39
  extensions: []
47
-
48
40
  extra_rdoc_files: []
49
-
50
- files:
41
+ files:
51
42
  - .travis.yml
52
43
  - Gemfile
53
44
  - Gemfile.lock
@@ -231,46 +222,51 @@ files:
231
222
  - lib/textpow/syntax/text.xml.xsl.syntax
232
223
  - lib/textpow/version.rb
233
224
  - spec/fixtures/objeck.plist
225
+ - spec/fixtures/utf8.txt
234
226
  - spec/spec_helper.rb
235
227
  - spec/textpow/score_manager_spec.rb
236
228
  - spec/textpow/syntax_files_spec.rb
237
229
  - spec/textpow/syntax_spec.rb
238
230
  - spec/textpow_spec.rb
239
231
  - textpow1x.gemspec
240
- has_rdoc: true
241
232
  homepage: http://github.com/grosser/textpow
242
- licenses:
233
+ licenses:
243
234
  - MIT
244
235
  post_install_message:
245
- rdoc_options:
236
+ rdoc_options:
246
237
  - --main
247
238
  - README.rdoc
248
- require_paths:
239
+ require_paths:
249
240
  - lib
250
- required_ruby_version: !ruby/object:Gem::Requirement
241
+ required_ruby_version: !ruby/object:Gem::Requirement
251
242
  none: false
252
- requirements:
253
- - - ">="
254
- - !ruby/object:Gem::Version
255
- hash: 3
256
- segments:
243
+ requirements:
244
+ - - ! '>='
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ segments:
257
248
  - 0
258
- version: "0"
259
- required_rubygems_version: !ruby/object:Gem::Requirement
249
+ hash: -742741068401622208
250
+ required_rubygems_version: !ruby/object:Gem::Requirement
260
251
  none: false
261
- requirements:
262
- - - ">="
263
- - !ruby/object:Gem::Version
264
- hash: 3
265
- segments:
252
+ requirements:
253
+ - - ! '>='
254
+ - !ruby/object:Gem::Version
255
+ version: '0'
256
+ segments:
266
257
  - 0
267
- version: "0"
258
+ hash: -742741068401622208
268
259
  requirements: []
269
-
270
260
  rubyforge_project:
271
- rubygems_version: 1.6.2
261
+ rubygems_version: 1.8.24
272
262
  signing_key:
273
263
  specification_version: 3
274
264
  summary: A library for parsing TextMate bundles on ruby 1.x
275
- test_files: []
276
-
265
+ test_files:
266
+ - spec/fixtures/objeck.plist
267
+ - spec/fixtures/utf8.txt
268
+ - spec/spec_helper.rb
269
+ - spec/textpow/score_manager_spec.rb
270
+ - spec/textpow/syntax_files_spec.rb
271
+ - spec/textpow/syntax_spec.rb
272
+ - spec/textpow_spec.rb