Class: Metanorma::Standoc::Converter

Inherits:
Object
  • Object
show all
Includes:
Asciidoctor::Converter, Asciidoctor::Writer, Base, Blocks, Cleanup, Front, Inline, Lists, Refs, Section, Table, Utils, Validate
Defined in:
lib/metanorma/standoc/converter.rb

Overview

A Converter implementation that generates Standoc output, and a document schema encapsulation of the document for validation

Constant Summary

Constants included from Validate

Validate::MATHML_NS, Validate::SOURCELOCALITY, Validate::SVG_NS, Validate::TOO_BIG_IMG_ERR, Validate::WILDCARD_ATTRS

Constants included from Cleanup

Metanorma::Standoc::Cleanup::ABBRnoSYM, Metanorma::Standoc::Cleanup::CONN_REGEX_STR, Metanorma::Standoc::Cleanup::DESIGNATOR, Metanorma::Standoc::Cleanup::ELEMS_ALLOW_NOTES, Metanorma::Standoc::Cleanup::FIGURE_FN_XPATH, Metanorma::Standoc::Cleanup::IDREF, Metanorma::Standoc::Cleanup::IGNORE_QUOTES_ELEMENTS, Metanorma::Standoc::Cleanup::IGNORE_TEXT_ELEMENTS, Metanorma::Standoc::Cleanup::IRI_TAG_PROPERTIES_MAP, Metanorma::Standoc::Cleanup::LOCALITIES, Metanorma::Standoc::Cleanup::LOCALITY_REGEX_STR, Metanorma::Standoc::Cleanup::LOCALITY_REGEX_STR_TRIPLEDASH, Metanorma::Standoc::Cleanup::LOCALITY_REGEX_VALUE_ONLY_STR, Metanorma::Standoc::Cleanup::MATHML_NS, Metanorma::Standoc::Cleanup::MATHVARIANT_OVERRIDE, Metanorma::Standoc::Cleanup::NORM_REF, Metanorma::Standoc::Cleanup::NO_SYMABBR, Metanorma::Standoc::Cleanup::NUMERIC_REGEX, Metanorma::Standoc::Cleanup::PRESERVE_LINEBREAK_ELEMENTS, Metanorma::Standoc::Cleanup::RELATON_SEVERITIES, Metanorma::Standoc::Cleanup::SECTION_CONTAINERS, Metanorma::Standoc::Cleanup::STRIP_LINEBREAK_ELEMENTS, Metanorma::Standoc::Cleanup::SVG_NS, Metanorma::Standoc::Cleanup::SYMABBR, Metanorma::Standoc::Cleanup::SYMnoABBR, Metanorma::Standoc::Cleanup::TERMDEF_BLOCKS, Metanorma::Standoc::Cleanup::TERM_CLAUSE, Metanorma::Standoc::Cleanup::TEXT_ELEMS, Metanorma::Standoc::Cleanup::UNITSML_NS

Constants included from Utils

Utils::SUBCLAUSE_XPATH

Constants included from Section

Section::MAIN_CLAUSE_NAMES, Section::PREFACE_CLAUSE_NAMES, Section::TERM_REFERENCE_RE, Section::TERM_REFERENCE_RE_STR

Constants included from Inline

Inline::STEM_ATTRS, Inline::XREF_ATTRS

Constants included from Refs

Refs::ISO_REF, Refs::ISO_REF_ALL_PARTS, Refs::ISO_REF_NO_YEAR, Refs::JOINT_REFS, Refs::MALFORMED_REF, Refs::NON_ISO_REF, Refs::NON_ISO_REF1

Constants included from Base

Base::FONTS_MANIFEST, Base::XML_NAMESPACE, Base::XML_ROOT_TAG

Class Attribute Summary collapse

Attributes included from Base

#log

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Validate

#asset_style, #asset_title_style, #callouts_error, #concept_validate, #concept_validate_ids, #concept_validate_msg, #content_validate, #empty_table_validate, #expand_path, #formattedstr_strip, #hanging_para_style, #iev_validate, #iev_validate1, #image_exists, #image_toobig, #image_validate, #init_iev, #math_validate, #math_validate_error, #mathml_sanitise, #max_td_count, #maxcols_check, #maxcols_validate1, #maxrowcols_validate, #maxrowcols_validate0, #maxrows_validate, #nested_asset_report, #nested_asset_validate, #nested_asset_validate_basic, #nested_asset_xref_report, #nested_note_validate, #norm_ref_validate, #png_validate, #png_validate1, #preferred_validate, #preferred_validate_report, #repeat_id_validate, #repeat_id_validate1, #schema_validate, #schema_validate1, #section_validate, #sourcecode_style, #style_warning, #table_tracker_update, #table_validate, #validate, #xref_validate

Methods included from Cleanup

#add_locality, #add_misc_container, #add_to_hash, #align_callouts_to_annotations, #alternate_termdefinitions, #amend_attrs, #amend_classification, #amend_classification1, #amend_description, #amend_hash2mn, #amend_hash2mn1, #amend_location, #ancestor_include?, #anchor_alias, #anchor_alias1, #anchor_cleanup, #anchor_cleanup1, #asciimath2mathml, #asciimath2mathml_err, #asciimath2mathml_indiv, #asciimath2mathml_wrap, #asciimath2unitsml_options, #asciimath_cleanup, #asciimath_parse, #attachment_cleanup, #attachment_location, #attachment_uri, #auto_name_definitions, #auto_name_terms, #bib_relation_insert_pt, #bibabstract_location, #bibdata_anchor_cleanup, #bibdata_cleanup, #bibdata_docidentifier_cleanup, #bibdata_embed_hdr_cleanup, #bibdata_embed_id_cleanup, #bibitem_cleanup, #bibitem_id_docid_hash, #bibitem_nested_id, #biblio_annex, #biblio_cleanup, #biblio_hidden_inherit, #biblio_indirect_erefs, #biblio_linkonly, #biblio_nested, #biblio_nested_initial_items, #biblio_nested_sections, #biblio_no_ext, #biblio_renumber, #biblio_reorder, #biblio_reorder1, #block?, #block_index_cleanup, #blocksource_cleanup, #boilerplate, #boilerplate_cleanup, #boilerplate_file, #boilerplate_file_convert, #boilerplate_file_restructure, #boilerplate_isodoc, #boilerplate_read, #boilerplate_snippet_convert, #boilerplate_top_elements, #boilerplate_xml_cleanup, #bookmark_cleanup, #bookmark_to_id, #bpart_cleanup, #callout_cleanup, #change_clauses, #clausebefore_cleanup, #clean_abstract, #cleanup, #concept_cleanup, #concept_cleanup1, #concept_eref_cleanup, #concept_termbase_cleanup, #concept_xref_cleanup, #contenthash, #contenthash_id_cleanup, #contenthash_id_make, #contenthash_id_update_refs, #create_amend, #create_amend1, #create_amend2, #datauri_attachment, #dd_bib_extract, #dl1_table_cleanup, #dl2_table_cleanup, #dl_bib_extract, #dl_bib_extract_title, #dl_to_designation, #docidentifier_cleanup, #dt_bookmark_cleanup, #dumb2smart_quotes, #dumb2smart_quotes1, #dumbquote_cleanup, #element_name_cleanup, #embed_recurse, #empty_element_cleanup, #empty_tag_with_text_content?, #empty_text_before_first_element, #endofpreface_clausebefore, #eref_stack, #ext_contributor_cleanup, #ext_contributors_process, #ext_dochistory_cleanup, #ext_dochistory_process, #external_terms_boilerplate, #extract_from_p, #extract_localities, #extract_localities1, #extract_localities_update_text, #extract_notes_from_biblio, #extract_symbols_list, #fetch_local_bibitem, #fetch_termbase, #figure_cleanup, #figure_dl_cleanup1, #figure_dl_cleanup2, #figure_footnote_cleanup, #fill_in_eref_connectives, #floating_title_preface2sections, #floatingtitle_cleanup, #fold_notes_into_biblio, #footnote_block_cleanup, #footnote_block_error, #footnote_block_remove, #footnote_cleanup, #footnote_content, #form_cleanup, #format_ref, #formattedref_spans, #formula_cleanup, #formula_cleanup_where1, #formula_cleanup_where2, #gather_indirect_erefs, #gather_text_for_linebreak_cleanup, #gather_unitsml, #generate_termdefinitions, #get_or_make_title, #hdr2bibitem, #hdr2bibitem_type, #header_rows_cleanup, #idtype2cit, #ignoretext?, #img_cleanup, #include_indexterm?, #index_cleanup1, #indexterm_para?, #indirect_eref_to_xref, #init_attachments, #initial_boilerplate, #inject_id, #insert_before, #insert_hidden_bibitems, #insert_indirect_biblio, #insert_thead, #internal_external_terms_boilerplate, #key_extract_locality, #li_bookmark_cleanup, #linebreak_cleanup, #linebreak_cleanup_block, #lines_strip_textspan, #link_callouts_to_annotations, #link_cleanup, #locality_label, #locality_normalise, #make_abstract, #make_annexes, #make_bibliography, #make_colophon, #make_indexsect, #make_preface, #mathml_cleanup, #mathml_italicise, #mathml_mathvariant, #mathml_mi_italics, #mathml_mn_format, #mathml_mn_profile, #mathml_namespace, #mathml_number_format, #mathml_preserve_space, #mathml_stem_format, #mathml_stem_format_attr, #mathml_unitsml, #mathml_xml_cleanup, #mathvariant_override, #maxlevel, #merge_annotations_into_sourcecode, #merge_bibitem_from_formattedref_spans, #merge_boilerplate_files, #metadata_cleanup, #mi_italicise?, #misccontainer_cleanup, #move_attrs_to_amend, #move_clauses_into_preface, #new_bibitem_from_formattedref_spans, #norm_ref_boilerplate_insert_location, #norm_ref_preface, #norm_ref_process_boilerplate_note, #normref_cleanup, #note_cleanup, #notes_table_cleanup, #obligations_cleanup, #obligations_cleanup_info, #obligations_cleanup_inherit, #obligations_cleanup_norm, #ol_cleanup, #origin_cleanup, #other_footnote_renumber, #other_footnote_renumber1, #p_unwrap, #para_cleanup, #para_index_cleanup, #para_index_cleanup1, #passthrough_cleanup, #pop_floating_title, #preface_clausebefore_cleanup, #process_boilerplate_file, #progress_conv, #quotesource_cleanup, #read_in_if_svg, #read_local_bibitem, #read_local_bibitem_file, #redundant_bookmark_cleanup, #ref_cleanup, #ref_dl_cleanup, #reference_names, #related2pref, #related_cleanup, #relaton_iev_cleanup, #relaton_log_cleanup, #remove_dup_bibtem_id, #replace_title, #requirement_cleanup, #resolve_boilerplate_files, #resolve_boilerplate_statement, #resolve_local_indirect_erefs, #safe_noko, #save_attachment, #script_cleanup, #section_names_definitions, #section_names_refs_cleanup, #section_names_terms1_cleanup, #section_names_terms_cleanup, #sections_clausebefore_cleanup, #sections_cleanup, #sections_level_cleanup, #sections_names_cleanup, #sections_names_pref_cleanup, #sections_order_cleanup, #sections_variant_title_cleanup, #select_docid, #set_title_with_footnotes, #single_clause_annex, #single_subfigure_cleanup, #smartquotes_cleanup, #smartquotes_cleanup1, #sort_biblio, #sourcecode_cleanup, #sourcecode_markup, #sources_table_cleanup, #split_termdefinitions, #strip_initial_space, #subfigure_cleanup, #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, #symbol_key, #symbols_cleanup, #table_cleanup, #table_footnote_number, #table_footnote_renumber, #table_footnote_renumber1, #term_children_cleanup, #term_defs_boilerplate, #term_defs_boilerplate_cont, #term_designation_redundant, #term_designation_reorder, #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_index_cleanup, #term_nonverbal_designations, #term_nonverbal_designations1, #term_termsource_to_designation, #term_to_letter_symbol, #termdef_boilerplate_cleanup, #termdef_boilerplate_climb_up, #termdef_boilerplate_insert, #termdef_boilerplate_insert1, #termdef_boilerplate_insert_location, #termdef_cleanup, #termdef_from_termbase, #termdef_remove_initial_paras, #termdef_stem_cleanup, #termdef_unnest_cleanup, #termdefinition_cleanup, #termdocsource_cleanup, #termdomain1_cleanup, #termdomain_cleanup, #termlookup_cleanup, #termnote_example_cleanup, #terms_subclause_type_tally, #terms_subclauses, #terms_terms_cleanup, #textcleanup, #title_footnote_move, #to_preface, #to_regex, #to_xreftarget, #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, #tq, #uninterrupt_quotes_around_xml, #uninterrupt_quotes_around_xml1, #uninterrupt_quotes_around_xml_skip, #unnumbered_blocks_cleanup, #unwrap_boilerplate_clauses, #uri_cleanup, #uri_component_encode, #valid_attachment?, #validate_ref_dl, #validate_ref_dl1, #variant_cleanup, #variant_cleanup1, #variant_space_cleanup, #verify_term_defs_source, #xml_unescape_mathml, #xref_alias, #xref_cleanup, #xref_cleanup1, #xref_compound_cleanup, #xref_compound_cleanup1, #xref_compound_wrapup, #xref_parse_compound_locations, #xref_to_eref, #xref_to_eref1, #xref_to_internal_eref, #xreftarget_cleanup, #yaml2relaton

