Module: MdxTex::ToTextile::Header

Defined in:
lib/mdx_tex/to_textile/header.rb

Overview

Converts a Markdown heading to a Textile heading. The caller supplies the desired Textile header tag via header_level. A space must follow the # characters for the line to be recognised as a heading. Lines that do not match are returned unchanged.

| Input (Markdown) | header_level | Output (Textile) | |——————–|————–|——————| | # Title | h1 | h1. Title | | ## Section | h2 | h2. Section | | ### Note | h3 | h3. Note | | #NoSpace | h1 | #NoSpace |

Class Method Summary collapse

Class Method Details

.execute(line, header_level:) ⇒ Object



17
18
19
# File 'lib/mdx_tex/to_textile/header.rb', line 17

def self.execute(line, header_level:)
  line.sub(/\A#+\s+(.+)\z/, "#{header_level}. \\1")
end