File: redcloth.rb

package info (click to toggle)
ruby-tilt 2.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 632 kB
  • sloc: ruby: 4,975; makefile: 7
file content (40 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

# = Textile (<tt>textile</tt>)
#
# Textile is a lightweight markup language originally developed by Dean Allen and
# billed as a "humane Web text generator". Textile converts its marked-up text
# input to valid, well-formed XHTML and also inserts character entity references
# for apostrophes, opening and closing single and double quotation marks,
# ellipses and em dashes.
#
# Textile formatted texts are converted to HTML with the {RedCloth}[http://redcloth.org]
# engine, which is a Ruby extension written in C.
#
# === Example
#
#     h1. Hello Textile Templates
#
#     Hello World. This is a paragraph.
#
# === Usage
#
# __NOTE:__ It's suggested that your program <tt>require 'redcloth'</tt> at load time
# when using this template engine in a threaded environment.
#
# === See Also
#
# * {RedCloth}[http://redcloth.org]
# * https://github.com/jgarber/redcloth

require_relative 'template'
require 'redcloth'

Tilt::RedClothTemplate = Tilt::StaticTemplate.subclass do
  engine = RedCloth.new(@data)
  @options.each  do |k, v|
    m = :"#{k}="
    engine.send(m, v) if engine.respond_to? m
  end
  engine.to_html
end