polytexnic 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: 1033c3048267f0615e99cb2f3601e4cee702fd54
4
- data.tar.gz: bc78579e1d2156b1402be2f92c983ed9bcb2085f
3
+ metadata.gz: de8929b21f46055c1eccdbbc6ead05b0d5aa3480
4
+ data.tar.gz: f62ab6bd126d89ce3091240bfb2756447d30f19c
5
5
  SHA512:
6
- metadata.gz: 8ff08d1c73e0a7b63710e6d0749648cb17cc19305c2dbf9ad4c93134345559504c615e78c0af8e520e646b372c6c6a51a3f94ebb5dc573c61a02965371c9db57
7
- data.tar.gz: 7516e7eb5c1916c9ea9d8933b3450eec56b4ba728168e0da2a8aa2e67468d125e999fa3c7572c43f4bedf18c881652f93944319028eba32321f86ddcef887178
6
+ metadata.gz: 1cc6ab63fc1aaa5eb4ac4c6832af09891b5d20912344f3534e7cc26f4e0a0abc5440d4a77e23cebac50fd5f73616ac54af5cce165ca6a6e0797e01c46bd144d4
7
+ data.tar.gz: 8e93034c107c9be60ec2cf18051b659c626160f1238f84b5cb609aa330cd6285a6e2a877dd1cb253e44f3026bb0349362c200c401a4818b3000a395c443ff189
@@ -5,7 +5,9 @@ module Polytexnic
5
5
 
6
6
  # Converts Tralics XML output to HTML.
7
7
  def xml_to_html(xml)
8
+ restore_underscores(xml)
8
9
  doc = Nokogiri::XML(xml)
10
+ comments(doc)
9
11
  emphasis(doc)
10
12
  boldface(doc)
11
13
  small_caps(doc)
@@ -56,6 +58,21 @@ module Polytexnic
56
58
 
57
59
  private
58
60
 
61
+ # Restores underscores.
62
+ # Tralics does weird stuff with underscores, in some contexts,
63
+ # so they are subbed out and passed through the pipeline intact.
64
+ # This is where we restore them.
65
+ def restore_underscores(xml)
66
+ xml.gsub!(underscore_digest, '_')
67
+ end
68
+
69
+ # Replaces comment content with proper HTML comments.
70
+ def comments(doc)
71
+ doc.xpath('//comment').each do |node|
72
+ node.replace("<!-- #{node.inner_html} -->")
73
+ end
74
+ end
75
+
59
76
  # Handles output of \emph{} and \textit{}.
60
77
  def emphasis(doc)
61
78
  doc.xpath('//hi[@rend="it"]').each do |node|
@@ -538,12 +555,9 @@ module Polytexnic
538
555
  end
539
556
  end
540
557
 
541
- # Restores the label.
542
- # Tralics does weird stuff with underscores, so they are subbed out
543
- # so that they can be passed through the pipeline intact. This is where
544
- # we restore them.
558
+ # Pulls the label out of the node.
545
559
  def pipeline_label(node)
546
- node.inner_html.gsub(underscore_digest, '_')
560
+ node.inner_html
547
561
  end
548
562
 
549
563
  # Processes the <head> tag given a section node.
@@ -120,8 +120,12 @@ module Polytexnic
120
120
  end
121
121
 
122
122
  # Removes commented-out lines.
123
+ # Contents of the special sequence `%=` are converted to HTML comments.
123
124
  def remove_comments(output)
124
- output.gsub!(/[^\\]%.*$/, '')
125
+ output.gsub!(/[^\\]%[^=].*$/, '')
126
+ output.gsub!(/[^\\]%=(.*)$/) do
127
+ xmlelement('comment') { $1.gsub('_', underscore_digest) }
128
+ end
125
129
  end
126
130
 
127
131
  # Converts LaTeX double backslashes to HTML breaks.
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -18,11 +18,6 @@ describe 'Polytexnic::Pipeline#to_html' do
18
18
  it { should eq '' }
19
19
  end
20
20
 
21
- context "with a manual break" do
22
- let(:polytex) { 'foo \\\\ bar' }
23
- it { should include '<span class="break">' }
24
- end
25
-
26
21
  context "with a code listing" do
27
22
  let(:polytex) do <<-'EOS'
28
23
  % \begin{codelisting}
@@ -73,6 +68,11 @@ describe 'Polytexnic::Pipeline#to_html' do
73
68
  end
74
69
  it { should eq '' }
75
70
  end
71
+
72
+ context "with a percent-equals" do
73
+ let(:polytex) { '%= literal_text' }
74
+ it { should include '<!-- literal_text -->' }
75
+ end
76
76
  end
77
77
 
78
78
  describe "a complete document" do
@@ -88,6 +88,12 @@ describe 'Polytexnic::Pipeline#to_html' do
88
88
  it { should resemble "<p>lorem ipsum</p>" }
89
89
  end
90
90
 
91
+ describe "a manual break" do
92
+ let(:polytex) { 'foo \\\\ bar' }
93
+ it { should include '<span class="break">' }
94
+ end
95
+
96
+
91
97
  describe "paragraphs" do
92
98
  let(:polytex) { 'lorem ipsum' }
93
99
  it { should resemble "<p>lorem ipsum</p>" }
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.1.0
4
+ version: 1.1.1
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: 2015-05-19 00:00:00.000000000 Z
12
+ date: 2015-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri