Sha256: 6dace440ea54ee98b44360009ee8352b39c1bab1194e822a01abac20bbc9af5f

Contents?: true

Size: 1.13 KB

Versions: 30

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(name)]").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

30 entries across 30 versions & 1 rubygems

Version Path
metanorma-standoc-1.3.17 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.16 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.15 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.14 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.13 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.12 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.11 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.10 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.9 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.8 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.7 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.6 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.5 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.4 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.3 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.2 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.1 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.3.0 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.2.4 lib/asciidoctor/standoc/validate_section.rb
metanorma-standoc-1.2.3 lib/asciidoctor/standoc/validate_section.rb