latex-decode 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f075a3a6e28fdeb92c9dba6486f56c461936a5a9
4
- data.tar.gz: 27de3bebcc186f328d8bb6122357933a51baef51
2
+ SHA256:
3
+ metadata.gz: 1c01f8f064a264d72d7d3a94e4f1b1b9f911756390eb2bc669e4586674b4d2ae
4
+ data.tar.gz: 8305a76f2fe47be9c3027f24d7c9354fdafebf90c8a1c4e3b27421934517cfb0
5
5
  SHA512:
6
- metadata.gz: 6810f6ecdddf8d2b27e0bc8b9b80ef1277b3ac1270fa0901f1936edb057a0e19471c8a61768623df8e33661106103a1bebb00963425f324f68fde763a3aada53
7
- data.tar.gz: 93f809598a9dbb63331c52c6e0b76a866a68103cdca6783ec468eced7b23e937907eae56fcd3f54230fc8b17f45d9047671a0fffe273555896b53efa8f62b7fb
6
+ metadata.gz: e53e8ee74e70d711b337a5ef81734a921b5dd89ef9e41e50d94f4a6f2cbd8b9834ff0930a822659a42b87b6c2771104e947d5315a2cd5c22c9b4d66d451daf6e
7
+ data.tar.gz: c50fa7ef133fdb373b2ea9399dd46c1a7181cd01a697a11299735956525fec8e551028d7db018f4e02deb81fb91bf6f4b2d717196002c4593ee6932c1f9c801a
@@ -0,0 +1,40 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ build:
11
+ environment: CI
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby-version:
17
+ - '2.7'
18
+ - '3.0'
19
+ - '3.1'
20
+ - 'jruby'
21
+
22
+ steps:
23
+ - name: Git checkout
24
+ uses: actions/checkout@v2
25
+
26
+ - name: Setup Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ bundler-cache: true
31
+
32
+ - name: Run tests
33
+ run: bundle exec rake
34
+
35
+ - name: Upload coverage results
36
+ if: matrix.ruby-version == '3.1'
37
+ continue-on-error: true
38
+ uses: coverallsapp/github-action@master
39
+ with:
40
+ github-token: ${{ github.token }}
data/.simplecov ADDED
@@ -0,0 +1,18 @@
1
+ require 'simplecov-lcov'
2
+
3
+ SimpleCov::Formatter::LcovFormatter.config do |c|
4
+ c.output_directory = 'coverage'
5
+ c.lcov_file_name = 'lcov.info'
6
+ c.report_with_single_file = true
7
+ end
8
+
9
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
10
+ SimpleCov::Formatter::HTMLFormatter,
11
+ SimpleCov::Formatter::LcovFormatter
12
+ ])
13
+
14
+ SimpleCov.start do
15
+ add_filter 'features/'
16
+
17
+ enable_coverage :branch
18
+ end
data/Gemfile CHANGED
@@ -3,19 +3,14 @@ gemspec
3
3
 
4
4
  group :test do
5
5
  gem 'rake'
6
- gem 'rspec', '~> 3.0'
7
- gem 'cucumber', '~> 1.3'
6
+ gem 'rspec'
7
+ gem 'cucumber'
8
+ gem 'simplecov', platform: 'mri'
9
+ gem 'simplecov-lcov', platform: 'mri'
8
10
  end
9
11
 
10
12
  group :debug do
11
- gem 'debugger', :platforms => :mri_19
12
- gem 'byebug', :platforms => :mri if RUBY_VERSION > '2.0'
13
-
14
- gem 'rubinius-debugger', :require => false, :platforms => :rbx
15
- gem 'rubinius-compiler', :require => false, :platforms => :rbx
13
+ gem 'debug', platform: 'mri'
16
14
  end
17
15
 
18
- gem 'unicode', '~> 0.4', :platforms => [:mri, :rbx, :mswin, :mingw] if RUBY_VERSION < '2.4'
19
16
  gem 'ritex', '~> 1.0.1'
20
-
21
- gem 'rubysl', '~> 2.0', :platforms => :rbx
data/README.md CHANGED
@@ -1,38 +1,30 @@
1
1
  LaTeX::Decode
2
2
  =============
