Sha256: d8024bbb47272e202da4e88fb7cfc84196552cadc21289c674a736757bc15359

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'docify/utils'
require 'docify/format'
require 'docify/template'
require 'docify/style'
require 'docify/markup'
require 'docify/document'

module Docify
  extend Docify::Markup
  extend Docify::Format
  
  class << self
    # Alias for Docify::Document.new
    #
    # @return [Docify::Document]
    #
    def new(path, format=:markdown)
      Docify::Document.new(path, format)
    end
    
    # Simply renders content for the markup
    #
    def render(text, format=:markdown)
      if Docify::FORMATS.include?(format.to_sym)
        Docify::Markup.send(format.to_sym, text)
      else
        raise ArgumentError, "Invalid markup: #{format}."
      end
    end
    
    # Simple render content with auto-detection from filename
    # It returns the original text if markup language was not detected
    # or not supported
    #
    def render_auto(text, filename)
      format = detect_format(filename)
      
      if Docify.valid_format?(format)
        Docify::Markup.send(format, text)
      else
        text
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docify-1.0.7 lib/docify.rb
docify-1.0.6 lib/docify.rb