Module: Inferno::Utils::MarkdownFormatter
- Included in:
- DSL::Messages, DSL::Runnable, TestRunner
- Defined in:
- lib/inferno/utils/markdown_formatter.rb
Instance Method Summary collapse
-
#format_markdown(markdown) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
Instance Method Details
#format_markdown(markdown) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
5 6 7 8 9 10 11 12 |
# File 'lib/inferno/utils/markdown_formatter.rb', line 5 def format_markdown(markdown) # rubocop:disable Metrics/CyclomaticComplexity lines = markdown.lines return markdown if lines.any? { |line| line.match?(/^\S/) } natural_indent = lines.collect { |l| l.index(/[^ ]/) }.select { |l| !l.nil? && l.positive? }.min || 0 markdown.lines.map { |l| l[natural_indent..] || "\n" }.join end |