rdoc 6.17.0 → 8.1.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.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +193 -0
  3. data/LEGAL.rdoc +6 -0
  4. data/LICENSE.rdoc +4 -0
  5. data/README.md +132 -8
  6. data/RI.md +75 -75
  7. data/doc/markup_reference/markdown.md +659 -0
  8. data/doc/markup_reference/rdoc.rdoc +1169 -0
  9. data/exe/rdoc +2 -2
  10. data/lib/rdoc/code_object/alias.rb +70 -74
  11. data/lib/rdoc/code_object/any_method.rb +308 -293
  12. data/lib/rdoc/code_object/attr.rb +150 -142
  13. data/lib/rdoc/code_object/class_module.rb +802 -715
  14. data/lib/rdoc/code_object/constant.rb +181 -144
  15. data/lib/rdoc/code_object/context/section.rb +140 -130
  16. data/lib/rdoc/code_object/context.rb +925 -941
  17. data/lib/rdoc/code_object/extend.rb +7 -5
  18. data/lib/rdoc/code_object/include.rb +7 -5
  19. data/lib/rdoc/code_object/method_attr.rb +328 -315
  20. data/lib/rdoc/code_object/mixin.rb +97 -92
  21. data/lib/rdoc/code_object/normal_class.rb +77 -78
  22. data/lib/rdoc/code_object/normal_module.rb +61 -59
  23. data/lib/rdoc/code_object/require.rb +23 -39
  24. data/lib/rdoc/code_object/single_class.rb +21 -19
  25. data/lib/rdoc/code_object/top_level.rb +215 -202
  26. data/lib/rdoc/code_object.rb +305 -305
  27. data/lib/rdoc/comment.rb +274 -337
  28. data/lib/rdoc/cross_reference.rb +195 -206
  29. data/lib/rdoc/encoding.rb +105 -103
  30. data/lib/rdoc/erb_partial.rb +13 -11
  31. data/lib/rdoc/erbio.rb +29 -27
  32. data/lib/rdoc/generator/aliki.rb +196 -30
  33. data/lib/rdoc/generator/darkfish.rb +647 -629
  34. data/lib/rdoc/generator/json_index.rb +233 -229
  35. data/lib/rdoc/generator/markup.rb +165 -122
  36. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  37. data/lib/rdoc/generator/pot/po.rb +52 -51
  38. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  39. data/lib/rdoc/generator/pot.rb +85 -81
  40. data/lib/rdoc/generator/ri.rb +23 -19
  41. data/lib/rdoc/generator/template/aliki/DESIGN.md +538 -0
  42. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
  43. data/lib/rdoc/generator/template/aliki/_footer.rhtml +2 -2
  44. data/lib/rdoc/generator/template/aliki/_head.rhtml +15 -10
  45. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  46. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
  47. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
  48. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
  49. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +3 -3
  50. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +3 -3
  51. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
  52. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
  53. data/lib/rdoc/generator/template/aliki/class.rhtml +71 -61
  54. data/lib/rdoc/generator/template/aliki/css/rdoc.css +796 -323
  55. data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
  56. data/lib/rdoc/generator/template/aliki/js/aliki.js +119 -113
  57. data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  58. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +1 -1
  59. data/lib/rdoc/generator/template/aliki/js/{search.js → search_controller.js} +16 -7
  60. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  61. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  62. data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
  63. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
  64. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
  65. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  66. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
  67. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
  68. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
  69. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +2 -2
  70. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
  71. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
  72. data/lib/rdoc/generator/template/darkfish/class.rhtml +29 -32
  73. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +19 -1
  74. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  75. data/lib/rdoc/generator.rb +48 -46
  76. data/lib/rdoc/i18n/locale.rb +99 -95
  77. data/lib/rdoc/i18n/text.rb +109 -105
  78. data/lib/rdoc/i18n.rb +7 -5
  79. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  80. data/lib/rdoc/markdown.kpeg +52 -33
  81. data/lib/rdoc/markdown.rb +365 -177
  82. data/lib/rdoc/markup/blank_line.rb +25 -23
  83. data/lib/rdoc/markup/block_quote.rb +12 -8
  84. data/lib/rdoc/markup/document.rb +127 -123
  85. data/lib/rdoc/markup/element.rb +21 -0
  86. data/lib/rdoc/markup/formatter.rb +220 -203
  87. data/lib/rdoc/markup/hard_break.rb +30 -27
  88. data/lib/rdoc/markup/heading.rb +163 -77
  89. data/lib/rdoc/markup/include.rb +33 -29
  90. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  91. data/lib/rdoc/markup/inline_parser.rb +316 -0
  92. data/lib/rdoc/markup/list.rb +80 -88
  93. data/lib/rdoc/markup/list_item.rb +73 -85
  94. data/lib/rdoc/markup/paragraph.rb +23 -19
  95. data/lib/rdoc/markup/parser.rb +501 -497
  96. data/lib/rdoc/markup/pre_process.rb +284 -305
  97. data/lib/rdoc/markup/raw.rb +52 -55
  98. data/lib/rdoc/markup/rule.rb +16 -12
  99. data/lib/rdoc/markup/table.rb +48 -40
  100. data/lib/rdoc/markup/to_ansi.rb +143 -92
  101. data/lib/rdoc/markup/to_bs.rb +86 -102
  102. data/lib/rdoc/markup/to_html.rb +608 -506
  103. data/lib/rdoc/markup/to_html_crossref.rb +219 -210
  104. data/lib/rdoc/markup/to_html_snippet.rb +210 -205
  105. data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
  106. data/lib/rdoc/markup/to_label.rb +64 -51
  107. data/lib/rdoc/markup/to_markdown.rb +212 -184
  108. data/lib/rdoc/markup/to_rdoc.rb +341 -277
  109. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  110. data/lib/rdoc/markup/to_test.rb +62 -50
  111. data/lib/rdoc/markup/to_tt_only.rb +83 -92
  112. data/lib/rdoc/markup/verbatim.rb +62 -58
  113. data/lib/rdoc/markup.rb +196 -215
  114. data/lib/rdoc/options.rb +1063 -1076
  115. data/lib/rdoc/parser/c.rb +1039 -1036
  116. data/lib/rdoc/parser/changelog.rb +320 -287
  117. data/lib/rdoc/parser/markdown.rb +17 -13
  118. data/lib/rdoc/parser/rbs.rb +279 -0
  119. data/lib/rdoc/parser/rd.rb +17 -13
  120. data/lib/rdoc/parser/ruby.rb +1231 -2222
  121. data/lib/rdoc/parser/ruby_colorizer.rb +303 -0
  122. data/lib/rdoc/parser/simple.rb +31 -27
  123. data/lib/rdoc/parser/text.rb +12 -8
  124. data/lib/rdoc/parser.rb +230 -221
  125. data/lib/rdoc/rbs_helper.rb +186 -0
  126. data/lib/rdoc/rd/inline.rb +57 -53
  127. data/lib/rdoc/rd.rb +90 -88
  128. data/lib/rdoc/rdoc.rb +547 -366
  129. data/lib/rdoc/ri/driver.rb +1141 -1130
  130. data/lib/rdoc/ri/formatter.rb +7 -3
  131. data/lib/rdoc/ri/paths.rb +140 -136
  132. data/lib/rdoc/ri/servlet.rb +456 -0
  133. data/lib/rdoc/ri/store.rb +4 -2
  134. data/lib/rdoc/ri/task.rb +55 -51
  135. data/lib/rdoc/ri.rb +14 -11
  136. data/lib/rdoc/rubygems_hook.rb +194 -192
  137. data/lib/rdoc/server.rb +462 -0
  138. data/lib/rdoc/stats/normal.rb +46 -42
  139. data/lib/rdoc/stats/quiet.rb +39 -35
  140. data/lib/rdoc/stats/verbose.rb +35 -31
  141. data/lib/rdoc/stats.rb +363 -338
  142. data/lib/rdoc/store.rb +919 -725
  143. data/lib/rdoc/task.rb +260 -255
  144. data/lib/rdoc/text.rb +164 -240
  145. data/lib/rdoc/token_stream.rb +88 -106
  146. data/lib/rdoc/tom_doc.rb +203 -201
  147. data/lib/rdoc/version.rb +1 -1
  148. data/lib/rdoc.rb +35 -7
  149. data/lib/rubygems_plugin.rb +2 -11
  150. data/rdoc-logo.svg +43 -0
  151. data/rdoc.gemspec +9 -7
  152. metadata +46 -32
  153. data/CONTRIBUTING.rdoc +0 -219
  154. data/ExampleMarkdown.md +0 -39
  155. data/ExampleRDoc.rdoc +0 -210
  156. data/lib/rdoc/code_object/anon_class.rb +0 -10
  157. data/lib/rdoc/code_object/ghost_method.rb +0 -6
  158. data/lib/rdoc/code_object/meta_method.rb +0 -6
  159. data/lib/rdoc/markdown/literals.kpeg +0 -21
  160. data/lib/rdoc/markdown/literals.rb +0 -454
  161. data/lib/rdoc/markup/attr_changer.rb +0 -22
  162. data/lib/rdoc/markup/attr_span.rb +0 -35
  163. data/lib/rdoc/markup/attribute_manager.rb +0 -405
  164. data/lib/rdoc/markup/attributes.rb +0 -70
  165. data/lib/rdoc/markup/regexp_handling.rb +0 -40
  166. data/lib/rdoc/parser/prism_ruby.rb +0 -1100
  167. data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
  168. data/lib/rdoc/parser/ruby_tools.rb +0 -163
  169. data/lib/rdoc/servlet.rb +0 -452
