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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bed34195adfad66c6ed6a2dc8bcc45afee0ee6f
4
- data.tar.gz: 5ad3896b86c6508999899cc7f29b21532f7ba3b7
3
+ metadata.gz: ac0f741ed9f9e9fc12fae1ece2669ea3cac6c297
4
+ data.tar.gz: c9b400b7656626d7c01c62685a6afcf54cfa62d7
5
5
  SHA512:
6
- metadata.gz: 329319d7caec676b297950414ea456e4a68ea0bea7e5e5ef2593c25d39c21436103421476c0e1a19c059678907143b25bee33087b2ef8321fc3be34ecf822fcf
7
- data.tar.gz: ded73a11334a690c6c3027d627c0d971c8ace4ea65e5b9f95cb91238bc14f996e6d33aaff3288064af930120e35e6c53213d7bec34f0b3c6914f3dc07a0458b4
6
+ metadata.gz: c08b0a2d337d40b82bf0d3dff77c2b192452c100cd1df7d306e1b1a877c11c24e103aac217d55b5a040beac93e29d7b40b1a1b5877c4ab555cb620b374b0300e
7
+ data.tar.gz: 9fb84efd1b845ba40d59af9123f0e0a8cab3276901b7fa952e41df771a7153643a59edd4b3986286fa76ef44c7a34ff37392231e967aa9a8ea8f354172a37eef
@@ -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)
@@ -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 metadcode] + math_environments
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
- literal_cache[key] = $1
280
- xmlelement('unicode') { key }
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|
@@ -10,6 +10,7 @@ module Polytexnic
10
10
  # XML is straightforward.
11
11
  def to_xml
12
12
  polytex = process_for_tralics(@polytex)
13
+ puts "after processing for Tralics:\n#{polytex}" if debug?
13
14
  doc = Nokogiri::XML(tralics_xml(polytex))
14
15
  add_document_tag(doc)
15
16
  @xml = doc.to_xml
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
@@ -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) { 'Cap<span class="unicode">í</span>tulo' }
92
- let(:seccion) { 'Secci<span class="unicode">ó</span>n' }
93
- let(:ecuacion) { 'Ecuaci<span class="unicode">ó</span>n' }
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}) }
@@ -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 k<span class="unicode">ö</span>nyv c<span class="unicode">í</span>me</h1>
143
- <h1 class="subtitle">Alc<span class="unicode">í</span>m - itt lesz az alc<span class="unicode">í</span>m</h1>
144
- <h2 class="author"><span class="unicode">Á</span>rv<span class="unicode">í</span>zt<span class="unicode">ű</span>r<span class="unicode">ő</span> f<span class="unicode">ú</span>r<span class="unicode">ó</span>g<span class="unicode">é</span>p</h2>
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 %(<span class="unicode">Алексей</span>) }
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
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-26 00:00:00.000000000 Z
12
+ date: 2014-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri