module Riffer::Rig::Terminal::Markdown::Blocks
Constants
- DIVIDER
- FENCE
- HEADING
- ITEM
- MARKER
- QUOTE
- RULE
Public Instance Methods
(String fence) → Regexp
Source
# File lib/riffer/rig/terminal/markdown/blocks.rb, line 46 def closing(fence) /\A {0,3}#{Regexp.escape(fence)}#{Regexp.escape(fence[0].to_s)}*\s*\z/ end
@rbs fence: String @rbs return: Regexp
(Array[String] lines, Integer index) → Symbol
Source
# File lib/riffer/rig/terminal/markdown/blocks.rb, line 30 def kind(lines, index) line = lines.fetch(index) if line.strip.empty? then :blank elsif FENCE.match?(line) then :fence elsif HEADING.match?(line) then :heading elsif RULE.match?(line) then :rule elsif QUOTE.match?(line) then :quote elsif ITEM.match?(line) then :list elsif table?(lines, index) then :table else :paragraph end end
@rbs lines: Array @rbs index: Integer @rbs return: Symbol
(Array[String] lines) → Array[Array[String]]
Source
# File lib/riffer/rig/terminal/markdown/blocks.rb, line 22 def split(lines) starts = Enumerator.produce(0) { |start| boundary(lines, start) }.take_while { |start| start < lines.size } [*starts, lines.size].each_cons(2).map { |from, to| lines.slice(from...to) || [] } end