polytexnic 1.5.16 → 1.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 366c5378205e1d46c56fd6c6e7cf506fa2b2937ebded2743a60e0af437e51259
4
- data.tar.gz: 47bc5e5e8a67b75ec4bc183830083893be0c38c25ec627bee9aeec690ebfac8a
3
+ metadata.gz: 941f1eb78908726af53bd97f91cbcbfb528805328149e6d1b38e1b5cea42e0d1
4
+ data.tar.gz: bfdb4f07708016f5edf71bb4fce5438a513dfbf57a1d3de96a2aac91f445d1e0
5
5
  SHA512:
6
- metadata.gz: 5cd4a0ee09c5d5b5940d841ad38188b48a1c980dc3639c1a8c375349a18bfe2c7277e603ada6c7fd7be0435c987c44a91b80780ba562df8e4e2d5ae0424af74c
7
- data.tar.gz: 0d5943cea55ffa09f092e0f3b13c030abe716a3d1eaaf177ed577c99a6ff3811e65b7d32ae1deeb4068835f9073360cae0ed32e1e846a42d0b65a078c215456b
6
+ metadata.gz: d8eec9d8e3922e7950210938453e7f2a945c7afd225c20f83280003f62ffba4d1fcaa4a126e729135454d81dce11b1300e00e75b1a5039c5e4dc8b0e8947164a
7
+ data.tar.gz: a3e720691cdd208445f1e78e3050ca36030ec0421929f42d9cffd718752f237ae4f8ffae80ec3899c43f40eea29e6ced41bb5f2cc905a847124a0a63ed9fa42b
data/Gemfile CHANGED
@@ -24,4 +24,4 @@ end
24
24
  group :development do
25
25
  gem 'guard-rspec'
26
26
  gem 'rake'
27
- end
27
+ end
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polytexnic (1.5.16)
4
+ polytexnic (1.6.0)
5
5
  json (~> 2.3.0)
6
- kramdown (~> 1.17)
6
+ kramdown (>= 1.17, < 3.0)
7
7
  msgpack (~> 1.2.0)
8
8
  nokogiri (~> 1.10.8)
9
9
  pygments.rb (~> 1.2.1)
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- coderay (1.1.2)
14
+ coderay (1.1.3)
15
15
  columnize (0.9.0)
16
16
  coveralls (0.7.2)
17
17
  multi_json (~> 1.3)
@@ -23,9 +23,9 @@ GEM
23
23
  debugger2 (1.0.0.beta2)
24
24
  columnize (>= 0.3.1)
25
25
  debugger-linecache (~> 1.2.0)
26
- diff-lcs (1.3)
26
+ diff-lcs (1.4.4)
27
27
  docile (1.1.5)
28
- ffi (1.12.2)
28
+ ffi (1.13.1)
29
29
  formatador (0.2.5)
30
30
  growl (1.0.3)
31
31
  guard (2.16.2)
@@ -42,21 +42,22 @@ GEM
42
42
  guard (~> 2.1)
43
43
  guard-compat (~> 1.1)
44
44
  rspec (>= 2.99.0, < 4.0)
45
- json (2.3.0)
46
- kramdown (1.17.0)
45
+ json (2.3.1)
46
+ kramdown (2.3.0)
47
+ rexml
47
48
  listen (3.2.1)
48
49
  rb-fsevent (~> 0.10, >= 0.10.3)
49
50
  rb-inotify (~> 0.9, >= 0.9.10)
50
- lumberjack (1.2.4)
51
+ lumberjack (1.2.7)
51
52
  method_source (1.0.0)
52
53
  mime-types (3.3.1)
53
54
  mime-types-data (~> 3.2015)
54
- mime-types-data (3.2019.1009)
55
+ mime-types-data (3.2020.0512)
55
56
  mini_portile2 (2.4.0)
56
57
  msgpack (1.2.10)
57
- multi_json (1.14.1)
58
+ multi_json (1.15.0)
58
59
  nenv (0.3.0)
59
- nokogiri (1.10.9)
60
+ nokogiri (1.10.10)
60
61
  mini_portile2 (~> 2.4.0)
61
62
  notiffany (0.1.3)
62
63
  nenv (~> 0.1)
@@ -67,11 +68,12 @@ GEM
67
68
  pygments.rb (1.2.1)
68
69
  multi_json (>= 1.0.0)
69
70
  rake (13.0.1)
70
- rb-fsevent (0.10.3)
71
+ rb-fsevent (0.10.4)
71
72
  rb-inotify (0.10.1)
72
73
  ffi (~> 1.0)
73
74
  rest-client (1.6.7)
74
75
  mime-types (>= 1.16)
76
+ rexml (3.2.4)
75
77
  rspec (2.99.0)
76
78
  rspec-core (~> 2.99.0)