@@ -1,126 +1,130 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # An i18n supported text.
4
- #
5
- # This object provides the following two features:
6
- #
7
- # * Extracts translation messages from wrapped raw text.
8
- # * Translates wrapped raw text in specified locale.
9
- #
10
- # Wrapped raw text is one of String, RDoc::Comment or Array of them.
2
+ module RDoc
3
+ module I18n
4
+ ##
5
+ # An i18n supported text.
6
+ #
7
+ # This object provides the following two features:
8
+ #
9
+ # * Extracts translation messages from wrapped raw text.
10
+ # * Translates wrapped raw text in specified locale.
11
+ #
12
+ # Wrapped raw text is one of String, RDoc::Comment or Array of them.
11
13
 
12
- class RDoc::I18n::Text
14
+ class Text
13
15
 
14
- ##
15
- # Creates a new i18n supported text for +raw+ text.
16
+ ##
17
+ # Creates a new i18n supported text for +raw+ text.
16
18
 
17
- def initialize(raw)
18
- @raw = raw
19
- end
19
+ def initialize(raw)
20
+ @raw = raw
21
+ end
20
22
 
21
- ##
22
- # Extracts translation target messages and yields each message.
23
- #
24
- # Each yielded message is a Hash. It consists of the followings:
25
- #
26
- # :type :: :paragraph
27
- # :paragraph :: String (The translation target message itself.)
28
- # :line_no :: Integer (The line number of the :paragraph is started.)
29
- #
30
- # The above content may be added in the future.
23
+ ##
24
+ # Extracts translation target messages and yields each message.
25
+ #
26
+ # Each yielded message is a Hash. It consists of the followings:
27
+ #
28
+ # :type :: :paragraph
29
+ # :paragraph :: String (The translation target message itself.)
30
+ # :line_no :: Integer (The line number of the :paragraph is started.)
31
+ #
32
+ # The above content may be added in the future.
31
33
 
