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.4.9 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.8 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.7 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.7.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.6 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.5 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.4 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.3 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.2 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.2.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.1 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.1.pre2 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.1.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.4.0 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.12 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.11 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.10 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.9 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.8 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.7 lib/inferno/utils/markdown_formatter.rb