literati 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/literati.rb +4 -3
- data/literati.gemspec +2 -2
- data/test/test_literati.rb +30 -1
- metadata +49 -62
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Render literate Haskell into HTML using Ruby and magic. But mostly Ruby.
|
|
13
13
|
|
14
14
|
Simple and straightforward!
|
15
15
|
|
16
|
-
By default, we render using Markdown. If you want to use another markup language or Markdown renderer, then you can use the extra magical extended API. The only requirement is that the class takes the content as the sole argument for the initializer and exposes a `to_html` method.
|
16
|
+
By default, we render using Markdown. If you want to use another markup language or Markdown renderer, then you can use the extra magical extended API. The only requirement is that the class takes the content as the sole argument for the initializer and exposes a `to_html` method. An example `RedCarpet` wrapper would look like this:
|
17
17
|
|
18
18
|
# A simple class to wrap passing the right arguments to RedCarpet.
|
19
19
|
class RedCarpetRenderer
|
@@ -33,7 +33,7 @@ By default, we render using Markdown. If you want to use another markup languag
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
You can use that as a base for other wrappers. If you wanted to use, for example, a `reStructuredText` wrapper of some sort with `literati`, you'd do something like this:
|
36
|
+
You can easily use that as a base for other wrappers. If you wanted to use, for example, a `reStructuredText` wrapper of some sort with `literati`, you'd do something like this:
|
37
37
|
|
38
38
|
renderer = Literati::Renderer.new("content", RSTRenderer)
|
39
39
|
renderer.to_html
|
data/lib/literati.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
3
|
module Literati
|
4
|
-
VERSION = '0.0.
|
4
|
+
VERSION = '0.0.3'
|
5
5
|
|
6
6
|
# Render the given content to HTML.
|
7
7
|
#
|
@@ -73,7 +73,7 @@ module Literati
|
|
73
73
|
attr_accessor :markdown_class
|
74
74
|
|
75
75
|
# Regex used to determine presence of Bird-style comments
|
76
|
-
BIRD_TRACKS_REGEX = /^\> (.*)/
|
76
|
+
BIRD_TRACKS_REGEX = /^\>(\-\-| )(.*)/
|
77
77
|
|
78
78
|
# Initialize a new literate Haskell renderer.
|
79
79
|
#
|
@@ -121,7 +121,8 @@ module Literati
|
|
121
121
|
#
|
122
122
|
# Returns the given line of text sans bird tracks.
|
123
123
|
def remove_bird_tracks(line)
|
124
|
-
line.
|
124
|
+
tracks = line.scan(BIRD_TRACKS_REGEX)[0]
|
125
|
+
(tracks.first == " ") ? tracks[1] : tracks.join
|
125
126
|
end
|
126
127
|
|
127
128
|
# Given an Array of lines, pulls from the front of the Array
|
data/literati.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'literati'
|
16
|
-
s.version = '0.0.
|
17
|
-
s.date = '2012-
|
16
|
+
s.version = '0.0.3'
|
17
|
+
s.date = '2012-11-07'
|
18
18
|
s.rubyforge_project = 'literati'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/test/test_literati.rb
CHANGED
@@ -14,6 +14,13 @@ TEST_CONTENT = "Hello there.
|
|
14
14
|
|
15
15
|
More *Markdown*..."
|
16
16
|
|
17
|
+
TEST_CONTENT_WITH_COMMENT = "Well this is convenient.
|
18
|
+
|
19
|
+
>-- A comment, mi lord.
|
20
|
+
> WHAT? WHERE???
|
21
|
+
|
22
|
+
Mo' content."
|
23
|
+
|
17
24
|
class DummyRenderer
|
18
25
|
def initialize(content)
|
19
26
|
@content = content
|
@@ -43,8 +50,30 @@ class LiteratiTest < Test::Unit::TestCase
|
|
43
50
|
end
|
44
51
|
end
|
45
52
|
|
53
|
+
context "Markdown rendering with comments" do
|
54
|
+
setup do
|
55
|
+
@renderer = Literati::Renderer.new(TEST_CONTENT_WITH_COMMENT)
|
56
|
+
end
|
57
|
+
|
58
|
+
test "renders to Markdown string" do
|
59
|
+
assert_match /\`\`\`haskell/m, @renderer.to_markdown
|
60
|
+
end
|
61
|
+
|
62
|
+
test "removes bird tracks" do
|
63
|
+
assert_equal "-- a wild comment appears!", @renderer.remove_bird_tracks(">-- a wild comment appears!")
|
64
|
+
end
|
65
|
+
|
66
|
+
test "slurps remaining block properly" do
|
67
|
+
assert_equal "\n-- line one\nline two\nline three", @renderer.slurp_remaining_bird_tracks([">-- line one", "> line two", "> line three", ""])
|
68
|
+
end
|
69
|
+
|
70
|
+
test "slurps remaining block properly with multiple comment lines" do
|
71
|
+
assert_equal "\n-- line one\n--line two\nline three\n-- more commenting...", @renderer.slurp_remaining_bird_tracks([">-- line one", ">--line two", "> line three", ">-- more commenting...", ""])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
46
75
|
context "HTML rendering" do
|
47
|
-
test "renders to HTML using our Smart Renderer
|
76
|
+
test "renders to HTML using our Smart Renderer(tm) by default" do
|
48
77
|
Literati::MarkdownRenderer.any_instance.expects(:to_html)
|
49
78
|
Literati.render("markdown\n\n> codes\n\nmoar markdown")
|
50
79
|
end
|
metadata
CHANGED
@@ -1,61 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: literati
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jeremy McAnally
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: redcarpet
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: contest
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: contest
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
47
38
|
type: :development
|
48
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
49
46
|
description: Render literate Haskell with Ruby for great good.
|
50
47
|
email: jeremy@github.com
|
51
|
-
executables:
|
48
|
+
executables:
|
52
49
|
- literati
|
53
50
|
extensions: []
|
54
|
-
|
55
|
-
extra_rdoc_files:
|
51
|
+
extra_rdoc_files:
|
56
52
|
- README.md
|
57
53
|
- LICENSE
|
58
|
-
files:
|
54
|
+
files:
|
59
55
|
- LICENSE
|
60
56
|
- README.md
|
61
57
|
- Rakefile
|
@@ -63,39 +59,30 @@ files:
|
|
63
59
|
- lib/literati.rb
|
64
60
|
- literati.gemspec
|
65
61
|
- test/test_literati.rb
|
66
|
-
has_rdoc: true
|
67
62
|
homepage: http://github.com/jm/literati
|
68
63
|
licenses: []
|
69
|
-
|
70
64
|
post_install_message:
|
71
|
-
rdoc_options:
|
65
|
+
rdoc_options:
|
72
66
|
- --charset=UTF-8
|
73
|
-
require_paths:
|
67
|
+
require_paths:
|
74
68
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
70
|
none: false
|
77
|
-
requirements:
|
78
|
-
- -
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
|
82
|
-
- 0
|
83
|
-
version: "0"
|
84
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
76
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
93
81
|
requirements: []
|
94
|
-
|
95
82
|
rubyforge_project: literati
|
96
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.8.23
|
97
84
|
signing_key:
|
98
85
|
specification_version: 2
|
99
86
|
summary: Render literate Haskell with Ruby.
|
100
|
-
test_files:
|
87
|
+
test_files:
|
101
88
|
- test/test_literati.rb
|