PageRenderTime 68ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rdoc/markdown.rb

https://github.com/bobmandude/Instaswag
Ruby | 16336 lines | 14783 code | 1131 blank | 422 comment | 1032 complexity | d02593a245f87b69b867ef7e4fbce24e MD5 | raw file
Possible License(s): Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. # coding: UTF-8
  2. # :markup: markdown
  3. ##
  4. # RDoc::Markdown as described by the [markdown syntax][syntax].
  5. #
  6. # To choose Markdown as your only default format see
  7. # RDoc::Options@Saved+Options for instructions on setting up a `.doc_options`
  8. # file to store your project default.
  9. #
  10. # ## Extensions
  11. #
  12. # The following markdown extensions are supported by the parser, but not all
  13. # are used in RDoc output by default.
  14. #
  15. # ### RDoc
  16. #
  17. # The RDoc Markdown parser has the following built-in behaviors that cannot be
  18. # disabled.
  19. #
  20. # Underscores embedded in words are never interpreted as emphasis. (While the
  21. # [markdown dingus][dingus] emphasizes in-word underscores, neither the
  22. # Markdown syntax nor MarkdownTest mention this behavior.)
  23. #
  24. # For HTML output, RDoc always auto-links bare URLs.
  25. #
  26. # ### Break on Newline
  27. #
  28. # The break_on_newline extension converts all newlines into hard line breaks
  29. # as in [Github Flavored Markdown][GFM]. This extension is disabled by
  30. # default.
  31. #
  32. # ### CSS
  33. #
  34. # The #css extension enables CSS blocks to be included in the output, but they
  35. # are not used for any built-in RDoc output format. This extension is disabled
  36. # by default.
  37. #
  38. # Example:
  39. #
  40. # <style type="text/css">
  41. # h1 { font-size: 3em }
  42. # </style>
  43. #
  44. # ### Definition Lists
  45. #
  46. # The definition_lists extension allows definition lists using the [PHP
  47. # Markdown Extra syntax][PHPE], but only one label and definition are supported
  48. # at this time. This extension is enabled by default.
  49. #
  50. # Example:
  51. #
  52. # ```
  53. # cat
  54. # : A small furry mammal
  55. # that seems to sleep a lot
  56. #
  57. # ant
  58. # : A little insect that is known
  59. # to enjoy picnics
  60. #
  61. # ```
  62. #
  63. # Produces:
  64. #
  65. # cat
  66. # : A small furry mammal
  67. # that seems to sleep a lot
  68. #
  69. # ant
  70. # : A little insect that is known
  71. # to enjoy picnics
  72. #
  73. # ### Github
  74. #
  75. # The #github extension enables a partial set of [Github Flavored Markdown]
  76. # [GFM]. This extension is enabled by default.
  77. #
  78. # Supported github extensions include:
  79. #
  80. # #### Fenced code blocks
  81. #
  82. # Use ` ``` ` around a block of code instead of indenting it four spaces.
  83. #
  84. # #### Syntax highlighting
  85. #
  86. # Use ` ``` ruby ` as the start of a code fence to add syntax highlighting.
  87. # (Currently only `ruby` syntax is supported).
  88. #
  89. # ### HTML
  90. #
  91. # Enables raw HTML to be included in the output. This extension is enabled by
  92. # default.
  93. #
  94. # Example:
  95. #
  96. # <table>
  97. # ...
  98. # </table>
  99. #
  100. # ### Notes
  101. #
  102. # The #notes extension enables footnote support. This extension is enabled by
  103. # default.
  104. #
  105. # Example:
  106. #
  107. # Here is some text[^1] including an inline footnote ^[for short footnotes]
  108. #
  109. # ...
  110. #
  111. # [^1]: With the footnote text down at the bottom
  112. #
  113. # Produces:
  114. #
  115. # Here is some text[^1] including an inline footnote ^[for short footnotes]
  116. #
  117. # [^1]: With the footnote text down at the bottom
  118. #
  119. # ## Limitations
  120. #
  121. # * Link titles are not used
  122. # * Image links are not generated correctly
  123. # * Footnotes are collapsed into a single paragraph
  124. #
  125. # ## Author
  126. #
  127. # This markdown parser is a port to kpeg from [peg-markdown][pegmarkdown] by
  128. # John MacFarlane.
  129. #
  130. # It is used under the MIT license:
  131. #
  132. # Permission is hereby granted, free of charge, to any person obtaining a copy
  133. # of this software and associated documentation files (the "Software"), to deal
  134. # in the Software without restriction, including without limitation the rights
  135. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  136. # copies of the Software, and to permit persons to whom the Software is
  137. # furnished to do so, subject to the following conditions:
  138. #
  139. # The above copyright notice and this permission notice shall be included in
  140. # all copies or substantial portions of the Software.
  141. #
  142. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  143. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  144. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  145. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  146. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  147. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  148. # THE SOFTWARE.
  149. #
  150. # The port to kpeg was performed by Eric Hodel and Evan Phoenix
  151. #
  152. # [dingus]: http://daringfireball.net/projects/markdown/dingus
  153. # [GFM]: http://github.github.com/github-flavored-markdown/
  154. # [pegmarkdown]: https://github.com/jgm/peg-markdown
  155. # [PHPE]: http://michelf.com/projects/php-markdown/extra/#def-list
  156. # [syntax]: http://daringfireball.net/projects/markdown/syntax
  157. #--
  158. # Last updated to jgm/peg-markdown commit 8f8fc22ef0
  159. class RDoc::Markdown
  160. # :stopdoc:
  161. # This is distinct from setup_parser so that a standalone parser
  162. # can redefine #initialize and still have access to the proper
  163. # parser setup code.
  164. def initialize(str, debug=false)
  165. setup_parser(str, debug)
  166. end
  167. # Prepares for parsing +str+. If you define a custom initialize you must
  168. # call this method before #parse
  169. def setup_parser(str, debug=false)
  170. @string = str
  171. @pos = 0
  172. @memoizations = Hash.new { |h,k| h[k] = {} }
  173. @result = nil
  174. @failed_rule = nil
  175. @failing_rule_offset = -1
  176. setup_foreign_grammar
  177. end
  178. attr_reader :string
  179. attr_reader :failing_rule_offset
  180. attr_accessor :result, :pos
  181. def current_column(target=pos)
  182. if c = string.rindex("\n", target-1)
  183. return target - c - 1
  184. end
  185. target + 1
  186. end
  187. def current_line(target=pos)
  188. cur_offset = 0
  189. cur_line = 0
  190. string.each_line do |line|
  191. cur_line += 1
  192. cur_offset += line.size
  193. return cur_line if cur_offset >= target
  194. end
  195. -1
  196. end
  197. def lines
  198. lines = []
  199. string.each_line { |l| lines << l }
  200. lines
  201. end
  202. def get_text(start)
  203. @string[start..@pos-1]
  204. end
  205. def show_pos
  206. width = 10
  207. if @pos < width
  208. "#{@pos} (\"#{@string[0,@pos]}\" @ \"#{@string[@pos,width]}\")"
  209. else
  210. "#{@pos} (\"... #{@string[@pos - width, width]}\" @ \"#{@string[@pos,width]}\")"
  211. end
  212. end
  213. def failure_info
  214. l = current_line @failing_rule_offset
  215. c = current_column @failing_rule_offset
  216. if @failed_rule.kind_of? Symbol
  217. info = self.class::Rules[@failed_rule]
  218. "line #{l}, column #{c}: failed rule '#{info.name}' = '#{info.rendered}'"
  219. else
  220. "line #{l}, column #{c}: failed rule '#{@failed_rule}'"
  221. end
  222. end
  223. def failure_caret
  224. l = current_line @failing_rule_offset
  225. c = current_column @failing_rule_offset
  226. line = lines[l-1]
  227. "#{line}\n#{' ' * (c - 1)}^"
  228. end
  229. def failure_character
  230. l = current_line @failing_rule_offset
  231. c = current_column @failing_rule_offset
  232. lines[l-1][c-1, 1]
  233. end
  234. def failure_oneline
  235. l = current_line @failing_rule_offset
  236. c = current_column @failing_rule_offset
  237. char = lines[l-1][c-1, 1]
  238. if @failed_rule.kind_of? Symbol
  239. info = self.class::Rules[@failed_rule]
  240. "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
  241. else
  242. "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
  243. end
  244. end
  245. class ParseError < RuntimeError
  246. end
  247. def raise_error
  248. raise ParseError, failure_oneline
  249. end
  250. def show_error(io=STDOUT)
  251. error_pos = @failing_rule_offset
  252. line_no = current_line(error_pos)
  253. col_no = current_column(error_pos)
  254. io.puts "On line #{line_no}, column #{col_no}:"
  255. if @failed_rule.kind_of? Symbol
  256. info = self.class::Rules[@failed_rule]
  257. io.puts "Failed to match '#{info.rendered}' (rule '#{info.name}')"
  258. else
  259. io.puts "Failed to match rule '#{@failed_rule}'"
  260. end
  261. io.puts "Got: #{string[error_pos,1].inspect}"
  262. line = lines[line_no-1]
  263. io.puts "=> #{line}"
  264. io.print(" " * (col_no + 3))
  265. io.puts "^"
  266. end
  267. def set_failed_rule(name)
  268. if @pos > @failing_rule_offset
  269. @failed_rule = name
  270. @failing_rule_offset = @pos
  271. end
  272. end
  273. attr_reader :failed_rule
  274. def match_string(str)
  275. len = str.size
  276. if @string[pos,len] == str
  277. @pos += len
  278. return str
  279. end
  280. return nil
  281. end
  282. def scan(reg)
  283. if m = reg.match(@string[@pos..-1])
  284. width = m.end(0)
  285. @pos += width
  286. return true
  287. end
  288. return nil
  289. end
  290. if "".respond_to? :getbyte
  291. def get_byte
  292. if @pos >= @string.size
  293. return nil
  294. end
  295. s = @string.getbyte @pos
  296. @pos += 1
  297. s
  298. end
  299. else
  300. def get_byte
  301. if @pos >= @string.size
  302. return nil
  303. end
  304. s = @string[@pos]
  305. @pos += 1
  306. s
  307. end
  308. end
  309. def parse(rule=nil)
  310. # We invoke the rules indirectly via apply
  311. # instead of by just calling them as methods because
  312. # if the rules use left recursion, apply needs to
  313. # manage that.
  314. if !rule
  315. apply(:_root)
  316. else
  317. method = rule.gsub("-","_hyphen_")
  318. apply :"_#{method}"
  319. end
  320. end
  321. class MemoEntry
  322. def initialize(ans, pos)
  323. @ans = ans
  324. @pos = pos
  325. @result = nil
  326. @set = false
  327. @left_rec = false
  328. end
  329. attr_reader :ans, :pos, :result, :set
  330. attr_accessor :left_rec
  331. def move!(ans, pos, result)
  332. @ans = ans
  333. @pos = pos
  334. @result = result
  335. @set = true
  336. @left_rec = false
  337. end
  338. end
  339. def external_invoke(other, rule, *args)
  340. old_pos = @pos
  341. old_string = @string
  342. @pos = other.pos
  343. @string = other.string
  344. begin
  345. if val = __send__(rule, *args)
  346. other.pos = @pos
  347. other.result = @result
  348. else
  349. other.set_failed_rule "#{self.class}##{rule}"
  350. end
  351. val
  352. ensure
  353. @pos = old_pos
  354. @string = old_string
  355. end
  356. end
  357. def apply_with_args(rule, *args)
  358. memo_key = [rule, args]
  359. if m = @memoizations[memo_key][@pos]
  360. @pos = m.pos
  361. if !m.set
  362. m.left_rec = true
  363. return nil
  364. end
  365. @result = m.result
  366. return m.ans
  367. else
  368. m = MemoEntry.new(nil, @pos)
  369. @memoizations[memo_key][@pos] = m
  370. start_pos = @pos
  371. ans = __send__ rule, *args
  372. lr = m.left_rec
  373. m.move! ans, @pos, @result
  374. # Don't bother trying to grow the left recursion
  375. # if it's failing straight away (thus there is no seed)
  376. if ans and lr
  377. return grow_lr(rule, args, start_pos, m)
  378. else
  379. return ans
  380. end
  381. return ans
  382. end
  383. end
  384. def apply(rule)
  385. if m = @memoizations[rule][@pos]
  386. @pos = m.pos
  387. if !m.set
  388. m.left_rec = true
  389. return nil
  390. end
  391. @result = m.result
  392. return m.ans
  393. else
  394. m = MemoEntry.new(nil, @pos)
  395. @memoizations[rule][@pos] = m
  396. start_pos = @pos
  397. ans = __send__ rule
  398. lr = m.left_rec
  399. m.move! ans, @pos, @result
  400. # Don't bother trying to grow the left recursion
  401. # if it's failing straight away (thus there is no seed)
  402. if ans and lr
  403. return grow_lr(rule, nil, start_pos, m)
  404. else
  405. return ans
  406. end
  407. return ans
  408. end
  409. end
  410. def grow_lr(rule, args, start_pos, m)
  411. while true
  412. @pos = start_pos
  413. @result = m.result
  414. if args
  415. ans = __send__ rule, *args
  416. else
  417. ans = __send__ rule
  418. end
  419. return nil unless ans
  420. break if @pos <= m.pos
  421. m.move! ans, @pos, @result
  422. end
  423. @result = m.result
  424. @pos = m.pos
  425. return m.ans
  426. end
  427. class RuleInfo
  428. def initialize(name, rendered)
  429. @name = name
  430. @rendered = rendered
  431. end
  432. attr_reader :name, :rendered
  433. end
  434. def self.rule_info(name, rendered)
  435. RuleInfo.new(name, rendered)
  436. end
  437. # :startdoc:
  438. require 'rubygems'
  439. require 'rdoc'
  440. require 'rdoc/markup/to_joined_paragraph'
  441. require 'rdoc/markdown/entities'
  442. if RUBY_VERSION > '1.9' then
  443. require 'rdoc/markdown/literals_1_9'
  444. else
  445. require 'rdoc/markdown/literals_1_8'
  446. end
  447. ##
  448. # Supported extensions
  449. EXTENSIONS = []
  450. ##
  451. # Extensions enabled by default
  452. DEFAULT_EXTENSIONS = [
  453. :definition_lists,
  454. :github,
  455. :html,
  456. :notes,
  457. ]
  458. # :section: Extensions
  459. ##
  460. # Creates extension methods for the `name` extension to enable and disable
  461. # the extension and to query if they are active.
  462. def self.extension name
  463. EXTENSIONS << name
  464. eval <<-RUBY
  465. def #{name}?
  466. extension? __method__
  467. end
  468. def #{name}= enable
  469. extension __method__, enable
  470. end
  471. RUBY
  472. end
  473. ##
  474. # Converts all newlines into hard breaks
  475. extension :break_on_newline
  476. ##
  477. # Allow style blocks
  478. extension :css
  479. ##
  480. # Allow PHP Markdown Extras style definition lists
  481. extension :definition_lists
  482. ##
  483. # Allow Github Flavored Markdown
  484. extension :github
  485. ##
  486. # Allow HTML
  487. extension :html
  488. ##
  489. # Enables the notes extension
  490. extension :notes
  491. # :section:
  492. ##
  493. # Parses the `markdown` document into an RDoc::Document using the default
  494. # extensions.
  495. def self.parse markdown
  496. parser = new
  497. parser.parse markdown
  498. end
  499. # TODO remove when kpeg 0.10 is released
  500. alias orig_initialize initialize # :nodoc:
  501. ##
  502. # Creates a new markdown parser that enables the given +extensions+.
  503. def initialize extensions = DEFAULT_EXTENSIONS, debug = false
  504. @debug = debug
  505. @formatter = RDoc::Markup::ToJoinedParagraph.new
  506. @extensions = extensions
  507. @references = nil
  508. @unlinked_references = nil
  509. @footnotes = nil
  510. @note_order = nil
  511. end
  512. ##
  513. # Wraps `text` in emphasis for rdoc inline formatting
  514. def emphasis text
  515. if text =~ /\A[a-z\d.\/]+\z/i then
  516. "_#{text}_"
  517. else
  518. "<em>#{text}</em>"
  519. end
  520. end
  521. ##
  522. # :category: Extensions
  523. #
  524. # Is the extension `name` enabled?
  525. def extension? name
  526. name = name.to_s.delete('?').intern
  527. @extensions.include? name
  528. end
  529. ##
  530. # :category: Extensions
  531. #
  532. # Enables or disables the extension with `name`
  533. def extension name, enable
  534. name = name.to_s.delete('=').intern
  535. if enable then
  536. @extensions |= [name]
  537. else
  538. @extensions -= [name]
  539. end
  540. end
  541. ##
  542. # Parses `text` in a clone of this parser. This is used for handling nested
  543. # lists the same way as markdown_parser.
  544. def inner_parse text # :nodoc:
  545. parser = clone
  546. parser.setup_parser text, @debug
  547. parser.peg_parse
  548. doc = parser.result
  549. doc.accept @formatter
  550. doc.parts
  551. end
  552. ##
  553. # Finds a link reference for `label` and creates a new link to it with
  554. # `content` as the link text. If `label` was not encountered in the
  555. # reference-gathering parser pass the label and content are reconstructed
  556. # with the linking `text` (usually whitespace).
  557. def link_to content, label = content, text = nil
  558. raise 'enable notes extension' if
  559. content.start_with? '^' and label.equal? content
  560. if ref = @references[label] then
  561. "{#{content}}[#{ref}]"
  562. elsif label.equal? content then
  563. "[#{content}]#{text}"
  564. else
  565. "[#{content}]#{text}[#{label}]"
  566. end
  567. end
  568. ##
  569. # Creates an RDoc::Markup::ListItem by parsing the `unparsed` content from
  570. # the first parsing pass.
  571. def list_item_from unparsed
  572. parsed = inner_parse unparsed.join
  573. RDoc::Markup::ListItem.new nil, *parsed
  574. end
  575. ##
  576. # Stores `label` as a note and fills in previously unknown note references.
  577. def note label
  578. #foottext = "rdoc-label:foottext-#{label}:footmark-#{label}"
  579. #ref.replace foottext if ref = @unlinked_notes.delete(label)
  580. @notes[label] = foottext
  581. #"{^1}[rdoc-label:footmark-#{label}:foottext-#{label}] "
  582. end
  583. ##
  584. # Creates a new link for the footnote `reference` and adds the reference to
  585. # the note order list for proper display at the end of the document.
  586. def note_for ref
  587. @note_order << ref
  588. label = @note_order.length
  589. "{*#{label}}[rdoc-label:foottext-#{label}:footmark-#{label}]"
  590. end
  591. ##
  592. # The internal kpeg parse method
  593. alias peg_parse parse # :nodoc:
  594. ##
  595. # Creates an RDoc::Markup::Paragraph from `parts` and including
  596. # extension-specific behavior
  597. def paragraph parts
  598. parts = parts.map do |part|
  599. if "\n" == part then
  600. RDoc::Markup::HardBreak.new
  601. else
  602. part
  603. end
  604. end if break_on_newline?
  605. RDoc::Markup::Paragraph.new(*parts)
  606. end
  607. ##
  608. # Parses `markdown` into an RDoc::Document
  609. def parse markdown
  610. @references = {}
  611. @unlinked_references = {}
  612. markdown += "\n\n"
  613. setup_parser markdown, @debug
  614. peg_parse 'References'
  615. if notes? then
  616. @footnotes = {}
  617. setup_parser markdown, @debug
  618. peg_parse 'Notes'
  619. # using note_order on the first pass would be a bug
  620. @note_order = []
  621. end
  622. setup_parser markdown, @debug
  623. peg_parse
  624. doc = result
  625. if notes? and not @footnotes.empty? then
  626. doc << RDoc::Markup::Rule.new(1)
  627. @note_order.each_with_index do |ref, index|
  628. label = index + 1
  629. note = @footnotes[ref]
  630. link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] "
  631. note.parts.unshift link
  632. doc << note
  633. end
  634. end
  635. doc.accept @formatter
  636. doc
  637. end
  638. ##
  639. # Stores `label` as a reference to `link` and fills in previously unknown
  640. # link references.
  641. def reference label, link
  642. if ref = @unlinked_references.delete(label) then
  643. ref.replace link
  644. end
  645. @references[label] = link
  646. end
  647. ##
  648. # Wraps `text` in strong markup for rdoc inline formatting
  649. def strong text
  650. if text =~ /\A[a-z\d.\/-]+\z/i then
  651. "*#{text}*"
  652. else
  653. "<b>#{text}</b>"
  654. end
  655. end
  656. # :stopdoc:
  657. def setup_foreign_grammar
  658. @_grammar_literals = RDoc::Markdown::Literals.new(nil)
  659. end
  660. # root = Doc
  661. def _root
  662. _tmp = apply(:_Doc)
  663. set_failed_rule :_root unless _tmp
  664. return _tmp
  665. end
  666. # Doc = BOM? Block*:a { RDoc::Markup::Document.new(*a.compact) }
  667. def _Doc
  668. _save = self.pos
  669. while true # sequence
  670. _save1 = self.pos
  671. _tmp = apply(:_BOM)
  672. unless _tmp
  673. _tmp = true
  674. self.pos = _save1
  675. end
  676. unless _tmp
  677. self.pos = _save
  678. break
  679. end
  680. _ary = []
  681. while true
  682. _tmp = apply(:_Block)
  683. _ary << @result if _tmp
  684. break unless _tmp
  685. end
  686. _tmp = true
  687. @result = _ary
  688. a = @result
  689. unless _tmp
  690. self.pos = _save
  691. break
  692. end
  693. @result = begin; RDoc::Markup::Document.new(*a.compact) ; end
  694. _tmp = true
  695. unless _tmp
  696. self.pos = _save
  697. end
  698. break
  699. end # end sequence
  700. set_failed_rule :_Doc unless _tmp
  701. return _tmp
  702. end
  703. # Block = BlankLine* (BlockQuote | Verbatim | CodeFence | Note | Reference | HorizontalRule | Heading | OrderedList | BulletList | DefinitionList | HtmlBlock | StyleBlock | Para | Plain)
  704. def _Block
  705. _save = self.pos
  706. while true # sequence
  707. while true
  708. _tmp = apply(:_BlankLine)
  709. break unless _tmp
  710. end
  711. _tmp = true
  712. unless _tmp
  713. self.pos = _save
  714. break
  715. end
  716. _save2 = self.pos
  717. while true # choice
  718. _tmp = apply(:_BlockQuote)
  719. break if _tmp
  720. self.pos = _save2
  721. _tmp = apply(:_Verbatim)
  722. break if _tmp
  723. self.pos = _save2
  724. _tmp = apply(:_CodeFence)
  725. break if _tmp
  726. self.pos = _save2
  727. _tmp = apply(:_Note)
  728. break if _tmp
  729. self.pos = _save2
  730. _tmp = apply(:_Reference)
  731. break if _tmp
  732. self.pos = _save2
  733. _tmp = apply(:_HorizontalRule)
  734. break if _tmp
  735. self.pos = _save2
  736. _tmp = apply(:_Heading)
  737. break if _tmp
  738. self.pos = _save2
  739. _tmp = apply(:_OrderedList)
  740. break if _tmp
  741. self.pos = _save2
  742. _tmp = apply(:_BulletList)
  743. break if _tmp
  744. self.pos = _save2
  745. _tmp = apply(:_DefinitionList)
  746. break if _tmp
  747. self.pos = _save2
  748. _tmp = apply(:_HtmlBlock)
  749. break if _tmp
  750. self.pos = _save2
  751. _tmp = apply(:_StyleBlock)
  752. break if _tmp
  753. self.pos = _save2
  754. _tmp = apply(:_Para)
  755. break if _tmp
  756. self.pos = _save2
  757. _tmp = apply(:_Plain)
  758. break if _tmp
  759. self.pos = _save2
  760. break
  761. end # end choice
  762. unless _tmp
  763. self.pos = _save
  764. end
  765. break
  766. end # end sequence
  767. set_failed_rule :_Block unless _tmp
  768. return _tmp
  769. end
  770. # Para = NonindentSpace Inlines:a BlankLine+ { paragraph a }
  771. def _Para
  772. _save = self.pos
  773. while true # sequence
  774. _tmp = apply(:_NonindentSpace)
  775. unless _tmp
  776. self.pos = _save
  777. break
  778. end
  779. _tmp = apply(:_Inlines)
  780. a = @result
  781. unless _tmp
  782. self.pos = _save
  783. break
  784. end
  785. _save1 = self.pos
  786. _tmp = apply(:_BlankLine)
  787. if _tmp
  788. while true
  789. _tmp = apply(:_BlankLine)
  790. break unless _tmp
  791. end
  792. _tmp = true
  793. else
  794. self.pos = _save1
  795. end
  796. unless _tmp
  797. self.pos = _save
  798. break
  799. end
  800. @result = begin; paragraph a ; end
  801. _tmp = true
  802. unless _tmp
  803. self.pos = _save
  804. end
  805. break
  806. end # end sequence
  807. set_failed_rule :_Para unless _tmp
  808. return _tmp
  809. end
  810. # Plain = Inlines:a { paragraph a }
  811. def _Plain
  812. _save = self.pos
  813. while true # sequence
  814. _tmp = apply(:_Inlines)
  815. a = @result
  816. unless _tmp
  817. self.pos = _save
  818. break
  819. end
  820. @result = begin; paragraph a ; end
  821. _tmp = true
  822. unless _tmp
  823. self.pos = _save
  824. end
  825. break
  826. end # end sequence
  827. set_failed_rule :_Plain unless _tmp
  828. return _tmp
  829. end
  830. # AtxInline = !Newline !(Sp? "#"* Sp Newline) Inline
  831. def _AtxInline
  832. _save = self.pos
  833. while true # sequence
  834. _save1 = self.pos
  835. _tmp = apply(:_Newline)
  836. _tmp = _tmp ? nil : true
  837. self.pos = _save1
  838. unless _tmp
  839. self.pos = _save
  840. break
  841. end
  842. _save2 = self.pos
  843. _save3 = self.pos
  844. while true # sequence
  845. _save4 = self.pos
  846. _tmp = apply(:_Sp)
  847. unless _tmp
  848. _tmp = true
  849. self.pos = _save4
  850. end
  851. unless _tmp
  852. self.pos = _save3
  853. break
  854. end
  855. while true
  856. _tmp = match_string("#")
  857. break unless _tmp
  858. end
  859. _tmp = true
  860. unless _tmp
  861. self.pos = _save3
  862. break
  863. end
  864. _tmp = apply(:_Sp)
  865. unless _tmp
  866. self.pos = _save3
  867. break
  868. end
  869. _tmp = apply(:_Newline)
  870. unless _tmp
  871. self.pos = _save3
  872. end
  873. break
  874. end # end sequence
  875. _tmp = _tmp ? nil : true
  876. self.pos = _save2
  877. unless _tmp
  878. self.pos = _save
  879. break
  880. end
  881. _tmp = apply(:_Inline)
  882. unless _tmp
  883. self.pos = _save
  884. end
  885. break
  886. end # end sequence
  887. set_failed_rule :_AtxInline unless _tmp
  888. return _tmp
  889. end
  890. # AtxStart = < ("######" | "#####" | "####" | "###" | "##" | "#") > { text.length }
  891. def _AtxStart
  892. _save = self.pos
  893. while true # sequence
  894. _text_start = self.pos
  895. _save1 = self.pos
  896. while true # choice
  897. _tmp = match_string("######")
  898. break if _tmp
  899. self.pos = _save1
  900. _tmp = match_string("#####")
  901. break if _tmp
  902. self.pos = _save1
  903. _tmp = match_string("####")
  904. break if _tmp
  905. self.pos = _save1
  906. _tmp = match_string("###")
  907. break if _tmp
  908. self.pos = _save1
  909. _tmp = match_string("##")
  910. break if _tmp
  911. self.pos = _save1
  912. _tmp = match_string("#")
  913. break if _tmp
  914. self.pos = _save1
  915. break
  916. end # end choice
  917. if _tmp
  918. text = get_text(_text_start)
  919. end
  920. unless _tmp
  921. self.pos = _save
  922. break
  923. end
  924. @result = begin; text.length ; end
  925. _tmp = true
  926. unless _tmp
  927. self.pos = _save
  928. end
  929. break
  930. end # end sequence
  931. set_failed_rule :_AtxStart unless _tmp
  932. return _tmp
  933. end
  934. # AtxHeading = AtxStart:s Sp? AtxInline+:a (Sp? "#"* Sp)? Newline { RDoc::Markup::Heading.new(s, a.join) }
  935. def _AtxHeading
  936. _save = self.pos
  937. while true # sequence
  938. _tmp = apply(:_AtxStart)
  939. s = @result
  940. unless _tmp
  941. self.pos = _save
  942. break
  943. end
  944. _save1 = self.pos
  945. _tmp = apply(:_Sp)
  946. unless _tmp
  947. _tmp = true
  948. self.pos = _save1
  949. end
  950. unless _tmp
  951. self.pos = _save
  952. break
  953. end
  954. _save2 = self.pos
  955. _ary = []
  956. _tmp = apply(:_AtxInline)
  957. if _tmp
  958. _ary << @result
  959. while true
  960. _tmp = apply(:_AtxInline)
  961. _ary << @result if _tmp
  962. break unless _tmp
  963. end
  964. _tmp = true
  965. @result = _ary
  966. else
  967. self.pos = _save2
  968. end
  969. a = @result
  970. unless _tmp
  971. self.pos = _save
  972. break
  973. end
  974. _save3 = self.pos
  975. _save4 = self.pos
  976. while true # sequence
  977. _save5 = self.pos
  978. _tmp = apply(:_Sp)
  979. unless _tmp
  980. _tmp = true
  981. self.pos = _save5
  982. end
  983. unless _tmp
  984. self.pos = _save4
  985. break
  986. end
  987. while true
  988. _tmp = match_string("#")
  989. break unless _tmp
  990. end
  991. _tmp = true
  992. unless _tmp
  993. self.pos = _save4
  994. break
  995. end
  996. _tmp = apply(:_Sp)
  997. unless _tmp
  998. self.pos = _save4
  999. end
  1000. break
  1001. end # end sequence
  1002. unless _tmp
  1003. _tmp = true
  1004. self.pos = _save3
  1005. end
  1006. unless _tmp
  1007. self.pos = _save
  1008. break
  1009. end
  1010. _tmp = apply(:_Newline)
  1011. unless _tmp
  1012. self.pos = _save
  1013. break
  1014. end
  1015. @result = begin; RDoc::Markup::Heading.new(s, a.join) ; end
  1016. _tmp = true
  1017. unless _tmp
  1018. self.pos = _save
  1019. end
  1020. break
  1021. end # end sequence
  1022. set_failed_rule :_AtxHeading unless _tmp
  1023. return _tmp
  1024. end
  1025. # SetextHeading = (SetextHeading1 | SetextHeading2)
  1026. def _SetextHeading
  1027. _save = self.pos
  1028. while true # choice
  1029. _tmp = apply(:_SetextHeading1)
  1030. break if _tmp
  1031. self.pos = _save
  1032. _tmp = apply(:_SetextHeading2)
  1033. break if _tmp
  1034. self.pos = _save
  1035. break
  1036. end # end choice
  1037. set_failed_rule :_SetextHeading unless _tmp
  1038. return _tmp
  1039. end
  1040. # SetextBottom1 = "===" "="* Newline
  1041. def _SetextBottom1
  1042. _save = self.pos
  1043. while true # sequence
  1044. _tmp = match_string("===")
  1045. unless _tmp
  1046. self.pos = _save
  1047. break
  1048. end
  1049. while true
  1050. _tmp = match_string("=")
  1051. break unless _tmp
  1052. end
  1053. _tmp = true
  1054. unless _tmp
  1055. self.pos = _save
  1056. break
  1057. end
  1058. _tmp = apply(:_Newline)
  1059. unless _tmp
  1060. self.pos = _save
  1061. end
  1062. break
  1063. end # end sequence
  1064. set_failed_rule :_SetextBottom1 unless _tmp
  1065. return _tmp
  1066. end
  1067. # SetextBottom2 = "---" "-"* Newline
  1068. def _SetextBottom2
  1069. _save = self.pos
  1070. while true # sequence
  1071. _tmp = match_string("---")
  1072. unless _tmp
  1073. self.pos = _save
  1074. break
  1075. end
  1076. while true
  1077. _tmp = match_string("-")
  1078. break unless _tmp
  1079. end
  1080. _tmp = true
  1081. unless _tmp
  1082. self.pos = _save
  1083. break
  1084. end
  1085. _tmp = apply(:_Newline)
  1086. unless _tmp
  1087. self.pos = _save
  1088. end
  1089. break
  1090. end # end sequence
  1091. set_failed_rule :_SetextBottom2 unless _tmp
  1092. return _tmp
  1093. end
  1094. # SetextHeading1 = &(RawLine SetextBottom1) StartList:a (!Endline Inline:b { a << b })+ Sp? Newline SetextBottom1 { RDoc::Markup::Heading.new(1, a.join) }
  1095. def _SetextHeading1
  1096. _save = self.pos
  1097. while true # sequence
  1098. _save1 = self.pos
  1099. _save2 = self.pos
  1100. while true # sequence
  1101. _tmp = apply(:_RawLine)
  1102. unless _tmp
  1103. self.pos = _save2
  1104. break
  1105. end
  1106. _tmp = apply(:_SetextBottom1)
  1107. unless _tmp
  1108. self.pos = _save2
  1109. end
  1110. break
  1111. end # end sequence
  1112. self.pos = _save1
  1113. unless _tmp
  1114. self.pos = _save
  1115. break
  1116. end
  1117. _tmp = apply(:_StartList)
  1118. a = @result
  1119. unless _tmp
  1120. self.pos = _save
  1121. break
  1122. end
  1123. _save3 = self.pos
  1124. _save4 = self.pos
  1125. while true # sequence
  1126. _save5 = self.pos
  1127. _tmp = apply(:_Endline)
  1128. _tmp = _tmp ? nil : true
  1129. self.pos = _save5
  1130. unless _tmp
  1131. self.pos = _save4
  1132. break
  1133. end
  1134. _tmp = apply(:_Inline)
  1135. b = @result
  1136. unless _tmp
  1137. self.pos = _save4
  1138. break
  1139. end
  1140. @result = begin; a << b ; end
  1141. _tmp = true
  1142. unless _tmp
  1143. self.pos = _save4
  1144. end
  1145. break
  1146. end # end sequence
  1147. if _tmp
  1148. while true
  1149. _save6 = self.pos
  1150. while true # sequence
  1151. _save7 = self.pos
  1152. _tmp = apply(:_Endline)
  1153. _tmp = _tmp ? nil : true
  1154. self.pos = _save7
  1155. unless _tmp
  1156. self.pos = _save6
  1157. break
  1158. end
  1159. _tmp = apply(:_Inline)
  1160. b = @result
  1161. unless _tmp
  1162. self.pos = _save6
  1163. break
  1164. end
  1165. @result = begin; a << b ; end
  1166. _tmp = true
  1167. unless _tmp
  1168. self.pos = _save6
  1169. end
  1170. break
  1171. end # end sequence
  1172. break unless _tmp
  1173. end
  1174. _tmp = true
  1175. else
  1176. self.pos = _save3
  1177. end
  1178. unless _tmp
  1179. self.pos = _save
  1180. break
  1181. end
  1182. _save8 = self.pos
  1183. _tmp = apply(:_Sp)
  1184. unless _tmp
  1185. _tmp = true
  1186. self.pos = _save8
  1187. end
  1188. unless _tmp
  1189. self.pos = _save
  1190. break
  1191. end
  1192. _tmp = apply(:_Newline)
  1193. unless _tmp
  1194. self.pos = _save
  1195. break
  1196. end
  1197. _tmp = apply(:_SetextBottom1)
  1198. unless _tmp
  1199. self.pos = _save
  1200. break
  1201. end
  1202. @result = begin; RDoc::Markup::Heading.new(1, a.join) ; end
  1203. _tmp = true
  1204. unless _tmp
  1205. self.pos = _save
  1206. end
  1207. break
  1208. end # end sequence
  1209. set_failed_rule :_SetextHeading1 unless _tmp
  1210. return _tmp
  1211. end
  1212. # SetextHeading2 = &(RawLine SetextBottom2) StartList:a (!Endline Inline:b { a << b })+ Sp? Newline SetextBottom2 { RDoc::Markup::Heading.new(2, a.join) }
  1213. def _SetextHeading2
  1214. _save = self.pos
  1215. while true # sequence
  1216. _save1 = self.pos
  1217. _save2 = self.pos
  1218. while true # sequence
  1219. _tmp = apply(:_RawLine)
  1220. unless _tmp
  1221. self.pos = _save2
  1222. break
  1223. end
  1224. _tmp = apply(:_SetextBottom2)
  1225. unless _tmp
  1226. self.pos = _save2
  1227. end
  1228. break
  1229. end # end sequence
  1230. self.pos = _save1
  1231. unless _tmp
  1232. self.pos = _save
  1233. break
  1234. end
  1235. _tmp = apply(:_StartList)
  1236. a = @result
  1237. unless _tmp
  1238. self.pos = _save
  1239. break
  1240. end
  1241. _save3 = self.pos
  1242. _save4 = self.pos
  1243. while true # sequence
  1244. _save5 = self.pos
  1245. _tmp = apply(:_Endline)
  1246. _tmp = _tmp ? nil : true
  1247. self.pos = _save5
  1248. unless _tmp
  1249. self.pos = _save4
  1250. break
  1251. end
  1252. _tmp = apply(:_Inline)
  1253. b = @result
  1254. unless _tmp
  1255. self.pos = _save4
  1256. break
  1257. end
  1258. @result = begin; a << b ; end
  1259. _tmp = true
  1260. unless _tmp
  1261. self.pos = _save4
  1262. end
  1263. break
  1264. end # end sequence
  1265. if _tmp
  1266. while true
  1267. _save6 = self.pos
  1268. while true # sequence
  1269. _save7 = self.pos
  1270. _tmp = apply(:_Endline)
  1271. _tmp = _tmp ? nil : true
  1272. self.pos = _save7
  1273. unless _tmp
  1274. self.pos = _save6
  1275. break
  1276. end
  1277. _tmp = apply(:_Inline)
  1278. b = @result
  1279. unless _tmp
  1280. self.pos = _save6
  1281. break
  1282. end
  1283. @result = begin; a << b ; end
  1284. _tmp = true
  1285. unless _tmp
  1286. self.pos = _save6
  1287. end
  1288. break
  1289. end # end sequence
  1290. break unless _tmp
  1291. end
  1292. _tmp = true
  1293. else
  1294. self.pos = _save3
  1295. end
  1296. unless _tmp
  1297. self.pos = _save
  1298. break
  1299. end
  1300. _save8 = self.pos
  1301. _tmp = apply(:_Sp)
  1302. unless _tmp
  1303. _tmp = true
  1304. self.pos = _save8
  1305. end
  1306. unless _tmp
  1307. self.pos = _save
  1308. break
  1309. end
  1310. _tmp = apply(:_Newline)
  1311. unless _tmp
  1312. self.pos = _save
  1313. break
  1314. end
  1315. _tmp = apply(:_SetextBottom2)
  1316. unless _tmp
  1317. self.pos = _save
  1318. break
  1319. end
  1320. @result = begin; RDoc::Markup::Heading.new(2, a.join) ; end
  1321. _tmp = true
  1322. unless _tmp
  1323. self.pos = _save
  1324. end
  1325. break
  1326. end # end sequence
  1327. set_failed_rule :_SetextHeading2 unless _tmp
  1328. return _tmp
  1329. end
  1330. # Heading = (SetextHeading | AtxHeading)
  1331. def _Heading
  1332. _save = self.pos
  1333. while true # choice
  1334. _tmp = apply(:_SetextHeading)
  1335. break if _tmp
  1336. self.pos = _save
  1337. _tmp = apply(:_AtxHeading)
  1338. break if _tmp
  1339. self.pos = _save
  1340. break
  1341. end # end choice
  1342. set_failed_rule :_Heading unless _tmp
  1343. return _tmp
  1344. end
  1345. # BlockQuote = BlockQuoteRaw:a { RDoc::Markup::BlockQuote.new(*a) }
  1346. def _BlockQuote
  1347. _save = self.pos
  1348. while true # sequence
  1349. _tmp = apply(:_BlockQuoteRaw)
  1350. a = @result
  1351. unless _tmp
  1352. self.pos = _save
  1353. break
  1354. end
  1355. @result = begin; RDoc::Markup::BlockQuote.new(*a) ; end
  1356. _tmp = true
  1357. unless _tmp
  1358. self.pos = _save
  1359. end
  1360. break
  1361. end # end sequence
  1362. set_failed_rule :_BlockQuote unless _tmp
  1363. return _tmp
  1364. end
  1365. # BlockQuoteRaw = StartList:a (">" " "? Line:l { a << l } (!">" !BlankLine Line:c { a << c })* (BlankLine:n { a << n })*)+ { inner_parse a.join }
  1366. def _BlockQuoteRaw
  1367. _save = self.pos
  1368. while true # sequence
  1369. _tmp = apply(:_StartList)
  1370. a = @result
  1371. unless _tmp
  1372. self.pos = _save
  1373. break
  1374. end
  1375. _save1 = self.pos
  1376. _save2 = self.pos
  1377. while true # sequence
  1378. _tmp = match_string(">")
  1379. unless _tmp
  1380. self.pos = _save2
  1381. break
  1382. end
  1383. _save3 = self.pos
  1384. _tmp = match_string(" ")
  1385. unless _tmp
  1386. _tmp = true
  1387. self.pos = _save3
  1388. end
  1389. unless _tmp
  1390. self.pos = _save2
  1391. break
  1392. end
  1393. _tmp = apply(:_Line)
  1394. l = @result
  1395. unless _tmp
  1396. self.pos = _save2
  1397. break
  1398. end
  1399. @result = begin; a << l ; end
  1400. _tmp = true
  1401. unless _tmp
  1402. self.pos = _save2
  1403. break
  1404. end
  1405. while true
  1406. _save5 = self.pos
  1407. while true # sequence
  1408. _save6 = self.pos
  1409. _tmp = match_string(">")
  1410. _tmp = _tmp ? nil : true
  1411. self.pos = _save6
  1412. unless _tmp
  1413. self.pos = _save5
  1414. break
  1415. end
  1416. _save7 = self.pos
  1417. _tmp = apply(:_BlankLine)
  1418. _tmp = _tmp ? nil : true
  1419. self.pos = _save7
  1420. unless _tmp
  1421. self.pos = _save5
  1422. break
  1423. end
  1424. _tmp = apply(:_Line)
  1425. c = @result
  1426. unless _tmp
  1427. self.pos = _save5
  1428. break
  1429. end
  1430. @result = begin; a << c ; end
  1431. _tmp = true
  1432. unless _tmp
  1433. self.pos = _save5
  1434. end
  1435. break
  1436. end # end sequence
  1437. break unless _tmp
  1438. end
  1439. _tmp = true
  1440. unless _tmp
  1441. self.pos = _save2
  1442. break
  1443. end
  1444. while true
  1445. _save9 = self.pos
  1446. while true # sequence
  1447. _tmp = apply(:_BlankLine)
  1448. n = @result
  1449. unless _tmp
  1450. self.pos = _save9
  1451. break
  1452. end
  1453. @result = begin; a << n ; end
  1454. _tmp = true
  1455. unless _tmp
  1456. self.pos = _save9
  1457. end
  1458. break
  1459. end # end sequence
  1460. break unless _tmp
  1461. end
  1462. _tmp = true
  1463. unless _tmp
  1464. self.pos = _save2
  1465. end
  1466. break
  1467. end # end sequence
  1468. if _tmp
  1469. while true
  1470. _save10 = self.pos
  1471. while true # sequence
  1472. _tmp = match_string(">")
  1473. unless _tmp
  1474. self.pos = _save10
  1475. break
  1476. end
  1477. _save11 = self.pos
  1478. _tmp = match_string(" ")
  1479. unless _tmp
  1480. _tmp = true
  1481. self.pos = _save11
  1482. end
  1483. unless _tmp
  1484. self.pos = _save10
  1485. break
  1486. end
  1487. _tmp = apply(:_Line)
  1488. l = @result
  1489. unless _tmp
  1490. self.pos = _save10
  1491. break
  1492. end
  1493. @result = begin; a << l ; end
  1494. _tmp = true
  1495. unless _tmp
  1496. self.pos = _save10
  1497. break
  1498. end
  1499. while true
  1500. _save13 = self.pos
  1501. while true # sequence
  1502. _save14 = self.pos
  1503. _tmp = match_string(">")
  1504. _tmp = _tmp ? nil : true
  1505. self.pos = _save14
  1506. unless _tmp
  1507. self.pos = _save13
  1508. break
  1509. end
  1510. _save15 = self.pos
  1511. _tmp = apply(:_BlankLine)
  1512. _tmp = _tmp ? nil : true
  1513. self.pos = _save15
  1514. unless _tmp
  1515. self.pos = _save13
  1516. break
  1517. end
  1518. _tmp = apply(:_Line)
  1519. c = @result
  1520. unless _tmp
  1521. self.pos = _save13
  1522. break
  1523. end
  1524. @result = begin; a << c ; end
  1525. _tmp = true
  1526. unless _tmp
  1527. self.pos = _save13
  1528. end
  1529. break
  1530. end # end sequence
  1531. break unless _tmp
  1532. end
  1533. _tmp = true
  1534. unless _tmp
  1535. self.pos = _save10
  1536. break
  1537. end
  1538. while true
  1539. _save17 = self.pos
  1540. while true # sequence
  1541. _tmp = apply(:_BlankLine)
  1542. n = @result
  1543. unless _tmp
  1544. self.pos = _save17
  1545. break
  1546. end
  1547. @result = begin; a << n ; end
  1548. _tmp = true
  1549. unless _tmp
  1550. self.pos = _save17
  1551. end
  1552. break
  1553. end # end sequence
  1554. break unless _tmp
  1555. end
  1556. _tmp = true
  1557. unless _tmp
  1558. self.pos = _save10
  1559. end
  1560. break
  1561. end # end sequence
  1562. break unless _tmp
  1563. end
  1564. _tmp = true
  1565. else
  1566. self.pos = _save1
  1567. end
  1568. unless _tmp
  1569. self.pos = _save
  1570. break
  1571. end
  1572. @result = begin; inner_parse a.join ; end
  1573. _tmp = true
  1574. unless _tmp
  1575. self.pos = _save
  1576. end
  1577. break
  1578. end # end sequence
  1579. set_failed_rule :_BlockQuoteRaw unless _tmp
  1580. return _tmp
  1581. end
  1582. # NonblankIndentedLine = !BlankLine IndentedLine
  1583. def _NonblankIndentedLine
  1584. _save = self.pos
  1585. while true # sequence
  1586. _save1 = self.pos
  1587. _tmp = apply(:_BlankLine)
  1588. _tmp = _tmp ? nil : true
  1589. self.pos = _save1
  1590. unless _tmp
  1591. self.pos = _save
  1592. break
  1593. end
  1594. _tmp = apply(:_IndentedLine)
  1595. unless _tmp
  1596. self.pos = _save
  1597. end
  1598. break
  1599. end # end sequence
  1600. set_failed_rule :_NonblankIndentedLine unless _tmp
  1601. return _tmp
  1602. end
  1603. # VerbatimChunk = BlankLine*:a NonblankIndentedLine+:b { a.concat b }
  1604. def _VerbatimChunk
  1605. _save = self.pos
  1606. while true # sequence
  1607. _ary = []
  1608. while true
  1609. _tmp = apply(:_BlankLine)
  1610. _ary << @result if _tmp
  1611. break unless _tmp
  1612. end
  1613. _tmp = true
  1614. @result = _ary
  1615. a = @result
  1616. unless _tmp
  1617. self.pos = _save
  1618. break
  1619. end
  1620. _save2 = self.pos
  1621. _ary = []
  1622. _tmp = apply(:_NonblankIndentedLine)
  1623. if _tmp
  1624. _ary << @result
  1625. while true
  1626. _tmp = apply(:_NonblankIndentedLine)
  1627. _ary << @result if _tmp
  1628. break unless _tmp
  1629. end
  1630. _tmp = true
  1631. @result = _ary
  1632. else
  1633. self.pos = _save2
  1634. end
  1635. b = @result
  1636. unless _tmp
  1637. self.pos = _save
  1638. break
  1639. end
  1640. @result = begin; a.concat b ; end
  1641. _tmp = true
  1642. unless _tmp
  1643. self.pos = _save
  1644. end
  1645. break
  1646. end # end sequence
  1647. set_failed_rule :_VerbatimChunk unless _tmp
  1648. return _tmp
  1649. end
  1650. # Verbatim = VerbatimChunk+:a { RDoc::Markup::Verbatim.new(*a.flatten) }
  1651. def _Verbatim
  1652. _save = self.pos
  1653. while true # sequence
  1654. _save1 = self.pos
  1655. _ary = []
  1656. _tmp = apply(:_VerbatimChunk)
  1657. if _tmp
  1658. _ary << @result
  1659. while true
  1660. _tmp = apply(:_VerbatimChunk)
  1661. _ary << @result if _tmp
  1662. break unless _tmp
  1663. end
  1664. _tmp = true
  1665. @result = _ary
  1666. else
  1667. self.pos = _save1
  1668. end
  1669. a = @result
  1670. unless _tmp
  1671. self.pos = _save
  1672. break
  1673. end
  1674. @result = begin; RDoc::Markup::Verbatim.new(*a.flatten) ; end
  1675. _tmp = true
  1676. unless _tmp
  1677. self.pos = _save
  1678. end
  1679. break
  1680. end # end sequence
  1681. set_failed_rule :_Verbatim unless _tmp
  1682. return _tmp
  1683. end
  1684. # HorizontalRule = NonindentSpace ("*" Sp "*" Sp "*" (Sp "*")* | "-" Sp "-" Sp "-" (Sp "-")* | "_" Sp "_" Sp "_" (Sp "_")*) Sp Newline BlankLine+ { RDoc::Markup::Rule.new 1 }
  1685. def _HorizontalRule
  1686. _save = self.pos
  1687. while true # sequence
  1688. _tmp = apply(:_NonindentSpace)
  1689. unless _tmp
  1690. self.pos = _save
  1691. break
  1692. end
  1693. _save1 = self.pos
  1694. while true # choice
  1695. _save2 = self.pos
  1696. while true # sequence
  1697. _tmp = match_string("*")
  1698. unless _tmp
  1699. self.pos = _save2
  1700. break
  1701. end
  1702. _tmp = apply(:_Sp)
  1703. unless _tmp
  1704. self.pos = _save2
  1705. break
  1706. end
  1707. _tmp = match_string("*")
  1708. unless _tmp
  1709. self.pos = _save2
  1710. break
  1711. end
  1712. _tmp = apply(:_Sp)
  1713. unless _tmp
  1714. self.pos = _save2
  1715. break
  1716. end
  1717. _tmp = match_string("*")
  1718. unless _tmp
  1719. self.pos = _save2
  1720. break
  1721. end
  1722. while true
  1723. _save4 = self.pos
  1724. while true # sequence
  1725. _tmp = apply(:_Sp)
  1726. unless _tmp
  1727. self.pos = _save4
  1728. break
  1729. end
  1730. _tmp = match_string("*")
  1731. unless _tmp
  1732. self.pos = _save4
  1733. end
  1734. break
  1735. end # end sequence
  1736. break unless _tmp
  1737. end
  1738. _tmp = true
  1739. unless _tmp
  1740. self.pos = _save2
  1741. end
  1742. break
  1743. end # end sequence
  1744. break if _tmp
  1745. self.pos = _save1
  1746. _save5 = self.pos
  1747. while true # sequence
  1748. _tmp = match_string("-")
  1749. unless _tmp
  1750. self.pos = _save5
  1751. break
  1752. end
  1753. _tmp = apply(:_Sp)
  1754. unless _tmp
  1755. self.pos = _save5
  1756. break
  1757. end
  1758. _tmp = match_string("-")
  1759. unless _tmp
  1760. self.pos = _save5
  1761. break
  1762. end
  1763. _tmp = apply(:_Sp)
  1764. unless _tmp
  1765. self.pos = _save5
  1766. break
  1767. end
  1768. _tmp = match_string("-")
  1769. unless _tmp
  1770. self.pos = _save5
  1771. break
  1772. end
  1773. while true
  1774. _save7 = self.pos
  1775. while true # sequence
  1776. _tmp = apply(:_Sp)
  1777. unless _tmp
  1778. self.pos = _save7
  1779. break
  1780. end
  1781. _tmp = match_string("-")
  1782. unless _tmp
  1783. self.pos = _save7
  1784. end
  1785. break
  1786. end # end sequence
  1787. break unless _tmp
  1788. end
  1789. _tmp = true
  1790. unless _tmp
  1791. self.pos = _save5
  1792. end
  1793. break
  1794. end # end sequence
  1795. break if _tmp
  1796. self.pos = _save1
  1797. _save8 = self.pos
  1798. while true # sequence
  1799. _tmp = match_string("_")
  1800. unless _tmp
  1801. self.pos = _save8
  1802. break
  1803. end
  1804. _tmp = apply(:_Sp)
  1805. unless _tmp
  1806. self.pos = _save8
  1807. break
  1808. end
  1809. _tmp = match_string("_")
  1810. unless _tmp
  1811. self.pos = _save8
  1812. break
  1813. end
  1814. _tmp = apply(:_Sp)
  1815. unless _tmp
  1816. self.pos = _save8
  1817. break
  1818. end
  1819. _tmp = match_string("_")
  1820. unless _tmp
  1821. self.pos = _save8
  1822. break
  1823. end
  1824. while true
  1825. _save10 = self.pos
  1826. while true # sequence
  1827. _tmp = apply(:_Sp)
  1828. unless _tmp
  1829. self.pos = _save10
  1830. break
  1831. end
  1832. _tmp = match_string("_")
  1833. unless _tmp
  1834. self.pos = _save10
  1835. end
  1836. break
  1837. end # end sequence
  1838. break unless _tmp
  1839. end
  1840. _tmp = true
  1841. unless _tmp
  1842. self.pos = _save8
  1843. end
  1844. break
  1845. end # end sequence
  1846. break if _tmp
  1847. self.pos = _save1
  1848. break
  1849. end # end choice
  1850. unless _tmp
  1851. self.pos = _save
  1852. break
  1853. end
  1854. _tmp = apply(:_Sp)
  1855. unless _tmp
  1856. self.pos = _save
  1857. break
  1858. end
  1859. _tmp = apply(:_Newline)
  1860. unless _tmp
  1861. self.pos = _save
  1862. break
  1863. end
  1864. _save11 = self.pos
  1865. _tmp = apply(:_BlankLine)
  1866. if _tmp
  1867. while true
  1868. _tmp = apply(:_BlankLine)
  1869. break unless _tmp
  1870. end
  1871. _tmp = true
  1872. else
  1873. self.pos = _save11
  1874. end
  1875. unless _tmp
  1876. self.pos = _save
  1877. break
  1878. end
  1879. @result = begin; RDoc::Markup::Rule.new 1 ; end
  1880. _tmp = true
  1881. unless _tmp
  1882. self.pos = _save
  1883. end
  1884. break
  1885. end # end sequence
  1886. set_failed_rule :_HorizontalRule unless _tmp
  1887. return _tmp
  1888. end
  1889. # Bullet = !HorizontalRule NonindentSpace ("+" | "*" | "-") Spacechar+
  1890. def _Bullet
  1891. _save = self.pos
  1892. while true # sequence
  1893. _save1 = self.pos
  1894. _tmp = apply(:_HorizontalRule)
  1895. _tmp = _tmp ? nil : true
  1896. self.pos = _save1
  1897. unless _tmp
  1898. self.pos = _save
  1899. break
  1900. end
  1901. _tmp = apply(:_NonindentSpace)
  1902. unless _tmp
  1903. self.pos = _save
  1904. break
  1905. end
  1906. _save2 = self.pos
  1907. while true # choice
  1908. _tmp = match_string("+")
  1909. break if _tmp
  1910. self.pos = _save2
  1911. _tmp = match_string("*")
  1912. break if _tmp
  1913. self.pos = _save2
  1914. _tmp = match_string("-")
  1915. break if _tmp
  1916. self.pos = _save2
  1917. break
  1918. end # end choice
  1919. unless _tmp
  1920. self.pos = _save
  1921. break
  1922. end
  1923. _save3 = self.pos
  1924. _tmp = apply(:_Spacechar)
  1925. if _tmp
  1926. while true
  1927. _tmp = apply(:_Spacechar)
  1928. break unless _tmp
  1929. end
  1930. _tmp = true
  1931. else
  1932. self.pos = _save3
  1933. end
  1934. unless _tmp
  1935. self.pos = _save
  1936. end
  1937. break
  1938. end # end sequence
  1939. set_failed_rule :_Bullet unless _tmp
  1940. return _tmp
  1941. end
  1942. # BulletList = &Bullet (ListTight | ListLoose):a { RDoc::Markup::List.new(:BULLET, *a) }
  1943. def _BulletList
  1944. _save = self.pos
  1945. while true # sequence
  1946. _save1 = self.pos
  1947. _tmp = apply(:_Bullet)
  1948. self.pos = _save1
  1949. unless _tmp
  1950. self.pos = _save
  1951. break
  1952. end
  1953. _save2 = self.pos
  1954. while true # choice
  1955. _tmp = apply(:_ListTight)
  1956. break if _tmp
  1957. self.pos = _save2
  1958. _tmp = apply(:_ListLoose)
  1959. break if _tmp
  1960. self.pos = _save2
  1961. break
  1962. end # end choice
  1963. a = @result
  1964. unless _tmp
  1965. self.pos = _save
  1966. break
  1967. end
  1968. @result = begin; RDoc::Markup::List.new(:BULLET, *a) ; end
  1969. _tmp = true
  1970. unless _tmp
  1971. self.pos = _save
  1972. end
  1973. break
  1974. end # end sequence
  1975. set_failed_rule :_BulletList unless _tmp
  1976. return _tmp
  1977. end
  1978. # ListTight = ListItemTight+:a BlankLine* !(Bullet | Enumerator) { a }
  1979. def _ListTight
  1980. _save = self.pos
  1981. while true # sequence
  1982. _save1 = self.pos
  1983. _ary = []
  1984. _tmp = apply(:_ListItemTight)
  1985. if _tmp
  1986. _ary << @result
  1987. while true
  1988. _tmp = apply(:_ListItemTight)
  1989. _ary << @result if _tmp
  1990. break unless _tmp
  1991. end
  1992. _tmp = true
  1993. @result = _ary
  1994. else

Large files files are truncated, but you can click here to view the full file