Methods included from Utils

adoc2xml, #asciimath_key, #attr_code, #convert, #csv_split, #dl_to_attrs, #dl_to_elems, #document_ns_attributes, #grkletters, #isodoc, #kv_parse, #link_unwrap, #noko, #quoted_csv_split, #refid?, #term_expr, #to_xml, #wrap_in_para, #xml_encode

Methods included from Table

#table, #table_attrs

Methods included from Section

#abstract_parse, #acknowledgements_parse, #add_term_source, #add_term_source_mod, #annex_parse, #bibitem_parse, #biblio_prep, #bibliography_parse, #clause_parse, #emend_biblio, #emend_biblio_id, #emend_biblio_title, #emend_biblio_usrlbl, #extract_termsource_refs, #floating_title, #floating_title_attrs, #foreword_parse, #in_biblio?, #in_norm_ref?, #in_terms?, #indexsect_parse, #introduction_parse, #misccontainer_parse, #nonterm_symbols_parse, #nonterm_term_def_subclause_parse, #norm_ref_parse, #pop_symbols, #pop_term_def, #preamble, #preface_main_filter, #role_style, #scope_parse, #section, #section_attributes, #section_attributes_change, #sectiontype, #sectiontype1, #sectiontype_streamline, #set_obligation, #start_main_section, #stash_symbols, #stash_term_def, #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

