asciidoctor 0.0.3 → 0.0.4
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/asciidoctor.gemspec +2 -2
- data/lib/asciidoctor/lexer.rb +27 -12
- data/lib/asciidoctor/section.rb +1 -1
- data/lib/asciidoctor/version.rb +1 -1
- metadata +2 -2
data/asciidoctor.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 = 'asciidoctor'
|
16
|
-
s.version = '0.0.
|
17
|
-
s.date = '2012-08-
|
16
|
+
s.version = '0.0.4'
|
17
|
+
s.date = '2012-08-14'
|
18
18
|
s.rubyforge_project = 'asciidoctor'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/asciidoctor/lexer.rb
CHANGED
@@ -8,6 +8,14 @@ class Asciidoctor::Lexer
|
|
8
8
|
raise 'Au contraire, mon frere. No lexer instances will be running around.'
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.document_from_parent(parent)
|
12
|
+
if parent.is_a? Document
|
13
|
+
parent
|
14
|
+
else
|
15
|
+
parent.document
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
# Return the next block from the Reader.
|
12
20
|
#
|
13
21
|
# * Skip over blank lines to find the start of the next content block.
|
@@ -31,7 +39,7 @@ class Asciidoctor::Lexer
|
|
31
39
|
# match[1] being bracketed, so the condition isn't necessary.
|
32
40
|
anchor = match[1].match(/^\[(.*)\]/) ? $1 : match[1]
|
33
41
|
# NOTE: Set @references['foo'] = '[foo]'
|
34
|
-
parent.
|
42
|
+
document_from_parent(parent).references[anchor] = match[1]
|
35
43
|
reader.get_line
|
36
44
|
else
|
37
45
|
anchor = nil
|
@@ -93,7 +101,8 @@ class Asciidoctor::Lexer
|
|
93
101
|
|
94
102
|
block = Block.new(parent, :oblock, [])
|
95
103
|
while buffer.has_lines?
|
96
|
-
|
104
|
+
new_block = next_block(buffer, block)
|
105
|
+
block.blocks << new_block unless new_block.nil?
|
97
106
|
end
|
98
107
|
|
99
108
|
elsif list_type = [:olist, :colist].detect{|l| this_line.match( REGEXP[l] )}
|
@@ -106,7 +115,8 @@ class Asciidoctor::Lexer
|
|
106
115
|
reader.unshift match[2].lstrip.sub(/^\./, '\.')
|
107
116
|
item_segment = Reader.new(list_item_segment(reader, :alt_ending => REGEXP[list_type]))
|
108
117
|
while item_segment.has_lines?
|
109
|
-
|
118
|
+
new_block = next_block(item_segment, block)
|
119
|
+
item.blocks << new_block unless new_block.nil?
|
110
120
|
end
|
111
121
|
|
112
122
|
if item.blocks.any? &&
|
@@ -149,7 +159,8 @@ class Asciidoctor::Lexer
|
|
149
159
|
|
150
160
|
dd_segment = Reader.new(list_item_segment(reader, :alt_ending => this_dlist))
|
151
161
|
while dd_segment.has_lines?
|
152
|
-
|
162
|
+
new_block = next_block(dd_segment, block)
|
163
|
+
dd.blocks << new_block unless new_block.nil?
|
153
164
|
end
|
154
165
|
|
155
166
|
if dd.blocks.any? &&
|
@@ -185,8 +196,9 @@ class Asciidoctor::Lexer
|
|
185
196
|
block = Block.new(parent, :quote)
|
186
197
|
buffer = Reader.new(reader.grab_lines_until {|line| line.match( REGEXP[:quote] ) })
|
187
198
|
|
188
|
-
while buffer.
|
189
|
-
|
199
|
+
while buffer.has_lines?
|
200
|
+
new_block = next_block(buffer, block)
|
201
|
+
block.blocks << new_block unless new_block.nil?
|
190
202
|
end
|
191
203
|
|
192
204
|
elsif this_line.match(REGEXP[:lit_blk])
|
@@ -378,7 +390,8 @@ class Asciidoctor::Lexer
|
|
378
390
|
item_segment = Reader.new(list_item_segment(reader, :alt_ending => REGEXP[list_type]))
|
379
391
|
# item_segment = list_item_segment(reader)
|
380
392
|
while item_segment.has_lines?
|
381
|
-
|
393
|
+
new_block = next_block(item_segment, block)
|
394
|
+
list_item.blocks << new_block unless new_block.nil?
|
382
395
|
end
|
383
396
|
|
384
397
|
Asciidoctor.debug "\n\nlist_item has #{list_item.blocks.count} blocks, and first is a #{list_item.blocks.first.class} with context #{list_item.blocks.first.context rescue 'n/a'}\n\n"
|
@@ -441,7 +454,8 @@ class Asciidoctor::Lexer
|
|
441
454
|
lines.unshift match[2].lstrip.sub(/^\./, '\.')
|
442
455
|
item_segment = list_item_segment(lines, :alt_ending => REGEXP[list_type], :list_level => level)
|
443
456
|
while item_segment.any?
|
444
|
-
|
457
|
+
new_block = next_block(item_segment, block)
|
458
|
+
list_item.blocks << new_block unless new_block.nil?
|
445
459
|
end
|
446
460
|
|
447
461
|
first_block = list_item.blocks.first
|
@@ -563,14 +577,14 @@ class Asciidoctor::Lexer
|
|
563
577
|
return [sect_name, sect_level, sect_anchor]
|
564
578
|
end
|
565
579
|
|
566
|
-
# Private: Return the next section from the
|
580
|
+
# Private: Return the next section from the Reader.
|
567
581
|
#
|
568
582
|
# Examples
|
569
583
|
#
|
570
584
|
# source
|
571
585
|
# => "GREETINGS\n---------\nThis is my doc.\n\nSALUTATIONS\n-----------\nIt is awesome."
|
572
586
|
#
|
573
|
-
# doc = Asciidoctor::Document.new(source)
|
587
|
+
# TODO: doc = Asciidoctor::Document.new(source)
|
574
588
|
#
|
575
589
|
# doc.next_section
|
576
590
|
# ["GREETINGS", [:paragraph, "This is my doc."]]
|
@@ -602,7 +616,7 @@ class Asciidoctor::Lexer
|
|
602
616
|
|
603
617
|
if !section.anchor.nil?
|
604
618
|
anchor_id = section.anchor.match(/^\[(.*)\]/) ? $1 : section.anchor
|
605
|
-
parent.
|
619
|
+
document_from_parent(parent).references[anchor_id] = section.anchor
|
606
620
|
section.anchor = anchor_id
|
607
621
|
end
|
608
622
|
|
@@ -645,7 +659,8 @@ class Asciidoctor::Lexer
|
|
645
659
|
while section_reader.has_lines?
|
646
660
|
section_reader.skip_blank
|
647
661
|
|
648
|
-
|
662
|
+
new_block = next_block(section_reader, section) if section_reader.has_lines?
|
663
|
+
section << new_block unless new_block.nil?
|
649
664
|
end
|
650
665
|
|
651
666
|
section
|
data/lib/asciidoctor/section.rb
CHANGED
@@ -55,7 +55,7 @@ class Asciidoctor::Section
|
|
55
55
|
# Returns the String section name
|
56
56
|
def name
|
57
57
|
@name &&
|
58
|
-
@name.gsub(/(^|[^\\])\{(\w[\w\-]+\w)\}/) { $1 +
|
58
|
+
@name.gsub(/(^|[^\\])\{(\w[\w\-]+\w)\}/) { $1 + Asciidoctor::INTRINSICS[$2] }.
|
59
59
|
gsub( /`([^`]+)`/, '<tt>\1</tt>' )
|
60
60
|
end
|
61
61
|
|
data/lib/asciidoctor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|