32
- def extract_messages
33
- parse do |part|
34
- case part[:type]
35
- when :empty_line
36
- # ignore
37
- when :paragraph
38
- yield(part)
34
+ def extract_messages
35
+ parse do |part|
36
+ case part[:type]
37
+ when :empty_line
38
+ # ignore
39
+ when :paragraph
40
+ yield(part)
41
+ end
42
+ end
39
43
  end
40
- end
41
- end
42
44
 
43
- # Translates raw text into +locale+.
44
- def translate(locale)
45
- translated_text = ''
46
- parse do |part|
47
- case part[:type]
48
- when :paragraph
49
- translated_text += locale.translate(part[:paragraph])
50
- when :empty_line
51
- translated_text += part[:line]
52
- else
53
- raise "should not reach here: unexpected type: #{type}"
45
+ # Translates raw text into +locale+.
46
+ def translate(locale)
47
+ translated_text = ''
48
+ parse do |part|
49
+ case part[:type]
50
+ when :paragraph
51
+ translated_text += locale.translate(part[:paragraph])
52
+ when :empty_line
53
+ translated_text += part[:line]
54
+ else
55
+ raise "should not reach here: unexpected type: #{type}"
56
+ end
57
+ end
58
+ translated_text
54
59
  end
55
- end
56
- translated_text
57
- end
58
60
 
