Class: Metanorma::Standoc::Cleanup
- Inherits:
-
Object
- Object
- Metanorma::Standoc::Cleanup
- Extended by:
- Forwardable
- Includes:
- Amend, Asciibib, Attachment, Bibdata, Bibitem, Block, Boilerplate, Dochistory, Footnotes, Image, Index, Inline, Maths, Metadata, Ref, Reqt, Review, Section, SectionNames, Symbols, Table, Terms, TermsDesignations, Text, Toc, Xref
- Defined in:
- lib/metanorma/cleanup/log.rb,
lib/metanorma/cleanup/cleanup.rb,
lib/metanorma/cleanup/merge_bibitems.rb,
lib/metanorma/cleanup/spans_to_bibitem.rb,
lib/metanorma/cleanup/spans_to_bibitem_preprocessing.rb
Defined Under Namespace
Classes: MergeBibitems, SpansToBibitem
Constant Summary collapse
- RELATON_SEVERITIES =
{ "INFO": "RELATON_4", "WARN": "RELATON_3", "ERROR": "RELATON_2", "FATAL": "RELATON_1", "UNKNOWN": "RELATON_4" }.freeze
- NORM_REF =
XPath expressions for boilerplate insertion
"//bibliography/references[@normative = 'true'][not(@hidden)] | " \ "//bibliography/clause[.//references[@normative = 'true']]".freeze
- TERM_CLAUSE =
"//sections//terms[not(.//ancestor::clause[@type = 'terms'])] | " \ "//sections/clause[descendant::terms][@type = 'terms'] | " \ "//sections/clause[not(@type = 'terms')]//terms".freeze
- TEXT_ELEMS =
%w{status language script version author name callout phone email street city state country postcode identifier referenceFrom surname referenceTo docidentifier docnumber prefix initial addition forename title draft secretariat title-main title-intro title-part verbal-definition non-verbal-representation}.freeze
Constants included from TermsDesignations
Constants included from Text
Text::IGNORE_QUOTES_ELEMENTS, Text::IGNORE_TEXT_ELEMENTS, Text::PRESERVE_LINEBREAK_ELEMENTS, Text::STRIP_LINEBREAK_ELEMENTS
Constants included from Image
Image::IRI_TAG_PROPERTIES_MAP, Image::SVG_NS
Constants included from Maths
Maths::MATHML_NS, Maths::MATHVARIANT_OVERRIDE, Maths::UNITSML_NS
Constants included from Regex
Regex::CONN_REGEX_STR, Regex::ISO_REF, Regex::ISO_REF_ALL_PARTS, Regex::ISO_REF_NO_YEAR, Regex::LOCALITIES, Regex::LOCALITY_REGEX_STR, Regex::LOCALITY_REGEX_STR_TRIPLEDASH, Regex::LOCALITY_REGEX_VALUE_ONLY_STR, Regex::NON_ISO_REF, Regex::NON_ISO_REF1, Regex::NUMERIC_REGEX, Regex::TERM_REFERENCE_RE, Regex::TERM_REFERENCE_RE_STR
Constants included from Inline
Inline::STEM_ATTRS, Inline::XREF_ATTRS
Constants included from Utils
Utils::SECTION_CONTAINERS, Utils::SUBCLAUSE_XPATH
Constants included from Terms
Constants included from SectionNames
SectionNames::ABBR_NO_SYM, SectionNames::NO_SYMABBR, SectionNames::SYMABBR, SectionNames::SYM_NO_ABBR
Constants included from Section
Section::MAIN_CLAUSE_NAMES, Section::PREFACE_CLAUSE_NAMES, Section::SECTIONTYPE_STREAMLINE
Constants included from Boilerplate
Boilerplate::ADOC_MACRO_PATTERN
Constants included from Footnotes
Constants included from Block
Class Attribute Summary collapse
-
._file ⇒ Object
Returns the value of attribute _file.
Instance Attribute Summary collapse
-
#files_to_delete ⇒ Object
readonly
Returns the value of attribute files_to_delete.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
Class Method Summary collapse
-
.inherited(konv) ⇒ Object
rubocop:disable Lint/MissingSuper.
Instance Method Summary collapse
- #cleanup(xmldoc) ⇒ Object
-
#copied_instance_variables ⇒ Object
Use metaprogramming to copy instance variables from converter.
- #element_name_cleanup(xmldoc) ⇒ Object
- #empty_element_cleanup(xmldoc) ⇒ Object
-
#initialize(converter) ⇒ Cleanup
constructor
A new instance of Cleanup.
- #relaton_iev_cleanup(xmldoc) ⇒ Object
- #relaton_key_eqv?(sought, found) ⇒ Boolean
- #relaton_log_add?(entry) ⇒ Boolean
- #relaton_log_cleanup(_xmldoc) ⇒ Object
-
#script_cleanup(xmldoc) ⇒ Object
it seems Nokogiri::XML is treating the content of <script> as cdata, because of its use in HTML.
- #to_xml(xml) ⇒ Object
Methods included from Metadata
#annotation_cleanup, #metadata_cleanup, #metadata_cleanup_final, #pres_metadata_cleanup
Methods included from TermsDesignations
#dl_to_designation, #related2pref, #term_designation_redundant, #term_designation_reorder, #term_designation_unnest_cleanup, #term_designation_unnest_cleanup1, #term_dl_to_designation_category, #term_dl_to_designation_metadata, #term_dl_to_expression_grammar, #term_dl_to_expression_metadata, #term_dl_to_expression_name_metadata, #term_dl_to_expression_root_metadata, #term_dl_to_metadata, #term_dl_to_term_metadata, #term_element_insert_point, #term_nonverbal_designations, #term_nonverbal_designations1, #term_termsource_to_designation, #term_to_letter_symbol, #termdef_stem_cleanup, #termdef_unnest_cleanup
Methods included from Dochistory
#amend_attrs, #amend_classification, #amend_classification1, #amend_description, #amend_hash2mn, #amend_hash2mn1, #amend_location, #bib_relation_insert_pt, #dochistory_yaml2relaton, #ext_dochistory_cleanup, #ext_dochistory_process, #yaml_deep_stringify_dates
Methods included from Review
#available_bookmark_destination, #find_review_sibling, #first_non_stem_text, #review_cleanup, #review_insert_bookmark, #review_set_location
Methods included from Toc
#toc_cleanup, #toc_cleanup1, #toc_cleanup1_entry, #toc_cleanup_clause, #toc_cleanup_clause_entry, #toc_cleanup_para, #toc_index, #toc_index1, #toc_index_depths, #toc_metadata, #toc_metadata1
Methods included from Text
#ancestor_include?, #block?, #dumb2smart_quotes, #dumb2smart_quotes1, #dumbquote_cleanup, #empty_tag_with_text_content?, #gather_text_for_linebreak_cleanup, #gather_text_for_linebreak_cleanup1, #ignoretext?, #linebreak_cleanup, #linebreak_cleanup_block, #lines_strip_textspan, #smartquotes_cleanup, #smartquotes_cleanup1, #uninterrupt_quotes_around_xml, #uninterrupt_quotes_around_xml1, #uninterrupt_quotes_around_xml_skip
Methods included from Reqt
Methods included from Image
#altmedia_cleanup, #altmedia_prep, #altmedia_root_cleanup, #altsource_attr_copy, #altsource_populate, #datauri_image, #image_attr_copy, #img_cleanup, #read_in_if_svg?, #svg_attrupdate, #svg_classupdate, #svg_classupdate1, #svg_cleanup, #svg_idupdate, #svg_iri_properties, #svg_linkupdate, #svg_styleupdate, #svg_suffix_css_style, #svg_uniqueids, #svg_uniqueids1, #svg_uniqueids2, #svg_update_url, #svgmap_cleanup, #svgmap_moveattrs, #svgmap_moveattrs1, #svgmap_populate, #svgmap_target
Methods included from Maths
#add_misc_container, #asciimath2mathml, #asciimath2mathml_err, #asciimath2mathml_indiv, #asciimath2mathml_wrap, #asciimath2unitsml_options, #asciimath_cleanup, #asciimath_parse, #gather_unitsml, #mathml_cleanup, #mathml_italicise, #mathml_mathvariant, #mathml_mi_italics, #mathml_mn_format, #mathml_mn_profile, #mathml_namespace, #mathml_number_format, #mathml_number_to_mathml, #mathml_preserve_space, #mathml_stem_format, #mathml_stem_format_attr, #mathml_unitsml, #mathml_xml_cleanup, #mathvariant_override, #mi_italicise?, #progress_conv, #xml_unescape_mathml
Methods included from Regex
Methods included from Amend
#change_clauses, #create_amend, #create_amend1, #create_amend2, #create_amend2_prep, #create_amend_autonum, #move_attrs_to_amend, #move_attrs_to_amend_locality
Methods included from Inline
#altmedia_id_attr, #anchor_cleanup, #bookmark_cleanup, #bookmark_to_id, #concatenate_attributes_to_xref_text, #concept_cleanup, #concept_cleanup1, #concept_eref_cleanup, #concept_termbase_cleanup, #concept_xref_cleanup, #contenthash_id_cleanup, #contenthash_id_make, #dt_bookmark_cleanup, #duplicate_langvariants, #empty_text_before_first_element, #hash2styles, #highlight_parse, #image_attributes, #image_attributes1, #image_mimetype, #image_src_uri, #inline_anchor, #inline_anchor_bibref, #inline_anchor_bibref_contents, #inline_anchor_link, #inline_anchor_link_attrs, #inline_anchor_ref, #inline_anchor_xref, #inline_anchor_xref_attrs, #inline_anchor_xref_attrs1, #inline_anchor_xref_match, #inline_anchor_xref_text, #inline_break, #inline_callout, #inline_footnote, #inline_image, #inline_indexterm, #inline_indexterm1, #inline_indexterm_extract, #inline_indexterm_see, #inline_quoted, #key_extract_locality, #lang_variant_to_node, #latex_parse, #latex_parse1, #li_bookmark_cleanup, #link_cleanup, #only_langvariant_children?, #page_break, #pass, #passthrough_cleanup, #passthrough_metanorma_cleanup, #redundant_bookmark_cleanup, #related_cleanup, #source_id_cleanup, #stem_attrs, #stem_parse, #strip_initial_space, #thematic_break, #to_xreftarget, #uri_cleanup, #uri_component_encode, #variant_cleanup, #variant_space_cleanup
Methods included from Utils
#add_id, #add_id_text, #add_noko_elem, adoc2xml, #asciimath_key, #attr_code, #complete_and_compare_dates, #complete_iso_date, #complete_year_month, #complete_year_only, #convert, #csv_split, #dl_to_attrs, #dl_to_elems, #document_ns_attributes, #grkletters, #insert_before, #isodoc, #isolated_asciidoctor_convert, #kv_parse, #link_unwrap, #noko, #parse_complete_date, #parse_partial_date, #processor, #quoted_csv_split, #refid?, #section_containers, #separate_numbering_footnotes, #term_expr, #textcleanup, #wrap_in_para, #xml_encode
Methods included from Xref
#add_locality, #add_locality_attributes, #anchor_alias, #anchor_alias1, #eref_default_style, #eref_stack, #eref_style_normalise, #eref_style_normalise_prep, #extract_localities, #extract_localities1, #extract_localities_update_text, #fill_in_eref_connectives, #locality_label, #locality_normalise, #origin_cleanup, #origin_default_style, #quotesource_cleanup, #tq, #xref_alias, #xref_cleanup, #xref_cleanup1, #xref_compound_cleanup, #xref_compound_cleanup1, #xref_compound_wrapup, #xref_default_style, #xref_display_text, #xref_parse_compound_locations, #xref_parse_compound_locations_fill_in, #xref_to_eref, #xref_to_eref1, #xref_to_internal_eref
Methods included from Symbols
#extract_symbols_list, #symbol_key, #symbols_cleanup
Methods included from Terms
#alternate_termdefinitions, #generate_termdefinitions, #split_termdefinitions, #term_children_cleanup, #term_id_attr_cleanup, #termdef_cleanup, #termdef_from_termbase, #termdefinition_cleanup, #termdocsource_cleanup, #termdomain1_cleanup, #termdomain_cleanup, #termlookup_cleanup, #termnote_example_cleanup, #terms_terms_cleanup
Methods included from Index
#block_index_cleanup, #include_indexterm?, #index_cleanup1, #indexterm_para?, #para_index_cleanup, #para_index_cleanup1, #term_index_cleanup
Methods included from SectionNames
#auto_name_definitions, #auto_name_terms, #floating_title_preface2sections, #floatingtitle_cleanup, #get_or_make_title, #pop_floating_title, #replace_title, #section_names_definitions, #section_names_refs_cleanup, #section_names_terms1_cleanup, #section_names_terms_cleanup, #sections_names_cleanup, #sections_names_pref_cleanup, #sections_variant_title_cleanup, #set_title_with_footnotes, #terms_subclause_type_tally, #terms_subclauses
Methods included from Section
#abstract_parse, #acknowledgements_parse, #add_term_source, #add_term_source_mod, #annex_attrs_preprocess, #annex_parse, #appendix_parse, #bibabstract_location, #bibitem_parse, #biblio_prep, #bibliography_parse, #clause_attrs_preprocess, #clause_parse, #clausebefore_cleanup, #clean_abstract, #emend_biblio, #emend_biblio_fn, #emend_biblio_id, #emend_biblio_title, #emend_biblio_usrlbl, #endofpreface_clausebefore, #executivesummary_parse, #extract_termsource_refs, #floating_title, #floating_title_attrs, #foreword_parse, #in_biblio?, #in_norm_ref?, #in_terms?, #indexsect_parse, #introduction_parse, #make_abstract, #make_annexes, #make_bibliography, #make_colophon, #make_indexsect, #make_preface, #maxlevel, #metanorma_extension_parse, #misccontainer_cleanup, #move_clauses_into_preface, #nonterm_symbols_parse, #nonterm_term_def_subclause_parse, #norm_ref_parse, #obligations_cleanup, #obligations_cleanup_info, #obligations_cleanup_inherit, #obligations_cleanup_norm, #pop_symbols, #pop_term_def, #preamble, #preface_clausebefore_cleanup, #preface_main_filter, #role_style, #scope_parse, #section, #section_attributes, #section_attributes_change, #section_title, #sections_clausebefore_cleanup, #sections_cleanup, #sections_level_cleanup, #sections_order_cleanup, #sectiontype, #sectiontype1, #sectiontype_streamline, #set_obligation, #single_clause_annex, #source_include_cleanup, #source_sanitise, #start_main_section, #stash_symbols, #stash_term_def, #support_appendix?, #symbols_attrs, #symbols_parse, #term_contains_subclauses, #term_def_parse, #term_def_subclause_parse, #term_def_subclause_parse1, #term_designation, #termdefinition, #terms_boilerplate_parse, #termsource, #termsource_attrs, #termsource_origin_attrs, #to_preface
Methods included from Bibitem
#bibitem_cleanup, #bibitem_i18n, #bibitem_i18n_insert, #bibitem_id_docid_hash, #bibitem_nested_id, #bibitem_title_to_id, #biblio_hidden_inherit, #biblio_no_ext, #empty_docid_to_title, #empty_docid_to_title?, #extract_notes_from_biblio, #fetch_local_bibitem, #fetch_termbase, #fold_notes_into_biblio, #format_ref, #formattedref_spans, #idtype2cit, #merge_bibitem_from_formattedref_span_attrs, #merge_bibitem_from_formattedref_spans, #new_bibitem_from_formattedref_spans, #read_local_bibitem, #read_local_bibitem_file, #reference_names, #remove_dup_bibtem_id, #remove_empty_docid, #select_docid
Methods included from Attachment
#attachment_cleanup, #attachment_location, #attachment_uri, #datauri_attachment, #init_attachments, #save_attachment, #valid_attachment?
Methods included from Bibdata
#bibdata_anchor_cleanup, #bibdata_cleanup, #bibdata_docidentifier_cleanup, #bibdata_embed_hdr_cleanup, #bibdata_embed_id_cleanup, #bibdata_empty_contribs, #bibdata_published, #biblio_indirect_erefs, #bpart_cleanup, #coverpage_images, #docidentifier_cleanup, #embed_recurse, #ext_contributor_cleanup, #ext_contributors_process, #gather_indirect_erefs, #hdr2bibitem, #hdr2bibitem_type, #indirect_eref_to_xref, #insert_indirect_biblio, #published?, #published_base?, #resolve_local_indirect_erefs, #resolve_local_indirect_erefs_prep, #yaml2relaton
Methods included from Boilerplate
#boilerplate, #boilerplate_cleanup, #boilerplate_file, #boilerplate_file_convert, #boilerplate_file_restructure, #boilerplate_isodoc, #boilerplate_read, #boilerplate_snippet_convert, #docidentifier_boilerplate_isodoc, #dup_with_namespace, #external_terms_boilerplate, #initial_boilerplate, #internal_external_terms_boilerplate, #isodoc_bibdata_parse, #merge_boilerplate_files, #norm_ref_boilerplate_insert_location, #norm_ref_preface, #norm_ref_process_boilerplate_note, #process_boilerplate_file, #resolve_boilerplate_append, #resolve_boilerplate_append1, #resolve_boilerplate_files, #resolve_boilerplate_statement, #term_defs_boilerplate, #term_defs_boilerplate_cont, #termdef_boilerplate_cleanup, #termdef_boilerplate_climb_up, #termdef_boilerplate_insert, #termdef_boilerplate_insert1, #termdef_boilerplate_insert_location, #termdef_remove_initial_paras, #unwrap_boilerplate_clauses, #verify_term_defs_source
Methods included from Asciibib
#add_to_hash, #dd_bib_extract, #dl_bib_extract, #dl_bib_extract_title, #extract_from_p, #p_unwrap, #ref_dl_cleanup, #ref_dl_cleanup_id, #validate_ref_dl, #validate_ref_dl1
Methods included from Ref
#biblio_annex, #biblio_cleanup, #biblio_linkonly, #biblio_nested, #biblio_nested_initial_items, #biblio_nested_sections, #biblio_renumber, #biblio_reorder, #biblio_reorder1, #insert_hidden_bibitems, #insert_sorted_bibitems, #normref_cleanup, #ref_cleanup, #sort_biblio
Methods included from Footnotes
#duplicate_footnote, #figure_footnote_cleanup, #footnote_block_cleanup, #footnote_block_error, #footnote_block_remove, #footnote_cleanup, #footnote_content, #other_footnote_renumber, #other_footnote_renumber1, #process_hidden_footnotes, #table_footnote_number, #table_footnote_renumber, #table_footnote_renumber1, #title_footnote_move
Methods included from Table
#dl1_table_cleanup, #dl2_table_cleanup, #header_rows_cleanup, #insert_thead, #notes_table_cleanup, #sources_table_cleanup, #table, #table_attrs, #table_cleanup, #td_style_cleanup, #tr_style_cleanup
Methods included from Block
#align_callouts_to_annotations, #blocksource_cleanup, #callout_cleanup, #figure_cleanup, #figure_dl_cleanup1, #figure_dl_cleanup2, #figure_table_cleanup, #form_cleanup, #formula_cleanup, #formula_cleanup_where1, #formula_cleanup_where2, #inject_id, #key_cleanup, #key_concatenate, #link_callouts_to_annotations, #merge_annotations_into_sourcecode, #note_cleanup, #ol_cleanup, #para_cleanup, #safe_noko, #single_subfigure_cleanup, #source_markup_prep, #source_markup_validate, #sourcecode_cleanup, #sourcecode_markup, #subfigure_cleanup, #text_key_extract, #unnumbered_blocks_cleanup
Constructor Details
#initialize(converter) ⇒ Cleanup
Returns a new instance of Cleanup.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 68 def initialize(converter) @conv= converter @anchor_alias = {} @internal_eref_namespaces = [] # Shadow instance variables from converter (attributes/accessors) @log = converter.log @bibdb = converter.bibdb @lang = converter.lang @script = converter.script @libdir = converter.libdir @locale = converter.locale @novalid = converter.novalid @output_dir = converter.output_dir @filename = converter.filename @files_to_delete = converter.files_to_delete copied_instance_variables.each do |var| instance_variable_set("@#{var}", converter.instance_variable_get("@#{var}")) end # Special handling for derived values @i18n = @isodoc&.i18n # Reuse converter's relaton_log instead of creating a new one @relaton_log = converter.relaton_log end |
Class Attribute Details
._file ⇒ Object
Returns the value of attribute _file.
102 103 104 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 102 def _file @_file end |
Instance Attribute Details
#files_to_delete ⇒ Object (readonly)
Returns the value of attribute files_to_delete.
42 43 44 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 42 def files_to_delete @files_to_delete end |
#log ⇒ Object (readonly)
Returns the value of attribute log.
42 43 44 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 42 def log @log end |
Class Method Details
.inherited(konv) ⇒ Object
rubocop:disable Lint/MissingSuper
105 106 107 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 105 def self.inherited(konv) # rubocop:disable Lint/MissingSuper konv._file = caller_locations(1..1).first.absolute_path end |
Instance Method Details
#cleanup(xmldoc) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 137 def cleanup(xmldoc) @doctype = xmldoc.at("//bibdata/ext/doctype")&.text element_name_cleanup(xmldoc) source_include_cleanup(xmldoc) # feeds: misccontainer_cleanup passthrough_cleanup(xmldoc) # feeds: smartquotes_cleanup annotation_cleanup(xmldoc) unnumbered_blocks_cleanup(xmldoc) termdocsource_cleanup(xmldoc) # feeds: metadata_cleanup (xmldoc) # feeds: boilerplate_cleanup, bibdata_cleanup, # docidentifier_cleanup misccontainer_cleanup(xmldoc) sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup, # floatingtitle_cleanup obligations_cleanup(xmldoc) para_index_cleanup(xmldoc) block_index_cleanup(xmldoc) key_cleanup(xmldoc) # feeds: table_cleanup, figure_cleanup, # formula_cleanup table_cleanup(xmldoc) # feeds: blocksource_cleanup formula_cleanup(xmldoc) form_cleanup(xmldoc) sourcecode_cleanup(xmldoc) # feeds: callout_cleanup figure_cleanup(xmldoc) blocksource_cleanup(xmldoc) requirement_cleanup(xmldoc) # feeds: xref_cleanup element_name_cleanup(xmldoc) ref_cleanup(xmldoc) # feeds: bibitem_cleanup note_cleanup(xmldoc) clausebefore_cleanup(xmldoc) # feeeds: floatingtitle_cleanup floatingtitle_cleanup(xmldoc) bibitem_cleanup(xmldoc) # feeds: normref_cleanup, biblio_cleanup, # reference_names, bpart_cleanup, attachment_cleanup normref_cleanup(xmldoc) biblio_cleanup(xmldoc) reference_names(xmldoc) terms_terms_cleanup(xmldoc) # feeds: boilerplate_cleanup asciimath_cleanup(xmldoc) # feeds: mathml_cleanup, termdef_cleanup, # symbols_cleanup symbols_cleanup(xmldoc) # feeds: termdef_cleanup xref_cleanup(xmldoc) # feeds: concept_cleanup, origin_cleanup concept_cleanup(xmldoc) # feeds: related_cleanup, termdef_cleanup (xmldoc) # feeds: termdef_cleanup origin_cleanup(xmldoc) # feeds: termdef_cleanup bookmark_cleanup(xmldoc) termdef_cleanup(xmldoc) # feeds: relaton_iev_cleanup, term_index_cleanup relaton_iev_cleanup(xmldoc) relaton_log_cleanup(xmldoc) element_name_cleanup(xmldoc) term_index_cleanup(xmldoc) bpart_cleanup(xmldoc) quotesource_cleanup(xmldoc) callout_cleanup(xmldoc) footnote_cleanup(xmldoc) ol_cleanup(xmldoc) mathml_cleanup(xmldoc) script_cleanup(xmldoc) docidentifier_cleanup(xmldoc) # feeds: bibdata_cleanup ext_contributor_cleanup(xmldoc) # feeds: bibdata_cleanup ext_dochistory_cleanup(xmldoc) # feeds: bibdata_cleanup bibdata_cleanup(xmldoc) # feeds: boilerplate_cleanup boilerplate_cleanup(xmldoc) # feeds: xref_cleanup for new <<>> # introduced, pres_metadata_cleanup (xmldoc) xref_cleanup(xmldoc) svgmap_cleanup(xmldoc) # feeds: img_cleanup review_cleanup(xmldoc) toc_cleanup(xmldoc) smartquotes_cleanup(xmldoc) linebreak_cleanup(xmldoc) variant_cleanup(xmldoc) para_cleanup(xmldoc) source_id_cleanup(xmldoc) empty_element_cleanup(xmldoc) img_cleanup(xmldoc) anchor_cleanup(xmldoc) link_cleanup(xmldoc) (xmldoc) (xmldoc) xmldoc end |
#copied_instance_variables ⇒ Object
Use metaprogramming to copy instance variables from converter
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 55 def copied_instance_variables %i[ datauriattachment datauriimage local_log isodoc anchors localdir c refids sourcecode_markup_start sourcecode_markup_end smartquotes toclevels htmltoclevels doctoclevels pdftoclevels stage_published numberfmt_default svg_conform_profile dataurimaxsize index_terms boilerplateauthority embed_hdr embed_id erefstyle originstyle xrefstyle blockunnumbered keepasciimath numberfmt_formula numberfmt_prof sort_biblio reqt_models default_requirement_model document_scheme ] end |
#element_name_cleanup(xmldoc) ⇒ Object
239 240 241 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 239 def element_name_cleanup(xmldoc) xmldoc.traverse { |n| n.name = n.name.tr("_", "-") } end |
#empty_element_cleanup(xmldoc) ⇒ Object
232 233 234 235 236 237 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 232 def empty_element_cleanup(xmldoc) xmldoc.xpath("//#{TEXT_ELEMS.join(' | //')}").each do |x| x.name == "name" && x.parent.name == "expression" and next x.children.empty? and x.remove end end |
#relaton_iev_cleanup(xmldoc) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/metanorma/cleanup/log.rb', line 4 def relaton_iev_cleanup(xmldoc) _, err = RelatonIev::iev_cleanup(xmldoc, @bibdb) err.each do |e| @log.add("RELATON_5", nil, params: e) end end |
#relaton_key_eqv?(sought, found) ⇒ Boolean
34 35 36 37 38 |
# File 'lib/metanorma/cleanup/log.rb', line 34 def relaton_key_eqv?(sought, found) sought = sought.sub(" (all parts)", "").sub(/:(19|20)\d\d$/, "") found = found.sub(" (all parts)", "").sub(/:(19|20)\d\d$/, "") sought.end_with?(found) end |
#relaton_log_add?(entry) ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/metanorma/cleanup/log.rb', line 26 def relaton_log_add?(entry) entry["message"].include?("Fetching from") and return false entry["message"].include?("Downloaded index from") and return false entry["message"].start_with?("Found:") or return true id = /^Found: `(.+)`$/.match(entry["message"]) or return true !relaton_key_eqv?(entry["key"], id[1]) end |
#relaton_log_cleanup(_xmldoc) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/metanorma/cleanup/log.rb', line 15 def relaton_log_cleanup(_xmldoc) @relaton_log or return @relaton_log.rewind @relaton_log.string.split(/(?<=})\n(?={)/).each do |l| e = JSON.parse(l) relaton_log_add?(e) and @log.add(RELATON_SEVERITIES[e["severity"].to_sym], e["key"], params: [e["message"]]) end end |
#script_cleanup(xmldoc) ⇒ Object
it seems Nokogiri::XML is treating the content of <script> as cdata, because of its use in HTML. Bad Nokogiri. Undoing that, since we use script as a normal tag
228 229 230 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 228 def script_cleanup(xmldoc) xmldoc.xpath("//script").each { |x| x.content = x.to_str } end |
#to_xml(xml) ⇒ Object
97 98 99 |
# File 'lib/metanorma/cleanup/cleanup.rb', line 97 def to_xml(xml) @conv.to_xml(xml) end |