Class: Migrator::Converter::TwfToMarkdown

Inherits:
Object
  • Object
show all
Defined in:
lib/tractive/migrator/converter/twf_to_markdown.rb

Overview

twf => Trac wiki format

Instance Method Summary collapse

Constructor Details

#initialize(base_url, attachment_options, changeset_base_url, wiki_attachments_url, revmap_file_path, options = {}) ⇒ TwfToMarkdown

Returns a new instance of TwfToMarkdown.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tractive/migrator/converter/twf_to_markdown.rb', line 9

def initialize(base_url, attachment_options, changeset_base_url, wiki_attachments_url, revmap_file_path, options = {})
  @base_url = base_url
  @attach_url = attachment_options[:url]
  @attach_hashed = attachment_options[:hashed]
  @changeset_base_url = changeset_base_url
  @wiki_attachments_url = wiki_attachments_url
  @revmap = load_revmap_file(revmap_file_path)

  @git_repo = options[:git_repo]
  @home_page_name = options[:home_page_name]
  @wiki_extensions = options[:wiki_extensions]
  @source_folders = options[:source_folders]
end

Instance Method Details

#convert(str, image_options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tractive/migrator/converter/twf_to_markdown.rb', line 23

def convert(str, image_options = {})
  # Fix 'Windows EOL' to 'Linux EOL'
  str.gsub!("\r\n", "\n")

  convert_tables(str)
  convert_newlines(str)
  convert_comments(str)
  convert_html_snippets(str)
  convert_code_snippets(str)
  convert_headings(str)
  convert_links(str, @git_repo)
  convert_font_styles(str)
  convert_changeset(str, @changeset_base_url)
  convert_image(str, @base_url, @attach_url, @wiki_attachments_url, image_options)
  convert_ticket(str, @base_url)
  revert_intermediate_references(str)

  str
end