htmlsync

command module
v0.0.0-...-a52fbc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 11 Imported by: 0

README

HTMLsync

HTMLsync is a tool that managed all the HTML section, header and footer elements in a HTML directory, keeping them in sync as you work.

When HTMLsync is first executed in a HTML directory, it adds a hash attribute to these elements, and adds id attributes if not present.

After editing HTML, when HTMLsync is re-run, it identifies which elements have changed due to a hash mismatch, and updates elements with the same id. Where multiple sections have changed, it prompts the user which section should be used.

How to use it

  1. First build it:
    $ git clone https://github.com/dblueman/htmlsync
    $ cd htmlsync
    $ go install
    
  2. [optional] Run HTMLsync from a directory of HTML files to initially reflow the HTML:
    $ cd webroot
    $ htmlsync --reformat
    
  3. After editing one or more HTML section, header or footer elements, propagate change to all files:
    $ htmlsync
    
  4. HTMLsync will ask you to select which HTML section where there are multiple unique ones

How it works

  1. HTMLsync traverses all HTML files recursively, identifying HTML section, header and footer elements (sections)
  2. It builds a global list of sections, storing hash, id and node pointer
  3. A data-htmlsync hash attrbute is added to each section (id and hash are skipped during hash calculation)

If --reformat was used:

  1. sections with same hash are updated with the same id
  2. sections with different hash but same id are given unique id

otherwise:

  1. sections with same id are iterated
  2. if more than one has been updated (new hash != old hash), ask used which section to use
  3. update all sections with the chosen section
  4. a list of sections ids is shown across all files
  5. all HTML files are rewritten

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL