Sha256: 137975bb328174ec62cc298e696717da726b275e9353d96c6d8fe7db74f6035d
Contents?: true
Size: 874 Bytes
Versions: 4
Compression:
Stored size: 874 Bytes
Contents
# encoding: UTF-8 require 'kramdown' module Spontaneous::Field class Markdown < Base has_editor def outputs [:html] end def generate_html(input) input.to_html end def preprocess(input) # convert lines ending with newlines into a <br/> # as official Markdown syntax isn't suitable for # casual users # code taken from: # http://github.github.com/github-flavored-markdown/ output = input.gsub(/^[\w\<][^\n]*\n+/) do |x| x =~ /\n{2}/ ? x : (x.strip!; x << " \n") end # prevent foo_bar_baz from ending up with an italic word in the middle output.gsub!(/(^(?! {4}|\t)\w+_\w+_\w[\w_]*)/) do |x| x.gsub('_', '\_') if x.split('').sort.to_s[0..1] == '__' end Kramdown::Document.new(output) end self.register(:markdown, :text, :richtext) end end
Version data entries
4 entries across 4 versions & 1 rubygems