### Home Classes Methods

### In Files

- lib/rdoc/rd/inline_parser.rb

### Parent

Racc::Parser

### Methods

- ::new
- #inline
- #next_token
- #next_words_on_error
- #on_error
- #parse
- #prev_words_on_error

### Files

- CONTRIBUTING.rdoc
- CVE-2013-0256.rdoc
- ExampleRDoc.rdoc
- LICENSE.rdoc
- Manifest.txt
- README.rdoc
- RI.rdoc
- Rakefile
- TODO.rdoc

### Class/Module Index

Quicksearch

- RDoc
- RDoc::Alias
- RDoc::AnonClass
- RDoc::AnyMethod
- RDoc::Attr
- RDoc::ClassModule
- RDoc::CodeObject
- RDoc::Comment
- RDoc::Constant
- RDoc::Context
- RDoc::Context::Section
- RDoc::CrossReference
- RDoc::ERBIO
- RDoc::ERBPartial
- RDoc::Encoding
- RDoc::Error
- RDoc::Extend
- RDoc::Gauntlet
- RDoc::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::Include
- RDoc::Markdown
- RDoc::Markdown::Literals
- RDoc::Markup
- RDoc::Markup::AttrChanger
- RDoc::Markup::AttrSpan
- RDoc::Markup::AttributeManager
- RDoc::Markup::Attributes
- RDoc::Markup::BlankLine
- RDoc::Markup::BlockQuote
- RDoc::Markup::Document
- RDoc::Markup::Formatter
- RDoc::Markup::FormatterTestCase
- RDoc::Markup::HardBreak
- RDoc::Markup::Include
- RDoc::Markup::IndentedParagraph
- RDoc::Markup::List
- RDoc::Markup::ListItem
- RDoc::Markup::Paragraph
- RDoc::Markup::Parser
- RDoc::Markup::Parser::Error
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::Rule
- RDoc::Markup::Special
- RDoc::Markup::TextFormatterTestCase
- RDoc::Markup::ToAnsi
- RDoc::Markup::ToBs
- RDoc::Markup::ToHtml
- RDoc::Markup::ToHtmlCrossref
- RDoc::Markup::ToHtmlSnippet
- RDoc::Markup::ToJoinedParagraph
- RDoc::Markup::ToLabel
- RDoc::Markup::ToMarkdown
- RDoc::Markup::ToRdoc
- RDoc::Markup::ToTableOfContents
- RDoc::Markup::ToTest
- RDoc::Markup::ToTtOnly
- RDoc::Markup::Verbatim
- RDoc::MetaMethod
- RDoc::MethodAttr
- RDoc::Mixin
- RDoc::NormalClass
- RDoc::NormalModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::Parser::ChangeLog
- RDoc::Parser::Markdown
- RDoc::Parser::RD
- RDoc::Parser::Ruby
- RDoc::Parser::RubyTools
- RDoc::Parser::Simple
- RDoc::Parser::Text
- RDoc::RD
- RDoc::RD::BlockParser
- RDoc::RD::Inline
- RDoc::RD::InlineParser
- RDoc::RDoc
- RDoc::RI
- RDoc::RI::Driver
- RDoc::RI::Driver::Error
- RDoc::RI::Driver::NotFoundError
- RDoc::RI::Error
- RDoc::RI::Paths
- RDoc::Require
- RDoc::RubyLex
- RDoc::RubyLex::Error
- RDoc::RubyToken
- RDoc::RubygemsHook
- RDoc::Servlet
- RDoc::SingleClass
- RDoc::Stats
- RDoc::Stats::Normal
- RDoc::Stats::Quiet
- RDoc::Stats::Verbose
- RDoc::Store
- RDoc::Store::Error
- RDoc::Store::MissingFileError
- RDoc::Task
- RDoc::Task
- RDoc::TestCase
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- Object

No matching classes.

# RDoc::RD::InlineParser

RD format parser for inline markup such as emphasis, links, footnotes, etc.

### Public Class Methods

new(block_parser) click to toggle source

Creates a new parser for inline markup in the rd format. The `block_parser` is used to for footnotes and labels in the inline text.

    # File lib/rdoc/rd/inline_parser.rb, line 89
    def initialize block_parser
      @block_parser = block_parser
    end

### Public Instance Methods

inline(rdoc, reference = rdoc) click to toggle source

Creates a new RDoc::RD::Inline for the `rdoc` markup and the raw `reference`

    # File lib/rdoc/rd/inline_parser.rb, line 238
    def inline rdoc, reference = rdoc
      RDoc::RD::Inline.new rdoc, reference
    end

