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.3.6 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.5 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.4 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.3 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.2 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.1 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.0 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.3.0.rc1 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.2.0 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.2.0.rc4 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.2.0.rc3 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.2.0.rc2 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.2.0.rc1 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.4.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.3 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.3.pre2 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.3.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.2 lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.2.pre lib/inferno/utils/markdown_formatter.rb
inferno_core-0.1.1 lib/inferno/utils/markdown_formatter.rb