59
- private
60
- def parse(&block)
61
- paragraph = ''
62
- paragraph_start_line = 0
63
- line_no = 0
61
+ private
62
+ def parse(&block)
63
+ paragraph = ''
64
+ paragraph_start_line = 0
65
+ line_no = 0
64
66
 
65
- each_line(@raw) do |line|
66
- line_no += 1
67
- case line
68
- when /\A\s*\z/
69
- if paragraph.empty?
70
- emit_empty_line_event(line, line_no, &block)
71
- else
72
- paragraph += line
73
- emit_paragraph_event(paragraph, paragraph_start_line, line_no,
74
- &block)
75
- paragraph = ''
67
+ each_line(@raw) do |line|
68
+ line_no += 1
69
+ case line
70
+ when /\A\s*\z/
71
+ if paragraph.empty?
72
+ emit_empty_line_event(line, line_no, &block)
73
+ else
74
+ paragraph += line
75
+ emit_paragraph_event(paragraph, paragraph_start_line, line_no,
76
+ &block)
77
+ paragraph = ''
78
+ end
79
+ else
80
+ paragraph_start_line = line_no if paragraph.empty?
81
+ paragraph += line
82
+ end
83
+ end
84
+
85
+ unless paragraph.empty?
86
+ emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
76
87
  end
77
- else
78
- paragraph_start_line = line_no if paragraph.empty?
79
- paragraph += line
80
88
  end
81
- end
82
89
 
83
- unless paragraph.empty?
84
- emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
85
- end
86
- end
90
+ def each_line(raw, &block)
91
+ case raw
92
+ when Comment
93
+ raw.text.each_line(&block)
94
+ when Hash
95
+ raw.each_value do |comments|
96
+ comments.each { |comment| each_line(comment, &block) }
97
+ end
98
+ else
99
+ raw.each_line(&block)
100
+ end
101
+ end
87
102
 
88
- def each_line(raw, &block)
89
- case raw
90
- when RDoc::Comment
91
- raw.text.each_line(&block)
92
- when Array
93
- raw.each do |comment, location|
94
- each_line(comment, &block)
103
+ def emit_empty_line_event(line, line_no)
104
+ part = {
105
+ :type => :empty_line,
106
+ :line => line,
107
+ :line_no => line_no,
108
+ }
109
+ yield(part)
95
110
  end
96
- else
97
- raw.each_line(&block)
98
- end
99
- end
100
111
 
101
- def emit_empty_line_event(line, line_no)
102
- part = {
103
- :type => :empty_line,
104
- :line => line,
105
- :line_no => line_no,
106
- }
107
- yield(part)
108
- end
112
+ def emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
113
+ paragraph_part = {
114
+ :type => :paragraph,
115
+ :line_no => paragraph_start_line,
116
+ }
117
+ match_data = /(\s*)\z/.match(paragraph)
118
+ if match_data
119
+ paragraph_part[:paragraph] = match_data.pre_match
120
+ yield(paragraph_part)
121
+ emit_empty_line_event(match_data[1], line_no, &block)
122
+ else
123
+ paragraph_part[:paragraph] = paragraph
124
+ yield(paragraph_part)
125
+ end
126
+ end
109
127
 
110
- def emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
111
- paragraph_part = {
112
- :type => :paragraph,
113
- :line_no => paragraph_start_line,
114
- }
115
- match_data = /(\s*)\z/.match(paragraph)
116
- if match_data
117
- paragraph_part[:paragraph] = match_data.pre_match
118
- yield(paragraph_part)
119
- emit_empty_line_event(match_data[1], line_no, &block)
120
- else
121
- paragraph_part[:paragraph] = paragraph
122
- yield(paragraph_part)
123
128
  end
124
129
  end
125
-
126
130
  end
data/lib/rdoc/i18n.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # This module provides i18n related features.
2
+ module RDoc
3
+ ##
4
+ # This module provides i18n related features.
4
5
 
5
- module RDoc::I18n
6
+ module I18n
6
7
 
7
- autoload :Locale, "#{__dir__}/i18n/locale"
8
- require_relative 'i18n/text'
8
+ autoload :Locale, "#{__dir__}/i18n/locale"
9
+ require_relative 'i18n/text'
9
10
 
11
+ end
10
12
  end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'strscan'
