Sha256: e230a62a104bfdc797f404cecc0f869bab7be605dc8dc84029bbbd65c9661178

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

# This file is intended to be used via a Livetext .mixin  
# or the equivalent.

module Markdown
  SimpleFormats = {}
  SimpleFormats[:b] = %w[* *]
  SimpleFormats[:i] = %w[_ _]
  SimpleFormats[:t] = %w[` `]
  SimpleFormats[:s] = %w[<strike> </strike>]


  def h1(args = nil, body = nil); _out "# #{Livetext.interpolate(@_data)}"; _optional_blank_line end       # atx style for now
  def h2(args = nil, body = nil); _out "## #{Livetext.interpolate(@_data)}"; _optional_blank_line end
  def h3(args = nil, body = nil); _out "### #{Livetext.interpolate(@_data)}"; _optional_blank_line end
  def h4(args = nil, body = nil); _out "#### #{Livetext.interpolate(@_data)}"; _optional_blank_line end
  def h5(args = nil, body = nil); _out "##### #{Livetext.interpolate(@_data)}"; _optional_blank_line end
  def h6(args = nil, body = nil); _out "###### #{Livetext.interpolate(@_data)}"; _optional_blank_line end

  def title(args = nil, body = nil)
    h1
  end

  def section(args = nil, body = nil)
    h3
  end

  def bq(args = nil, body = nil)   # block quote
    _body {|line| _out "> #{line}" }
  end

  def list(args = nil, body = nil)
    _body {|line| _out " * #{line}" }
  end

  def olist(args = nil, body = nil)   # Doesn't handle paragraphs yet
    n = 0
    _body do |line|
      n += 1
      _out "#{n}. #{_format(line)}"
    end
  end

  alias nlist olist
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
livetext-0.9.24 imports/markdown.rb
livetext-0.9.23 imports/markdown.rb
livetext-0.9.22 imports/markdown.rb
livetext-0.9.21 imports/markdown.rb