lesstile 0.2 → 0.3
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.
- data/History.txt +4 -0
- data/Manifest.txt +0 -1
- data/README.txt +4 -2
- data/lib/lesstile.rb +22 -2
- data/spec/spec_lesstile.rb +15 -0
- metadata +6 -7
- data/bin/lesstile +0 -0
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -10,6 +10,7 @@ Integrates with CodeRay for sexy syntax highlighting.
|
|
10
10
|
== SYNOPSIS:
|
11
11
|
|
12
12
|
comment = <<-EOS
|
13
|
+
"Ego Link":http://rhnh.net
|
13
14
|
Wow, this post is awesome. I'd implement it like this:
|
14
15
|
|
15
16
|
--- Ruby
|
@@ -35,9 +36,10 @@ Integrates with CodeRay for sexy syntax highlighting.
|
|
35
36
|
|
36
37
|
* CodeRay (optional)
|
37
38
|
|
38
|
-
== INSTALL:
|
39
|
+
== INSTALL (pick one):
|
39
40
|
|
40
|
-
sudo gem install lesstile
|
41
|
+
sudo gem install lesstile # gem install
|
42
|
+
git clone git://github.com/xaviershay/lesstile.git # go from source
|
41
43
|
|
42
44
|
== LICENSE:
|
43
45
|
|
data/lib/lesstile.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'cgi'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
class Lesstile
|
4
|
-
VERSION = '0.
|
5
|
+
VERSION = '0.3'
|
5
6
|
|
6
7
|
class << self
|
7
8
|
# Returns lesstile formatted text as valid XHTML
|
@@ -35,7 +36,26 @@ class Lesstile
|
|
35
36
|
def default_options
|
36
37
|
{
|
37
38
|
:code_formatter => lambda {|code, lang| "<pre><code>#{code}</code></pre>" },
|
38
|
-
:text_formatter => lambda {|text|
|
39
|
+
:text_formatter => lambda {|text|
|
40
|
+
text = text.gsub(/\n/, "<br />\n")
|
41
|
+
uris = URI.extract(text)
|
42
|
+
|
43
|
+
buffer = ""
|
44
|
+
uris.each do |uri|
|
45
|
+
pivot = text.index(uri)
|
46
|
+
pre = text[0..pivot-1]
|
47
|
+
m = pre.match(/"(.*)":$/)
|
48
|
+
link = m ? m.captures.first : nil
|
49
|
+
if link
|
50
|
+
buffer += m.pre_match + "<a href='#{uri.to_s}'>#{link}</a>"
|
51
|
+
else
|
52
|
+
buffer += pre + uri
|
53
|
+
end
|
54
|
+
text = text[pivot+uri.length..-1]
|
55
|
+
end
|
56
|
+
buffer += text
|
57
|
+
buffer
|
58
|
+
}
|
39
59
|
}
|
40
60
|
end
|
41
61
|
|
data/spec/spec_lesstile.rb
CHANGED
@@ -44,6 +44,21 @@ describe "Lesstile#format_as_xhtml" do
|
|
44
44
|
it 'escapes html' do
|
45
45
|
@format["<a>&---\nyo<---"].should == "<a>&|yo<|"
|
46
46
|
end
|
47
|
+
|
48
|
+
it 'escapes quotes' do
|
49
|
+
@format['"'].should == """
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'Lesstile default text formatter' do
|
54
|
+
before(:all) do
|
55
|
+
@format = lambda {|text| Lesstile.default_options[:text_formatter][text] }
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'recognises links in text' do
|
59
|
+
@format['"a link":http://example.com "<link":http://example.com linkage'].should ==
|
60
|
+
"<a href='http://example.com'>a link</a> <a href='http://example.com'><link</a> linkage"
|
61
|
+
end
|
47
62
|
end
|
48
63
|
|
49
64
|
describe "Lesstile#format_with_xhtml with default formatters" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lesstile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ""
|
6
6
|
authors:
|
7
7
|
- Xavier Shay
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-04-17 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,12 +19,12 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
22
|
+
version: 1.5.1
|
23
23
|
version:
|
24
|
-
description: "Integrates with CodeRay for sexy syntax highlighting. == SYNOPSIS: comment = <<-EOS Wow, this post is awesome. I'd implement it like this: --- Ruby def hello_world puts \"hello world!\" end ---"
|
24
|
+
description: "Integrates with CodeRay for sexy syntax highlighting. == SYNOPSIS: comment = <<-EOS \"Ego Link\":http://rhnh.net Wow, this post is awesome. I'd implement it like this: --- Ruby def hello_world puts \"hello world!\" end ---"
|
25
25
|
email: xavier@rhnh.net
|
26
|
-
executables:
|
27
|
-
|
26
|
+
executables: []
|
27
|
+
|
28
28
|
extensions: []
|
29
29
|
|
30
30
|
extra_rdoc_files:
|
@@ -36,7 +36,6 @@ files:
|
|
36
36
|
- Manifest.txt
|
37
37
|
- README.txt
|
38
38
|
- Rakefile
|
39
|
-
- bin/lesstile
|
40
39
|
- lib/lesstile.rb
|
41
40
|
- spec/spec_lesstile.rb
|
42
41
|
has_rdoc: true
|
data/bin/lesstile
DELETED
File without changes
|