4
+
5
+ module RDoc
6
+ class Markdown
7
+
8
+ ##
9
+ # Byte-offset replacements for the position helpers of the kpeg-generated
10
+ # parser runtime.
11
+ #
12
+ # The generated runtime addresses +@string+ by character index, which makes
13
+ # every position lookup scan the string from its beginning when the input
14
+ # contains non-ASCII characters, so parse time becomes quadratic in the
15
+ # input size. Generated rule bodies only save and restore +pos+ without
16
+ # inspecting it, so replacing these helpers is enough to switch the whole
17
+ # parser to byte offsets.
18
+ #
19
+ # get_byte (the grammar's `.`) consumes one character and returns its
20
+ # codepoint, exactly like the character-index runtime, so positions always
21
+ # stay on character boundaries and the only observable difference is the
22
+ # position values themselves. The input must be validly encoded in an
23
+ # ASCII-compatible encoding.
24
+ #
25
+ # The error-reporting helpers of the generated runtime (+current_line+,
26
+ # +current_column+, ...) are left as-is and would misreport locations when
27
+ # given byte offsets. They are unreachable: markdown is deliberately
28
+ # designed to parse any input somehow rather than fail (the root rule
29
+ # `Doc = Block*` cannot fail), so a parse failure means a bug in the
30
+ # grammar itself, and nothing in RDoc invokes +raise_error+ or
31
+ # +show_error+. Make these helpers byte-aware before using them for
32
+ # anything.
33
+
34
+ module ByteRuntime
35
+ def set_string(string, pos)
36
+ @string = string
37
+ @string_size = string ? string.bytesize : 0
38
+ @pos = pos
39
+ @position_line_offsets = nil
40
+ @scanner = string ? StringScanner.new(string) : nil
41
+ end
42
+
43
+ def scan(reg)
44
+ @scanner.pos = @pos
45
+ if @scanner.skip(reg)
46
+ @pos = @scanner.pos
47
+ true
48
+ end
49
+ end
50
+
51
+ def match_string(str)
52
+ len = str.bytesize
53
+ if @string.byteslice(@pos, len) == str
54
+ @pos += len
55
+ str
56
+ end
57
+ end
58
+
59
+ def get_byte
60
+ byte = @string.getbyte(@pos)
61
+ return nil unless byte
62
+
63
+ if byte < 0x80
64
+ @pos += 1
65
+ byte
66
+ else
67
+ @scanner.pos = @pos
68
+ # /./ interprets the character in the string's own encoding
69
+ char = @scanner.scan(/./m)
70
+ @pos = @scanner.pos
71
+ char.ord
72
+ end
73
+ end
74
+
75
+ def get_text(start)
76
+ @string.byteslice(start, @pos - start)
77
+ end
78
+ end
79
+ end
80
+ end
@@ -191,7 +191,9 @@
191
191
  require_relative 'markup/to_joined_paragraph'
192
192
  require_relative 'markdown/entities'
193
193
 
194
- require_relative 'markdown/literals'
194
+ require_relative 'markdown/byte_runtime'
195
+
196
+ prepend ByteRuntime
195
197
 
196
198
  ##
197
199
  # Supported extensions
@@ -303,6 +305,20 @@
303
305
  end
304
306
  end
305
307
 
308
+ # Escape character that has special meaning in RDoc format.
309
+ # To allow rdoc-styled link used in markdown format for now, bracket and brace are not escaped.
310
+
311
+ def rdoc_escape(text)
312
+ text.gsub(/[*+<\\_]/) {|s| "\\#{s}" }
313
+ end
314
+
315
+ # Escape link url that contains brackets.
316
+ # Brackets needs escape because link url will be surrounded by `[]` in RDoc format.
317
+
318
+ def rdoc_link_url_escape(text)
319
+ text.gsub(/[\[\]\\]/) {|s| "\\#{s}" }
320
+ end
321
+
306
322
  ##
307
323
  # :category: Extensions
308
324
  #
@@ -389,6 +405,8 @@
389
405
  # the note order list for proper display at the end of the document.
390
406
 
391
407
  def note_for ref
408
+ return unless @note_order
409
+
392
410
  @note_order << ref
393
411
 
394
412
  label = @note_order.length
@@ -432,8 +450,12 @@
432
450
  if notes? then
433
451
  @footnotes = {}
