Sha256: f16087d0c0bbf6a5e68e461c2a6c4e00b7976018046bec8e039e7a211bdcee5e

Contents?: true

Size: 464 Bytes

Versions: 87

Compression:

Stored size: 464 Bytes

Contents

module Inferno
  module Utils
    # @private
    module MarkdownFormatter
      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
    end
  end
end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
inferno_core-0.1.1.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.0 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.0.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.0.8 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.0.8.pre2 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.0.8.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.0.7 lib/inferno/utils/markdown_formatter.rb