Module: MdxTex::ToMarkdown::Bold
- Defined in:
- lib/mdx_tex/to_markdown/bold.rb
Overview
Converts Textile bold syntax to Markdown bold syntax. Textile bold is text with non-whitespace immediately inside both asterisks; whitespace-padded asterisks are not bold (and are typically list markers).
| Input (Textile) | Output (Markdown) | |——————-|——————-| | hello | hello | | a and b | a and b | | * hello * | * hello * |
Constant Summary collapse
- PATTERN =
Matches a Textile bold span: …
\* opening literal * ( capture the content [^\s*] first char must be non-whitespace and non-* (Textile rule: no padding inside the asterisks; also keeps us from matching list markers like `* item`) (?: optional trailing run, present only for 2+ char content [^*]*? any chars except *, non-greedy so we stop at the nearest closing * rather than spanning into another span [^\s*] last char must also be non-whitespace and non-* )? optional, so single-char bold like *a* still matches ) \* closing literal * /\*([^\s*](?:[^*]*?[^\s*])?)\*/.freeze
Class Method Summary collapse
Class Method Details
.execute(line) ⇒ Object
30 31 32 |
# File 'lib/mdx_tex/to_markdown/bold.rb', line 30 def self.execute(line) line.gsub(PATTERN, '**\1**') end |