rdoc 7.1.0 → 7.2.0
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.
- checksums.yaml +4 -4
- data/lib/rdoc/code_object/attr.rb +2 -1
- data/lib/rdoc/code_object/context/section.rb +26 -8
- data/lib/rdoc/code_object/context.rb +15 -4
- data/lib/rdoc/code_object/mixin.rb +3 -0
- data/lib/rdoc/code_object/top_level.rb +2 -0
- data/lib/rdoc/comment.rb +1 -1
- data/lib/rdoc/cross_reference.rb +1 -3
- data/lib/rdoc/generator/template/aliki/_head.rhtml +5 -0
- data/lib/rdoc/generator/template/aliki/class.rhtml +5 -5
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +28 -36
- data/lib/rdoc/generator/template/aliki/js/aliki.js +8 -2
- data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/lib/rdoc/generator/template/aliki/js/search_controller.js +1 -1
- data/lib/rdoc/markdown.kpeg +21 -7
- data/lib/rdoc/markdown.rb +35 -21
- data/lib/rdoc/markup/formatter.rb +129 -106
- data/lib/rdoc/markup/heading.rb +2 -2
- data/lib/rdoc/markup/inline_parser.rb +312 -0
- data/lib/rdoc/markup/parser.rb +1 -1
- data/lib/rdoc/markup/to_ansi.rb +51 -4
- data/lib/rdoc/markup/to_bs.rb +22 -42
- data/lib/rdoc/markup/to_html.rb +152 -177
- data/lib/rdoc/markup/to_html_crossref.rb +38 -78
- data/lib/rdoc/markup/to_html_snippet.rb +62 -62
- data/lib/rdoc/markup/to_label.rb +20 -21
- data/lib/rdoc/markup/to_markdown.rb +61 -37
- data/lib/rdoc/markup/to_rdoc.rb +86 -26
- data/lib/rdoc/markup/to_test.rb +9 -1
- data/lib/rdoc/markup/to_tt_only.rb +10 -16
- data/lib/rdoc/markup.rb +8 -30
- data/lib/rdoc/parser/changelog.rb +21 -0
- data/lib/rdoc/parser/prism_ruby.rb +44 -32
- data/lib/rdoc/parser/ruby.rb +1 -1
- data/lib/rdoc/text.rb +29 -5
- data/lib/rdoc/version.rb +1 -1
- metadata +4 -7
- data/lib/rdoc/markup/attr_changer.rb +0 -22
- data/lib/rdoc/markup/attr_span.rb +0 -35
- data/lib/rdoc/markup/attribute_manager.rb +0 -432
- data/lib/rdoc/markup/attributes.rb +0 -70
- data/lib/rdoc/markup/regexp_handling.rb +0 -40
data/lib/rdoc/markdown.rb
CHANGED
|
@@ -688,6 +688,20 @@ class RDoc::Markdown
|
|
|
688
688
|
end
|
|
689
689
|
end
|
|
690
690
|
|
|
691
|
+
# Escape character that has special meaning in RDoc format.
|
|
692
|
+
# To allow rdoc-styled link used in markdown format for now, bracket and brace are not escaped.
|
|
693
|
+
|
|
694
|
+
def rdoc_escape(text)
|
|
695
|
+
text.gsub(/[*+<\\_]/) {|s| "\\#{s}" }
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
# Escape link url that contains brackets.
|
|
699
|
+
# Brackets needs escape because link url will be surrounded by `[]` in RDoc format.
|
|
700
|
+
|
|
701
|
+
def rdoc_link_url_escape(text)
|
|
702
|
+
text.gsub(/[\[\]\\]/) {|s| "\\#{s}" }
|
|
703
|
+
end
|
|
704
|
+
|
|
691
705
|
##
|
|
692
706
|
# :category: Extensions
|
|
693
707
|
#
|
|
@@ -9731,7 +9745,7 @@ class RDoc::Markdown
|
|
|
9731
9745
|
return _tmp
|
|
9732
9746
|
end
|
|
9733
9747
|
|
|
9734
|
-
# Str = @StartList:a < @NormalChar+ > { a = text } (StrChunk:c { a << c })* { a }
|
|
9748
|
+
# Str = @StartList:a < @NormalChar+ > { a = text } (StrChunk:c { a << c })* { rdoc_escape(a) }
|
|
9735
9749
|
def _Str
|
|
9736
9750
|
|
|
9737
9751
|
_save = self.pos
|
|
@@ -9792,7 +9806,7 @@ class RDoc::Markdown
|
|
|
9792
9806
|
self.pos = _save
|
|
9793
9807
|
break
|
|
9794
9808
|
end
|
|
9795
|
-
@result = begin; a ; end
|
|
9809
|
+
@result = begin; rdoc_escape(a) ; end
|
|
9796
9810
|
_tmp = true
|
|
9797
9811
|
unless _tmp
|
|
9798
9812
|
self.pos = _save
|
|
@@ -9894,7 +9908,7 @@ class RDoc::Markdown
|
|
|
9894
9908
|
return _tmp
|
|
9895
9909
|
end
|
|
9896
9910
|
|
|
9897
|
-
# EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { text }
|
|
9911
|
+
# EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { rdoc_escape(text) }
|
|
9898
9912
|
def _EscapedChar
|
|
9899
9913
|
|
|
9900
9914
|
_save = self.pos
|
|
@@ -9921,7 +9935,7 @@ class RDoc::Markdown
|
|
|
9921
9935
|
self.pos = _save
|
|
9922
9936
|
break
|
|
9923
9937
|
end
|
|
9924
|
-
@result = begin; text ; end
|
|
9938
|
+
@result = begin; rdoc_escape(text) ; end
|
|
9925
9939
|
_tmp = true
|
|
9926
9940
|
unless _tmp
|
|
9927
9941
|
self.pos = _save
|
|
@@ -10122,7 +10136,7 @@ class RDoc::Markdown
|
|
|
10122
10136
|
return _tmp
|
|
10123
10137
|
end
|
|
10124
10138
|
|
|
10125
|
-
# Symbol = < @SpecialChar > { text }
|
|
10139
|
+
# Symbol = < @SpecialChar > { rdoc_escape(text) }
|
|
10126
10140
|
def _Symbol
|
|
10127
10141
|
|
|
10128
10142
|
_save = self.pos
|
|
@@ -10136,7 +10150,7 @@ class RDoc::Markdown
|
|
|
10136
10150
|
self.pos = _save
|
|
10137
10151
|
break
|
|
10138
10152
|
end
|
|
10139
|
-
@result = begin; text ; end
|
|
10153
|
+
@result = begin; rdoc_escape(text) ; end
|
|
10140
10154
|
_tmp = true
|
|
10141
10155
|
unless _tmp
|
|
10142
10156
|
self.pos = _save
|
|
@@ -11189,7 +11203,7 @@ class RDoc::Markdown
|
|
|
11189
11203
|
return _tmp
|
|
11190
11204
|
end
|
|
11191
11205
|
|
|
11192
|
-
# ExplicitLink = ExplicitLinkWithLabel:a { "{#{a[:label]}}[#{a[:link]}]" }
|
|
11206
|
+
# ExplicitLink = ExplicitLinkWithLabel:a { "{#{a[:label]}}[#{rdoc_link_url_escape(a[:link])}]" }
|
|
11193
11207
|
def _ExplicitLink
|
|
11194
11208
|
|
|
11195
11209
|
_save = self.pos
|
|
@@ -11200,7 +11214,7 @@ class RDoc::Markdown
|
|
|
11200
11214
|
self.pos = _save
|
|
11201
11215
|
break
|
|
11202
11216
|
end
|
|
11203
|
-
@result = begin; "{#{a[:label]}}[#{a[:link]}]" ; end
|
|
11217
|
+
@result = begin; "{#{a[:label]}}[#{rdoc_link_url_escape(a[:link])}]" ; end
|
|
11204
11218
|
_tmp = true
|
|
11205
11219
|
unless _tmp
|
|
11206
11220
|
self.pos = _save
|
|
@@ -14615,7 +14629,7 @@ class RDoc::Markdown
|
|
|
14615
14629
|
return _tmp
|
|
14616
14630
|
end
|
|
14617
14631
|
|
|
14618
|
-
# HexEntity = /&#x/i < /[0-9a-fA-F]+/ > ";" { [text.to_i(16)].pack
|
|
14632
|
+
# HexEntity = /&#x/i < /[0-9a-fA-F]+/ > ";" { rdoc_escape([text.to_i(16)].pack('U')) }
|
|
14619
14633
|
def _HexEntity
|
|
14620
14634
|
|
|
14621
14635
|
_save = self.pos
|
|
@@ -14639,7 +14653,7 @@ class RDoc::Markdown
|
|
|
14639
14653
|
self.pos = _save
|
|
14640
14654
|
break
|
|
14641
14655
|
end
|
|
14642
|
-
@result = begin; [text.to_i(16)].pack
|
|
14656
|
+
@result = begin; rdoc_escape([text.to_i(16)].pack('U')) ; end
|
|
14643
14657
|
_tmp = true
|
|
14644
14658
|
unless _tmp
|
|
14645
14659
|
self.pos = _save
|
|
@@ -14651,7 +14665,7 @@ class RDoc::Markdown
|
|
|
14651
14665
|
return _tmp
|
|
14652
14666
|
end
|
|
14653
14667
|
|
|
14654
|
-
# DecEntity = "&#" < /[0-9]+/ > ";" { [text.to_i].pack
|
|
14668
|
+
# DecEntity = "&#" < /[0-9]+/ > ";" { rdoc_escape([text.to_i].pack('U')) }
|
|
14655
14669
|
def _DecEntity
|
|
14656
14670
|
|
|
14657
14671
|
_save = self.pos
|
|
@@ -14675,7 +14689,7 @@ class RDoc::Markdown
|
|
|
14675
14689
|
self.pos = _save
|
|
14676
14690
|
break
|
|
14677
14691
|
end
|
|
14678
|
-
@result = begin; [text.to_i].pack
|
|
14692
|
+
@result = begin; rdoc_escape([text.to_i].pack('U')) ; end
|
|
14679
14693
|
_tmp = true
|
|
14680
14694
|
unless _tmp
|
|
14681
14695
|
self.pos = _save
|
|
@@ -14687,7 +14701,7 @@ class RDoc::Markdown
|
|
|
14687
14701
|
return _tmp
|
|
14688
14702
|
end
|
|
14689
14703
|
|
|
14690
|
-
# CharEntity = "&" < /[A-Za-z0-9]+/ > ";" { if entity = HTML_ENTITIES[text] then entity.pack
|
|
14704
|
+
# CharEntity = "&" < /[A-Za-z0-9]+/ > ";" { if entity = HTML_ENTITIES[text] then rdoc_escape(entity.pack('U*')) else "&#{text};" end }
|
|
14691
14705
|
def _CharEntity
|
|
14692
14706
|
|
|
14693
14707
|
_save = self.pos
|
|
@@ -14712,7 +14726,7 @@ class RDoc::Markdown
|
|
|
14712
14726
|
break
|
|
14713
14727
|
end
|
|
14714
14728
|
@result = begin; if entity = HTML_ENTITIES[text] then
|
|
14715
|
-
entity.pack
|
|
14729
|
+
rdoc_escape(entity.pack('U*'))
|
|
14716
14730
|
else
|
|
14717
14731
|
"&#{text};"
|
|
14718
14732
|
end
|
|
@@ -16563,15 +16577,15 @@ class RDoc::Markdown
|
|
|
16563
16577
|
Rules[:_Inlines] = rule_info("Inlines", "(!@Endline Inline:i { i } | @Endline:c !(&{ github? } Ticks3 /[^`\\n]*$/) &Inline { c })+:chunks @Endline? { chunks }")
|
|
16564
16578
|
Rules[:_Inline] = rule_info("Inline", "(Str | @Endline | UlOrStarLine | @Space | Strong | Emph | Strike | Image | Link | NoteReference | InlineNote | Code | RawHtml | Entity | EscapedChar | Symbol)")
|
|
16565
16579
|
Rules[:_Space] = rule_info("Space", "@Spacechar+ { \" \" }")
|
|
16566
|
-
Rules[:_Str] = rule_info("Str", "@StartList:a < @NormalChar+ > { a = text } (StrChunk:c { a << c })* { a }")
|
|
16580
|
+
Rules[:_Str] = rule_info("Str", "@StartList:a < @NormalChar+ > { a = text } (StrChunk:c { a << c })* { rdoc_escape(a) }")
|
|
16567
16581
|
Rules[:_StrChunk] = rule_info("StrChunk", "< (@NormalChar | /_+/ &Alphanumeric)+ > { text }")
|
|
16568
|
-
Rules[:_EscapedChar] = rule_info("EscapedChar", "\"\\\\\" !@Newline < /[:\\\\`|*_{}\\[\\]()\#+.!><-]/ > { text }")
|
|
16582
|
+
Rules[:_EscapedChar] = rule_info("EscapedChar", "\"\\\\\" !@Newline < /[:\\\\`|*_{}\\[\\]()\#+.!><-]/ > { rdoc_escape(text) }")
|
|
16569
16583
|
Rules[:_Entity] = rule_info("Entity", "(HexEntity | DecEntity | CharEntity):a { a }")
|
|
16570
16584
|
Rules[:_Endline] = rule_info("Endline", "(@LineBreak | @TerminalEndline | @NormalEndline)")
|
|
16571
16585
|
Rules[:_NormalEndline] = rule_info("NormalEndline", "@Sp @Newline !@BlankLine !\">\" !AtxStart !(Line /={1,}|-{1,}/ @Newline) { \"\\n\" }")
|
|
16572
16586
|
Rules[:_TerminalEndline] = rule_info("TerminalEndline", "@Sp @Newline @Eof")
|
|
16573
16587
|
Rules[:_LineBreak] = rule_info("LineBreak", "\" \" @NormalEndline { RDoc::Markup::HardBreak.new }")
|
|
16574
|
-
Rules[:_Symbol] = rule_info("Symbol", "< @SpecialChar > { text }")
|
|
16588
|
+
Rules[:_Symbol] = rule_info("Symbol", "< @SpecialChar > { rdoc_escape(text) }")
|
|
16575
16589
|
Rules[:_UlOrStarLine] = rule_info("UlOrStarLine", "(UlLine | StarLine):a { a }")
|
|
16576
16590
|
Rules[:_StarLine] = rule_info("StarLine", "(< /\\*{4,}/ > { text } | < @Spacechar /\\*+/ &@Spacechar > { text })")
|
|
16577
16591
|
Rules[:_UlLine] = rule_info("UlLine", "(< /_{4,}/ > { text } | < @Spacechar /_+/ &@Spacechar > { text })")
|
|
@@ -16588,7 +16602,7 @@ class RDoc::Markdown
|
|
|
16588
16602
|
Rules[:_ReferenceLink] = rule_info("ReferenceLink", "(ReferenceLinkDouble | ReferenceLinkSingle)")
|
|
16589
16603
|
Rules[:_ReferenceLinkDouble] = rule_info("ReferenceLinkDouble", "Label:content < Spnl > !\"[]\" Label:label { link_to content, label, text }")
|
|
16590
16604
|
Rules[:_ReferenceLinkSingle] = rule_info("ReferenceLinkSingle", "Label:content < (Spnl \"[]\")? > { link_to content, content, text }")
|
|
16591
|
-
Rules[:_ExplicitLink] = rule_info("ExplicitLink", "ExplicitLinkWithLabel:a { \"{\#{a[:label]}}[\#{a[:link]}]\" }")
|
|
16605
|
+
Rules[:_ExplicitLink] = rule_info("ExplicitLink", "ExplicitLinkWithLabel:a { \"{\#{a[:label]}}[\#{rdoc_link_url_escape(a[:link])}]\" }")
|
|
16592
16606
|
Rules[:_ExplicitLinkWithLabel] = rule_info("ExplicitLinkWithLabel", "Label:label \"(\" @Sp Source:link Spnl Title @Sp \")\" { { label: label, link: link } }")
|
|
16593
16607
|
Rules[:_Source] = rule_info("Source", "(\"<\" < SourceContents > \">\" | < SourceContents >) { text }")
|
|
16594
16608
|
Rules[:_SourceContents] = rule_info("SourceContents", "((!\"(\" !\")\" !\">\" Nonspacechar)+ | \"(\" SourceContents \")\")*")
|
|
@@ -16631,9 +16645,9 @@ class RDoc::Markdown
|
|
|
16631
16645
|
Rules[:_BOM] = rule_info("BOM", "%literals.BOM")
|
|
16632
16646
|
Rules[:_Newline] = rule_info("Newline", "%literals.Newline")
|
|
16633
16647
|
Rules[:_Spacechar] = rule_info("Spacechar", "%literals.Spacechar")
|
|
16634
|
-
Rules[:_HexEntity] = rule_info("HexEntity", "/&\#x/i < /[0-9a-fA-F]+/ > \";\" { [text.to_i(16)].pack
|
|
16635
|
-
Rules[:_DecEntity] = rule_info("DecEntity", "\"&\#\" < /[0-9]+/ > \";\" { [text.to_i].pack
|
|
16636
|
-
Rules[:_CharEntity] = rule_info("CharEntity", "\"&\" < /[A-Za-z0-9]+/ > \";\" { if entity = HTML_ENTITIES[text] then entity.pack
|
|
16648
|
+
Rules[:_HexEntity] = rule_info("HexEntity", "/&\#x/i < /[0-9a-fA-F]+/ > \";\" { rdoc_escape([text.to_i(16)].pack('U')) }")
|
|
16649
|
+
Rules[:_DecEntity] = rule_info("DecEntity", "\"&\#\" < /[0-9]+/ > \";\" { rdoc_escape([text.to_i].pack('U')) }")
|
|
16650
|
+
Rules[:_CharEntity] = rule_info("CharEntity", "\"&\" < /[A-Za-z0-9]+/ > \";\" { if entity = HTML_ENTITIES[text] then rdoc_escape(entity.pack('U*')) else \"&\#{text};\" end }")
|
|
16637
16651
|
Rules[:_NonindentSpace] = rule_info("NonindentSpace", "/ {0,3}/")
|
|
16638
16652
|
Rules[:_Indent] = rule_info("Indent", "/\\t| /")
|
|
16639
16653
|
Rules[:_IndentedLine] = rule_info("IndentedLine", "Indent Line")
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
# RDoc::Markup::FormatterTestCase. If you're writing a text-output formatter
|
|
11
11
|
# use RDoc::Markup::TextFormatterTestCase which provides extra test cases.
|
|
12
12
|
|
|
13
|
+
require 'rdoc/markup/inline_parser'
|
|
14
|
+
|
|
13
15
|
class RDoc::Markup::Formatter
|
|
14
16
|
|
|
15
17
|
##
|
|
@@ -18,6 +20,7 @@ class RDoc::Markup::Formatter
|
|
|
18
20
|
|
|
19
21
|
InlineTag = Struct.new(:bit, :on, :off)
|
|
20
22
|
|
|
23
|
+
|
|
21
24
|
##
|
|
22
25
|
# Converts a target url to one that is relative to a given path
|
|
23
26
|
|
|
@@ -49,17 +52,7 @@ class RDoc::Markup::Formatter
|
|
|
49
52
|
@options = options
|
|
50
53
|
|
|
51
54
|
@markup = markup || RDoc::Markup.new
|
|
52
|
-
@am = @markup.attribute_manager
|
|
53
|
-
@am.add_regexp_handling(/<br>/, :HARD_BREAK)
|
|
54
|
-
|
|
55
|
-
@attributes = @am.attributes
|
|
56
|
-
|
|
57
|
-
@attr_tags = []
|
|
58
|
-
|
|
59
|
-
@in_tt = 0
|
|
60
|
-
@tt_bit = @attributes.bitmap_for :TT
|
|
61
55
|
|
|
62
|
-
@hard_break = ''
|
|
63
56
|
@from_path = '.'
|
|
64
57
|
end
|
|
65
58
|
|
|
@@ -84,29 +77,6 @@ class RDoc::Markup::Formatter
|
|
|
84
77
|
@markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
|
|
85
78
|
end
|
|
86
79
|
|
|
87
|
-
##
|
|
88
|
-
# Adds a regexp handling for links of the form {<text>}[<url>] and
|
|
89
|
-
# <word>[<url>]
|
|
90
|
-
|
|
91
|
-
def add_regexp_handling_TIDYLINK
|
|
92
|
-
@markup.add_regexp_handling(/(?:
|
|
93
|
-
\{[^{}]*\} | # multi-word label
|
|
94
|
-
\b[^\s{}]+? # single-word label
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
\[\S+?\] # link target
|
|
98
|
-
/x, :TIDYLINK)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
##
|
|
102
|
-
# Add a new set of tags for an attribute. We allow separate start and end
|
|
103
|
-
# tags for flexibility
|
|
104
|
-
|
|
105
|
-
def add_tag(name, start, stop)
|
|
106
|
-
attr = @attributes.bitmap_for name
|
|
107
|
-
@attr_tags << InlineTag.new(attr, start, stop)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
80
|
##
|
|
111
81
|
# Allows +tag+ to be decorated with additional information.
|
|
112
82
|
|
|
@@ -121,117 +91,170 @@ class RDoc::Markup::Formatter
|
|
|
121
91
|
@markup.convert content, self
|
|
122
92
|
end
|
|
123
93
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
94
|
+
# Applies regexp handling to +text+ and returns an array of [text, converted?] pairs.
|
|
95
|
+
|
|
96
|
+
def apply_regexp_handling(text)
|
|
97
|
+
output = []
|
|
98
|
+
start = 0
|
|
99
|
+
loop do
|
|
100
|
+
pos = text.size
|
|
101
|
+
matched_name = matched_text = nil
|
|
102
|
+
@markup.regexp_handlings.each do |pattern, name|
|
|
103
|
+
m = text.match(pattern, start)
|
|
104
|
+
next unless m
|
|
105
|
+
idx = m[1] ? 1 : 0
|
|
106
|
+
if m.begin(idx) < pos
|
|
107
|
+
pos = m.begin(idx)
|
|
108
|
+
matched_text = m[idx]
|
|
109
|
+
matched_name = name
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
output << [text[start...pos], false] if pos > start
|
|
113
|
+
if matched_name
|
|
114
|
+
handled = public_send(:"handle_regexp_#{matched_name}", matched_text)
|
|
115
|
+
output << [handled, true]
|
|
116
|
+
start = pos + matched_text.size
|
|
139
117
|
else
|
|
140
|
-
|
|
118
|
+
start = pos
|
|
141
119
|
end
|
|
120
|
+
break if pos == text.size
|
|
142
121
|
end
|
|
143
|
-
|
|
144
|
-
res.join
|
|
122
|
+
output
|
|
145
123
|
end
|
|
146
124
|
|
|
147
|
-
|
|
148
|
-
#
|
|
125
|
+
# Called when processing plain text while traversing inline nodes from handle_inline.
|
|
126
|
+
# +text+ may need proper escaping.
|
|
149
127
|
|
|
150
|
-
def
|
|
151
|
-
|
|
128
|
+
def handle_PLAIN_TEXT(text)
|
|
129
|
+
end
|
|
152
130
|
|
|
153
|
-
|
|
131
|
+
# Called when processing regexp-handling-processed text while traversing inline nodes from handle_inline.
|
|
132
|
+
# +text+ may contain markup tags.
|
|
154
133
|
|
|
155
|
-
|
|
156
|
-
|
|
134
|
+
def handle_REGEXP_HANDLING_TEXT(text)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Called when processing text node while traversing inline nodes from handle_inline.
|
|
138
|
+
# Apply regexp handling and dispatch to the appropriate handler: handle_REGEXP_HANDLING_TEXT or handle_PLAIN_TEXT.
|
|
157
139
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
140
|
+
def handle_TEXT(text)
|
|
141
|
+
apply_regexp_handling(text).each do |part, converted|
|
|
142
|
+
if converted
|
|
143
|
+
handle_REGEXP_HANDLING_TEXT(part)
|
|
144
|
+
else
|
|
145
|
+
handle_PLAIN_TEXT(part)
|
|
161
146
|
end
|
|
162
147
|
end
|
|
148
|
+
end
|
|
163
149
|
|
|
164
|
-
|
|
165
|
-
target_name = @attributes.as_string target.type
|
|
150
|
+
# Called when processing a hard break while traversing inline nodes from handle_inline.
|
|
166
151
|
|
|
167
|
-
|
|
168
|
-
|
|
152
|
+
def handle_HARD_BREAK
|
|
153
|
+
end
|
|
169
154
|
|
|
170
|
-
|
|
155
|
+
# Called when processing bold nodes while traversing inline nodes from handle_inline.
|
|
156
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
157
|
+
|
|
158
|
+
def handle_BOLD(nodes)
|
|
159
|
+
traverse_inline_nodes(nodes)
|
|
171
160
|
end
|
|
172
161
|
|
|
173
|
-
|
|
174
|
-
#
|
|
162
|
+
# Called when processing emphasis nodes while traversing inline nodes from handle_inline.
|
|
163
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
175
164
|
|
|
176
|
-
def
|
|
177
|
-
|
|
165
|
+
def handle_EM(nodes)
|
|
166
|
+
traverse_inline_nodes(nodes)
|
|
178
167
|
end
|
|
179
168
|
|
|
180
|
-
|
|
181
|
-
#
|
|
182
|
-
#
|
|
183
|
-
# ##
|
|
184
|
-
# # We don't support raw nodes in ToNoRaw
|
|
185
|
-
#
|
|
186
|
-
# alias accept_raw ignore
|
|
169
|
+
# Called when processing bold word nodes while traversing inline nodes from handle_inline.
|
|
170
|
+
# +word+ may need proper escaping.
|
|
187
171
|
|
|
188
|
-
def
|
|
172
|
+
def handle_BOLD_WORD(word)
|
|
173
|
+
handle_PLAIN_TEXT(word)
|
|
189
174
|
end
|
|
190
175
|
|
|
191
|
-
|
|
192
|
-
#
|
|
176
|
+
# Called when processing emphasis word nodes while traversing inline nodes from handle_inline.
|
|
177
|
+
# +word+ may need proper escaping.
|
|
193
178
|
|
|
194
|
-
def
|
|
195
|
-
|
|
179
|
+
def handle_EM_WORD(word)
|
|
180
|
+
handle_PLAIN_TEXT(word)
|
|
196
181
|
end
|
|
197
182
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
183
|
+
# Called when processing tt nodes while traversing inline nodes from handle_inline.
|
|
184
|
+
# +code+ may need proper escaping.
|
|
185
|
+
|
|
186
|
+
def handle_TT(code)
|
|
187
|
+
handle_PLAIN_TEXT(code)
|
|
203
188
|
end
|
|
204
189
|
|
|
205
|
-
|
|
206
|
-
#
|
|
190
|
+
# Called when processing strike nodes while traversing inline nodes from handle_inline.
|
|
191
|
+
# Traverse the children nodes and dispatch to the appropriate handlers.
|
|
207
192
|
|
|
208
|
-
def
|
|
209
|
-
|
|
210
|
-
res << annotate(tag.on)
|
|
211
|
-
@in_tt += 1 if tt? tag
|
|
212
|
-
end
|
|
193
|
+
def handle_STRIKE(nodes)
|
|
194
|
+
traverse_inline_nodes(nodes)
|
|
213
195
|
end
|
|
214
196
|
|
|
215
|
-
|
|
216
|
-
#
|
|
197
|
+
# Called when processing tidylink nodes while traversing inline nodes from handle_inline.
|
|
198
|
+
# +label_part+ is an array of strings or nodes representing the link label.
|
|
199
|
+
# +url+ is the link URL.
|
|
200
|
+
# Traverse the label_part nodes and dispatch to the appropriate handlers.
|
|
217
201
|
|
|
218
|
-
def
|
|
219
|
-
|
|
220
|
-
@in_tt -= 1 if tt? tag
|
|
221
|
-
res << annotate(tag.off)
|
|
222
|
-
end
|
|
202
|
+
def handle_TIDYLINK(label_part, url)
|
|
203
|
+
traverse_inline_nodes(label_part)
|
|
223
204
|
end
|
|
224
205
|
|
|
225
|
-
|
|
226
|
-
|
|
206
|
+
# Parses inline +text+, traverse the resulting nodes, and calls the appropriate handler methods.
|
|
207
|
+
|
|
208
|
+
def handle_inline(text)
|
|
209
|
+
nodes = RDoc::Markup::InlineParser.new(text).parse
|
|
210
|
+
traverse_inline_nodes(nodes)
|
|
211
|
+
end
|
|
227
212
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
213
|
+
# Traverses +nodes+ and calls the appropriate handler methods
|
|
214
|
+
# Nodes formats are described in RDoc::Markup::InlineParser#parse
|
|
215
|
+
|
|
216
|
+
def traverse_inline_nodes(nodes)
|
|
217
|
+
nodes.each do |node|
|
|
218
|
+
next handle_TEXT(node) if String === node
|
|
219
|
+
case node[:type]
|
|
220
|
+
when :TIDYLINK
|
|
221
|
+
handle_TIDYLINK(node[:children], node[:url])
|
|
222
|
+
when :HARD_BREAK
|
|
223
|
+
handle_HARD_BREAK
|
|
224
|
+
when :BOLD
|
|
225
|
+
handle_BOLD(node[:children])
|
|
226
|
+
when :BOLD_WORD
|
|
227
|
+
handle_BOLD_WORD(node[:children][0] || '')
|
|
228
|
+
when :EM
|
|
229
|
+
handle_EM(node[:children])
|
|
230
|
+
when :EM_WORD
|
|
231
|
+
handle_EM_WORD(node[:children][0] || '')
|
|
232
|
+
when :TT
|
|
233
|
+
handle_TT(node[:children][0] || '')
|
|
234
|
+
when :STRIKE
|
|
235
|
+
handle_STRIKE(node[:children])
|
|
231
236
|
end
|
|
232
237
|
end
|
|
233
238
|
end
|
|
234
239
|
|
|
240
|
+
##
|
|
241
|
+
# Converts a string to be fancier if desired
|
|
242
|
+
|
|
243
|
+
def convert_string(string)
|
|
244
|
+
string
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
##
|
|
248
|
+
# Use ignore in your subclass to ignore the content of a node.
|
|
249
|
+
#
|
|
250
|
+
# ##
|
|
251
|
+
# # We don't support raw nodes in ToNoRaw
|
|
252
|
+
#
|
|
253
|
+
# alias accept_raw ignore
|
|
254
|
+
|
|
255
|
+
def ignore *node
|
|
256
|
+
end
|
|
257
|
+
|
|
235
258
|
##
|
|
236
259
|
# Extracts and a scheme, url and an anchor id from +url+ and returns them.
|
|
237
260
|
|
data/lib/rdoc/markup/heading.rb
CHANGED