434
452
 
435
- setup_parser markdown, @debug
436
- peg_parse 'Notes'
453
+ # A note definition must contain "[^", so documents without one
454
+ # have nothing for the collecting pass to find
455
+ if markdown.include? '[^' then
456
+ setup_parser markdown, @debug
457
+ peg_parse 'Notes'
458
+ end
437
459
 
438
460
  # using note_order on the first pass would be a bug
439
461
  @note_order = []
@@ -490,11 +512,7 @@
490
512
  # Wraps `text` in strike markup for rdoc inline formatting
491
513
 
492
514
  def strike text
493
- if text =~ /\A[a-z\d.\/-]+\z/i then
494
- "~#{text}~"
495
- else
496
- "<s>#{text}</s>"
497
- end
515
+ "<del>#{text}</del>"
498
516
  end
499
517
 
500
518
  ##
@@ -551,7 +569,7 @@
551
569
 
552
570
  root = Doc
553
571
 
554
- Doc = BOM? Block*:a { RDoc::Markup::Document.new(*a.compact) }
572
+ Doc = Block*:a { RDoc::Markup::Document.new(*a.compact) }
555
573
 
556
574
  Block = @BlankLine*
557
575
  ( BlockQuote
@@ -607,8 +625,8 @@ BlockQuote = BlockQuoteRaw:a
607
625
 
608
626
  BlockQuoteRaw = @StartList:a
609
627
  (( ">" " "? Line:l { a << l } )
610
- ( !">" !@BlankLine Line:c { a << c } )*
611
- ( @BlankLine:n { a << n } )*
628
+ ( !">" !@BlankLine !(AtxStart @Spacechar) !Bullet !Enumerator !( &{ github? } Ticks3 ) Line:c { a << c } )*
629
+ ( ">" @BlankLine:n { a << n } )*
612
630
  )+
613
631
  { inner_parse a.join }
614
632
 
@@ -855,7 +873,7 @@ HtmlBlockInTags = HtmlAnchor
855
873
  | HtmlBlockScript
856
874
  | HtmlBlockHead
857
875
 
858
- HtmlBlock = < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) >
876
+ HtmlBlock = &"<" < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing | HtmlUnclosed) >
859
877
  @BlankLine+
