Ruby 2.5.0 リファレンスマニュアル > ライブラリ一覧 > rdoc/markupライブラリ > RDoc::Markupクラス

class RDoc::Markup

クラス・モジュールの継承リスト: RDoc::Markup < Object < Kernel < BasicObject

要約

RDoc 形式のドキュメントを目的の形式に変換するためのクラスです。

例:

require 'rdoc/markup/to_html'

h = RDoc::Markup::ToHtml.new
puts h.convert(input_string)

独自のフォーマットを行うようにパーサを拡張する事もできます。

例:

require 'rdoc/markup'
require 'rdoc/markup/to_html'

class WikiHtml < RDoc::Markup::ToHtml
  # WikiWord のフォントを赤く表示。
  def handle_special_WIKIWORD(special)
    "<font color=red>" + special.text + "</font>"
  end
end

m = RDoc::Markup.new
# { 〜 } までを :STRIKE でフォーマットする。
m.add_word_pair("{", "}", :STRIKE)
# <no> 〜 </no> までを :STRIKE でフォーマットする。
m.add_html("no", :STRIKE)

# WikiWord を追加。
m.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)

wh = WikiHtml.new(m)
# :STRIKE のフォーマットを <strike> 〜 </strike> に指定。
wh.add_tag(:STRIKE, "<strike>", "</strike>")

puts "<body>#{wh.convert ARGF.read}</body>"

変換する形式を変更する場合、フォーマッタ(例. RDoc::Markup::ToHtml) を変更、拡張する必要があります。

特異メソッド

定義 説明
new(attribute_manager = nil) -> RDoc::Markup

自身を初期化します。

インスタンスメソッド

定義 説明
add_html(tag, name) -> ()

tag で指定したタグをフォーマットの対象にします。

add_special(pattern, name) -> ()

pattern で指定した正規表現にマッチする文字列をフォーマットの対象にします。

add_word_pair(start, stop, name) -> ()

start と stop ではさまれる文字列(例. *bold*)をフォーマットの対象にします。

attribute_manager -> RDoc::AttributeManager

自身の RDoc::AttributeManager オブジェクトを返します。

content -> String

変換する文字列を返します。

convert(str, formatter) -> object | ""

str で指定された文字列を formatter に変換させます。

get_line_types -> [Symbol]

変換する文字列の各行のタイプを Symbol の配列で返します。

定数

定義 説明
LABEL_LIST_RE -> Regexp

ラベル付きリストにマッチする正規表現です。ライブラリの内部で使用します。

SIMPLE_LIST_RE -> Regexp

リストにマッチする正規表現です。ライブラリの内部で使用します。

SPACE -> ?\s

空白文字です。?\s を返します。ライブラリの内部で使用します。

継承したメソッド

! != __id__ __send__ instance_eval instance_exec method_missing singleton_method_added singleton_method_removed singleton_method_undefined !~ <=> == === =~ _dump class clone define_singleton_method display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? itself marshal_dump marshal_load method methods nil? object_id pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods psych_to_yaml public_method public_methods public_send remove_instance_variable respond_to? respond_to_missing? send singleton_class singleton_method singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_s to_str trust untaint untrust untrusted? yield_self .yaml_tag ::ARGF ::ARGV ::DATA ::ENV ::FALSE ::NIL ::RUBY_COPYRIGHT ::RUBY_DESCRIPTION ::RUBY_ENGINE ::RUBY_ENGINE_VERSION ::RUBY_PATCHLEVEL ::RUBY_PLATFORM ::RUBY_RELEASE_DATE ::RUBY_REVISION ::RUBY_VERSION ::SCRIPT_LINES__ ::STDERR ::STDIN ::STDOUT ::TOPLEVEL_BINDING ::TRUE