polytexnic 1.6.2 → 1.6.6

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
2
  SHA256:
3
- metadata.gz: 7811a66c9d17ae4c458e5ae584f9d5c7b5d967aa6c6405a34b3e5203c4923e2b
4
- data.tar.gz: f50df8db56ef4f75072f4ae6fb094f5cc3e9165a0f982db1f09c4e4c01dd7619
3
+ metadata.gz: 0e758ae9c4c23afe6aa06e9a916d9c41d207b8ded3da0c6e405e3e4b979c1864
4
+ data.tar.gz: 2e44dbade1df1aa4e573c87c10e5adf34c2939e8cfe3690234fa5404c9ebc679
5
5
  SHA512:
6
- metadata.gz: b62df40cecb2a8c2e94a4afcbbb74c013f2395963a405c2f4a6bb7ae859d3325c458e6a1622e6a8aee0eafe72a9b34ecf4789bc8e90bcd65f4c17b6c13dfc4cd
7
- data.tar.gz: 5d64cc55e439a0588090320c7911415e75d6267d2d00280fabfd06d92418431cb9cf829303de8b26604fc305a5a2decedd1bd354372559551d31c9e152cdd937
6
+ metadata.gz: 3908f4a3795694c34c7c9443f475ca62662e9b6e3d8b0593641e8c42a5b99237fcc45e293704400eac7b243a813e814a898a560d4c9b6d51d08b0885afd77cc4
7
+ data.tar.gz: 7517c3f0636b7472568dbb0252c1ac1090c8554907868977a943b96b0ee5d689d81febbbefa4e6dba79536ce8c985bc406d47ddf5360f82b409e2dd80b20f33a
data/Gemfile CHANGED
@@ -22,6 +22,6 @@ group :test do
22
22
  end
23
23
 
24
24
  group :development do
25
- gem 'guard-rspec'
25
+ gem 'guard-rspec', require: false
26
26
  gem 'rake'
27
27
  end
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polytexnic (1.6.2)
4
+ polytexnic (1.6.6)
5
5
  json (~> 2.3.0)
6
- kramdown (>= 1.17, < 3.0)
6
+ kramdown (>= 2.0, < 3.0)
7
7
  msgpack (~> 1.2.0)
8
8
  nokogiri (>= 1.6.0, < 2.0)
9
9
  pygments.rb (~> 2.1)
@@ -25,16 +25,16 @@ GEM
25
25
  debugger-linecache (~> 1.2.0)
26
26
  diff-lcs (1.4.4)
27
27
  docile (1.1.5)
28
- ffi (1.14.2)
29
- formatador (0.2.5)
28
+ ffi (1.15.3)
29
+ formatador (0.3.0)
30
30
  growl (1.0.3)
31
- guard (2.16.2)
31
+ guard (2.18.0)
32
32
  formatador (>= 0.2.4)
33
33
  listen (>= 2.7, < 4.0)
34
34
  lumberjack (>= 1.0.12, < 2.0)
35
35
  nenv (~> 0.1)
36
36
  notiffany (~> 0.0)
37
- pry (>= 0.9.12)
37
+ pry (>= 0.13.0)
38
38
  shellany (~> 0.0)
39
39
  thor (>= 0.18.1)
40
40
  guard-compat (1.2.1)
@@ -43,36 +43,36 @@ GEM
43
43
  guard-compat (~> 1.1)
44
44
  rspec (>= 2.99.0, < 4.0)
45
45
  json (2.3.1)
46
- kramdown (2.3.0)
46
+ kramdown (2.3.1)
47
47
  rexml
48
- listen (3.4.1)
48
+ listen (3.7.0)
49
49
  rb-fsevent (~> 0.10, >= 0.10.3)
50
50
  rb-inotify (~> 0.9, >= 0.9.10)
51
51
  lumberjack (1.2.8)
52
52
  method_source (1.0.0)
53
53
  mime-types (3.3.1)
54
54
  mime-types-data (~> 3.2015)
55
- mime-types-data (3.2021.0225)
55
+ mime-types-data (3.2021.0704)
56
56
  msgpack (1.2.10)
57
57
  multi_json (1.15.0)
58
58
  nenv (0.3.0)
59
- nokogiri (1.11.1-x86_64-darwin)
59
+ nokogiri (1.12.4-x86_64-darwin)
60
60
  racc (~> 1.4)
61
61
  notiffany (0.1.3)
62
62
  nenv (~> 0.1)
63
63
  shellany (~> 0.0)
64
- pry (0.14.0)
64
+ pry (0.14.1)
65
65
  coderay (~> 1.1)