860
878
  { if html? then
861
879
  RDoc::Markup::Raw.new text
@@ -965,6 +983,7 @@ Inline = Str
965
983
  | InlineNote
966
984
  | Code
967
985
  | RawHtml
986
+ | StrippedComment
968
987
  | Entity
969
988
  | EscapedChar
970
989
  | Symbol
@@ -973,11 +992,11 @@ Space = @Spacechar+ { " " }
973
992
 
974
993
  Str = @StartList:a
975
994
  < @NormalChar+ > { a = text }
976
- ( StrChunk:c { a << c } )* { a }
995
+ ( StrChunk:c { a << c } )* { rdoc_escape(a) }
977
996
 
978
997
  StrChunk = < (@NormalChar | /_+/ &Alphanumeric)+ > { text }
979
998
 
980
- EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { text }
999
+ EscapedChar = "\\" !@Newline < /[:\\`|*_{}\[\]()#+.!><-]/ > { rdoc_escape(text) }
981
1000
 
982
1001
  Entity = ( HexEntity | DecEntity | CharEntity ):a { a }
983
1002
 
@@ -992,7 +1011,7 @@ TerminalEndline = @Sp @Newline @Eof
992
1011
  LineBreak = " " @NormalEndline { RDoc::Markup::HardBreak.new }
993
1012
 
994
1013
  Symbol = < @SpecialChar >
995
- { text }
1014
+ { rdoc_escape(text) }
996
1015
 
997
1016
  # This keeps the parser from getting bogged down on long strings of '*' or '_',
998
1017
  # or strings of '*' or '_' with space on each side:
@@ -1057,7 +1076,7 @@ ReferenceLinkSingle = Label:content < (Spnl "[]")? >
1057
1076
  { link_to content, content, text }
1058
1077
 
1059
1078
  ExplicitLink = ExplicitLinkWithLabel:a
1060
- { "{#{a[:label]}}[#{a[:link]}]" }
1079
+ { "{#{a[:label]}}[#{rdoc_link_url_escape(a[:link])}]" }
1061
1080
 
1062
1081
  ExplicitLinkWithLabel = Label:label "(" @Sp Source:link Spnl Title @Sp ")"
1063
1082
  { { label: label, link: link } }
@@ -1142,8 +1161,8 @@ Code = ( Ticks1 < (
1142
1161
  )
1143
1162
  { code text }
1144
1163
 
1145
- RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) >
1146
- { if html? then text else '' end }
1164
+ RawHtml = < HtmlBlockScript | HtmlTag > { html? ? text : '' }
1165
+ StrippedComment = HtmlComment { '' }
1147
1166
 
1148
1167
  BlankLine = @Sp @Newline { "\n" }
1149
1168
 
@@ -1159,20 +1178,18 @@ SpecialChar = /[~*_`&\[\]()<!#\\'"]/ | @ExtendedSpecialChar
1159
1178
  NormalChar = !( @SpecialChar | @Spacechar | @Newline ) .
1160
1179
  Digit = [0-9]
1161
1180
 
1162
- %literals = RDoc::Markdown::Literals
1163
- Alphanumeric = %literals.Alphanumeric
1164
- AlphanumericAscii = %literals.AlphanumericAscii
1165
- BOM = %literals.BOM
1166
- Newline = %literals.Newline
1167
- Spacechar = %literals.Spacechar
1181
+ Alphanumeric = /\p{Word}/
1182
+ AlphanumericAscii = /[A-Za-z0-9]/
1183
+ Newline = /\n|\r\n?|\p{Zl}|\p{Zp}/
1184
+ Spacechar = /\t|\p{Zs}/
1168
1185
 
1169
1186
  HexEntity = /&#x/i < /[0-9a-fA-F]+/ > ";"
1170
- { [text.to_i(16)].pack 'U' }
1187
+ { rdoc_escape([text.to_i(16)].pack('U')) }
1171
1188
  DecEntity = "&#" < /[0-9]+/ > ";"
1172
- { [text.to_i].pack 'U' }
1189
+ { rdoc_escape([text.to_i].pack('U')) }
1173
1190
  CharEntity = "&" </[A-Za-z0-9]+/ > ";"
1174
1191
  { if entity = HTML_ENTITIES[text] then
1175
- entity.pack 'U*'
1192
+ rdoc_escape(entity.pack('U*'))
1176
1193
  else
1177
1194
  "&#{text};"
1178
1195
  end
@@ -1223,10 +1240,12 @@ InlineNote = &{ notes? }
1223
1240
  @StartList:a
1224
1241
  ( !"]" Inline:l { a << l } )+
1225
1242
  "]"
1226
- { ref = [:inline, @note_order.length]
1227
- @footnotes[ref] = paragraph a
1243
+ { if @note_order
1244
+ ref = [:inline, @note_order.length]
1245
+ @footnotes[ref] = paragraph a
1228
1246
 
1229
- note_for ref
1247
+ note_for ref
1248
+ end
1230
1249
  }
1231
1250
 
1232
1251
  Notes = ( Note | SkipBlock )*
@@ -1239,7 +1258,7 @@ RawNoteBlock = @StartList:a
1239
1258
  # Markdown extensions added by RDoc follow
1240
1259
 
1241
1260
  CodeFence = &{ github? }
1242
- Ticks3 (@Sp StrChunk:format)? Spnl < (
1261
+ Ticks3 (@Sp StrChunk:format)? @Sp @Newline? < (
1243
1262
  ( !"`" Nonspacechar )+ |
1244
1263
  !Ticks3 /`+/ |
1245
1264
  Spacechar |
@@ -1260,13 +1279,13 @@ Table = &{ github? }
1260
1279
  TableHead = TableItem2+:items "|"? @Newline
1261
1280
  { items }
1262
1281
 
1263
- TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
1282
+ TableRow = ( ( TableItem:item1 TableItem2+:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
1264
1283
  { row }
1265
1284
  TableItem2 = "|" TableItem
1266
1285
  TableItem = < /(?:\\.|[^|\n])+/ >
1267
1286
  { text.strip.gsub(/\\([|])/, '\1') }
1268
1287
 
1269
- TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1288
+ TableLine = ( ( TableAlign:align1 TableAlign2+:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1270
1289
  { line }
1271
1290
  TableAlign2 = "|" @Sp TableAlign
1272
1291
  TableAlign = < /:?-+:?/ > @Sp