Class: Kramdown::Parser::GFM

### Home Classes Methods

### In Files

- lib/kramdown/parser/gfm.rb

### Parent

Kramdown::Parser::Kramdown

### Methods

- ::new
- #add_hard_line_breaks
- #parse

### Class/Module Index

Quicksearch

- Kramdown
- Kramdown::Converter
- Kramdown::Converter::Base
- Kramdown::Converter::Html
- Kramdown::Converter::Kramdown
- Kramdown::Converter::Latex
- Kramdown::Converter::MathEngine
- Kramdown::Converter::MathEngine::Itex2MML
- Kramdown::Converter::MathEngine::Mathjax
- Kramdown::Converter::MathEngine::MathjaxNode
- Kramdown::Converter::MathEngine::Ritex
- Kramdown::Converter::RemoveHtmlTags
- Kramdown::Converter::SyntaxHighlighter
- Kramdown::Converter::SyntaxHighlighter::Coderay
- Kramdown::Converter::SyntaxHighlighter::Minted
- Kramdown::Converter::SyntaxHighlighter::Rouge
- Kramdown::Converter::Toc
- Kramdown::Document
- Kramdown::Element
- Kramdown::Error
- Kramdown::Options
- Kramdown::Options::Boolean
- Kramdown::Parser
- Kramdown::Parser::Base
- Kramdown::Parser::GFM
- Kramdown::Parser::Html
- Kramdown::Parser::Html::Constants
- Kramdown::Parser::Html::ElementConverter
- Kramdown::Parser::Html::Parser
- Kramdown::Parser::Kramdown
- Kramdown::Parser::Markdown
- Kramdown::Utils
- Kramdown::Utils::Configurable
- Kramdown::Utils::Entities
- Kramdown::Utils::Entities::Entity
- Kramdown::Utils::Html
- Kramdown::Utils::OrderedHash
- Kramdown::Utils::StringScanner
- Kramdown::Utils::Unidecoder

No matching classes.

# Kramdown::Parser::GFM

### Constants

ATX_HEADER_START
FENCED_CODEBLOCK_MATCH

### Public Class Methods

new(source, options) click to toggle source

    # File lib/kramdown/parser/gfm.rb, line 16
    def initialize(source, options)
      super
      @span_parsers.delete(:line_break) if @options[:hard_wrap]
      {:codeblock_fenced => :codeblock_fenced_gfm,
        :atx_header => :atx_header_gfm}.each do |current, replacement|
        i = @block_parsers.index(current)
        @block_parsers.delete(current)
        @block_parsers.insert(i, replacement)
      end
    end

### Public Instance Methods

add_hard_line_breaks(element) click to toggle source

    # File lib/kramdown/parser/gfm.rb, line 32
    def add_hard_line_breaks(element)
      element.children.map! do |child|
        if child.type == :text && child.value =~ /\n/
          children = []
          lines = child.value.split(/\n/, -1)
          omit_trailing_br = (Kramdown::Element.category(element) == :block && element.children[-1] == child &&
                              lines[-1].empty?)
          lines.each_with_index do |line, index|
            children << Element.new(:text, (index > 0 ? "\n#{line}" : line))
            children << Element.new(:br) if index < lines.size - 2 ||
              (index == lines.size - 2 && !omit_trailing_br)
          end
          children
        elsif child.type == :html_element
          child
        else
          add_hard_line_breaks(child)
          child
        end
      end.flatten!
    end

parse() click to toggle source

    # File lib/kramdown/parser/gfm.rb, line 27
    def parse
      super
      add_hard_line_breaks(@root) if @options[:hard_wrap]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.