polytexnic 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: df279f88dd6e422ea262d2e255b5b933dc223384
4
- data.tar.gz: ced8e931e05b505565ce0b0b3fd6ae5decbac2c2
3
+ metadata.gz: 757c2437b73c6509896eda399a9884e6f85207fb
4
+ data.tar.gz: 74828c99d7eb804dd3ac58f242ad312d857d2a8b
5
5
  SHA512:
6
- metadata.gz: ade036c3345158c4712df8177944ef2ca263975dd5cbb0d2d2cfc126dd558e66854cb3f4d86f37fc4158c04b492f61ffc584006482432625f9c1ee9511dcf7e8
7
- data.tar.gz: 93d91db198dbfe33f303d9c7d16a27a98e7a8123f5e426696db679665129e1aa27a3a64e97891aa4f5a62b4df0e2e26eca01015ab061d027af526407a59f4616
6
+ metadata.gz: 54f0cdd506ad08cb61feebfa52eb0724492d59d263e34efa3c6f4f79d174305a5244231a375c0e8a12b3cb195937d89d1f7badc2c397b08154a47f6c0d895cbc
7
+ data.tar.gz: 49413d0d8bae6d4a49a6b02d943987334943b7a83dc73deca4ff91ca0b2c2d419ec5180ce3cbed756e51020bdd5a27f5adf1f89e953ddd7f401e7914c245fc0c
@@ -357,7 +357,7 @@ module Polytexnic
357
357
  # Move footnote outside section anchor tag.
358
358
  node.parent = node.parent.parent
359
359
  end
360
- # Add an inter-sentence space if appropriate.
360
+ # Add an intersentence space if appropriate.
361
361
  previous_character = node.previous_sibling.content[-1]
362
362
  end_of_sentence = %w[. ! ?].include?(previous_character)
363
363
  after = node.next_sibling
@@ -368,6 +368,11 @@ module Polytexnic
368
368
  node['class'] += ' intersentence'
369
369
  node.add_next_sibling(space)
370
370
  end
371
+ # Remove spurious intersentence space from mid-sentence notes.
372
+ unless end_of_sentence
373
+ intersentence_space = node.next_sibling
374
+ intersentence_space.remove unless intersentence_space.nil?
375
+ end
371
376
  end
372
377
  end
373
378
  end
@@ -405,12 +410,12 @@ module Polytexnic
405
410
 
406
411
  # Returns HTML for a nicely styled TeX logo.
407
412
  def tex
408
- %(<span class="texhtml" style="font-family: 'CMU Serif', cmr10, LMRoman10-Regular, 'Times New Roman', 'Nimbus Roman No9 L', Times, serif;">T<span style="text-transform: uppercase; vertical-align: -0.5ex; margin-left: -0.1667em; margin-right: -0.125em;">E</span>X</span>)
413
+ %(<span class="texhtml">T<span class="texhtmlE">E</span>X</span>)
409
414
  end
410
415
 
411
416
  # Returns HTML for a nicely styled LaTeX logo.
412
417
  def latex
413
- %(<span class="texhtml" style="font-family: 'CMU Serif', cmr10, LMRoman10-Regular, 'Times New Roman', 'Nimbus Roman No9 L', Times, serif;">L<span style="text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;">A</span>T<span style="text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;">E</span>X</span>)
418
+ %(<span class="texhtml">L<span class="texhtmlA">A</span>T<span class="texhtmlE">E</span>X</span>)
414
419
  end
415
420
 
416
421
  # Handles \begin{quote} ... \end{quote}.
