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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77cd3da83721b462b620c6264b757009d7764242
4
- data.tar.gz: 66afdad9074a52e82885ab4c59de356b41aefc27
3
+ metadata.gz: 5a8660e3ba5020ca916133a4dd388a904a44515a
4
+ data.tar.gz: 5677ef66765af80c5620c19ee5fe2f8f8c2f4218
5
5
  SHA512:
6
- metadata.gz: 6fc1fd9be6e8abca50d1974632eb8240a4cc1d2e0d9eb97f0c82fd38796a969f44477c426d54926f654b84325936e6ddd4825ea7ffd5b9d2ab924fb341a59a2d
7
- data.tar.gz: 333b985f56228ca304ace76eb0ee5b578fc01068c0c955e8d8cfb9f84f81b9983115ae9a0ca36022491561827ab28d6481ac9f88166df102b39f291472627c94
6
+ metadata.gz: f0bbb2b8122364b561ff3918907eea18d8159a18b2cda446d511730cc663ffdbd3bdc09267136cf2e4fff09740921c6be217e9c572abb25557b3e520cab66eea
7
+ data.tar.gz: 17299412d2276f2bc78b79938c3031d7cbe1cfec9715cfc12ae990b50d2e1bc47e413cf7a4f870c1497b94b05eb845e7f190d8fc7b15ad792a846508ad9e6d12
@@ -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
@@ -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 cache_hrefs(doc, latex=false)
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
- key = digest($1)
98
- literal_cache[key] = $1
99
- "\\href{#{key}}"
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
@@ -1,3 +1,3 @@
1
1
  module Polytexnic
2
- VERSION = "1.0.beta4"
2
+ VERSION = "1.0.beta5"
3
3
  end
@@ -201,7 +201,7 @@ describe 'Polytexnic::Pipeline#to_html' do
201
201
  it { should resemble output }
202
202
  end
203
203
 
204
- describe "href" do
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
@@ -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.beta4
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-02 00:00:00.000000000 Z
12
+ date: 2014-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri