class Prawndown::Parser

Markdown to Prawn parser

Constants

MATCHERS

Public Class Methods

new(text) click to toggle source

Initialize a new Prawndown::Parser. text must a a valid Markdown string that only contains supported tags.

Supported tags are: Header 1-6, bold, italic, strikethrough and link.

# File lib/prawndown/parser.rb, line 21
def initialize(text)
  @text = text.to_s
end

Public Instance Methods

to_prawn() click to toggle source

Parses the Markdown text and outputs a Prawn compatible string

# File lib/prawndown/parser.rb, line 26
def to_prawn
  MATCHERS.inject(@text) do |final_string, (markdown_matcher, prawn_tag)|
    final_string.gsub(markdown_matcher, prawn_tag)
  end
end