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].

FIXME: Can't get `brackets` to work.

Defined Under Namespace

Classes: ToHTML

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Markup.


18
19
20
# File 'lib/qed/document/markup.rb', line 18

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

Instance Method Details

#formatterObject


38
39
40
41
42
43
44
45
# File 'lib/qed/document/markup.rb', line 38

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

    f.add_tag(:CODE, "<code>", "</code>")
    f
  )
end

#parserObject


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

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

    m.add_special(/\`(\b.*?)\`/, :CODE)
    m
  )
end

#to_htmlObject


22
23
24
# File 'lib/qed/document/markup.rb', line 22

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