Class: QED::Document::Markup

Inherits:
Object
  • Object
show all
Defined in:
lib/qed/document/markup.rb

Overview

QED Document Markup

QED Document Markup is based on RDoc’s SimpleMarkup format but adds some additional features.

  • ‘[no-spaces]` produces [no-space].

Defined Under Namespace

Classes: ToHTML

Instance Method Summary collapse

Constructor Details

#initialize(text, options = {}) ⇒ Markup

Returns a new instance of Markup.



16
17
18
# File 'lib/qed/document/markup.rb', line 16

def initialize(text, options={})
  @text = text
end

Instance Method Details

#formatterObject



35
36
37
38
39
40
41
# File 'lib/qed/document/markup.rb', line 35

def formatter
  @formatter ||= (
    f = ToHTML.new
    #f.add_tag(:STRIKE, "<strike>", "</strike>")
    f
  )
end

#parserObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/qed/document/markup.rb', line 24

def parser
  @parser ||= (
    p = SM::SimpleMarkup.new
    #p.add_word_pair("{", "}", :STRIKE)
    #p.add_html("no", :STRIKE)
    #p.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
    p.add_special(/\`(\S+?)\`/, :CODE)
    p
  )
end

#to_htmlObject



20
21
22
# File 'lib/qed/document/markup.rb', line 20

def to_html
  parser.convert(@text, formatter)
end