asciidoctor 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- data/README.md +15 -11
- data/asciidoctor.gemspec +1 -1
- data/lib/asciidoctor/document.rb +20 -9
- data/lib/asciidoctor/lexer.rb +3 -3
- data/lib/asciidoctor/reader.rb +2 -0
- data/lib/asciidoctor/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -5,16 +5,19 @@ Asciidoctor is a pure-ruby processor for turning
|
|
5
5
|
[Asciidoc](http://www.methods.co.nz/asciidoc/index.html) documents
|
6
6
|
into HTML (and, eventually, other formats perhaps).
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
Asciidoctor uses simple built-in ERB templates to style the output in
|
9
|
+
a way that roughly matches the default HTML output of the native
|
10
|
+
Python processor. You can override this behavior by providing
|
11
|
+
[Tilt]-compatible templates. See the Usage section for more details.
|
11
12
|
|
12
13
|
Asciidoctor currently works with Ruby 1.8.7 and 1.9.3, though I don't
|
13
14
|
know of any reason it shouldn't work with more exotic Ruby versions,
|
14
15
|
and would welcome help in testing that out.
|
15
16
|
|
16
|
-
The initial code
|
17
|
-
site repo
|
17
|
+
The initial code from which asciidoctor started was from the [Git SCM
|
18
|
+
site repo][gitscm-next].
|
19
|
+
|
20
|
+
[gitscm-next]: https://github.com/github/gitscm-next
|
18
21
|
|
19
22
|
# Installation
|
20
23
|
|
@@ -49,12 +52,11 @@ Render an Asciidoc-formatted string
|
|
49
52
|
|
50
53
|
Asciidoctor allows you to override the default template used to render
|
51
54
|
almost any individual Asciidoc elements. If you provide a directory of
|
52
|
-
[Tilt]
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
else.
|
55
|
+
[Tilt]-compatible templates, named in a way Asciidoctor can figure out
|
56
|
+
which template goes with which element, Asciidoctor will use the
|
57
|
+
templates in this directory instead of its built-in templates for any
|
58
|
+
elements for which it finds a matching template. It will use its
|
59
|
+
default templates for everything else.
|
58
60
|
|
59
61
|
doc = Asciidoctor::Document.new("*This* is it.", :template_dir => 'templates')
|
60
62
|
puts doc.render
|
@@ -72,6 +74,8 @@ with an ERB template you'd put a file called
|
|
72
74
|
|
73
75
|
For more usage examples, see the test suite.
|
74
76
|
|
77
|
+
[Tilt]: https://github.com/rtomayko/tilt
|
78
|
+
|
75
79
|
## Contributing
|
76
80
|
In the spirit of [free software][free-sw], **everyone** is encouraged to help
|
77
81
|
improve this project.
|
data/asciidoctor.gemspec
CHANGED
@@ -13,7 +13,7 @@ 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 = 'asciidoctor'
|
16
|
-
s.version = '0.0.
|
16
|
+
s.version = '0.0.3'
|
17
17
|
s.date = '2012-08-03'
|
18
18
|
s.rubyforge_project = 'asciidoctor'
|
19
19
|
|
data/lib/asciidoctor/document.rb
CHANGED
@@ -30,17 +30,17 @@ class Asciidoctor::Document
|
|
30
30
|
@elements = []
|
31
31
|
@options = options
|
32
32
|
|
33
|
-
reader = Reader.new(data, &block)
|
33
|
+
@reader = Reader.new(data, &block)
|
34
34
|
|
35
35
|
# pseudo-delegation :)
|
36
|
-
@defines = reader.defines
|
37
|
-
@references = reader.references
|
36
|
+
@defines = @reader.defines
|
37
|
+
@references = @reader.references
|
38
38
|
|
39
39
|
# Now parse @lines into elements
|
40
|
-
while reader.has_lines?
|
41
|
-
reader.skip_blank
|
40
|
+
while @reader.has_lines?
|
41
|
+
@reader.skip_blank
|
42
42
|
|
43
|
-
@elements << Lexer.next_block(reader, self) if reader.has_lines?
|
43
|
+
@elements << Lexer.next_block(@reader, self) if @reader.has_lines?
|
44
44
|
end
|
45
45
|
|
46
46
|
Asciidoctor.debug "Found #{@elements.size} elements in this document:"
|
@@ -58,6 +58,11 @@ class Asciidoctor::Document
|
|
58
58
|
|
59
59
|
end
|
60
60
|
|
61
|
+
# Make the raw source for the Document available.
|
62
|
+
def source
|
63
|
+
@reader.source if @reader
|
64
|
+
end
|
65
|
+
|
61
66
|
# We need to be able to return some semblance of a title
|
62
67
|
def title
|
63
68
|
return @title if @title
|
@@ -72,6 +77,7 @@ class Asciidoctor::Document
|
|
72
77
|
|
73
78
|
@title
|
74
79
|
end
|
80
|
+
alias :name :title
|
75
81
|
|
76
82
|
def splain
|
77
83
|
if @header
|
@@ -91,19 +97,24 @@ class Asciidoctor::Document
|
|
91
97
|
nil
|
92
98
|
end
|
93
99
|
|
94
|
-
def renderer
|
100
|
+
def renderer(options = {})
|
95
101
|
return @renderer if @renderer
|
96
102
|
render_options = {}
|
103
|
+
# Load up relevant Document @options
|
97
104
|
if @options[:template_dir]
|
98
105
|
render_options[:template_dir] = @options[:template_dir]
|
99
106
|
end
|
107
|
+
# Override Document @option settings with options passed in
|
108
|
+
render_options.merge! options
|
109
|
+
|
100
110
|
@renderer = Renderer.new(render_options)
|
101
111
|
end
|
102
112
|
|
103
113
|
# Public: Render the Asciidoc document using erb templates
|
104
114
|
#
|
105
|
-
def render
|
106
|
-
|
115
|
+
def render(options = {})
|
116
|
+
r = renderer(options)
|
117
|
+
html = r.render('document', self, :header => @header, :preamble => @preamble)
|
107
118
|
end
|
108
119
|
|
109
120
|
def content
|
data/lib/asciidoctor/lexer.rb
CHANGED
@@ -148,7 +148,7 @@ class Asciidoctor::Lexer
|
|
148
148
|
reader.get_line if reader.has_lines? && reader.peek_line.strip.empty?
|
149
149
|
|
150
150
|
dd_segment = Reader.new(list_item_segment(reader, :alt_ending => this_dlist))
|
151
|
-
while dd_segment.
|
151
|
+
while dd_segment.has_lines?
|
152
152
|
dd.blocks << next_block(dd_segment, block)
|
153
153
|
end
|
154
154
|
|
@@ -602,7 +602,7 @@ class Asciidoctor::Lexer
|
|
602
602
|
|
603
603
|
if !section.anchor.nil?
|
604
604
|
anchor_id = section.anchor.match(/^\[(.*)\]/) ? $1 : section.anchor
|
605
|
-
|
605
|
+
parent.document.references[anchor_id] = section.anchor
|
606
606
|
section.anchor = anchor_id
|
607
607
|
end
|
608
608
|
|
@@ -633,7 +633,7 @@ class Asciidoctor::Lexer
|
|
633
633
|
section_lines << this_line
|
634
634
|
section_lines.concat reader.grab_lines_until {|line| line.match( REGEXP[:listing] ) }
|
635
635
|
# Also grab the last line, if there is one
|
636
|
-
this_line =
|
636
|
+
this_line = reader.get_line
|
637
637
|
section_lines << this_line unless this_line.nil?
|
638
638
|
else
|
639
639
|
section_lines << this_line
|
data/lib/asciidoctor/reader.rb
CHANGED
data/lib/asciidoctor/version.rb
CHANGED