polytexnic 1.0.beta4 → 1.0.beta5
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/literal.rb +1 -1
- data/lib/polytexnic/preprocessors/html.rb +2 -2
- data/lib/polytexnic/utils.rb +7 -6
- data/lib/polytexnic/version.rb +1 -1
- data/spec/to_html/core_spec.rb +6 -1
- data/spec/to_html/input_spec.rb +3 -1
- 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: 5a8660e3ba5020ca916133a4dd388a904a44515a
|
4
|
+
data.tar.gz: 5677ef66765af80c5620c19ee5fe2f8f8c2f4218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0bbb2b8122364b561ff3918907eea18d8159a18b2cda446d511730cc663ffdbd3bdc09267136cf2e4fff09740921c6be217e9c572abb25557b3e520cab66eea
|
7
|
+
data.tar.gz: 17299412d2276f2bc78b79938c3031d7cbe1cfec9715cfc12ae990b50d2e1bc47e413cf7a4f870c1497b94b05eb845e7f190d8fc7b15ad792a846508ad9e6d12
|
data/lib/polytexnic/literal.rb
CHANGED
@@ -4,7 +4,7 @@ module Polytexnic
|
|
4
4
|
|
5
5
|
# Matches the line for syntax highlighting.
|
6
6
|
# %= lang: <language>[, options: ...]
|
7
|
-
LANG_REGEX = /^\s*%=\s+lang:\s*(\w+)(?:,\s*options:(.*))?/
|
7
|
+
LANG_REGEX = /^\s*%=\s+lang:\s*([\w+]+)(?:,\s*options:(.*))?/
|
8
8
|
|
9
9
|
|
10
10
|
# Makes the caches for literal environments.
|
@@ -46,9 +46,9 @@ module Polytexnic
|
|
46
46
|
# global substitutions.
|
47
47
|
def clean_document(polytex)
|
48
48
|
doc = cache_literal(add_commands(polytex))
|
49
|
-
inline_verbatim(doc)
|
50
|
-
cache_hrefs(doc)
|
51
49
|
expand_input!(doc, Proc.new { |source| cache_literal(source) }, 'tex')
|
50
|
+
inline_verbatim(doc)
|
51
|
+
cache_urls(doc)
|
52
52
|
remove_comments(doc)
|
53
53
|
double_backslashes(cache_display_inline_math(doc))
|
54
54
|
end
|
data/lib/polytexnic/utils.rb
CHANGED
@@ -90,13 +90,14 @@ module Polytexnic
|
|
90
90
|
string.gsub(/\\(\s+|$)/) { '\\\\' + $1.to_s }
|
91
91
|
end
|
92
92
|
|
93
|
-
# Caches URLs for \href commands.
|
94
|
-
def
|
93
|
+
# Caches URLs for \href and \url commands.
|
94
|
+
def cache_urls(doc, latex=false)
|
95
95
|
doc.tap do |text|
|
96
|
-
text.gsub!(/\\href{(.*?)}/) do
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
text.gsub!(/\\(href|url){(.*?)}/) do
|
97
|
+
command, url = $1, $2
|
98
|
+
key = digest(url)
|
99
|
+
literal_cache[key] = url
|
100
|
+
command == 'url' ? "\\href{#{key}}{#{url}}" : "\\href{#{key}}"
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
data/lib/polytexnic/version.rb
CHANGED
data/spec/to_html/core_spec.rb
CHANGED
@@ -201,7 +201,7 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
201
201
|
it { should resemble output }
|
202
202
|
end
|
203
203
|
|
204
|
-
describe "
|
204
|
+
describe "URLs" do
|
205
205
|
|
206
206
|
context "standard URL" do
|
207
207
|
let(:polytex) { '\href{http://example.com/}{Example Site}' }
|
@@ -219,6 +219,11 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
219
219
|
let(:polytex) { '\href{http://example.com/escaped\_text}{Example Site}' }
|
220
220
|
it { should include '<a href="http://example.com/escaped_text">Example Site</a>' }
|
221
221
|
end
|
222
|
+
|
223
|
+
context "self-linking URL" do
|
224
|
+
let(:polytex) { '\url{http://example.com/}' }
|
225
|
+
it { should include '<a href="http://example.com/">http://example.com/</a>' }
|
226
|
+
end
|
222
227
|
end
|
223
228
|
|
224
229
|
describe "centering" do
|
data/spec/to_html/input_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe 'Polytexnic::Pipeline#to_html' do
|
|
10
10
|
let(:external_file) { 'foo.tex' }
|
11
11
|
let(:nested_external_file) { 'bar.tex' }
|
12
12
|
let(:input) do <<-'EOS'
|
13
|
-
Lorem ipsum
|
13
|
+
Lorem ipsum \href{http://example.com/}{example}
|
14
14
|
%= lang:ruby
|
15
15
|
\begin{code}
|
16
16
|
def foo; 'foo'; end
|
@@ -44,8 +44,10 @@ def bar(): return "bar"
|
|
44
44
|
let(:bar_html) do
|
45
45
|
'<div class="code"><div class="highlight"><pre><span class="k">def</span> <span class="nf">bar</span><span class="p">():'
|
46
46
|
end
|
47
|
+
let(:href_html) { '<a href="http://example.com/">example</a>' }
|
47
48
|
|
48
49
|
it { should include foo_html }
|
49
50
|
it { should include bar_html }
|
51
|
+
it { should include href_html }
|
50
52
|
end
|
51
53
|
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.beta5
|
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-08-
|
12
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|