Sha256: d97b72b795c11eaaede058957e976405701247f5b7d21d135db715cb178fa733

Contents?: true

Size: 958 Bytes

Versions: 11

Compression:

Stored size: 958 Bytes

Contents

module Appium
  class Lint
    ###
    # h2 must use the `##` syntax and not the `---` underline syntax.
    # check for three - to reduce false positives
    class H2Invalid < Base
      def call
        previous_line = ''

        input.lines.each_with_index do |line, index|
          # If the previous line is empty then --- triggers a line break
          previous_line_not_empty = !previous_line.match(/^\s*$/)
          h2_invalid              = previous_line_not_empty && line.match(/^---+\s*$/)
          warn index if h2_invalid

          previous_line = line
        end

        warnings
      end

      FAIL = 'h2 must not use --- underline syntax. Use ## instead'

      def fail
        FAIL
      end
    end
  end
end

=begin
md = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
> md.render("hi\n--")
=> "<h2>hi</h2>\n"
> md.render("hi\n -")
=> "<p>hi\n -</p>\n"
> md.render("hi\n- ")
=> "<h2>hi</h2>\n"
=end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
appium_doc_lint-0.0.11 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.10 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.9 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.8 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.7 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.6 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.5 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.4 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.3 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.2 lib/appium_doc_lint/lint/h2_invalid.rb
appium_doc_lint-0.0.1 lib/appium_doc_lint/lint/h2_invalid.rb