Methods included from Blocks

#admonition, #admonition_alternatives, #admonition_attrs, #admonition_core_attrs, #admonition_name, #boilerplate_note, #default_requirement_model, #example, #example_attrs, #example_by_role, #example_proper, #example_to_requirement, #figure_attrs, #figure_example, #figure_title, #form, #form_attrs, #formula_attrs, #id_attr, #id_unnum_attrs, #image, #keep_attrs, #listing, #listing_attrs, #literal, #literal_attrs, #note, #note_attrs, #open, #para_attrs, #paragraph, #pass, #pseudocode_example, #quote, #quote_attribution, #quote_attrs, #reqt_subpart?, #requirement, #requirement_subpart, #requirement_validate, #select_requirement_model, #sidebar, #sidebar_attrs, #stem, #svgmap_attrs, #svgmap_example, #term_example, #termnote, #termnote_attrs, #todo, #todo_attrs

Methods included from Inline

#concatenate_attributes_to_xref_text, #hash2styles, #highlight_parse, #image_attributes, #image_attributes1, #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_quoted, #latex_parse, #latex_parse1, #page_break, #stem_attrs, #stem_parse, #thematic_break

Methods included from Refs

#analyse_ref_code, #analyse_ref_code_csv, #analyse_ref_code_csv_breakup, #analyse_ref_code_csv_map, #analyse_ref_code_nested, #analyse_ref_dropid, #analyse_ref_dual, #analyse_ref_hidden, #analyse_ref_localfile, #analyse_ref_nofetch, #analyse_ref_numeric, #analyse_ref_repo_path, #conditional_date, #docid, #docnumber, #docrelation_insert, #dual_entries, #fetch_ref, #fetch_ref1, #fetch_ref_async, #fetch_ref_async1, #fetch_ref_async_dual, #global_ievcache_name, #id_and_year, #init_bib_caches, #init_iev_caches, #iso_publisher, #isorefmatches2_1, #isorefmatches2code, #isorefmatches2out, #isorefmatches3_1, #isorefmatches3code, #isorefmatches3out, #isorefmatchescode, #isorefmatchesout, #isorefrender1, #joint_entries, #joint_entries_prep, #local_ievcache_name, #merge_docids, #merge_entries, #merge_publishers, #merge_urls, #mn_code, #no_year_generic_ref, #norm_year, #plaintxt, #ref_attributes, #ref_normalise, #ref_normalise_no_format, #reference, #reference1_matches, #reference1code, #reference1out, #reference_normalise, #reference_populate, #reference_queue, #references2xml, #references_fetch, #refitem1code, #refitem1yr, #refitem_render, #refitem_render1, #refitem_render_formattedref, #refitem_uri, #refitemcode, #refitemout, #set_date_range, #skip_docid, #smart_render_xml, #supply_ref_prefix, #unfetchable_ref_code?, #use_my_anchor, #use_retrieved_relaton