3
+ [![ci](https://github.com/inukshuk/latex-decode/actions/workflows/ci.yml/badge.svg)](https://github.com/inukshuk/latex-decode/actions/workflows/ci.yml)
4
+ [![coverage](https://coveralls.io/repos/github/inukshuk/latex-decode/badge.svg?branch=main)](https://coveralls.io/github/inukshuk/latex-decode?branch=main)
3
5
 
4
- [![Build Status](https://travis-ci.org/inukshuk/latex-decode.png?branch=master)](https://travis-ci.org/inukshuk/latex-decode)
5
-
6
- LaTeX::Decode is a Ruby gem to convert LaTeX input to Unicode. Its original
7
- use was as an input filter for [BibTeX-Ruby](http://rubygems.org/gems/bibtex-ruby)
8
- but can be used independently to decode LaTeX. Many of the patterns used by
9
- this Ruby gem are based on François Charette's equivalent Perl module
10
- [LaTeX::Decode](https://github.com/fc7/LaTeX-Decode).
6
+ LaTeX::Decode is a Ruby gem to convert LaTeX input to Unicode.
7
+ Its original use was as an input filter for [BibTeX-Ruby][]
8
+ but it can be used independently to decode LaTeX.
9
+ Many of the patterns used by this Ruby gem
10
+ are based on François Charette's equivalent Perl module [LaTeX::Decode][].
11
11
 
12
12
  Quickstart
13
13
  ----------
14
-
15
14
  $ [sudo] gem install latex-decode
16
15
  $ irb
17
16
  >> require 'latex/decode'
18
17
  >> LaTeX.decode "dipl\\^{o}me d'\\'{e}tudes sup\\'erieures"
19
18
  => "diplôme d'études supérieures"
20
19
 
21
- Compatibility
22
- -------------
23
-
24
- Unicode handling is one of the major differences between Ruby 1.8 and newer
25
- version; LaTeX::Decode; nevertheless, we try to support 1.8 as best as possible.
26
20
 
27
21
  Issues
28
22
  ------
29
-
30
- Please use the tracker of the project's
31
- [GitHub repository](https://github.com/inukshuk/latex-decode) to report any
32
- issues. When describing intended behaviour, please use the extremely simple
33
- syntax of the Cucumber features used by LaTeX::Decode; for instance, you could
34
- describe the example above as:
35
-
23
+ Please use the tracker of the project's [repository][] to report any issues.
24
+ When describing intended behaviour,
25
+ please use the syntax of the Cucumber features used by LaTeX::Decode.
26
+ For instance, you could describe the example above as:
27
+ ```Gherkin
36
28
  Feature: Decode LaTeX accents
37
29
  As a hacker who works with LaTeX
38
30
  I want to be able to decode LaTeX accents
@@ -40,26 +32,19 @@ describe the example above as:
40
32
  Scenario: A French sentence
41
33
  When I decode the string "dipl\\^{o}me d'\\'{e}tudes sup\\'erieures"
42
34
  Then the result should be "diplôme d'études supérieures"
35
+ ```
43
36
 
44
37
  Credits
45
38
  -------
39
+ Kudos and thanks to all [contributors][] who have made LaTeX::Decode possible!
46
40
 
47
- Kudos and thanks to all [contributors](https://github.com/inukshuk/latex-decode/contributors)
48
- who have made LaTeX::Decode possible!
49
-
50
- Copyright (C) 2011-2015 [Sylvester Keil](sylvester.keil.or.at)
51
-
41
+ Copyright (C) 2011-2022 Sylvester Keil
52
42
  Copyright (C) 2010 François Charette
53
43
 
54
- This program is free software: you can redistribute it and/or modify
55
- it under the terms of the GNU General Public License as published by
56
- the Free Software Foundation, either version 3 of the License, or
57
- (at your option) any later version.
58
44
 
59
- This program is distributed in the hope that it will be useful,
60
- but WITHOUT ANY WARRANTY; without even the implied warranty of
61
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62
- GNU General Public License for more details.
45
+ [BibTeXRuby]: http://rubygems.org/gems/bibtex-ruby
46
+ [LaTeX::Decode]: https://github.com/fc7/LaTeX-Decode
63
47
 
64
- You should have received a copy of the GNU General Public License
65
- along with this program. If not, see <http://www.gnu.org/licenses/>.
48
+ [repository]: https://github.com/inukshuk/latex-decode
49
+ [contributors]: https://github.com/inukshuk/latex-decode/contributors
50
+ [LICENSE]: https://github.com/inukshuk/latex-decode/blob/main/LICENSE
data/Rakefile CHANGED
@@ -29,13 +29,10 @@ Cucumber::Rake::Task.new(:cucumber)
29
29
 
30
30
  task :release do |t|
31
31
  system "gem build latex-decode.gemspec"
32
- system "git tag #{LaTeX::Decode::VERSION}"
32
+ system "git tag v#{LaTeX::Decode::VERSION}"
33
33
  system "git push --tags"
34
34
  system "gem push latex-decode-#{LaTeX::Decode::VERSION}.gem"
35
35
  system "rm latex-decode-#{LaTeX::Decode::VERSION}.gem"
36
- system "jgem build latex-decode.gemspec"
37
- system "jgem push latex-decode-#{LaTeX::Decode::VERSION}.gem"
38
- system "rm latex-decode-#{LaTeX::Decode::VERSION}-java.gem"
39
36
  end
40
37
 
41
38
  task :default => :cucumber
data/cucumber.yml CHANGED
@@ -1 +1 @@
1
- default: --format progress --require features --color
1
+ default: --format progress --require features --color --publish-quiet
@@ -5,3 +5,8 @@ end
5
5
  Then /^the result should be ('|")(.*)\1$/ do |quote,value|
6
6
  expect(@result).to eq(value)
7
7
  end
8
+
9
+ # For whitespace or other characters that are hard to read in source code:
10
+ Then /^I should get '([^']*)' \+ U\+(\h{4,}) \+ '([^']*)'$/ do |pre,code,post|
11
+ expect(@result).to eq(pre + code.hex.chr(Encoding::UTF_8) + post)
12
+ end
@@ -1,12 +1,11 @@
1
1
  begin
2
- case
3
- when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
4
- require 'rubinius/debugger'
5
- when RUBY_VERSION > '2.0'
6
- require 'byebug'
7
- else
8
- require 'debugger'
9
- end
2
+ require 'simplecov'
3
+ rescue LoadError
4
+ # ignore
5
+ end
6
+
7
+ begin
8
+ require 'debug'
10
9
  rescue LoadError
11
10
  # ignore
12
11
  end
@@ -12,10 +12,3 @@ Feature: Decode LaTeX symbol directives
12
12
  | \\uparrow | ↑ |
13
13
  | \\downarrow | ↓ |
14
14
  | \\rightarrow | → |
15
-
16
- Scenarios: Whitespace
17
- | latex | unicode | description |
18
- | x\\,x | x x | small space |
19
- | x~x | x x | non-breaking space |
20
- | ~x |  x | non-breaking space |
21
-
@@ -0,0 +1,28 @@
1
+ Feature: Decode LaTeX whitespace directives
2
+ As a hacker who works with LaTeX
3
+ I want to be able to decode LaTeX whitespace
4
+
5
+ Scenario Outline: LaTeX to Unicode transformation
6
+ When I decode the string '<latex>'
7
+ Then I should get <pre> + U+<code> + <post>
8
+
9
+ Scenarios: Whitespace
10
+ | latex | pre | code | post | description |
11
+ | x~x | 'x' | 00A0 | 'x' | non-breaking space |
12
+ | ~y | '' | 00A0 | 'y' | leading non-breaking space |
13
+ | z\\,z | 'z' | 202F | 'z' | narrow no-break space |
14
+
15
+ # In LaTeX, `\,` produces a kern that is ⅙ em wide. A kern is a
16
+ # non-breaking space that is not subject to compression or expansion when
17
+ # determining optimal line breaks. The ideal representation might be a
18
+ # non-breaking variant of U+2006 Six-Per-Em Space, but the best option
19
+ # that exists seems to be U+202F Narrow No-Break Space. While U+202F
20
+ # doesn't have an explicit width, Unicode Standard Annex #14, “Unicode
21
+ # Line Breaking Algorithm,” revision 47, says:
22
+ #
23
+ # > When expanding or compressing interword space according to common
24
+ # > typographical practice, only the spaces marked by U+0020 SPACE and
25
+ # > U+00A0 NO-BREAK SPACE are subject to compression, and only spaces
26
+ # > marked by U+0020 SPACE, U+00A0 NO-BREAK SPACE, and occasionally spaces
27
+ # > marked by U+2009 THIN SPACE are subject to expansion. All other space
28
+ # > characters normally have fixed width.
data/latex-decode.gemspec CHANGED
@@ -8,17 +8,11 @@ Gem::Specification.new do |s|
8
8
  s.name = 'latex-decode'
9
9
  s.version = LaTeX::Decode::VERSION.dup
10
10
  s.authors = ['Sylvester Keil']
11
- s.email = ['http://sylvester.keil.or.at']
12
11
  s.homepage = 'http://github.com/inukshuk/latex-decode'
13
12
  s.summary = 'Decodes LaTeX to Unicode.'
14
13
  s.description = 'Decodes strings formatted in LaTeX to equivalent Unicode strings.'
15
14
  s.license = 'GPL-3.0'
16
-
17
- if RUBY_PLATFORM =~ /java/
18
- s.platform = 'java'
19
- else
20
- s.platform = 'ruby'
21
- end
15
+ s.platform = 'ruby'
22
16
 
23
17
  s.files = `git ls-files`.split("\n")
24
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -7,7 +7,7 @@ module LaTeX
7
7
  class << self
8
8
  attr_reader :patterns, :map
9
9
 
10
- def inherited (base)
10
+ def inherited(base)
11
11
  subclasses << base
12
12
  end
13
13
 
@@ -15,11 +15,11 @@ module LaTeX
15
15
  @subclasses ||= []
16
16
  end
17
17
 
18
- def decode (string)
18
+ def decode(string)
19
19
  decode!(string.dup)
20
20
  end
21
21
 
22
- def decode! (string)
22
+ def decode!(string)
23
23
  patterns.each do |pattern|
24
24
  string.gsub!(pattern) { |m| [$2,map[$1],$3].compact.join }
25
25
  end
@@ -32,7 +32,7 @@ module LaTeX
32
32
 
33
33
  module_function
34
34
 
35
- def normalize (string)
35
+ def normalize(string)
36
36
  string.gsub!(/\\(?:i|j)\b/) { |m| m == '\\i' ? 'ı' : 'ȷ' }
37
37
 
38
38
  # \foo\ bar -> \foo{} bar
@@ -50,7 +50,7 @@ module LaTeX
50
50
  string
51
51
  end
52
52
 
53
- def strip_braces (string)
53
+ def strip_braces(string)
54
54
  string.gsub!(/(^|[^\\])([\{\}]+)/, '\1')
55
55
  string.gsub!(/\\(\{|\})/, '\1')
56
56
  string
@@ -33,7 +33,7 @@ if RUBY_PLATFORM == 'java'
33
33
  end
34
34
 
35
35
  else
36
- if RUBY_VERSION >= '2.4'
36
+ if RUBY_VERSION >= '2.3'
37
37
  module LaTeX
38
38
  def self.normalize_C(string)
39
39
  string.unicode_normalize(:nfc)
@@ -6,7 +6,7 @@ module LaTeX
6
6
  /\$([^\$]+)\$/
7
7
  ].freeze
8
8
 
9
- def self.decode! (string)
9
+ def self.decode!(string)
10
10
  patterns.each do |pattern|
11
11
  string.gsub!(pattern) do
12
12
  LaTeX.to_math_ml($1)
@@ -211,7 +211,7 @@ module LaTeX
211
211
  tone2 ˨
212
212
  tone1 ˩
213
213
  ss ß
214
- , \u2009
214
+ , \u202F
215
215
  }.map { |s| LaTeX.to_unicode(s) }].freeze
216
216
 
217
217
 
@@ -1,5 +1,5 @@
1
1
  module LaTeX
2
2
  module Decode
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
data/lib/latex/decode.rb CHANGED
@@ -31,7 +31,7 @@ require 'latex/decode/greek'
31
31
  module LaTeX
32
32
 
33
33
  class << self
34
- def decode (string)
34
+ def decode(string)
35
35
  return string unless string.respond_to?(:to_s)
36
36
 
37
37
  string = string.is_a?(String) ? string.dup : string.to_s
metadata CHANGED
@@ -1,26 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latex-decode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-03 00:00:00.000000000 Z
11
+ date: 2022-07-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Decodes strings formatted in LaTeX to equivalent Unicode strings.
14
14
  email:
15
- - http://sylvester.keil.or.at
16
15
  executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files:
19
18
  - README.md
20
19
  - LICENSE
21
20
  files:
21
+ - ".github/workflows/ci.yml"
22
22
  - ".gitignore"
23
- - ".travis.yml"
23
+ - ".simplecov"
24
24
  - Gemfile
25
25
  - LICENSE
26
26
  - README.md
@@ -37,6 +37,7 @@ files:
37
37
  - features/support/env.rb
38
38
  - features/symbols.feature
39
39
  - features/umlauts.feature
40
+ - features/whitespace.feature
40
41
  - latex-decode.gemspec
41
42
  - lib/latex/decode.rb
42
43
  - lib/latex/decode/accents.rb
@@ -52,7 +53,7 @@ homepage: http://github.com/inukshuk/latex-decode
52
53
  licenses:
53
54
  - GPL-3.0
54
55
  metadata: {}
55
- post_install_message:
56
+ post_install_message:
56
57
  rdoc_options:
57
58
  - "--line-numbers"
58
59
  - "--inline-source"
@@ -74,9 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.6.12
79
- signing_key:
78
+ rubygems_version: 3.2.15
79
+ signing_key:
80
80
  specification_version: 4
81
81
  summary: Decodes LaTeX to Unicode.
82
82
  test_files:
@@ -91,3 +91,4 @@ test_files:
91
91
  - features/support/env.rb
92
92
  - features/symbols.feature
93
93
  - features/umlauts.feature
94
+ - features/whitespace.feature
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- language: ruby
2
- bundler_args: --without debug
3
- sudo: false
4
- cache: bundler
5
- rvm:
6
- - 2.0.0
7
- - 2.1.0
8
- - 2.2.0
9
- - 2.4.0
10
- - jruby-19mode
11
- - jruby-head
12
- - rbx-2
13
- notifications:
14
- email:
15
- recipients:
16
- - sylvester@keil.or.at
17
- on_success: change
18
- on_failure: always