Module: IsoDoc
- Defined in:
- lib/isodoc/spec_helpers/canon_html_input_guard.rb,
lib/isodoc.rb,
lib/isodoc/css.rb,
lib/isodoc/i18n.rb,
lib/isodoc/init.rb,
lib/isodoc/xref.rb,
lib/isodoc/common.rb,
lib/isodoc/convert.rb,
lib/isodoc/version.rb,
lib/isodoc/function.rb,
lib/isodoc/metadata.rb,
lib/isodoc/gem_tasks.rb,
lib/isodoc/class_utils.rb,
lib/isodoc/pdf_convert.rb,
lib/isodoc/html_convert.rb,
lib/isodoc/word_convert.rb,
lib/isodoc/function/form.rb,
lib/isodoc/function/reqt.rb,
lib/isodoc/html_function.rb,
lib/isodoc/metadata_date.rb,
lib/isodoc/word_function.rb,
lib/isodoc/xref/xref_gen.rb,
lib/isodoc/xslfo_convert.rb,
lib/isodoc/function/lists.rb,
lib/isodoc/function/setup.rb,
lib/isodoc/function/table.rb,
lib/isodoc/function/terms.rb,
lib/isodoc/function/utils.rb,
lib/isodoc/xref/xref_util.rb,
lib/isodoc/function/blocks.rb,
lib/isodoc/function/inline.rb,
lib/isodoc/function/cleanup.rb,
lib/isodoc/function/section.rb,
lib/isodoc/xref/xref_anchor.rb,
lib/isodoc/css_border_parser.rb,
lib/isodoc/xref/clause_order.rb,
lib/isodoc/xref/xref_counter.rb,
lib/isodoc/xref/xref_gen_seq.rb,
lib/isodoc/function/footnotes.rb,
lib/isodoc/function/utils_img.rb,
lib/isodoc/html_function/form.rb,
lib/isodoc/html_function/html.rb,
lib/isodoc/word_function/body.rb,
lib/isodoc/xref/xref_list_gen.rb,
lib/isodoc/xref/xref_sect_gen.rb,
lib/isodoc/function/references.rb,
lib/isodoc/word_function/lists.rb,
lib/isodoc/word_function/table.rb,
lib/isodoc/headlesshtml_convert.rb,
lib/isodoc/metadata_contributor.rb,
lib/isodoc/word_function/inline.rb,
lib/isodoc/xref/xref_sect_asset.rb,
lib/isodoc/function/to_word_html.rb,
lib/isodoc/xref/ol_type_provider.rb,
lib/isodoc/css_border_parser_vars.rb,
lib/isodoc/function/inline_simple.rb,
lib/isodoc/word_function/comments.rb,
lib/isodoc/function/section_titles.rb,
lib/isodoc/word_function/footnotes.rb,
lib/isodoc/xref/xref_counter_types.rb,
lib/isodoc/presentation_xml_convert.rb,
lib/isodoc/html_function/postprocess.rb,
lib/isodoc/presentation_function/ids.rb,
lib/isodoc/word_function/postprocess.rb,
lib/isodoc/presentation_function/list.rb,
lib/isodoc/presentation_function/math.rb,
lib/isodoc/presentation_function/refs.rb,
lib/isodoc/presentation_function/reqt.rb,
lib/isodoc/presentation_function/annex.rb,
lib/isodoc/presentation_function/block.rb,
lib/isodoc/presentation_function/docid.rb,
lib/isodoc/presentation_function/erefs.rb,
lib/isodoc/presentation_function/image.rb,
lib/isodoc/presentation_function/index.rb,
lib/isodoc/presentation_function/terms.rb,
lib/isodoc/presentation_function/title.rb,
lib/isodoc/presentation_function/xrefs.rb,
lib/isodoc/function/blocks_example_note.rb,
lib/isodoc/presentation_function/inline.rb,
lib/isodoc/presentation_function/source.rb,
lib/isodoc/presentation_function/autonum.rb,
lib/isodoc/presentation_function/bibdata.rb,
lib/isodoc/presentation_function/cleanup.rb,
lib/isodoc/presentation_function/section.rb,
lib/isodoc/word_function/postprocess_toc.rb,
lib/isodoc/presentation_function/concepts.rb,
lib/isodoc/presentation_function/metadata.rb,
lib/isodoc/html_function/postprocess_cover.rb,
lib/isodoc/presentation_function/footnotes.rb,
lib/isodoc/word_function/postprocess_cover.rb,
lib/isodoc/word_function/postprocess_table.rb,
lib/isodoc/presentation_function/sourcecode.rb,
lib/isodoc/html_function/mathvariant_to_plain.rb,
lib/isodoc/presentation_function/designations.rb,
lib/isodoc/presentation_function/section_refs.rb,
lib/isodoc/html_function/postprocess_footnotes.rb,
lib/isodoc/presentation_function/list_to_table.rb,
lib/isodoc/presentation_function/erefs_locality.rb
Overview
Guard against leading “<?xml ?>” processing instructions in HTML input strings passed to Canon’s be_html_equivalent_to / be_html4_equivalent_to / be_html5_equivalent_to matchers.
WHY: Nokogiri::HTML5.fragment parses a leading “<?xml ?>” as a bogus Nokogiri::XML::Comment at index 0 of the fragment. In Canon’s verbose mode (used by the matchers) comments are intentionally not filtered, so the bogus comment shifts fragment child indices and causes Canon’s diff report to blame elements at the tail of the document for an offence at the head — an “uninterpretable report” remote from the actual cause. Canon’s maintainer has chosen not to normalise this at the input boundary (closed PR lutaml/canon#124); this guard is the local defence.
WHEN: required for the side effect. Requiring this file installs a Module#prepend on Canon::RSpecMatchers::SerializationMatcher’s matches? method that raises IsoDoc::SpecHelpers::CanonGuardError if either side of an HTML-format comparison begins with an XML PI.
REUSE: downstream gems that build on isodoc’s spec idioms (metanorma family, mn2pdf, etc.) can opt in by adding a single line to their own spec_helper:
require "isodoc/spec_helpers/canon_html_input_guard"
No further setup is needed — the module installs on require.
Defined Under Namespace
Modules: ClassUtils, Function, GemTasks, HtmlFunction, SpecHelpers, WordFunction, XrefGen Classes: Common, Convert, CssBorderParser, HeadlessHtmlConvert, HtmlConvert, I18n, Metadata, PdfConvert, PresentationXMLConvert, WordConvert, Xref, XslfoPdfConvert
Constant Summary collapse
- VERSION =
"3.6.0".freeze