next_token() click to toggle source

Returns the next token from the inline text

    # File lib/rdoc/rd/inline_parser.rb, line 107
    def next_token
      return [false, false] if @src.eos?
    #  p @src.rest if @yydebug
      if ret = @src.scan(EM_OPEN_RE)
        @pre << ret
        [:EM_OPEN, ret]
      elsif ret = @src.scan(EM_CLOSE_RE)
        @pre << ret
        [:EM_CLOSE, ret]
      elsif ret = @src.scan(CODE_OPEN_RE)
        @pre << ret
        [:CODE_OPEN, ret]
      elsif ret = @src.scan(CODE_CLOSE_RE)
        @pre << ret
        [:CODE_CLOSE, ret]
      elsif ret = @src.scan(VAR_OPEN_RE)
        @pre << ret
        [:VAR_OPEN, ret]
      elsif ret = @src.scan(VAR_CLOSE_RE)
        @pre << ret
        [:VAR_CLOSE, ret]
      elsif ret = @src.scan(KBD_OPEN_RE)
        @pre << ret
        [:KBD_OPEN, ret]
      elsif ret = @src.scan(KBD_CLOSE_RE)
        @pre << ret
        [:KBD_CLOSE, ret]
      elsif ret = @src.scan(INDEX_OPEN_RE)
        @pre << ret
        [:INDEX_OPEN, ret]
      elsif ret = @src.scan(INDEX_CLOSE_RE)
        @pre << ret
        [:INDEX_CLOSE, ret]
      elsif ret = @src.scan(REF_OPEN_RE)
        @pre << ret
        [:REF_OPEN, ret]
      elsif ret = @src.scan(REF_CLOSE_RE)
        @pre << ret
        [:REF_CLOSE, ret]
      elsif ret = @src.scan(FOOTNOTE_OPEN_RE)
        @pre << ret
        [:FOOTNOTE_OPEN, ret]
      elsif ret = @src.scan(FOOTNOTE_CLOSE_RE)
        @pre << ret
        [:FOOTNOTE_CLOSE, ret]
      elsif ret = @src.scan(VERB_OPEN_RE)
        @pre << ret
        [:VERB_OPEN, ret]
      elsif ret = @src.scan(VERB_CLOSE_RE)
        @pre << ret
        [:VERB_CLOSE, ret]
      elsif ret = @src.scan(BAR_RE)
        @pre << ret
        [:BAR, ret]
      elsif ret = @src.scan(QUOTE_RE)
        @pre << ret
        [:QUOTE, ret]
      elsif ret = @src.scan(SLASH_RE)
        @pre << ret
        [:SLASH, ret]
      elsif ret = @src.scan(BACK_SLASH_RE)
        @pre << ret
        [:BACK_SLASH, ret]
      elsif ret = @src.scan(URL_RE)
        @pre << ret
        [:URL, ret]
      elsif ret = @src.scan(OTHER_RE)
        @pre << ret
        [:OTHER, ret]
      else
        ret = @src.rest
        @pre << ret
        @src.terminate
        [:OTHER, ret]
      end
    end

next_words_on_error() click to toggle source

Returns words following an error

    # File lib/rdoc/rd/inline_parser.rb, line 227
    def next_words_on_error
      if n = @src.rest.index("\n")
        @src.rest[0 .. (n-1)]
      else
        @src.rest
      end
    end

on_error(et, ev, values) click to toggle source

Raises a ParseError when invalid formatting is found

    # File lib/rdoc/rd/inline_parser.rb, line 187
    def on_error(et, ev, values)
      lines_of_rest = @src.rest.lines.to_a.length
      prev_words = prev_words_on_error(ev)
      at = 4 + prev_words.length

      message = RD syntax error: line #{@block_parser.line_index - lines_of_rest}:...#{prev_words} #{(ev||'')} #{next_words_on_error()} ...

      message << " " * at + "^" * (ev ? ev.length : 0) + "\n"
      raise ParseError, message
    end

parse(inline) click to toggle source

Parses the `inline` text from RD format into RDoc format.

    # File lib/rdoc/rd/inline_parser.rb, line 96
    def parse inline
      @inline = inline
      @src = StringScanner.new inline
      @pre = ""
      @yydebug = true
      do_parse.to_s
    end

prev_words_on_error(ev) click to toggle source

Returns words before the error

    # File lib/rdoc/rd/inline_parser.rb, line 204
    def prev_words_on_error(ev)
      pre = @pre
      if ev and /#{Regexp.quote(ev)}$/ =~ pre
        pre = $`
      end
      last_line(pre)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.