* *** CHKTAGSLINE_OVERVIEW TXT - 6 Aug 2025  12:24:56 - JGKNAUTH

The current file being edited should be the workfile set up by CHKTAGS.

Place the cursor at (1,1) and save the cursor numbers.

Check that cursor is really on a non-empty data line.

Initial checks.  (Call report for any errors.)
   ERROR: Mismatched bracket counts.
   ERROR: No "<" found.
   ERROR: Initial ">" before initial "<".

Loop thru line scanning for tags until no "<" is found.  (Call report for any errors.)
   Save tag's starting position in s_pos.
   Find next "<"; leave if none.
   Find next ">"; error if none.  ERROR: No matching ">" found
   Isolate found tag.
   ERROR: "<" within tag.
   ERROR: Blank right after tag's opening "<".
   Delete any trailing blanks from tag's inner text.
   Skip over any HTML comments: <!--...-->.  (iterate)
   ERROR: Tag contains multiple "/"s.
   ERROR: Tag is empty.  No cmd present.
   ERROR: "/" is misplaced or tag with "/" has extraneous text.
   Split any "/" from tag command and put at tag end as " />".
   ERROR: Tag cmd is not alphanumeric or contains a digit not in last place.

   Save first tag's position.
   Adjust s_pos to after ">" to prepare for seach for next tag.
   Skip over tag if it is <cmd ... />  (iterate).
      Record if it was the first tag found in the line.
   Update arrays:  Tag found, Tag position, Tag type (Start or End)

If appropriate, call report to note:
   Only <cmd ... /> tags found or No tags found.

Loop thru the TAGS array (and its parallel POSITION and TYPE arrays):
   If LIFO is empty:
      Set LIFO index (left) to 1.
      Set LIFO.1 entry to index of current tag in TAGS.
      Bump S or E count depending on type of current tag.
      Iterate
   If LIFO is not empty:
      Get the TAGS index recorded in last entry in LIFO.
      LIFO_tag = Uppercase the associated tag from TAGS.
      LOOP_tag = Uppercase the current tag from the TAGS loop (deleting "/" if present).
      If LIFO_tag is a Start tag and LOOP_tag *was* an End tag and LIFO_tag = LOOP_tag:
         Then delete (pop) the last array entry from LIFO and decrement the S count
         Else add (push) a new entry to LIFO, containing the LOOP_tag's index in TAGS and
              bump either the S or E count depending on the LOOP_tag type (before "/" was deleted).


--------------------------------  Process final results  ---------------------------------

When LIFO is empty
   Call report [brief report]:  No HTML tag problems were found.
   endrc = 0

When only one entry remains in LIFO:
   If E count = 0 (S count = 1):
      Prepare an appropriate end tag and save it via EDITV.
      Call report [brief report]:  An {end tag} will be appended.
      endrc = 1
   If E count = 1 (S count = 0):
      Call report:  There is one unpaired {end tag}.
      Call report:  Cannot be corrected with an append.
      endrc = 188
   Place cursor at entry position.

When more than on entry is in LIFO:
   Increase MSGLINE settings to handle the messages to come.
   Loop thru LIFO and call report with a message for each referenced tag from TAGS:
      Display tag position and tag: <cmd> or </cmd>.
      Save position of last tag encountered.
      Call report:  Blank separator line
   Save in restart_line the file line number of last message line output to file

   If E count = 0 (only start tags are not matched):
      Build an appropriate end tag for the last tag referenced by LIFO, which must be a start tag.
      Save in via EDITV.
      Call report:  An {end tag} will be appended to pair with the {start tag}.
      Call report:  At least one more start tag exists that can be paired with another invocation.
      Place cursor at entry position.
      endrc = 2

   If E count > 0:
      Find the first end tag left in LIFO
         (the original problem tag -- could never be matched).
      Build a matching start tag for the message.
      Call report:  An {end-tag} has no preceding {start tag}.
      Call report:  Cannot be corrected with an append.
      Place cursor at entry position.
      endrc = 888

   Restore MSGLINE settings.

KEDIT workfile
TOP


----------------------------------------  report  ----------------------------------------

SET COLOR HIGHLIGHT

Split "EMSG" or "MSG" from input

Set current focus line number
   Use start_msg_line if this is the first non-brief message.
   Otherwise use line number where last non-brief message was recorded.

If brief report, save message via EDITV.

If not brief report, add message line to workfile.
   INPUT the message after the last one written to the file
      (or after start_msg_line if this is the first message).
   Save its file line number.
   LOCATE start_msg_line (top of block to be highlighted) and mark it.
   Locate save file line number and go down one further.
   Mark that line.
   Go up one line to restore the "last line written" focus location.
   Use TAG to highlight the marked line block.
   Use RESET BLOCK to turn off the black marked-block coloring.

Turn on insert mode for better cursor visibility.
Return