77
79
  rspec-expectations (~> 2.99.0)
@@ -1,19 +1,62 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "polytexnic"
3
+ require 'optparse'
4
+ require 'fileutils'
3
5
 
4
- def latex_to_html(latex)
5
- Polytexnic::Pipeline.new(latex, article: true).to_html
6
+ # polytexnic command-line script
7
+ # The polytexnic script converts Markdown to LaTeX
8
+ # using the PolyTeXnic HTML pipeline.
9
+
10
+ examples = %(Examples:
11
+ polytexnic example.md example.tex
12
+ polytexnic example.md > example.tex
13
+ polytexnic < example.md > example.tex
14
+ cat example.md | polytexnic > example.tex
15
+ polytexnic -f example.md > example.tex
16
+ polytexnic -f example.md -o example.tex)
17
+
18
+ options = {}
19
+ OptionParser.new do |opts|
20
+ opts.banner = "Usage: polytexnic [options]\n#{examples}\n\n"
21
+
22
+ opts.on("-i", "--input", "Use file input") do |infile|
23
+ options[:infile] = infile
24
+ end
25
+
26
+ opts.on("-o", "--output", "Use file output") do |outfile|
27
+ options[:outfile] = outfile
28
+ end
29
+
30
+ opts.on("-f", "--format", "Use output format [html, tex]") do |format|
31
+ options[:format] = format
32
+ end
33
+ end.parse!
34
+
35
+ # Returns the file format based on extension.
36
+ # Should be 'html' or 'tex'.
37
+ def format(filename)
38
+ filename.split('.').last
39
+ rescue
40
+ nil
6
41
  end
7
42
 
8
- if ARGV.empty?
9
- puts latex_to_html(STDIN.read)
43
+ if (infile = options[:infile] || ARGV.shift)
44
+ input = File.read(infile)
10
45
  else
11
- filename = ARGV.shift
12
- latex = File.read(filename)
13
- html = latex_to_html(latex)
14
- if (outfile = ARGV.shift)
15
- File.write(outfile, html)
16
- else
17
- puts html.strip
18
- end
46
+ input = STDIN.read
47
+ end
48
+ outfile = options[:outfile] || ARGV.shift
49
+ pipeline = Polytexnic::Pipeline.new(input, article: true)
50
+ format = options[:format] || format(outfile) || "html"
51
+ if format == "html"
52
+ output = pipeline.to_html
53
+ elsif format == "tex"
54
+ output = pipeline.to_polytex
55
+ else
56
+ raise ArgumentError, "Invalid format: #{format}"
57
+ end
58
+ if outfile
59
+ File.write(outfile, output)
60
+ else
61
+ puts output.strip
19
62
  end
@@ -95,7 +95,7 @@ module Polytexnic
95
95
  def small_caps(doc)
96
96
  doc.xpath('//hi[@rend="sc"]').each do |node|
97
97
  node.name = 'span'
98
- node['class'] = 'sc'
98
+ node['class'] = 'smallcaps'
99
99
  node.remove_attribute('rend')
100
100
  end
101
101
  end
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.5.16"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency 'nokogiri', '~> 1.10.8'
22
22
  gem.add_dependency 'pygments.rb', '~> 1.2.1'
23
23
  gem.add_dependency 'msgpack', '~> 1.2.0'
24
- gem.add_dependency 'kramdown', '~> 1.17'
24
+ gem.add_dependency 'kramdown', '>= 1.17', '< 3.0'
25
25
  gem.add_dependency 'json', '~> 2.3.0'
26
26
 
27
27
  gem.add_development_dependency 'rspec', '~> 2.14'
@@ -29,7 +29,7 @@ describe 'Polytexnic::Pipeline#to_html' do
29
29
 
30
30
  describe "small caps" do
31
31
  let(:polytex) { '\textsc{small caps}' }
32
- it { should resemble '<span class="sc">small caps</span>' }
32
+ it { should resemble '<span class="smallcaps">small caps</span>' }
33
33
  end
34
34
 
35
35
  describe "small text" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polytexnic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.16
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-16 00:00:00.000000000 Z
12
+ date: 2020-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -57,16 +57,22 @@ dependencies:
57
57
  name: kramdown
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.17'
63
+ - - "<"
64
+ - !ruby/object:Gem::Version
65
+ version: '3.0'
63
66
  type: :runtime
64
67
  prerelease: false
65
68
  version_requirements: !ruby/object:Gem::Requirement
66
69
  requirements:
67
- - - "~>"
70
+ - - ">="
68
71
  - !ruby/object:Gem::Version
69
72
  version: '1.17'
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
70
76
  - !ruby/object:Gem::Dependency
71
77
  name: json
72
78
  requirement: !ruby/object:Gem::Requirement