LP#1848524: AsciiDoc HEADING CONVERSION
authorRemington Steed <rjs7@calvin.edu>
Thu, 5 Dec 2019 13:48:48 +0000 (08:48 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 4 Sep 2020 20:38:31 +0000 (16:38 -0400)
commitf77d39f111c73a88900c44bbe2e11b7970a9e33a
tree517097a7c892bf7816b1a1785ca85496e4505a5c
parent49debf2c5c2999455fc9c9404ad1b6015f42a399
LP#1848524: AsciiDoc HEADING CONVERSION

This commit changes all headings from two-line style to prefix/suffix
style. (For now, we're only doing this in the docs using Antora.) Example:

Heading 1
=========

becomes

= Heading 1 =

This conversion makes it much easier to adjust the heading levels of
several files which were previously included using the 'leveloffset'
command.

NOTE: Only the prefix is required, but we felt the suffix improves
readability of the source.

Below is the python script I used to do the conversion. It is slightly
modified from a script used by ___ here:

https://github.com/JanusGraph/janusgraph/pull/115/commits/dc67ce73c08e79fa65b30bc8280861056070c573

Here's my source:

import re
import sys

def main(argv):
    #http://asciidoctor.org/docs/asciidoc-recommended-practices/#section-titles
    patterns = [
        (re.compile('^=+$'), '='),
        (re.compile('^-+$'), '=='),
        (re.compile('^~+$'), '==='),
        (re.compile('^\^+$'), '===='),
        (re.compile('^\++$'), '====='),
    ]

    with open(argv[1], 'r') as input_file:
        prev_line = None
        curr_line = None
        for line in input_file.readlines():
            prev_line = curr_line
            curr_line = line

            if prev_line is None:
                continue

            for pattern, heading in patterns:
                if pattern.match(curr_line) and len(prev_line) == len(curr_line):
                    # remove newline so we can append suffix to heading
                    prev_line = prev_line.rstrip()
                    sys.stdout.write('%s %s %s\n' % (heading, prev_line, heading))
                    prev_line = None
                    curr_line = None
                    break

            if prev_line is not None:
                sys.stdout.write(prev_line)

        # end for
        if curr_line is not None:
            sys.stdout.write(curr_line)

    # end with

if __name__ == '__main__':
    main(sys.argv)

Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
176 files changed:
docs-antora/modules/acquisitions/pages/blanket.adoc
docs-antora/modules/acquisitions/pages/introduction.adoc
docs-antora/modules/acquisitions/pages/invoices.adoc
docs-antora/modules/acquisitions/pages/purchase_requests_management.adoc
docs-antora/modules/acquisitions/pages/purchase_requests_patron_view.adoc
docs-antora/modules/acquisitions/pages/receive_items_from_invoice.adoc
docs-antora/modules/acquisitions/pages/selection_lists_po.adoc
docs-antora/modules/acquisitions/pages/vandelay_acquisitions_integration.adoc
docs-antora/modules/admin/pages/Best_Hold_Selection_Sort_Order.adoc
docs-antora/modules/admin/pages/MARC_Import_Remove_Fields.adoc
docs-antora/modules/admin/pages/MARC_RAD_MVF_CRA.adoc
docs-antora/modules/admin/pages/Org_Unit_Proximity_Adjustments.adoc
docs-antora/modules/admin/pages/SMS_messaging.adoc
docs-antora/modules/admin/pages/acquisitions_admin.adoc
docs-antora/modules/admin/pages/actiontriggers.adoc
docs-antora/modules/admin/pages/actiontriggers_process.adoc
docs-antora/modules/admin/pages/age_hold_protection.adoc
docs-antora/modules/admin/pages/aged_circs.adoc
docs-antora/modules/admin/pages/allowed_payments.adoc
docs-antora/modules/admin/pages/apache_access_handler.adoc
docs-antora/modules/admin/pages/apache_rewrite_tricks.adoc
docs-antora/modules/admin/pages/audio_alerts.adoc
docs-antora/modules/admin/pages/authentication_proxy.adoc
docs-antora/modules/admin/pages/authorities.adoc
docs-antora/modules/admin/pages/auto_suggest_search.adoc
docs-antora/modules/admin/pages/autorenewals.adoc
docs-antora/modules/admin/pages/backups.adoc
docs-antora/modules/admin/pages/booking-admin.adoc
docs-antora/modules/admin/pages/circing_uncataloged_materials.adoc
docs-antora/modules/admin/pages/circulation_limit_groups.adoc
docs-antora/modules/admin/pages/closed_dates.adoc
docs-antora/modules/admin/pages/cn_prefixes_and_suffixes.adoc
docs-antora/modules/admin/pages/copy_locations.adoc
docs-antora/modules/admin/pages/copy_statuses.adoc
docs-antora/modules/admin/pages/copy_tags_admin.adoc
docs-antora/modules/admin/pages/desk_payments.adoc
docs-antora/modules/admin/pages/ebook_api.adoc
docs-antora/modules/admin/pages/ebook_api_service.adoc
docs-antora/modules/admin/pages/emergency_closing_handler.adoc
docs-antora/modules/admin/pages/floating_groups.adoc
docs-antora/modules/admin/pages/hold_driven_recalls.adoc
docs-antora/modules/admin/pages/hold_targeter_service.adoc
docs-antora/modules/admin/pages/hours.adoc
docs-antora/modules/admin/pages/infrastructure_auth_browse.adoc
docs-antora/modules/admin/pages/librarysettings.adoc
docs-antora/modules/admin/pages/lsa-address_alert.adoc
docs-antora/modules/admin/pages/lsa-barcode_completion.adoc
docs-antora/modules/admin/pages/lsa-standing_penalties.adoc
docs-antora/modules/admin/pages/lsa-statcat.adoc
docs-antora/modules/admin/pages/lsa-work_log.adoc
docs-antora/modules/admin/pages/marc_templates.adoc
docs-antora/modules/admin/pages/multilingual_search.adoc
docs-antora/modules/admin/pages/patron_address_by_zip_code.adoc
docs-antora/modules/admin/pages/patron_registration.adoc
docs-antora/modules/admin/pages/patron_self_registration.adoc
docs-antora/modules/admin/pages/permissions.adoc
docs-antora/modules/admin/pages/phonelist.adoc
docs-antora/modules/admin/pages/physical_char_wizard_db.adoc
docs-antora/modules/admin/pages/popularity_badges_web_client.adoc
docs-antora/modules/admin/pages/purge_holds.adoc
docs-antora/modules/admin/pages/purge_user_activity.adoc
docs-antora/modules/admin/pages/qstore_service.adoc
docs-antora/modules/admin/pages/receipt_template_editor.adoc
docs-antora/modules/admin/pages/restrict_Z39.50_sources_by_perm_group.adoc
docs-antora/modules/admin/pages/schema_bibliographic.adoc
docs-antora/modules/admin/pages/search_interface.adoc
docs-antora/modules/admin/pages/search_settings_web_client.adoc
docs-antora/modules/admin/pages/security.adoc
docs-antora/modules/admin/pages/sip_privacy.adoc
docs-antora/modules/admin/pages/sip_server.adoc
docs-antora/modules/admin/pages/sitemap_admin.adoc
docs-antora/modules/admin/pages/staff_client-column_picker.adoc
docs-antora/modules/admin/pages/staff_client-recent_searches.adoc
docs-antora/modules/admin/pages/staff_client-return_to_results_from_marc.adoc
docs-antora/modules/admin/pages/staff_from_command_line.adoc
docs-antora/modules/admin/pages/template_toolkit.adoc
docs-antora/modules/admin/pages/user_activity_type.adoc
docs-antora/modules/admin/pages/virtual_index_defs.adoc
docs-antora/modules/admin/pages/web-client-browser-best-practices.adoc
docs-antora/modules/admin/pages/web_client-login.adoc
docs-antora/modules/admin/pages/workstation_admin.adoc
docs-antora/modules/admin/partials/turn-off-print-headers-chrome.adoc
docs-antora/modules/admin/partials/turn-off-print-headers-firefox.adoc
docs-antora/modules/admin_initial_setup/pages/borrowing_items.adoc
docs-antora/modules/admin_initial_setup/pages/describing_your_organization.adoc
docs-antora/modules/admin_initial_setup/pages/describing_your_people.adoc
docs-antora/modules/admin_initial_setup/pages/designing_your_catalog.adoc
docs-antora/modules/admin_initial_setup/pages/different_styles_for_searchbar.adoc
docs-antora/modules/admin_initial_setup/pages/hard_due_dates.adoc
docs-antora/modules/admin_initial_setup/pages/importing_via_staff_client.adoc
docs-antora/modules/admin_initial_setup/pages/migrating_patron_data.adoc
docs-antora/modules/admin_initial_setup/pages/migrating_your_data.adoc
docs-antora/modules/admin_initial_setup/pages/ordering_materials.adoc
docs-antora/modules/admin_initial_setup/pages/troubleshooting_tpac.adoc
docs-antora/modules/cataloging/pages/MARC_Editor.adoc
docs-antora/modules/cataloging/pages/MARC_batch_edit.adoc
docs-antora/modules/cataloging/pages/authorities.adoc
docs-antora/modules/cataloging/pages/batch_importing_MARC.adoc
docs-antora/modules/cataloging/pages/cataloging_electronic_resources.adoc
docs-antora/modules/cataloging/pages/conjoined_items.adoc
docs-antora/modules/cataloging/pages/copy-buckets_web_client.adoc
docs-antora/modules/cataloging/pages/holdings_editor_hide_fields.adoc
docs-antora/modules/cataloging/pages/holdings_templates.adoc
docs-antora/modules/cataloging/pages/item_status.adoc
docs-antora/modules/cataloging/pages/item_tags_cataloging.adoc
docs-antora/modules/cataloging/pages/link_checker.adoc
docs-antora/modules/cataloging/pages/marc_tag_table.adoc
docs-antora/modules/cataloging/pages/merge_overlay_bibs.adoc
docs-antora/modules/cataloging/pages/monograph_parts.adoc
docs-antora/modules/cataloging/pages/overlay_record_3950_import.adoc
docs-antora/modules/cataloging/pages/physical_char_wizard.adoc
docs-antora/modules/cataloging/pages/record_buckets.adoc
docs-antora/modules/cataloging/pages/specific_variable_fields.adoc
docs-antora/modules/cataloging/pages/tpac_copy_edit_links.adoc
docs-antora/modules/cataloging/pages/volcopy_editor.adoc
docs-antora/modules/cataloging/pages/z39.50_search_enhancements.adoc
docs-antora/modules/circulation/pages/advanced_holds.adoc
docs-antora/modules/circulation/pages/basic_holds.adoc
docs-antora/modules/circulation/pages/booking.adoc
docs-antora/modules/circulation/pages/circulating_items_web_client.adoc
docs-antora/modules/circulation/pages/circulation_patron_records_web_client.adoc
docs-antora/modules/circulation/pages/offline_circ_webclient.adoc
docs-antora/modules/circulation/pages/self_check.adoc
docs-antora/modules/circulation/pages/self_check_configuration.adoc
docs-antora/modules/circulation/pages/triggered_events.adoc
docs-antora/modules/circulation/pages/user_buckets.adoc
docs-antora/modules/development/pages/data_opensearch.adoc
docs-antora/modules/development/pages/data_supercat.adoc
docs-antora/modules/development/pages/data_unapi.adoc
docs-antora/modules/development/pages/pgtap.adoc
docs-antora/modules/development/pages/support_scripts.adoc
docs-antora/modules/development/pages/updating_translations_launchpad.adoc
docs-antora/modules/installation/pages/edi_setup.adoc
docs-antora/modules/installation/pages/server_installation.adoc
docs-antora/modules/installation/pages/server_upgrade.adoc
docs-antora/modules/installation/pages/system_requirements.adoc
docs-antora/modules/opac/pages/advanced_features.adoc
docs-antora/modules/opac/pages/batch_actions_from_search.adoc
docs-antora/modules/opac/pages/catalog_browse.adoc
docs-antora/modules/opac/pages/kids_opac.adoc
docs-antora/modules/opac/pages/linked_libraries.adoc
docs-antora/modules/opac/pages/my_account.adoc
docs-antora/modules/opac/pages/my_lists.adoc
docs-antora/modules/opac/pages/new_skin_customizations.adoc
docs-antora/modules/opac/pages/opensearch.adoc
docs-antora/modules/opac/pages/search_form.adoc
docs-antora/modules/opac/pages/search_url.adoc
docs-antora/modules/opac/pages/sitemap.adoc
docs-antora/modules/opac/pages/tpac_meta_record_holds.adoc
docs-antora/modules/opac/pages/using_the_public_access_catalog.adoc
docs-antora/modules/opac/pages/visibility_on_the_web.adoc
docs-antora/modules/reports/pages/reporter_add_data_source.adoc
docs-antora/modules/reports/pages/reporter_cloning_shared_templates.adoc
docs-antora/modules/reports/pages/reporter_create_templates.adoc
docs-antora/modules/reports/pages/reporter_daemon.adoc
docs-antora/modules/reports/pages/reporter_export_usingpgAdmin.adoc
docs-antora/modules/reports/pages/reporter_folder.adoc
docs-antora/modules/reports/pages/reporter_generating_reports.adoc
docs-antora/modules/reports/pages/reporter_running_recurring_reports.adoc
docs-antora/modules/reports/pages/reporter_template_enhancements.adoc
docs-antora/modules/reports/pages/reporter_template_terminology.adoc
docs-antora/modules/reports/pages/reporter_view_output.adoc
docs-antora/modules/serials/pages/A-intro.adoc
docs-antora/modules/serials/pages/B-serials_admin.adoc
docs-antora/modules/serials/pages/C-serials_workflow.adoc
docs-antora/modules/serials/pages/D-Receiving.adoc
docs-antora/modules/serials/pages/E-routing_lists.adoc
docs-antora/modules/serials/pages/F-Special_issue.adoc
docs-antora/modules/serials/pages/G-binding.adoc
docs-antora/modules/serials/pages/Group_Serials_Issues_in_the_OPAC_2.2.adoc
docs-antora/modules/serials/pages/H-holdings_statements.adoc
docs-antora/modules/shared/pages/about_evergreen.adoc
docs-antora/modules/shared/pages/about_this_documentation.adoc
docs-antora/modules/shared/pages/attributions.adoc
docs-antora/modules/shared/pages/end_matter.adoc
docs-antora/modules/shared/pages/workstation_settings.adoc