polytexnic 0.9.4 → 0.9.5
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 +4 -4
- data/lib/polytexnic.rb +3 -1
- data/lib/polytexnic/literal.rb +3 -3
- data/lib/polytexnic/postprocessors/html.rb +9 -0
- data/lib/polytexnic/preprocessors/html.rb +1 -0
- data/lib/polytexnic/version.rb +1 -1
- data/spec/to_html/chapters_and_sections_spec.rb +3 -3
- data/spec/to_html/core_spec.rb +3 -3
- data/spec/to_html/graphics_and_figures_spec.rb +5 -0
- data/spec/to_html/literal_environments/unicode_spec.rb +1 -2
- 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: ac0f741ed9f9e9fc12fae1ece2669ea3cac6c297
|
4
|
+
data.tar.gz: c9b400b7656626d7c01c62685a6afcf54cfa62d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c08b0a2d337d40b82bf0d3dff77c2b192452c100cd1df7d306e1b1a877c11c24e103aac217d55b5a040beac93e29d7b40b1a1b5877c4ab555cb620b374b0300e
|
7
|
+
data.tar.gz: 9fb84efd1b845ba40d59af9123f0e0a8cab3276901b7fa952e41df771a7153643a59edd4b3986286fa76ef44c7a34ff37392231e967aa9a8ea8f354172a37eef
|
data/lib/polytexnic.rb
CHANGED
@@ -34,10 +34,11 @@ module Polytexnic
|
|
34
34
|
|
35
35
|
attr_accessor :literal_cache, :code_cache, :polytex, :xml, :html,
|
36
36
|
:math_label_cache, :highlight_cache, :maketitle_elements,
|
37
|
-
:custom_commands, :language_labels
|
37
|
+
:custom_commands, :language_labels, :unicode_cache
|
38
38
|
|
39
39
|
def initialize(source, options = {})
|
40
40
|
@literal_cache = options[:literal_cache] || {}
|
41
|
+
@unicode_cache = {}
|
41
42
|
@code_cache = {}
|
42
43
|
@maketitle_elements = {}
|
43
44
|
@language_labels = if (labels = options[:language_labels]).nil?
|
@@ -74,6 +75,7 @@ module Polytexnic
|
|
74
75
|
RubyProf.start
|
75
76
|
end
|
76
77
|
|
78
|
+
puts "before preprocess:\n#{@polytex}" if debug?
|
77
79
|
preprocess(:html)
|
78
80
|
puts "\nafter preprocess:\n#{@xml}" if debug?
|
79
81
|
postprocess(:html)
|
data/lib/polytexnic/literal.rb
CHANGED
@@ -37,7 +37,7 @@ module Polytexnic
|
|
37
37
|
|
38
38
|
# Returns a list of all literal types.
|
39
39
|
def literal_types
|
40
|
-
%w[verbatim Vertatim code
|
40
|
+
%w[verbatim Vertatim code metacode] + math_environments
|
41
41
|
end
|
42
42
|
|
43
43
|
# Handles environments that should be passed through the pipeline intact.
|
@@ -276,8 +276,8 @@ module Polytexnic
|
|
276
276
|
non_ascii_unicode = /([^\x00-\x7F]+)/
|
277
277
|
string.gsub!(non_ascii_unicode) do
|
278
278
|
key = digest($1)
|
279
|
-
|
280
|
-
|
279
|
+
unicode_cache[key] = $1
|
280
|
+
key
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
@@ -35,6 +35,7 @@ module Polytexnic
|
|
35
35
|
doc = smart_single_quotes(doc)
|
36
36
|
tex_logos(doc)
|
37
37
|
restore_literal(doc)
|
38
|
+
doc = restore_unicode(doc)
|
38
39
|
restore_inline_verbatim(doc)
|
39
40
|
codelistings(doc)
|
40
41
|
asides(doc)
|
@@ -747,6 +748,14 @@ module Polytexnic
|
|
747
748
|
end
|
748
749
|
end
|
749
750
|
|
751
|
+
def restore_unicode(doc)
|
752
|
+
s = doc.to_xml
|
753
|
+
unicode_cache.each do |key, value|
|
754
|
+
s.gsub!(key, value)
|
755
|
+
end
|
756
|
+
Nokogiri::XML(s)
|
757
|
+
end
|
758
|
+
|
750
759
|
# Restores things inside \verb+...+
|
751
760
|
def restore_inline_verbatim(doc)
|
752
761
|
doc.xpath('//inlineverbatim').each do |node|
|
data/lib/polytexnic/version.rb
CHANGED
@@ -88,9 +88,9 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
88
88
|
Ec.~\ref{eq:bar}
|
89
89
|
EOS
|
90
90
|
end
|
91
|
-
let(:capitulo) { '
|
92
|
-
let(:seccion) { '
|
93
|
-
let(:ecuacion) { '
|
91
|
+
let(:capitulo) { 'Capítulo' }
|
92
|
+
let(:seccion) { 'Sección' }
|
93
|
+
let(:ecuacion) { 'Ecuación' }
|
94
94
|
|
95
95
|
it { should include %(class="hyperref">#{capitulo}) }
|
96
96
|
it { should include %(class="hyperref">#{seccion}) }
|
data/spec/to_html/core_spec.rb
CHANGED
@@ -139,9 +139,9 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
139
139
|
it do
|
140
140
|
should resemble <<-'EOS'
|
141
141
|
<div id="title_page">
|
142
|
-
<h1 class="title">A
|
143
|
-
<h1 class="subtitle">
|
144
|
-
<h2 class="author"
|
142
|
+
<h1 class="title">A könyv címe</h1>
|
143
|
+
<h1 class="subtitle">Alcím - itt lesz az alcím</h1>
|
144
|
+
<h2 class="author">Árvíztűrő fúrógép</h2>
|
145
145
|
<h2 class="date">January 1, 2013</h2>
|
146
146
|
</div>
|
147
147
|
EOS
|
@@ -35,6 +35,11 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
35
35
|
EOS
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
context "with a Unicode filename" do
|
40
|
+
let(:polytex) { '\includegraphics{images/grusväg.jpg}' }
|
41
|
+
it { should include 'images/grusväg.jpg' }
|
42
|
+
end
|
38
43
|
end
|
39
44
|
|
40
45
|
describe "figures" do
|
@@ -6,7 +6,6 @@ describe Polytexnic::Pipeline do
|
|
6
6
|
|
7
7
|
describe "non-ASCII Unicode" do
|
8
8
|
let(:polytex) { 'Алексей Разуваев' }
|
9
|
-
it { should include
|
10
|
-
it { should include %(<span class="unicode">Разуваев</span>) }
|
9
|
+
it { should include 'Алексей Разуваев' }
|
11
10
|
end
|
12
11
|
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: 0.9.
|
4
|
+
version: 0.9.5
|
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: 2014-03-
|
12
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|