polytexnic 1.5.14 → 1.6.2

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: 8e4e57065af409b7eb58f284e648d5868d04fc7d207c77a823e2bcb8a7e84958
4
- data.tar.gz: 19f51c672304bf134250ecb2ea485014c649d7f4741e230383afc88c60840c00
3
+ metadata.gz: 7811a66c9d17ae4c458e5ae584f9d5c7b5d967aa6c6405a34b3e5203c4923e2b
4
+ data.tar.gz: f50df8db56ef4f75072f4ae6fb094f5cc3e9165a0f982db1f09c4e4c01dd7619
5
5
  SHA512:
6
- metadata.gz: 862fda861d2ef4c6afcc356478ca6d9ec7541c1670670611322c433aa7c669abbe924c4cb2452f124bf636a5241e24639df4fd466486368bea33222b29410c26
7
- data.tar.gz: efdc9c5a4f1d2dac32e4c31321072270cd4bd3c0cbbf4486d38959df61d51dd8ec9a6b157c70410721386b74485e85a8091e98423ddd6f10741861a905d9c6d1
6
+ metadata.gz: b62df40cecb2a8c2e94a4afcbbb74c013f2395963a405c2f4a6bb7ae859d3325c458e6a1622e6a8aee0eafe72a9b34ecf4789bc8e90bcd65f4c17b6c13dfc4cd
7
+ data.tar.gz: 5d64cc55e439a0588090320c7911415e75d6267d2d00280fabfd06d92418431cb9cf829303de8b26604fc305a5a2decedd1bd354372559551d31c9e152cdd937
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
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polytexnic (1.5.14)
5
- json (~> 1.8.1)
6
- kramdown (~> 1.17)
4
+ polytexnic (1.6.2)
5
+ json (~> 2.3.0)
6
+ kramdown (>= 1.17, < 3.0)
7
7
  msgpack (~> 1.2.0)
8
- nokogiri (~> 1.10.8)
9
- pygments.rb (~> 1.2.1)
8
+ nokogiri (>= 1.6.0, < 2.0)
9
+ pygments.rb (~> 2.1)
10
10
 
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,12 +23,12 @@ 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.14.2)
29
29
  formatador (0.2.5)
30
30
  growl (1.0.3)
31
- guard (2.16.1)
31
+ guard (2.16.2)
32
32
  formatador (>= 0.2.4)
33
33
  listen (>= 2.7, < 4.0)
34
34
  lumberjack (>= 1.0.12, < 2.0)
@@ -42,36 +42,37 @@ GEM
42
42
  guard (~> 2.1)
43
43
  guard-compat (~> 1.1)
44
44
  rspec (>= 2.99.0, < 4.0)
