polytexnic 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/polytexnic/postprocessors/html.rb +8 -3
- data/lib/polytexnic/preprocessors/html.rb +2 -2
- data/lib/polytexnic/preprocessors/polytex.rb +4 -3
- data/lib/polytexnic/version.rb +1 -1
- data/spec/markdown_to_polytex_spec.rb +1 -0
- data/spec/to_html/characters_and_punctuation_spec.rb +10 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 757c2437b73c6509896eda399a9884e6f85207fb
|
4
|
+
data.tar.gz: 74828c99d7eb804dd3ac58f242ad312d857d2a8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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"
|
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"
|
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
|
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
|
-
|
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
|
data/lib/polytexnic/version.rb
CHANGED
@@ -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"
|
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"
|
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"
|
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"
|
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.
|
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-
|
12
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|