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.6.1 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.6.0 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.5.4 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.5.3 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.5.2 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.5.1 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.5.0 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.44 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.43 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.42 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.41 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.40 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.39 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.38 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.35 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.34 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.33 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.32 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.31 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.30 lib/inferno/utils/markdown_formatter.rb