Sha256: fec20066c3a726f2d6b42d92f1f97000d0a3bcdd0073db1ab852dd065ff0f849

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

#
#--
#
# $Id: markdown.rb 203 2005-02-21 18:42:04Z thomas $
#
# webgen: template based static website generator
# Copyright (C) 2004 Thomas Leitner
#
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program; if not,
# write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#++
#


begin
  require 'bluecloth'
  require 'webgen/plugins/filehandler/pagehandler/page'

  module ContentHandlers

    # Handles text formatted in Markdown format using BlueCloth.
    class MarkdownHandler < ContentHandler

      summary "Handles content formatted in Markdown format using BlueCloth"
      depends_on "PageHandler"

      def initialize
        register_format( 'markdown' )
      end

      def format_content( txt )
        BlueCloth.new( txt ).to_html
      rescue
        self.logger.error { "Error converting Markdown text to HTML" }
        ''
      end

    end

  end

rescue LoadError => e
  self.logger.warn { "Markdown not available as content format as BlueCloth could not be loaded: #{e.message}" }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webgen-0.3.0 lib/webgen/plugins/filehandler/pagehandler/markdown.rb