45
- json (1.8.6)
46
- kramdown (1.17.0)
47
- listen (3.2.1)
45
+ json (2.3.1)
46
+ kramdown (2.3.0)
47
+ rexml
48
+ listen (3.4.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
- method_source (0.9.2)
51
+ lumberjack (1.2.8)
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
- mini_portile2 (2.4.0)
55
+ mime-types-data (3.2021.0225)
56
56
  msgpack (1.2.10)
57
- multi_json (1.14.1)
57
+ multi_json (1.15.0)
58
58
  nenv (0.3.0)
59
- nokogiri (1.10.8)
60
- mini_portile2 (~> 2.4.0)
59
+ nokogiri (1.11.1-x86_64-darwin)
60
+ racc (~> 1.4)
61
61
  notiffany (0.1.3)
62
62
  nenv (~> 0.1)
63
63
  shellany (~> 0.0)
64
- pry (0.12.2)
65
- coderay (~> 1.1.0)
66
- method_source (~> 0.9.0)
67
- pygments.rb (1.2.1)
68
- multi_json (>= 1.0.0)
69
- rake (13.0.1)
70
- rb-fsevent (0.10.3)
64
+ pry (0.14.0)
65
+ coderay (~> 1.1)
66
+ method_source (~> 1.0)
67
+ pygments.rb (2.1.0)
68
+ racc (1.5.2)
69
+ rake (13.0.3)
70
+ rb-fsevent (0.10.4)
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
76
  rspec (2.99.0)
76
77
  rspec-core (~> 2.99.0)
77
78
  rspec-expectations (~> 2.99.0)
@@ -92,7 +93,7 @@ GEM
92
93
  tins (0.13.2)
93
94
 
94
95
  PLATFORMS
95
- ruby
96
+ x86_64-darwin-19
96
97
 
97
98
  DEPENDENCIES
98
99
  coveralls
@@ -105,4 +106,4 @@ DEPENDENCIES
105
106
  simplecov (~> 0.15.1)
106
107
 
107
108
  BUNDLED WITH
108
- 2.1.4
109
+ 2.2.13
data/bin/polytexnic CHANGED
@@ -1,19 +1,81 @@
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 HTML or LaTeX
8
+ # using the PolyTeXnic HTML pipeline.
9
+
10
+ examples = %(
11
+ The polytexnic script converts Markdown to HTML or LaTeX
12
+ using the PolyTeXnic HTML pipeline.
13
+
14
+ Examples:
15
+ polytexnic example.md example.html
16
+ polytexnic example.md > example.html
17
+ polytexnic < example.md > example.html
18
+ cat example.md | polytexnic > example.html
19
+ polytexnic -i example.md > example.html
20
+ polytexnic -i example.md -o example.tex
21
+ polytexnic -f tex example.md)
22
+
23
+ options = {}
24
+ OptionParser.new do |opts|
25
+ opts.banner = "Usage: polytexnic [options]\n#{examples}\n\n"
26
+
27
+ opts.on("-i", "--input=INPUT", "Use file input") do |infile|
28
+ options[:infile] = infile
29
+ end
30
+
31
+ opts.on("-o", "--output=OUTPUT", "Use file output") do |outfile|
32
+ options[:outfile] = outfile
33
+ end
34
+
35
+ opts.on("-f", "--format", "Use output format [html, tex]") do |format|
36
+ options[:format] = format
37
+ end
38
+ end.parse!
39
+
40
+ # Returns the file format based on extension.
41
+ # Should be 'html' or 'tex'.
42
+ def format(filename)
43
+ puts '***********'
44
+ puts '***********'
45
+ puts '***********'
46
+ puts '***********'
47
+ puts '***********'
48
+ p filename.split('.')
49
+ filename.split('.').last
50
+ rescue
51
+ nil
6
52
  end
7
53
 
8
- if ARGV.empty?
9
- puts latex_to_html(STDIN.read)
54
+ puts '$$$$$$$$$$$'
55
+ puts '$$$$$$$$$$$'
56
+ puts '$$$$$$$$$$$'
57
+ puts '$$$$$$$$$$$'
58
+ puts '$$$$$$$$$$$'
59
+ p options
60
+ if (infile = options[:infile] || ARGV.shift)
61
+ puts infile
62
+ input = File.read(infile)
10
63
  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
64
+ input = STDIN.read
65
+ end
66
+ outfile = options[:outfile] || ARGV.shift
67
+ puts outfile
68
+ pipeline = Polytexnic::Pipeline.new(input, article: true)
69
+ format = options[:format] || format(outfile) || "html"
70
+ if format == "html"
71
+ output = pipeline.to_html
72
+ elsif format == "tex"
73
+ output = pipeline.to_polytex
74
+ else
75
+ raise ArgumentError, "Invalid format: #{format}"
76
+ end
77
+ if outfile
78
+ File.write(outfile, output)
79
+ else
80
+ puts output.strip
19
81
  end
@@ -55,7 +55,6 @@ module Polytexnic
55
55
  mainmatter(doc)
56
56
  footnotes(doc)
57
57
  table_of_contents(doc)
58
- add_noindent(doc)
59
58
  convert_to_html(doc)
60
59
  end
61
60
 
@@ -96,7 +95,7 @@ module Polytexnic
96
95
  def small_caps(doc)
97
96
  doc.xpath('//hi[@rend="sc"]').each do |node|
98
97
  node.name = 'span'
99
- node['class'] = 'sc'
98
+ node['class'] = 'smallcaps'
100
99
  node.remove_attribute('rend')
101
100
  end
102
101
  end
@@ -1399,27 +1398,34 @@ module Polytexnic
1399
1398
  html << open << link.to_xhtml << '</li>'
1400
1399
  end
1401
1400
 
1401
+
1402
+ # NOTE: The add_noindent method has been superseded by CSS rules as shown in the
1403
+ # softcover gem's epub.css files.
1404
+ # See div.chapter > p:first-of-type and related rules in
1405
+ # ./lib/softcover/article_template/epub/OEBPS/styles/epub.css
1406
+ # of the softcover gem's source.
1407
+
1402
1408
  # Adds a noindent class where appropriate.
1403
1409
  # The purpose is to give the designer the option to indent all paragraphs but the first
1404
1410
  # one after the beginning of a chapter or section. The method is to add a "noindent" class
1405
1411
  # in the first paragraph after each division (chapter, section, etc.).
1406
- def add_noindent(doc)
1407
- divisions = %w[chapter section subsection subsubsection]
1408
- divisions += divisions.map { |division| "#{division}-star"}
1409
- divisions.each do |type|
1410
- doc.css("div.#{type}").each do |node|
1411
- if (first_paragraph = node.at_css('p'))
1412
- if first_paragraph['class'] == 'noindent'
1413
- next
1414
- elsif first_paragraph['class'].nil?
1415
- first_paragraph['class'] = 'noindent'
1416
- else
1417
- first_paragraph['class'] += ' noindent'
1418
- end
1419
- end
1420
- end
1421
- end
1422
- end
1412
+ # def add_noindent(doc)
1413
+ # divisions = %w[chapter section subsection subsubsection]
1414
+ # divisions += divisions.map { |division| "#{division}-star"}
1415
+ # divisions.each do |type|
1416
+ # doc.css("div.#{type}").each do |node|
1417
+ # if (first_paragraph = node.at_css('p'))
1418
+ # if first_paragraph['class'] == 'noindent'
1419
+ # next
1420
+ # elsif first_paragraph['class'].nil?
1421
+ # first_paragraph['class'] = 'noindent'
1422
+ # else
1423
+ # first_paragraph['class'] += ' noindent'
1424
+ # end
1425
+ # end
1426
+ # end
1427
+ # end
1428
+ # end
1423
1429
 
1424
1430
  # Cleans a node by removing all the given attributes.
1425
1431
  def clean_node(node, attributes)
@@ -140,7 +140,7 @@ module Polytexnic
140
140
  # Removes commented-out lines.
141
141
  # Contents of the special sequence `%=` are converted to literal HTML.
142
142
  def remove_comments(output)
143
- output.gsub!(/[^\\]%[^=].*$/, '')
143
+ output.gsub!(/([^\\])(%[^=].*$)/, '\1')
144
144
  output.gsub!(/[^\\]%=(.*)$/) do
145
145
  key = digest($1)
146
146
  literal_html_cache[key] = $1
@@ -206,9 +206,17 @@ module Polytexnic
206
206
  # Inline numbers look much better in HTML but are invalid in LaTeX.
207
207
  options['linenos'] = 'inline'
208
208
  end
209
- highlight_cache[key] ||= Pygments.highlight(content, lexer: language,
209
+ if (lines = options['hl_lines'])
210
+ content_lines = content.split("\n")
211
+ if lines.max > content_lines.length
212
+ err = "\nHighlight line(s) out of range: #{lines.inspect}\n"
213
+ err += content
214
+ raise err
215
+ end
216
+ end
217
+ highlight_cache[key] ||= Pygments.highlight(content, lexer: language,
210
218
  formatter: formatter,
211
- options: options)
219
+ options: options)
212
220
  end
213
221
 
214
222
  # Adds some verbatim font info (including size).
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.5.14"
2
+ VERSION = "1.6.2"
3
3
  end
data/polytexnic.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Polytexnic::VERSION
9
9
  gem.authors = ["Michael Hartl", "Nick Merwin"]
10
10
  gem.email = ["michael@softcover.io"]
11
- gem.description = %q{Core translation engine for the polytexnic gem}
11
+ gem.description = %q{Core translation engine for the softcover gem}
12
12
  gem.summary = %q{Convert from PolyTeX & Markdown to HTML & LaTeX}
13
- gem.homepage = "https://polytexnic.org/"
13
+ gem.homepage = "https://github.com/softcover/polytexnic"
14
14
  gem.license = "MIT"
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
@@ -18,11 +18,11 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency 'nokogiri', '~> 1.10.8'
22
- gem.add_dependency 'pygments.rb', '~> 1.2.1'
21
+ gem.add_dependency 'nokogiri', '>= 1.6.0', '< 2.0'
22
+ gem.add_dependency 'pygments.rb', '~> 2.1'
23
23
  gem.add_dependency 'msgpack', '~> 1.2.0'
24
- gem.add_dependency 'kramdown', '~> 1.17'
25
- gem.add_dependency 'json', '~> 1.8.1'
24
+ gem.add_dependency 'kramdown', '>= 1.17', '< 3.0'
25
+ gem.add_dependency 'json', '~> 2.3.0'
26
26
 
27
27
  gem.add_development_dependency 'rspec', '~> 2.14'
28
28
  gem.add_development_dependency 'simplecov', '~> 0.15.1'
@@ -32,7 +32,7 @@ describe 'Polytexnic::Pipeline#to_html' do
32
32
  <span class="number">Box 1.1.</span>
33
33
  <span class="description">Lorem ipsum.</span>
34
34
  </div>
35
- <p class="noindent">lorem ipsum</p>
35
+ <p>lorem ipsum</p>
36
36
  <p>dolor sit amet</p>
37
37
  </div>
38
38
  <p><a href="#aside-lorem" class="hyperref">Box <span class="ref">1.1</span></a></p>
@@ -76,4 +76,4 @@ describe 'Polytexnic::Pipeline#to_html' do
76
76
  it { should include ">1<" }
77
77
  end
78
78
  end
79
- end
79
+ end
@@ -202,7 +202,7 @@ describe 'Polytexnic::Pipeline#to_html' do
202
202
  <h2><a href="#foo_baz" class="heading">Foo: baz</a></h2>
203
203
  <div class="subsection-star">
204
204
  <h3><a class="heading">Bar</a></h3>
205
- <p class="noindent">Lorem ipsum</p>
205
+ <p>Lorem ipsum</p>
206
206
  </div>
207
207
  </div>
208
208
  <div id="cid1" data-tralics-id="cid1" class="section" data-number="1">
@@ -233,7 +233,7 @@ describe 'Polytexnic::Pipeline#to_html' do
233
233
  should resemble <<-'EOS'
234
234
  <div id="cha-foo_bar" data-tralics-id="cid1" class="chapter" data-number="1">
235
235
  <h1><a href="#cha-foo_bar" class="heading"><span class="number">Chapter 1 </span>Foo</a></h1>
236
- <p class="noindent"><a href="#cha-foo_bar" class="hyperref">Chapter <span class="ref">1</span></a>
236
+ <p><a href="#cha-foo_bar" class="hyperref">Chapter <span class="ref">1</span></a>
237
237
  and
238
238
  <a href="#cha-foo_baz" class="hyperref">Chapter <span class="ref">2</span></a>
239
239
  </p>
@@ -241,7 +241,7 @@ describe 'Polytexnic::Pipeline#to_html' do
241
241
 
242
242
  <div id="cha-foo_baz" data-tralics-id="cid2" class="chapter" data-number="2">
243
243
  <h1><a href="#cha-foo_baz" class="heading"><span class="number">Chapter 2 </span>Baz</a></h1>
244
- <p class="noindent"><a href="#cha-foo_baz" class="hyperref">Chapter <span class="ref">2</span></a>
244
+ <p><a href="#cha-foo_baz" class="hyperref">Chapter <span class="ref">2</span></a>
245
245
  and
246
246
  <a href="#cha-foo_bar" class="hyperref">Chapter <span class="ref">1</span></a>
247
247
  </p>
@@ -270,13 +270,13 @@ describe 'Polytexnic::Pipeline#to_html' do
270
270
  it do
271
271
  should resemble <<-'EOS'
272
272
  <div id="sec-foo" data-tralics-id="cid1" class="section" data-number="1"><h2><a href="#sec-foo" class="heading"><span class="number">1 </span>Foo</a></h2>
273
- <p class="noindent">
273
+ <p>
274
274
  <a href="#sec-bar" class="hyperref">Section <span class="ref">1.1</span></a>
275
275
  and
276
276
  <a href="#sec-baz" class="hyperref">Section <span class="ref">1.1.1</span></a>
277
277
  </p>
278
278
  <div id="sec-bar" data-tralics-id="uid1" class="subsection" data-number="1.1"><h3><a href="#sec-bar" class="heading"><span class="number">1.1 </span>Bar</a></h3>
279
- <p class="noindent"><a href="#sec-foo" class="hyperref">Section <span class="ref">1</span></a>
279
+ <p><a href="#sec-foo" class="hyperref">Section <span class="ref">1</span></a>
280
280
  </p>
281
281
  <div id="sec-baz" data-tralics-id="uid2" class="subsubsection" data-number="1.1.1">
282
282
  <h4><a href="#sec-baz" class="heading">Baz</a></h4>
@@ -298,7 +298,7 @@ describe 'Polytexnic::Pipeline#to_html' do
298
298
  should resemble <<-'EOS'
299
299
  <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1">
300
300
  <h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo</a></h1>
301
- <p class="noindent"><a href="#cha-bar" class="hyperref">Chapter <span class="undefined_ref">cha:bar</span></a>
301
+ <p><a href="#cha-bar" class="hyperref">Chapter <span class="undefined_ref">cha:bar</span></a>
302
302
  </p>
303
303
  </div>
304
304
  EOS
@@ -324,7 +324,7 @@ describe 'Polytexnic::Pipeline#to_html' do
324
324
  should resemble <<-'EOS'
325
325
  <div id="frontmatter" data-number="0">
326
326
  <div class="chapter-star" id="foo"><h1><a href="#foo" class="heading">Foo</a></h1>
327
- <p class="noindent">Lorem ipsum.<sup id="cha-0_footnote-ref-1" class="footnote"><a href="#cha-0_footnote-1">1</a></sup></p>
327
+ <p>Lorem ipsum.<sup id="cha-0_footnote-ref-1" class="footnote"><a href="#cha-0_footnote-1">1</a></sup></p>
328
328
  </div></div>
329
329
 
330
330
  <div id="cha-0_footnotes">
@@ -332,7 +332,7 @@ describe 'Polytexnic::Pipeline#to_html' do
332
332
  <div id="cha-0_footnote-1" class="footnote"><a class="footnote-link" href="#cha-0_footnote-ref-1">1.</a> Foo bar.</div>
333
333
  </div>
334
334
  </div><div id="cha-bar" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cha-bar" class="heading"><span class="number">Chapter 1 </span>Bar</a></h1>
335
- <p class="noindent"><a href="#cha-bar" class="hyperref">Chapter <span class="ref">1</span></a>
335
+ <p><a href="#cha-bar" class="hyperref">Chapter <span class="ref">1</span></a>
336
336
  </p></div>
337
337
  EOS
338
338
  end
@@ -40,7 +40,7 @@ Listing~\ref{code:create_gemrc}
40
40
  </div>
41
41
  </div>
42
42
  </div>
43
- <p class="noindent"><a href="#code-create_gemrc" class="hyperref">Listing <span class="ref">1.1</span></a></p>
43
+ <p><a href="#code-create_gemrc" class="hyperref">Listing <span class="ref">1.1</span></a></p>
44
44
  </div>
45
45
  EOS
46
46
  end
@@ -121,4 +121,4 @@ Listing~\ref{code:create_gemrc}
121
121
  expect { processed_text }.not_to raise_error
122
122
  end
123
123
  end
124
- end
124
+ end
@@ -9,6 +9,15 @@ describe 'Polytexnic::Pipeline#to_html' do
9
9
  let(:polytex) { "% A LaTeX comment" }
10
10
  it { should eq '' }
11
11
 
12
+ context "occurring a the end of a line" do
13
+ let(:polytex) do <<-'EOS'
14
+ lorem ipsum
15
+ dolor sit amet.%this is a comment
16
+ EOS
17
+ end
18
+ it { should include("amet.") }
19
+ end
20
+
12
21
  context "with a section and label" do
13
22
  let(:polytex) do <<-'EOS'
14
23
  % \section{Foo}
@@ -108,6 +117,25 @@ describe 'Polytexnic::Pipeline#to_html' do
108
117
  it { should_not resemble '<unknown>' }
109
118
  end
110
119
 
120
+ describe "explicit noindent" do
121
+ let(:polytex) { '\noindent lorem ipsum' }
122
+ it { should resemble '<p class="noindent">lorem ipsum</p>' }
123
+ end
124
+
125
+ describe "free span" do
126
+ let(:polytex) do <<-'EOS'
127
+ \chapter{Basics} % (fold)
128
+ \label{cha:basics}
129
+
130
+ %= <span class="free"></span>
131
+ EOS
132
+ end
133
+
134
+ it { should resemble('<span class="free"></span>') }
135
+ it { should_not resemble('<p><span class="free"></span></p>') }
136
+ end
137
+
138
+
111
139
  describe '\maketitle' do
112
140
 
113
141
  context "with all elements filled out explicitly" do
@@ -26,14 +26,14 @@ describe 'Polytexnic::Pipeline#to_html' do
26
26
  <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
27
27
  </div>
28
28
  <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1"><h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
29
- <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
29
+ <p>Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
30
30
  </div>
31
31
  <div id="cha-1_footnotes">
32
32
  <div class="footnotes">
33
33
  <div id="cha-1_footnote-1" class="footnote"><a class="footnote-link" href="#cha-1_footnote-ref-1">1.</a> Cicero</div>
34
34
  </div>
35
35
  </div><div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2"><h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
36
- <p class="noindent">Dolor sit amet.
36
+ <p>Dolor sit amet.
37
37
  </p></div>
38
38
  EOS
39
39
  end
@@ -66,14 +66,14 @@ describe 'Polytexnic::Pipeline#to_html' do
66
66
  <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
67
67
  </div>
68
68
  <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1"><h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
69
- <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
69
+ <p>Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">1</a></sup></p>
70
70
  </div>
71
71
  <div id="cha-1_footnotes">
72
72
  <div class="footnotes">
73
73
  <div id="cha-1_footnote-1" class="footnote"><a class="footnote-link" href="#cha-1_footnote-ref-1">1.</a> Cicero</div>
74
74
  </div>
75
75
  </div><div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2"><h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
76
- <p class="noindent">Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">1</a></sup></p>
76
+ <p>Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">1</a></sup></p>
77
77
  <p>Hey Jude.<sup id="cha-2_footnote-ref-2" class="footnote"><a href="#cha-2_footnote-2">2</a></sup>
78
78
  </p></div><div id="cha-2_footnotes">
79
79
  <div class="footnotes">
@@ -120,14 +120,14 @@ describe 'Polytexnic::Pipeline#to_html' do
120
120
  <div id="cha-foo" data-tralics-id="cid1" class="chapter" data-number="1"><h1><a href="#cha-foo" class="heading"><span class="number">Chapter 1 </span>Foo <em>bar</em></a></h1>
121
121
  </div>
122
122
  <div id="sec-foobar" data-tralics-id="cid2" class="section" data-number="1.1"><h2><a href="#sec-foobar" class="heading"><span class="number">1.1 </span>Foobar</a></h2>
123
- <p class="noindent">Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">*</a></sup></p>
123
+ <p>Lorem ipsum.<sup id="cha-1_footnote-ref-1" class="footnote"><a href="#cha-1_footnote-1">*</a></sup></p>
124
124
  </div>
125
125
  <div id="cha-1_footnotes">
126
126
  <div class="footnotes nonumbers">
127
127
  <div id="cha-1_footnote-1" class="footnote"><sup><a class="footnote-link" href="#cha-1_footnote-ref-1">*</a></sup> Cicero</div>
128
128
  </div>
129
129
  </div><div id="cha-bar" data-tralics-id="cid3" class="chapter" data-number="2"><h1><a href="#cha-bar" class="heading"><span class="number">Chapter 2 </span>Bar</a></h1>
130
- <p class="noindent">Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">*</a></sup></p>
130
+ <p>Dolor sit amet.<sup id="cha-2_footnote-ref-1" class="footnote"><a href="#cha-2_footnote-1">*</a></sup></p>
131
131
  <p>Hey Jude!<sup id="cha-2_footnote-ref-2" class="footnote intersentence"><a href="#cha-2_footnote-2">†</a></sup><span class="intersentencespace"></span> Be afraid.<span class="intersentencespace"></span> </p></div>
132
132
  <div id="cha-2_footnotes">
133
133
  <div class="footnotes nonumbers">
@@ -250,7 +250,7 @@ describe 'Polytexnic::Pipeline#to_html' do
250
250
  <span class="description">This is another caption.</span>
251
251
  </div>
252
252
  </div>
253
- <p class="noindent">
253
+ <p>
254
254
  <a href="#fig-baz" class="hyperref">Figure <span class="ref">2.1</span></a>
255
255
  </p>
256
256
  </div>
@@ -268,7 +268,7 @@ describe 'Polytexnic::Pipeline#to_html' do
268
268
  <span class="description">Yet another.</span>
269
269
  </div>
270
270
  </div>
271
- <p class="noindent">
271
+ <p>
272
272
  <a href="#fig-foo" class="hyperref">Figure <span class="ref">1.1</span></a>
273
273
  and
274
274
  <a href="#fig-bar" class="hyperref">Figure <span class="ref">1.2</span></a>
@@ -378,4 +378,4 @@ describe 'Polytexnic::Pipeline#to_html' do
378
378
  end
379
379
  end
380
380
  end
381
- end
381
+ end
@@ -98,7 +98,7 @@ describe Polytexnic::Pipeline do
98
98
  <div class="code">
99
99
  <div class="highlight">
100
100
  <pre>
101
- <span></span>
101
+ <span></span>
102
102
  <span class="k">def</span> <span class="nf">foo</span>
103
103
  <span class="s2">"bar"</span>
104
104
  <span class="k">end</span>
@@ -126,15 +126,15 @@ describe Polytexnic::Pipeline do
126
126
  <div class="highlight">
127
127
  <pre>
128
128
  <span></span>
129
- <span class="lineno">1</span>
130
129
  <span class="hll">
130
+ <span class="linenos">1</span>
131
131
  <span class="k">def</span> <span class="nf">foo</span>
132
132
  </span>
133
- <span class="lineno">2</span>
134
133
  <span class="hll">
134
+ <span class="linenos">2</span>
135
135
  <span class="s2">"bar"</span>
136
136
  </span>
137
- <span class="lineno">3</span>
137
+ <span class="linenos">3</span>
138
138
  <span class="k">end</span>
139
139
  </pre>
140
140
  </div>
@@ -143,9 +143,25 @@ describe Polytexnic::Pipeline do
143
143
  end
144
144
  end
145
145
 
146
+ context "when highlighting HTML" do
147
+ let(:polytex) do <<-'EOS'
148
+ %= lang:html, options: "hl_lines": [3], "linenos": true
149
+ \begin{code}
150
+ ---
151
+ layout: default
152
+ title: Gallery for Learn Enough JavaScript to Be Dangerous
153
+ ---
154
+
155
+ <div class="gallery col-three">
156
+ <div class="col col-nav gallery-thumbs" id="gallery-thumbs">
157
+ \end{code}
158
+ end
159
+ it should include('class="linenos"')
160
+ end
161
+
146
162
  context "with highlight line out of range" do
147
163
  let(:polytex) do <<-'EOS'
148
- %= lang:ruby, options: "hl_lines": [17], "linenos": true
164
+ %= lang:ruby, options: "hl_lines": [4], "linenos": true
149
165
  \begin{code}
150
166
  def foo
151
167
  "bar"
@@ -155,7 +171,7 @@ describe Polytexnic::Pipeline do
155
171
  end
156
172
 
157
173
  it "should emit a warning" do
158
-
174
+ expect { processed_text }.to raise_error
159
175
  end
160
176
  end
161
177
 
@@ -238,7 +254,7 @@ describe Polytexnic::Pipeline do
238
254
 
239
255
  context "with custom options" do
240
256
  let(:polytex) do <<-'EOS'
241
- %= <<(polytexnic_commands.sty, lang: tex, options: "hl_lines": [5])
257
+ %= <<(polytexnic_commands.sty, lang: tex, options: "hl_lines": [1])
242
258
  EOS
243
259
  end
244
260
  let(:output) do <<-'EOS'
@@ -377,7 +393,17 @@ describe Polytexnic::Pipeline do
377
393
 
378
394
  context "with repo, tag, lang and options" do
379
395
  let(:polytex) do <<-'EOS'
380
- %= <<(tagged_file.rb, git: {tag: v0.9.4, repo:"repo_path/.git"}, lang: tex, options: "hl_lines": [5])
396
+ %= <<(tagged_file.rb, git: {tag: v0.9.4, repo:"repo_path/.git"}, lang: tex, options: "hl_lines": [2])
397
+ EOS
398
+ end
399
+ let(:output) do <<-'EOS'
400
+ <div class="code">
401
+ <div class="highlight">
402
+ <pre><span></span>Fake data
403
+ <span class="hll">second line
404
+ </span></pre>
405
+ </div>
406
+ </div>
381
407
  EOS
382
408
  end
383
409
  it_behaves_like "an inclusion"
@@ -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
@@ -29,7 +29,7 @@ Make a code listing as in Listing~\ref{code:hello}.
29
29
  \begin{codelisting}
30
30
  \label{code:hello}
31
31
  \codecaption{A hello program in Ruby.}
32
- %= lang:ruby, options: "hl_lines": [17]
32
+ %= lang:ruby, options: "hl_lines": [2]
33
33
  \begin{code}
34
34
  def hello
35
35
  "hello, world!"
@@ -262,4 +262,4 @@ end
262
262
  it { should_not include 'xmlelement' }
263
263
  end
264
264
  end
265
- end
265
+ end
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.14
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
@@ -9,36 +9,42 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-02-21 00:00:00.000000000 Z
12
+ date: 2021-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 1.6.0
21
+ - - "<"
19
22
  - !ruby/object:Gem::Version
20
- version: 1.10.8
23
+ version: '2.0'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: 1.6.0
31
+ - - "<"
26
32
  - !ruby/object:Gem::Version
27
- version: 1.10.8
33
+ version: '2.0'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: pygments.rb
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
38
  - - "~>"
33
39
  - !ruby/object:Gem::Version
34
- version: 1.2.1
40
+ version: '2.1'
35
41
  type: :runtime
36
42
  prerelease: false
37
43
  version_requirements: !ruby/object:Gem::Requirement
38
44
  requirements:
39
45
  - - "~>"
40
46
  - !ruby/object:Gem::Version
41
- version: 1.2.1
47
+ version: '2.1'
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: msgpack
44
50
  requirement: !ruby/object:Gem::Requirement
@@ -57,30 +63,36 @@ dependencies:
57
63
  name: kramdown
58
64
  requirement: !ruby/object:Gem::Requirement
59
65
  requirements:
60
- - - "~>"
66
+ - - ">="
61
67
  - !ruby/object:Gem::Version
62
68
  version: '1.17'
69
+ - - "<"
70
+ - !ruby/object:Gem::Version
71
+ version: '3.0'
63
72
  type: :runtime
64
73
  prerelease: false
65
74
  version_requirements: !ruby/object:Gem::Requirement
66
75
  requirements:
67
- - - "~>"
76
+ - - ">="
68
77
  - !ruby/object:Gem::Version
69
78
  version: '1.17'
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
70
82
  - !ruby/object:Gem::Dependency
71
83
  name: json
72
84
  requirement: !ruby/object:Gem::Requirement
73
85
  requirements:
74
86
  - - "~>"
75
87
  - !ruby/object:Gem::Version
76
- version: 1.8.1
88
+ version: 2.3.0
77
89
  type: :runtime
78
90
  prerelease: false
79
91
  version_requirements: !ruby/object:Gem::Requirement
80
92
  requirements:
81
93
  - - "~>"
82
94
  - !ruby/object:Gem::Version
83
- version: 1.8.1
95
+ version: 2.3.0
84
96
  - !ruby/object:Gem::Dependency
85
97
  name: rspec
86
98
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +121,7 @@ dependencies:
109
121
  - - "~>"
110
122
  - !ruby/object:Gem::Version
111
123
  version: 0.15.1
112
- description: Core translation engine for the polytexnic gem
124
+ description: Core translation engine for the softcover gem
113
125
  email:
114
126
  - michael@softcover.io
115
127
  executables:
@@ -277,7 +289,7 @@ files:
277
289
  - tasks/bin/ruby_tests
278
290
  - tasks/run_tests_with_both_rubies.rake
279
291
  - tmp/.gitkeep
280
- homepage: https://polytexnic.org/
292
+ homepage: https://github.com/softcover/polytexnic
281
293
  licenses:
282
294
  - MIT
283
295
  metadata: {}
@@ -296,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
308
  - !ruby/object:Gem::Version
297
309
  version: '0'
298
310
  requirements: []
299
- rubygems_version: 3.0.3
311
+ rubygems_version: 3.1.2
300
312
  signing_key:
301
313
  specification_version: 4
302
314
  summary: Convert from PolyTeX & Markdown to HTML & LaTeX