Methods included from Lists

#colist, #dd, #dl_attrs, #dlist, #dt, #li, #list_caption, #ol_attrs, #olist, #olist_style, #ul_attrs, #ul_li, #ul_li_attrs, #ulist

Methods included from Front

#committee_component, #copyright_parse, #datetypes, #default_publisher, #extract_org_attrs_address, #extract_org_attrs_complex, #metadata, #metadata_author, #metadata_classifications, #metadata_committee, #metadata_copyright, #metadata_date, #metadata_date1, #metadata_doctype, #metadata_ext, #metadata_getrelation, #metadata_getrelation1, #metadata_ics, #metadata_id, #metadata_id_build, #metadata_keywords, #metadata_language, #metadata_note, #metadata_other_id, #metadata_publisher, #metadata_relations, #metadata_script, #metadata_series, #metadata_source, #metadata_sponsor, #metadata_status, #metadata_subdoctype, #metadata_version, #org_abbrev, #org_address, #org_attrs_complex_parse, #org_attrs_parse, #org_attrs_simple_parse, #org_attrs_simple_parse_no_source, #org_contact, #org_contributor, #org_contributor_role, #org_logo, #org_organization, #organization, #person_address, #person_address_components, #person_affiliation, #person_credentials, #person_name, #person_org_logo, #person_organization, #personal_author, #personal_author1, #personal_contact, #personal_role, #relation_normalise, #relaton_relation_descriptions, #relaton_relations, #subdiv_build, #subdivision, #subdivision1, #title, #title_english, #title_otherlangs

Methods included from Base

#clean_abort, #clean_exit, #default_fonts, #doc_converter, #doc_extract_attributes, #doctype, #document, #document1, #document_scheme, #document_scheme_metadata, #draft?, #fonts_manifest_option, #front, #html_converter, #html_extract_attributes, #init, #init_bib_log, #init_biblio, #init_i18n, #init_image, #init_log, #init_math, #init_misc, #init_output, #init_processing, #init_reqt, #init_toc, #init_vars, #insert_xml_cr, #makexml, #makexml1, #metadata_attrs, #middle, #outputs, #pdf_converter, #pdf_extract_attributes, #presentation_xml_converter, #requirements_processor, #schema_version, #toc_default, #version, #xml_namespace, #xml_root_tag

Constructor Details

#initialize(backend, opts) ⇒ Converter

Returns a new instance of Converter.



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/metanorma/standoc/converter.rb', line 104

def initialize(backend, opts)
  super
  basebackend "html"
  outfilesuffix ".xml"
  @libdir = File.dirname(self.class::_file || __FILE__)
  @c = HTMLEntities.new
  unless opts && @log = opts[:document]&.options&.dig(:log)
    @log = Metanorma::Utils::Log.new
    @local_log = true
  end
end

Class Attribute Details

._fileObject

Returns the value of attribute _file.



117
118
119
# File 'lib/metanorma/standoc/converter.rb', line 117

def _file
  @_file
end

.embed_hdrObject

Returns the value of attribute embed_hdr.



117
118
119
# File 'lib/metanorma/standoc/converter.rb', line 117

def embed_hdr
  @embed_hdr
end

Class Method Details

.inherited(konv) ⇒ Object

rubocop:disable Lint/MissingSuper



120
121
122
# File 'lib/metanorma/standoc/converter.rb', line 120

def self.inherited(konv) # rubocop:disable Lint/MissingSuper
  konv._file = caller_locations(1..1).first.absolute_path
end

Instance Method Details

#content(node) ⇒ Object Also known as: embedded



129
130
131
# File 'lib/metanorma/standoc/converter.rb', line 129

def content(node)
  node.content
end

#html_doc_path(file) ⇒ Object

path to isodoc assets in child gems



125
126
127
# File 'lib/metanorma/standoc/converter.rb', line 125

def html_doc_path(file)
  File.join(@libdir, "../../isodoc/html", file)
end

#skip(node, name = nil) ⇒ Object Also known as: audio, video, inline_button, inline_kbd, inline_menu



133
134
135
136
137
138
# File 'lib/metanorma/standoc/converter.rb', line 133

def skip(node, name = nil)
  name = name || node.node_name
  w = "converter missing for #{name} node in Metanorma backend"
  @log.add("AsciiDoc Input", node, w, severity: 1)
  nil
end