Class: MdxTex::ToMarkdown

Inherits:
Object
  • Object
show all
Defined in:
lib/mdx_tex/to_markdown.rb,
lib/mdx_tex/to_markdown/bold.rb,
lib/mdx_tex/to_markdown/header.rb,
lib/mdx_tex/to_markdown/ordered_list.rb,
lib/mdx_tex/to_markdown/unordered_list.rb

Overview

Converts Textile to Markdown.

The base list depth is auto-detected per document (smallest asterisks/hashes count across all list lines) so that input with inconsistent base indentation still produces a clean depth-1 Markdown list. Ordered list items are numbered with incrementing per-depth counters that reset on blank lines or any non-ordered-list line.

Defined Under Namespace

Modules: Bold, Header, OrderedList, UnorderedList

Instance Method Summary collapse

Instance Method Details

#execute(input) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/mdx_tex/to_markdown.rb', line 17

def execute(input)
  return nil if input.nil?

  lines = input.to_s.split("\n", -1)
  @unordered_base, @ordered_base = detect_bases(lines)
  @counters = {}

  lines.map { |line| convert_line(line) }.join("\n")
end