66
66
  method_source (~> 1.0)
67
- pygments.rb (2.1.0)
67
+ pygments.rb (2.2.0)
68
68
  racc (1.5.2)
69
- rake (13.0.3)
70
- rb-fsevent (0.10.4)
69
+ rake (13.0.6)
70
+ rb-fsevent (0.11.0)
71
71
  rb-inotify (0.10.1)
72
72
  ffi (~> 1.0)
73
73
  rest-client (1.6.7)
74
74
  mime-types (>= 1.16)
75
- rexml (3.2.4)
75
+ rexml (3.2.5)
76
76
  rspec (2.99.0)
77
77
  rspec-core (~> 2.99.0)
78
78
  rspec-expectations (~> 2.99.0)
@@ -93,7 +93,7 @@ GEM
93
93
  tins (0.13.2)
94
94
 
95
95
  PLATFORMS
96
- x86_64-darwin-19
96
+ x86_64-darwin-20
97
97
 
98
98
  DEPENDENCIES
99
99
  coveralls
@@ -106,4 +106,4 @@ DEPENDENCIES
106
106
  simplecov (~> 0.15.1)
107
107
 
108
108
  BUNDLED WITH
109
- 2.2.13
109
+ 2.2.17
data/Guardfile CHANGED
@@ -1,15 +1,10 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # Feel free to open issues for suggestions and improvements
3
6
 
4
- guard :rspec do
5
7
  watch(%r{^spec/.+_spec\.rb$})
6
8
  watch(%r{^lib/(.+)\.rb$}) { "spec" }
7
- ## Uncomment & edit below (and comment out above) to watch particular specs.
8
- # watch(%r{^lib/(.+)\.rb$}) do
9
- # [
10
- # "spec/to_html/asides_spec.rb",
11
- # "spec/to_html/codelistings_spec.rb"
12
- # ]
13
- # end
14
9
  watch('spec/spec_helper.rb') { "spec" }
15
10
  end
data/bin/polytexnic CHANGED
@@ -40,23 +40,26 @@ end.parse!
40
40
  # Returns the file format based on extension.
41
41
  # Should be 'html' or 'tex'.
42
42
  def format(filename)
43
- puts '***********'
44
- puts '***********'
45
- puts '***********'
46
- puts '***********'
47
- puts '***********'
48
- p filename.split('.')
49
43
  filename.split('.').last
50
44
  rescue
51
45
  nil
52
46
  end
53
47
 
54
- puts '$$$$$$$$$$$'
55
- puts '$$$$$$$$$$$'
56
- puts '$$$$$$$$$$$'
57
- puts '$$$$$$$$$$$'
58
- puts '$$$$$$$$$$$'
59
- p options
48
+ # Defines a valid HTML template.
49
+ def html_template(title, body)
50
+ %(<!DOCTYPE html>
51
+ <html>
52
+ <head>
53
+ <title>#{title}</title>
54
+ <meta charset="utf-8">
55
+ </head>
56
+ <body>
57
+ #{body}
58
+ </body>
59
+ </html>
60
+ )
61
+ end
62
+
60
63
  if (infile = options[:infile] || ARGV.shift)
61
64
  puts infile
62
65
  input = File.read(infile)
@@ -68,7 +71,7 @@ puts outfile
68
71
  pipeline = Polytexnic::Pipeline.new(input, article: true)
69
72
  format = options[:format] || format(outfile) || "html"
70
73
  if format == "html"
71
- output = pipeline.to_html
74
+ output = html_template("HTML output", pipeline.to_html)
72
75
  elsif format == "tex"
73
76
  output = pipeline.to_polytex
74
77
  else
@@ -209,8 +209,10 @@ module Polytexnic
209
209
  # For completeness, we handle the case where the author neglects to
210
210
  # use the nonbreak space ~.
211
211
  def hyperrefs(string)
212
+ part = language_labels["part"]
212
213
  chapter = language_labels["chapter"]["word"]
213
214
  section = language_labels["section"]
215
+ appendix = language_labels["appendix"]
214
216
  table = language_labels["table"]
215
217
  box = language_labels["aside"]
216
218
  figure = language_labels["figure"]
@@ -218,7 +220,7 @@ module Polytexnic
218
220
  listing = language_labels["listing"]
219
221
  equation = language_labels["equation"]
220
222
  eq = language_labels["eq"]
221
- linked_item = "(#{chapter}|#{section}|#{table}|#{box}|#{figure}" +
223
+ linked_item = "(#{part}|#{chapter}|#{section}|#{appendix}|#{table}|#{box}|#{figure}" +
222
224
  "|#{fig}\.|#{listing}|#{equation}|#{eq}\.)"
