Sha256: 17c59aaa793ca9095e4c52ea8c1c29980d348c8592e930bd2249d2c97f08ceb1
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
require "nokogiri" module Asciidoctor module Standoc module Validate def section_validate(doc) sourcecode_style(doc.root) hanging_para_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" @log.add("AsciiDoc Input", x, "mismatch of callouts and annotations") end end end def style_warning(node, msg, text = nil) w = msg w += ": #{text}" if text #warn w @log.add("Style Warning", node, 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 def hanging_para_style(root) root.xpath("//clause | //annex | //foreword | //introduction | "\ "//acknowledgements").each do |c| next unless c.at("./clause") next if c.elements.select { |n| n.name != "clause" }.empty? style_warning(c, "Hanging paragraph in clause") end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
metanorma-standoc-1.3.28 | lib/asciidoctor/standoc/validate_section.rb |
metanorma-standoc-1.3.27 | lib/asciidoctor/standoc/validate_section.rb |