polytexnic 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 892dfff956c8768a5699346b9fa25dc69ff75f18
4
- data.tar.gz: ba8dd328779f0a4d004cb51eb2a3c80f3cecbb57
3
+ metadata.gz: 3e32b34fc0d486225db6bb18c5457718e9cd8a3e
4
+ data.tar.gz: aa209cf0b57e84058935229ccdc4eb00669ead80
5
5
  SHA512:
6
- metadata.gz: 1801e0852177628915042d8fc3e3044f5463ca108ba3fc738012a70ad4fce74338d62ba08c9aec6ebeda2279bc54bcd8329463d74633353a93f63014b4aea2bb
7
- data.tar.gz: dccbd899157e2d9fa56110ee283aa1681807bc93db003d3f1c80dea9ed97974417018fd6560a57e240006b4d67b35605c547cffdc6dd568325b5e961c1461150
6
+ metadata.gz: 2e292a89c3dfd6b5f0941093a4e1a11e327b4d3134ce3fecfd5ad0af0b063c558379009b9691df816a133e4e0a52206749ef7066244682bf34b556489a394968
7
+ data.tar.gz: c4638cb9a16135fc999b720b82bbe8bc262efd2d68f94fd993a100a6b5427fa7d50a2cc13653a94d3ff028058cf4e37c59c489f313775e75e76b765aa91970fe
File without changes
File without changes
@@ -27,12 +27,15 @@ module Polytexnic
27
27
  cache = {}
28
28
  math_cache = {}
29
29
  cleaned_markdown = cache_code_environments
30
+ puts cleaned_markdown if debug?
30
31
  cleaned_markdown.tap do |markdown|
31
32
  convert_code_inclusion(markdown)
32
33
  cache_latex_literal(markdown, cache)
33
34
  cache_raw_latex(markdown, cache)
35
+ puts markdown if debug?
34
36
  cache_math(markdown, math_cache)
35
37
  end
38
+ puts cleaned_markdown if debug?
36
39
  # Override the header ordering, which starts with 'section' by default.
37
40
  lh = 'chapter,section,subsection,subsubsection,paragraph,subparagraph'
38
41
  kramdown = Kramdown::Document.new(cleaned_markdown, latex_headers: lh)
@@ -67,13 +70,13 @@ module Polytexnic
67
70
  # Caches raw LaTeX commands to be passed through the pipeline.
68
71
  def cache_raw_latex(markdown, cache)
69
72
  command_regex = /(
70
- ^\s*\\\w+.*\}\s*$ # Command on line with arg
73
+ ^\s*\\\w+.*\}[ \t]*$ # Command on line with arg
71
74
  |
72
75
  ~\\ref\{.*?\} # reference with a tie
73
76
  |
74
77
  ~\\eqref\{.*?\} # eq reference with a tie
75
78
  |
76
- \\\w+\{.*?\} # command with one arg
79
+ \\[^\s]+\{.*?\} # command with one arg
77
80
  |
78
81
  \\\w+ # normal command
79
82
  |
@@ -90,13 +93,9 @@ module Polytexnic
90
93
  # Restores raw LaTeX from the cache
91
94
  def restore_raw_latex(text, cache)
92
95
  cache.each do |key, value|
93
- if value == '\&'
94
- # Bizarrely, the default code doesn't work for '\&'.
95
- # I actually suspect it may be a bug in Ruby. This hacks around it.
96
- text.gsub!(key, value.sub(/\\/, '\\\\\\'))
97
- else
98
- text.gsub!(key, value)
99
- end
96
+ # Because of the way backslashes get interpolated, we need to add
97
+ # some extra ones to cover all the cases.
98
+ text.gsub!(key, value.gsub(/\\/, '\\\\\\'))
100
99
  end
101
100
  end
102
101
 
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
@@ -104,6 +104,11 @@ That is it. You can keep writing your text after the footnote content.
104
104
  it { should include source }
105
105
  end
106
106
 
107
+ context "an accented character" do
108
+ let(:source) { "\\`{e}" }
109
+ it { should include source }
110
+ end
111
+
107
112
  context "a label and cross-reference" do
108
113
  let(:source) do <<-'EOS'
109
114
  # Chapter One
@@ -131,8 +136,15 @@ Chapter~\ref{cha:one}
131
136
  foo
132
137
 
133
138
  \begin{equation}
134
- \label{eq:phi}
135
- \phi = \frac{1+\sqrt{5}}{2}
139
+ \label{eq:maxwell}
140
+ \left.\begin{aligned}
141
+ \nabla\cdot\mathbf{E} & = \rho \\
142
+ \nabla\cdot\mathbf{B} & = 0 \\
143
+ \nabla\times\mathbf{E} & = -\dot{\mathbf{B}} \\
144
+ \nabla\times\mathbf{B} & = \mathbf{J} + \dot{\mathbf{E}}
145
+ \end{aligned}
146
+ \right\}
147
+ \quad\text{Maxwell equations}
136
148
  \end{equation}
137
149
 
138
150
  bar
@@ -169,6 +181,20 @@ def foo; "bar"; end
169
181
  end
170
182
  it { should resemble '%= <<(/path/to/code)' }
171
183
  end
184
+
185
+ context "codelisting followed by a section" do
186
+ let(:source) do <<-'EOS'
187
+ \begin{codelisting}
188
+ \codecaption{Lorem ipsum.}
189
+ \label{code:lorem}
190
+ <<(/path/to/code)
191
+ \end{codelisting}
192
+
193
+ # Foo
194
+ EOS
195
+ end
196
+ it { should resemble '\chapter{Foo}' }
197
+ end
172
198
  end
173
199
 
174
200
  describe "source code" do
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.4
4
+ version: 0.6.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: 2013-11-15 00:00:00.000000000 Z
12
+ date: 2013-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -165,6 +165,8 @@ files:
165
165
  - .pull_requests/1383274008
166
166
  - .pull_requests/1383327328
167
167
  - .pull_requests/1384446851
168
+ - .pull_requests/1384800466
169
+ - .pull_requests/1384811507
168
170
  - .rspec
169
171
  - .ruby-gemset
170
172
  - .ruby-version