lesstile 0.1.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -2
- data/Manifest.txt +1 -0
- data/README.txt +0 -1
- data/Rakefile +0 -1
- data/bin/lesstile +0 -0
- data/lib/lesstile.rb +16 -5
- metadata +5 -13
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -13,7 +13,6 @@ Hoe.new('lesstile', Lesstile::VERSION) do |p|
|
|
13
13
|
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
14
14
|
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
15
15
|
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
16
|
-
p.extra_deps << ['facets', '>= 1.0']
|
17
16
|
p.remote_rdoc_dir = ""
|
18
17
|
end
|
19
18
|
|
data/bin/lesstile
ADDED
File without changes
|
data/lib/lesstile.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
require 'facets/string/nchar'
|
2
|
-
require 'facets/string/blank'
|
3
1
|
require 'cgi'
|
4
2
|
|
5
3
|
class Lesstile
|
6
|
-
VERSION = '0.
|
4
|
+
VERSION = '0.2'
|
7
5
|
|
8
6
|
class << self
|
9
7
|
# Returns lesstile formatted text as valid XHTML
|
@@ -14,7 +12,7 @@ class Lesstile
|
|
14
12
|
def format_as_xhtml(text, options = {})
|
15
13
|
options = default_options.merge(options)
|
16
14
|
|
17
|
-
text += "\n" unless
|
15
|
+
text += "\n" unless ends_with?(text, "\n")
|
18
16
|
text.gsub!(/\r\n/, "\n")
|
19
17
|
text = CGI::escapeHTML(text)
|
20
18
|
|
@@ -24,7 +22,7 @@ class Lesstile
|
|
24
22
|
while match = text.match(code_regex)
|
25
23
|
captures = match.captures
|
26
24
|
code = captures[1]
|
27
|
-
lang = captures[0]
|
25
|
+
lang = blank?(captures[0]) ? nil : captures[0].downcase.intern
|
28
26
|
|
29
27
|
output += options[:text_formatter][match.pre_match] + options[:code_formatter][code, lang]
|
30
28
|
text = match.post_match
|
@@ -40,6 +38,19 @@ class Lesstile
|
|
40
38
|
:text_formatter => lambda {|text| text.gsub(/\n/, "<br />\n") }
|
41
39
|
}
|
42
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# From http://facets.rubyforge.org/
|
45
|
+
# Don't add to String since we don't need them that much so why reopen the class
|
46
|
+
|
47
|
+
def ends_with?(string, suffix)
|
48
|
+
string.rindex(suffix) == string.size - suffix.size
|
49
|
+
end
|
50
|
+
|
51
|
+
def blank?(string)
|
52
|
+
string !~ /\S/
|
53
|
+
end
|
43
54
|
end
|
44
55
|
|
45
56
|
# A formatter that syntax highlights code using CodeRay
|
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.2"
|
5
5
|
platform: ""
|
6
6
|
authors:
|
7
7
|
- Xavier Shay
|
@@ -9,18 +9,9 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2008-02-08 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: facets
|
17
|
-
version_requirement:
|
18
|
-
version_requirements: !ruby/object:Gem::Requirement
|
19
|
-
requirements:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: "1.0"
|
23
|
-
version:
|
24
15
|
- !ruby/object:Gem::Dependency
|
25
16
|
name: hoe
|
26
17
|
version_requirement:
|
@@ -32,8 +23,8 @@ dependencies:
|
|
32
23
|
version:
|
33
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 ---"
|
34
25
|
email: xavier@rhnh.net
|
35
|
-
executables:
|
36
|
-
|
26
|
+
executables:
|
27
|
+
- lesstile
|
37
28
|
extensions: []
|
38
29
|
|
39
30
|
extra_rdoc_files:
|
@@ -45,6 +36,7 @@ files:
|
|
45
36
|
- Manifest.txt
|
46
37
|
- README.txt
|
47
38
|
- Rakefile
|
39
|
+
- bin/lesstile
|
48
40
|
- lib/lesstile.rb
|
49
41
|
- spec/spec_lesstile.rb
|
50
42
|
has_rdoc: true
|