Sha256: 5a02403caa1c23b04f9ef11377da783f15eaa1e072838c3bfb8a19bc00c9af58

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

require "nokogiri"

module Asciidoctor
  module Standoc
    module Validate
      def section_validate(doc)
        sourcecode_style(doc.root)
        asset_style(doc.root)
      end

      def sourcecode_style(root)
        root.xpath("//sourcecode").each do |x|
          callouts = x.elements.select { |e| e.name == "callout" }
          annotations = x.elements.select { |e| e.name == "annotation" }
          if callouts.size != annotations.size
            warn "#{x['id']}: mismatch of callouts and annotations"
          end
        end
      end

      def style_warning(node, msg, text)
        return if @novalid
        w = "ISO style: WARNING (#{Utils::current_location(node)}): #{msg}"
        w += ": #{text}" if text
        warn w
      end

      def asset_title_style(root)
        root.xpath("//figure[image][not(title)]").each do |node|
          style_warning(node, "Figure should have title", nil)
        end
        root.xpath("//table[not(name)]").each do |node|
          style_warning(node, "Table should have title", nil)
        end
      end

      def asset_style(root)
        asset_title_style(root)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
metanorma-standoc-1.1.2 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.1.1 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.1.0 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.14 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.13 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.12 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.11 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.10 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.9 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.8 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.7 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.6 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.5 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.4 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.3 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.2 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.0.1 lib/asciidoctor/standoc/validate_section.rb