@@ -79,11 +79,11 @@ module Polytexnic
79
79
  doc.gsub!(/(#{not_a_capital})(#{end_of_sentence})\n([^\n])/) do
80
80
  $1 + $2 + xmlelement('intersentencespace') + ' ' + $3
81
81
  end
82
- # Case of "foo.}} A"
82
+ # Case of "foo.} A" or "foo.}} A"
83
83
  doc.gsub!(/(#{not_a_capital})(#{end_of_sentence})(\})+[ ]+([^\s])/) do
84
84
  $1 + $2 + $3 + xmlelement('intersentencespace') + ' ' + $4
85
85
  end
86
- # Handle the manual override to force an inter-sentence space, '\@',
86
+ # Handle the manual override to force an intersentence space, '\@',
87
87
  # as in 'Superman II\@. A new sentence'.
88
88
  doc.gsub!(/\\@\. /, '.' + xmlelement('intersentencespace') + ' ')
89
89
  end
@@ -32,8 +32,6 @@ module Kramdown
32
32
  end
33
33
  end
34
34
 
35
- alias_method :original_convert_standalone_image, :convert_standalone_image
36
-
37
35
  # Uses figures for images only when label is present.
38
36
  # This allows users to put raw (centered) images in their documents.
39
37
  # The default behavior of kramdown is to wrap such images in a figure
@@ -46,7 +44,10 @@ module Kramdown
46
44
  def convert_standalone_image(el, opts, img)
47
45
  alt_text = el.children.first.attr['alt']
48
46
  if has_label?(alt_text)
49
- original_convert_standalone_image(el, opts, img)
47
+ attrs = attribute_list(el)
48
+ # Override the kramdown default by adding "here" placement.
49
+ # Authors who want a different behavior can always use raw LaTeX.
50
+ "\\begin{figure}[h]#{attrs}\n\\begin{center}\n#{img}\n\\end{center}\n\\caption{#{escape(el.children.first.attr['alt'])}}\n#{latex_link_target(el, true)}\n\\end{figure}#{attrs}\n"
50
51
  else
51
52
  img.gsub('\includegraphics', '\image') + "\n"
52
53
  end
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -170,6 +170,7 @@ That is it. You can keep writing your text after the footnote content.
170
170
  ![\label{fig:softcover_server}](images/figures/softcover_server.png)
171
171
  EOS
172
172
  end
173
+ it { should include '\begin{figure}[h]' }
173
174
  it { should include '\caption' }
174
175
  end
175
176
 
@@ -88,11 +88,16 @@ describe 'Polytexnic::Pipeline#to_html' do
88
88
  it { should resemble "“Yes, indeed!”#{intsp} A new sentence." }
89
89
  end
90
90
 
91
- context "with sentence ending with curly braces" do
91
+ context "with a sentence ending with curly braces" do
92
92
  let(:polytex) { "\\emph{\\textbf{Foo.}} Bar." }
93
93
  it { should resemble "#{intsp} Bar" }
94
94
  end
95
95
 
96
+ context "with a mid-sentence footnote ending with a period" do
97
+ let(:polytex) { 'Lorem\footnote{Cicero.} ipsum.' }
98
+ it { should_not include 'intersentencespace' }
99
+ end
100
+
96
101
  context "forced inter-sentence override" do
97
102
  let(:polytex) { 'Superman II\@. Lorem ipsum.' }
98
103
  it { should resemble "Superman II.#{intsp} Lorem ipsum." }
@@ -111,7 +116,7 @@ describe 'Polytexnic::Pipeline#to_html' do
111
116
  describe "TeX logo" do
112
117
  let(:polytex) { '\TeX' }
113
118
  let(:output) do
114
- %(<span class="texhtml" style="font-family: 'CMU Serif', cmr10, LMRoman10-Regular, 'Times New Roman', 'Nimbus Roman No9 L', Times, serif;">T<span style="text-transform: uppercase; vertical-align: -0.5ex; margin-left: -0.1667em; margin-right: -0.125em;">E</span>X</span>)
119
+ %(<span class="texhtml">T<span class="texhtmlE">E</span>X</span>)
115
120
  end
116
121
  it { should include(output) }
117
122
  end
@@ -119,7 +124,7 @@ describe 'Polytexnic::Pipeline#to_html' do
119
124
  describe "LaTeX logo" do
120
125
  let(:polytex) { '\LaTeX' }
121
126
  let(:output) do
122
- %(<span class="texhtml" style="font-family: 'CMU Serif', cmr10, LMRoman10-Regular, 'Times New Roman', 'Nimbus Roman No9 L', Times, serif;">L<span style="text-transform: uppercase; font-size: 70%; margin-left: -0.36em; vertical-align: 0.3em; line-height: 0; margin-right: -0.15em;">A</span>T<span style="text-transform: uppercase; margin-left: -0.1667em; vertical-align: -0.5ex; line-height: 0; margin-right: -0.125em;">E</span>X</span>)
127
+ %(<span class="texhtml">L<span class="texhtmlA">A</span>T<span class="texhtmlE">E</span>X</span>)
123
128
  end
124
129
  it { should include(output) }
125
130
  end
@@ -127,7 +132,7 @@ describe 'Polytexnic::Pipeline#to_html' do
127
132
  describe "PolyTeX logo" do
128
133
  let(:polytex) { '\PolyTeX' }
129
134
  let(:output) do
130
- %(Poly<span class="texhtml" style="font-family: 'CMU Serif', cmr10, LMRoman10-Regular, 'Times New Roman', 'Nimbus Roman No9 L', Times, serif;">T<span style="text-transform: uppercase; vertical-align: -0.5ex; margin-left: -0.1667em; margin-right: -0.125em;">E</span>X</span>)
135
+ %(Poly<span class="texhtml">T<span class="texhtmlE">E</span>X</span>)
131
136
  end
132
137
  it { should include(output) }
133
138
  end
@@ -135,7 +140,7 @@ describe 'Polytexnic::Pipeline#to_html' do
135
140
  describe "PolyTeXnic logo" do
136
141
  let(:polytex) { '\PolyTeXnic' }
137
142
  let(:output) do
138
- %(Poly<span class="texhtml" style="font-family: 'CMU Serif', cmr10, LMRoman10-Regular, 'Times New Roman', 'Nimbus Roman No9 L', Times, serif;">T<span style="text-transform: uppercase; vertical-align: -0.5ex; margin-left: -0.1667em; margin-right: -0.125em;">E</span>X</span>nic)
143
+ %(Poly<span class="texhtml">T<span class="texhtmlE">E</span>X</span>nic)
139
144
  end
140
145
  it { should include(output) }
141
146
  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.0.2
4
+ version: 1.0.3
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-02-11 00:00:00.000000000 Z
12
+ date: 2015-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri