Class: MaRuKu::MDDocument

### Home Classes Methods

### In Files

- lib/maruku.rb
- lib/maruku/document.rb
- lib/maruku/ext/math/parsing.rb
- lib/maruku/input_textile2/t2_parser.rb
- lib/maruku/output/s5/to_s5.rb
- lib/maruku/output/to_latex.rb
- lib/maruku/output/to_markdown.rb
- lib/maruku/toc.rb

### Parent

MaRuKu::MDElement

### Methods

- ::new
- #create_toc
- #is_math_enabled?
- #old_md
- #s5_theme
- #t2_block_paragraph
- #t2_parse
- #t2_parse_blocks
- #t2_parse_span
- #to_md
- #to_s5

### Included Modules

- MaRuKu::In::Markdown
- MaRuKu::In::Markdown::SpanLevelParser
- MaRuKu::In::Markdown::BlockLevelParser
- MaRuKu::Out::Latex::MDDocumentExtensions

### Class/Module Index

Quicksearch

- MaRuKu
- MaRuKu::AttributeList
- MaRuKu::Errors
- MaRuKu::Exception
- MaRuKu::HTMLElement
- MaRuKu::HTMLFragment
- MaRuKu::Helpers
- MaRuKu::In
- MaRuKu::In::Markdown
- MaRuKu::In::Markdown::BlockLevelParser
- MaRuKu::In::Markdown::BlockLevelParser::BlockContext
- MaRuKu::In::Markdown::BlockLevelParser::LineSource
- MaRuKu::In::Markdown::SpanExtension
- MaRuKu::In::Markdown::SpanLevelParser
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceDebug
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceManual
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan
- MaRuKu::In::Markdown::SpanLevelParser::HTMLHelper
- MaRuKu::In::Markdown::SpanLevelParser::SpanContext
- MaRuKu::MDDocument
- MaRuKu::MDElement
- MaRuKu::MDHTMLElement
- MaRuKu::MDLine
- MaRuKu::NokogiriHTMLFragment
- MaRuKu::Out
- MaRuKu::Out::EntityTable
- MaRuKu::Out::HTML
- MaRuKu::Out::HTML::HTMLElement
- MaRuKu::Out::Latex
- MaRuKu::Out::Latex::MDDocumentExtensions
- MaRuKu::Out::Markdown
- MaRuKu::REXMLHTMLFragment
- MaRuKu::Section
- MaRuKu::Strings
- Maruku
- Maruku::In
- Maruku::In::Markdown
- Maruku::In::Markdown::FencedCode
- Object
- String
- Textile2Signature

No matching classes.

# MaRuKu::MDDocument

This represents the whole document and holds global data.

### Constants

Handling
T2_Handling

### Attributes

abbreviations[RW]

@return [{String => String}]

ald[RW]

Attribute definition lists.

@return [{String => AttributeList}]

eqid2eq[RW]

A hash of equation ids to equation elements

@return [String => MDElement]

footnotes[RW]

@return [{String => MDElement}]

footnotes_order[RW]

The order in which footnotes are used. Contains the id.

@return [Array<String>]

header_ids[RW]

A map of header IDs to a count of how many times they've occurred in the document.

@return [Hash<String, Number>]

id_counter[RW]

A counter for generating unique IDs [Integer]

refid2ref[RW]

@return [{String => {String => MDElement}}]

refs[RW]

@return [{String => {:url => String, :title => String}}]

### Public Class Methods

new(s=nil) click to toggle source

    # File lib/maruku/document.rb, line 29
    def initialize(s=nil)
      super(:document)

      self.doc = self
      self.refs = {}
      self.footnotes = {}
      self.footnotes_order = []
      self.abbreviations = {}
      self.ald = {}
      self.id_counter = 0

      parse_doc(s) if s
    end

### Public Instance Methods

is_math_enabled?() click to toggle source

    # File lib/maruku/ext/math/parsing.rb, line 8
    def is_math_enabled?
      get_setting :math_enabled
    end

old_md(context={}) click to toggle source
Alias for: to_md
s5_theme() click to toggle source

    # File lib/maruku/output/s5/to_s5.rb, line 5
    def s5_theme
      xtext(self.attributes[:slide_theme] || "default")
    end

t2_block_paragraph(src, output, signature, lines) click to toggle source

    # File lib/maruku/input_textile2/t2_parser.rb, line 151
                    def t2_block_paragraph(src, output, signature, lines)
                            paragraph = lines.join("\n")
                            src2 = CharSource.new(paragraph, src)
    #                       output =
                    end

t2_parse(source, params) click to toggle source

    # File lib/maruku/input_textile2/t2_parser.rb, line 95
    def t2_parse(source, params)
            src = LineSource.new(source)
            output = BlockContext.new
            t2_parse_blocks(src, output)
            self.children = output.elements
    end

t2_parse_blocks(src, output) click to toggle source

