Sha256: cbc1a577c30511713ce7929228270173c0bf134917d8f8cc3fbbc8e66a04238d

Contents?: true

Size: 871 Bytes

Versions: 9

Compression:

Stored size: 871 Bytes

Contents

description 'Markdown nowiki filter'

# Embeds indented markdown text blocks in <notags> tags
# and adds <notags> around ``texts``
Filter.create :markdown_nowiki do |context, content|
  output = ''
  block, state = nil, nil
  content.each_line do |line|
    if block
      if line =~ /\A( {4}|\t)/
        block << line
        state = :in
      elsif line =~ /\A\s*\Z/
        block << line
        state = :after if state == :in
      elsif state == :after
        output << "<notags>#{block}</notags>"
        block = nil
      else
        block << line
        line = block
        block = nil
      end
    elsif line =~ /\A\s*\Z/
      block, state = line, :before
    end

    unless block
      output << line.gsub(/``.*?``|`[^`]*`/, '<notags>\0</notags>')
    end
  end
  output << (state == :before ? block : "<notags>#{block}</notags>") if block
  output
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
olelo-0.9.15 plugins/filters/markdown_nowiki.rb
olelo-0.9.14 plugins/filters/markdown_nowiki.rb
olelo-0.9.13 plugins/filters/markdown_nowiki.rb
olelo-0.9.12 plugins/filters/markdown_nowiki.rb
olelo-0.9.11 plugins/filters/markdown_nowiki.rb
olelo-0.9.10 plugins/filters/markdown_nowiki.rb
olelo-0.9.9 plugins/filters/markdown_nowiki.rb
olelo-0.9.8 plugins/filters/markdown_nowiki.rb
olelo-0.9.7 plugins/filters/markdown_nowiki.rb