223
225
  ref = /(?:#{linked_item}(~| ))*(\\(?:eq)*ref){(.*?)}/i
224
226
  string.gsub!(ref) do
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.6.2"
2
+ VERSION = "1.6.6"
3
3
  end
data/lib/polytexnic.rb CHANGED
@@ -54,7 +54,7 @@ module Polytexnic
54
54
  else
55
55
  default_language_labels.merge(labels)
56
56
  end
57
- tempdir = 'tmp'
57
+ tempdir = 'tmp'
58
58
  FileUtils.mkdir(tempdir) unless File.directory?(tempdir)
59
59
  @highlight_cache_filename = File.join(tempdir, '.highlight_cache')
60
60
  if File.exist?(@highlight_cache_filename)
@@ -109,9 +109,9 @@ module Polytexnic
109
109
 
110
110
  # Returns the default labels for 'Chapter', 'Figure', etc.
111
111
  def default_language_labels
112
- {"chapter"=>{"word"=>"Chapter", "order"=>"standard"},
113
- "section"=>"Section", "table"=>"Table", "figure"=>"Figure",
114
- "fig"=>"Fig", "aside"=>"Box", "listing"=>"Listing",
112
+ {"part"=>"Part","chapter"=>{"word"=>"Chapter", "order"=>"standard"},
113
+ "section"=>"Section", "appendix"=>"Appendix", "table"=>"Table",
114
+ "figure"=>"Figure", "fig"=>"Fig", "aside"=>"Box", "listing"=>"Listing",
115
115
  "equation"=>"Equation", "eq"=>"Eq", "frontmatter"=>"Frontmatter",
116
116
  "contents"=>"Contents"}
117
117
  end
data/polytexnic.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency 'nokogiri', '>= 1.6.0', '< 2.0'
22
22
  gem.add_dependency 'pygments.rb', '~> 2.1'
23
23
  gem.add_dependency 'msgpack', '~> 1.2.0'
24
- gem.add_dependency 'kramdown', '>= 1.17', '< 3.0'
24
+ gem.add_dependency 'kramdown', '>= 2.0', '< 3.0'
25
25
  gem.add_dependency 'json', '~> 2.3.0'
26
26
 
27
27
  gem.add_development_dependency 'rspec', '~> 2.14'
@@ -149,11 +149,20 @@ end
149
149
 
150
150
  describe "hyperref links" do
151
151
  let(:polytex) do <<-'EOS'
152
- Chapter~\ref{cha:foo}
152
+ Part~\ref{prt:foo}
153
+ Chapter~\ref{cha:bar}
154
+ Section~\ref{sec:baz}
155
+ Appendix~\ref{cha:quux}
153
156
  EOS
154
157
  end
155
- let(:output) { '\hyperref[cha:foo]{Chapter~\ref{cha:foo}' }
156
- it { should resemble output }
158
+ let(:part_ref) { '\hyperref[prt:foo]{Part~\ref{prt:foo}' }
159
+ let(:chapter_ref) { '\hyperref[cha:bar]{Chapter~\ref{cha:bar}' }
160
+ let(:section_ref) { '\hyperref[sec:baz]{Section~\ref{sec:baz}' }
161
+ let(:appendix_ref) { '\hyperref[cha:quux]{Appendix~\ref{cha:quux}' }
162
+ it { should resemble part_ref }
163
+ it { should resemble chapter_ref }
164
+ it { should resemble section_ref }
165
+ it { should resemble appendix_ref }
157
166
  end
158
167
 
159
168
  describe "asides" 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.6.2
4
+ version: 1.6.6
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: 2021-03-05 00:00:00.000000000 Z
12
+ date: 2021-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -65,7 +65,7 @@ dependencies:
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.17'
68
+ version: '2.0'
69
69
  - - "<"
70
70
  - !ruby/object:Gem::Version
71
71
  version: '3.0'
@@ -75,7 +75,7 @@ dependencies:
75
75
  requirements:
76
76
  - - ">="
77
77
  - !ruby/object:Gem::Version
78
- version: '1.17'
78
+ version: '2.0'
79
79
  - - "<"
80
80
  - !ruby/object:Gem::Version
81
81
  version: '3.0'
@@ -308,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
308
308
  - !ruby/object:Gem::Version
309
309
  version: '0'
310
310
  requirements: []
311
- rubygems_version: 3.1.2
311
+ rubygems_version: 3.1.6
312
312
  signing_key:
313
313
  specification_version: 4
314
314
  summary: Convert from PolyTeX & Markdown to HTML & LaTeX