polytexnic 0.6.5 → 0.6.6

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: 3e32b34fc0d486225db6bb18c5457718e9cd8a3e
4
- data.tar.gz: aa209cf0b57e84058935229ccdc4eb00669ead80
3
+ metadata.gz: 03e62fa6b490d41676bdfa9726742aea94016aff
4
+ data.tar.gz: afbdc88da5dd5971e08d4e117254bca05908e2fb
5
5
  SHA512:
6
- metadata.gz: 2e292a89c3dfd6b5f0941093a4e1a11e327b4d3134ce3fecfd5ad0af0b063c558379009b9691df816a133e4e0a52206749ef7066244682bf34b556489a394968
7
- data.tar.gz: c4638cb9a16135fc999b720b82bbe8bc262efd2d68f94fd993a100a6b5427fa7d50a2cc13653a94d3ff028058cf4e37c59c489f313775e75e76b765aa91970fe
6
+ metadata.gz: 58b473266813ba1e121f9bf9691d5d49236ac834e2e3de7a2880078e5e0830d9131b22fd9b041670a9a4a43694909edb255f8acdbb20f8f0171183461dfa24e6
7
+ data.tar.gz: 8c9f0555371af7f274dfa301b23e037a1d10b27303a0c506186112761524a37cc3c8e03ed2a3c1cb716e2d32fa9964f4ff6af0574846a7cc5d3cdc4b9f41d38a
File without changes
@@ -39,8 +39,12 @@ module Polytexnic
39
39
  # Override the header ordering, which starts with 'section' by default.
40
40
  lh = 'chapter,section,subsection,subsubsection,paragraph,subparagraph'
41
41
  kramdown = Kramdown::Document.new(cleaned_markdown, latex_headers: lh)
42
- @source = restore_inclusion(restore_math(kramdown.to_latex, math_cache))
43
- restore_raw_latex(@source, cache)
42
+ @source = kramdown.to_latex.tap do |polytex|
43
+ convert_tt(polytex)
44
+ restore_math(polytex, math_cache)
45
+ restore_inclusion(polytex)
46
+ restore_raw_latex(polytex, cache)
47
+ end
44
48
  end
45
49
 
46
50
  # Adds support for <<(path/to/code) inclusion.
@@ -49,7 +53,7 @@ module Polytexnic
49
53
  text.gsub!(/^\s*<<(\(.*?\))/) { "<!-- inclusion= <<#{$1}-->" }
50
54
  end
51
55
  def restore_inclusion(text)
52
- text.gsub(/% <!-- inclusion= (.*?)-->/) { "%= #{$1}" }
56
+ text.gsub!(/% <!-- inclusion= (.*?)-->/) { "%= #{$1}" }
53
57
  end
54
58
 
55
59
  # Caches literal LaTeX environments.
@@ -84,9 +88,16 @@ module Polytexnic
84
88
  )
85
89
  /x
86
90
  markdown.gsub!(command_regex) do
87
- key = digest($1)
88
- cache[key] = $1
89
- key
91
+ content = $1
92
+ key = digest(content)
93
+ cache[key] = content
94
+
95
+ if content =~ /\{table\}|\\caption\{/
96
+ # Pad tables & captions with newlines for kramdown compatibility.
97
+ "\n#{key}\n"
98
+ else
99
+ key
100
+ end
90
101
  end
91
102
  end
92
103
 
@@ -140,6 +151,14 @@ module Polytexnic
140
151
  output.join("\n")
141
152
  end
142
153
 
154
+ # Converts {tt ...} to \kode{...}
155
+ # This effectively converts `inline code`, which kramdown sets as
156
+ # {\tt inline code}, to PolyTeX's native \kode command, which in
157
+ # turns allows inline code to be separately styled.
158
+ def convert_tt(text)
159
+ text.gsub!(/\{\\tt (.*?)\}/, '\kode{\1}')
160
+ end
161
+
143
162
  # Caches math.
144
163
  # Leanpub uses the notation {$$}...{/$$} for both inline and block math,
145
164
  # with the only difference being the presences of newlines:
@@ -178,7 +197,6 @@ module Polytexnic
178
197
  end
179
198
  text.gsub!(key, open + value + close)
180
199
  end
181
- text
182
200
  end
183
201
  end
184
202
  end
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "0.6.5"
2
+ VERSION = "0.6.6"
3
3
  end
@@ -59,8 +59,40 @@ x^2
59
59
 
60
60
  it { should resemble '\[ x^2 \]' }
61
61
  end
62
+
63
+ describe "tables" do
64
+ let(:markdown) do <<-'EOS'
65
+ \begin{table}
66
+
67
+ |**option**|**size**|**actual size**|
68
+ | k | kilobytes | (1024 bytes) |
69
+ | M | megabytes | (1024 kilobytes) |
70
+ | G | gigabytes | (1024 megabytes) |
71
+ | T | terabytes | (1024 gigabytes) |
72
+ | P | petabytes | (1024 terabytes) |
73
+ \end{table}
74
+
75
+ \begin{table}
76
+
77
+ |**option**|**size**|**actual size**|
78
+ | k | kilobytes | (1024 bytes) |
79
+ | M | megabytes | (1024 kilobytes) |
80
+ | G | gigabytes | (1024 megabytes) |
81
+ | T | terabytes | (1024 gigabytes) |
82
+ | P | petabytes | (1024 terabytes) |
83
+ \caption{A caption.}
84
+ \end{table}
85
+
86
+ EOS
87
+ end
88
+ it { should include '\begin{table}' }
89
+ it { should include '\begin{longtable}' }
90
+ it { should_not include '\textbar' }
91
+ end
62
92
  end
63
93
 
94
+
95
+
64
96
  describe "footnotes" do
65
97
  subject do
66
98
  Polytexnic::Pipeline.new(markdown, source: :markdown).polytex
@@ -198,6 +230,12 @@ def foo; "bar"; end
198
230
  end
199
231
 
200
232
  describe "source code" do
233
+
234
+ context "inline" do
235
+ let(:source) { '`foo bar`' }
236
+ it { should include '\kode{foo bar}' }
237
+ end
238
+
201
239
  context "without highlighting" do
202
240
  let(:source) do <<-EOS
203
241
  def foo
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.6.5
4
+ version: 0.6.6
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: 2013-11-18 00:00:00.000000000 Z
12
+ date: 2013-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -167,6 +167,7 @@ files:
167
167
  - .pull_requests/1384446851
168
168
  - .pull_requests/1384800466
169
169
  - .pull_requests/1384811507
170
+ - .pull_requests/1385061501
170
171
  - .rspec
171
172
  - .ruby-gemset
172
173
  - .ruby-version