module BBS::Markdown::Inline
The inline marks of a line of Markdown turned into SGR codes.
Constants
- SPANS
-
The spans in the order they are styled, each with its style.
Public Class Methods
Source
# File lib/bbs/markdown/inline.rb, line 15 def self.style(text, styles) spans = SPANS.reduce(text.to_s) do |s, (pattern, role)| s.gsub(pattern) { "#{styles[role]}#{::Regexp.last_match(1)}#{styles[:base]}" } end spans.gsub(ESCAPED) { ::Regexp.last_match(1) } end
Returns text with links (the link text only), `code`, **bold**, and *italic* or _italic_ each in their style of styles followed by its :base style, and the backslash escapes removed.