Module: MdxTex::ToTextile::OrderedList
- Defined in:
- lib/mdx_tex/to_textile/ordered_list.rb
Overview
Converts a Markdown ordered list item to a Textile ordered list item. Nesting depth is determined by leading indentation (2 spaces per level). Odd-numbered spaces are rounded down: 1 space is treated the same as 0 spaces.
| Input (Markdown) | Output (Textile) | |———————|——————| | 1. Item | # Item | | 99. Item | # Item | | 1. Nested | ## Nested | | 1. Deep | ### Deep |
Constant Summary collapse
- INDENT_SIZE =
2
Class Method Summary collapse
Class Method Details
.execute(line) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/mdx_tex/to_textile/ordered_list.rb', line 18 def self.execute(line) line.sub(/\A(\s*)\d+\.\s+(.+)\z/) do depth = (::Regexp.last_match(1).length / INDENT_SIZE) + 1 "#{'#' * depth} #{::Regexp.last_match(2)}" end end |