Input is a LineSource

    # File lib/maruku/input_textile2/t2_parser.rb, line 109
    def t2_parse_blocks(src, output)
            while src.cur_line
                    l = src.shift_line

                    # ignore empty line
                    if l.t2_empty? then
                            src.shift_line
                            next
                    end

                    # TODO: lists
                    # TODO: xml
                    # TODO: `==`

                    signature, l =
                            if l.t2_contains_signature?
                                    l.t2_get_signature
                            else
                                    [Textile2Signature.new, l]
                            end

                    if handling = T2_Handling.has_key?(signature.block_name)
                            if self.responds_to? handling.method
                                    # read as many non-empty lines that you can
                                    lines = [l]
                                    if handling.parse_lines
                                            while not src.cur_line.t2_empty?
                                                    lines.push src.shift_line
                                            end
                                    end

                                    self.send(handling.method, src, output, signature, lines)
                            else
                                    maruku_error("We don't know about method #{handling.method.inspect}")
                                    next
                            end
                    end

            end
    end

t2_parse_span(src, output) click to toggle source

    # File lib/maruku/input_textile2/t2_parser.rb, line 157
    def t2_parse_span(src, output)

    end

to_md(context={}) click to toggle source

    # File lib/maruku/output/to_markdown.rb, line 204
    def to_md(context={})
      warn "Maruku#to_md is deprecated and will be removed in a near-future version of Maruku."
      old_md(context)
    end

Also aliased as: old_md
to_s5(context={}) click to toggle source

Render as an HTML fragment (no head, just the content of BODY). (returns a string)

    # File lib/maruku/output/s5/to_s5.rb, line 10
    def to_s5(context={})
      content_only = context[:content_only] != false
      print_slides = context[:print_slides]

      if content_only
        body = xelem('div', doc)
      else
        html = xelem('html')
        html['xmlns'] = 'http://www.w3.org/1999/xhtml'
        html['xmlns:svg'] = "http://www.w3.org/2000/svg"
        html['xml:lang'] = self.attributes[:lang] || 'en'

        head = xelem('head')
        html << head

        me = xelem('meta')
        me['http-equiv'] = 'Content-type'
        me['content'] = 'text/html;charset=utf-8'
        head << me

        # Create title element
        doc_title = self.attributes[:title] || self.attributes[:subject] || ""
        begin
          title_content = MaRuKu::HTMLFragment.new(doc_title).to_html
        rescue
          title_content = xtext(doc_title)
        end
        title = xelem('title') << title_content
        head << title

        body = xelem('body')
        html << body
      end

      slide_header = self.attributes[:slide_header]
      slide_footer = self.attributes[:slide_footer]
      slide_subfooter = self.attributes[:slide_subfooter]
      slide_topleft  = self.attributes[:slide_topleft]
      slide_topright  = self.attributes[:slide_topright]
      slide_bottomleft  = self.attributes[:slide_bottomleft]
      slide_bottomright  = self.attributes[:slide_bottomright]

      dummy_layout_slide = "
    <div class='layout'>
    <div id='controls'> </div>
    <div id='currentSlide'> </div>
    <div id='header'> #{slide_header}</div>
    <div id='footer'>
    <h1>#{slide_footer}</h1>
    <h2>#{slide_subfooter}</h2>
    </div>
    <div class='topleft'> #{slide_topleft}</div>
    <div class='topright'> #{slide_topright}</div>
    <div class='bottomleft'> #{slide_bottomleft}</div>
    <div class='bottomright'> #{slide_bottomright}</div>
    </div>
                "
      body <<  dummy_layout_slide

      presentation = xelem('div')
      presentation['class'] = 'presentation'
      body << presentation

      first_slide = "
    <div class='slide'>
    <h1> #{self.attributes[:title] ||context[:title]}</h1>
    <h2> #{self.attributes[:subtitle] ||context[:subtitle]}</h2>
    <h3> #{self.attributes[:author] ||context[:author]}</h3>
    <h4> #{self.attributes[:company] ||context[:company]}</h4>
    </div>
    "
      presentation << first_slide

      slide_num = 0
      self.toc.section_children.each do |slide|
        slide_num += 1
        @doc.attributes[:doc_prefix] = "s#{slide_num}"

        div = xelem('div')
        presentation << div
        div['class'] = 'slide'

        h1 = xelem('h1')
        puts "Slide #{slide_num}: #{slide.header_element.children_to_html.join}" if print_slides
        slide.header_element.children_to_html.inject(h1, &:<<)
        div << h1

        array_to_html(slide.immediate_children).inject(div, &:<<)

        # render footnotes
        unless @doc.footnotes_order.empty?
          div << render_footnotes
          @doc.footnotes_order = []
        end
      end

      if content_only
        xml = body.to_html
      else
        head << S5_external

        add_css_to(head)

        xml = html.to_html
        Xhtml11_mathml2_svg11 + xml
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.