Module: TTY::Markdown
- Defined in:
- lib/tty/markdown.rb,
lib/tty/markdown/parser.rb,
lib/tty/markdown/version.rb,
lib/tty/markdown/syntax_highlighter.rb
Defined Under Namespace
Modules: SyntaxHighliter Classes: Parser
Constant Summary collapse
- SYMBOLS =
{ arrow: '»', bullet: '●', bar: '┃', diamond: '◈', pipe: '│', line: '─', hellip: '…', laquo: '«', laquo_space: '« ', raquo: '»', raquo_space: ' »', ndash: '-', mdash: "\u2014", lsquo: '‘', rsquo: '’', ldquo: '“', rdquo: '”', top_left: '┌', top_right: '┐', top_center: '┬', mid_left: '├', mid_right: '┤', mid_center: '┼', bottom_right: '┘', bottom_left: '└', bottom_center: '┴', }.freeze
- WIN_SYMBOLS =
{ arrow: '->', bullet: '*', diamond: '*', bar: '│', pipe: '|', line: '─', hellip: '...', laquo: '<<', laquo_space: '<< ', raquo: '>>', raquo_space: ' >>', ndash: '-', mdash: "--", lsquo: ''', rsquo: ''', ldquo: '"', rdquo: '"', top_left: '+', top_right: '+', top_center: '+', mid_left: '+', mid_right: '+', mid_center: '+', bottom_right: '+', bottom_left: '+', bottom_center: '+' }.freeze
- THEME =
{ em: :yellow, header: [:cyan, :bold], hr: :yellow, link: [:yellow, :underline], list: :yellow, strong: [:yellow, :bold], table: :yellow, quote: :yellow, }.freeze
- VERSION =
'0.5.1'
Class Method Summary collapse
-
.parse(source, **options) ⇒ Object
Parse a markdown string.
-
.parse_file(path, **options) ⇒ Object
Pase a markdown document.
- .symbols ⇒ Object
- .windows? ⇒ Boolean
Class Method Details
.parse(source, **options) ⇒ Object
Parse a markdown string
90 91 92 93 |
# File 'lib/tty/markdown.rb', line 90 def parse(source, **) doc = Kramdown::Document.new(source, ) Parser.convert(doc.root, doc.).join end |
.parse_file(path, **options) ⇒ Object
Pase a markdown document
99 100 101 |
# File 'lib/tty/markdown.rb', line 99 def parse_file(path, **) parse(::File.read(path), ) end |
.symbols ⇒ Object
104 105 106 |
# File 'lib/tty/markdown.rb', line 104 def symbols @symbols ||= windows? ? WIN_SYMBOLS : SYMBOLS end |
.windows? ⇒ Boolean
109 110 111 |
# File 'lib/tty/markdown.rb', line 109 def windows? ::File::ALT_SEPARATOR == "\\" end |