#!/usr/bin/perl # Copyright 2022 Jeffrey Kegler # This file is part of Marpa::R2. Marpa::R2 is free software: you can # redistribute it and/or modify it under the terms of the GNU Lesser # General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # Marpa::R2 is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser # General Public License along with Marpa::R2. If not, see # http://www.gnu.org/licenses/. =head1 Name html_fmt - Reformat HTML, indented according to structure =head1 Synopsis =for Marpa::R2::Display ignore: 1 html_fmt [--avoid-whitespace=[yes|comment|no]] [--no-ws-ok-before-end-tag|--no-ws-ok-before-end-tag] [--no-ws-ok-after-start-tag|--no-ws-ok-after-start-tag] [--added-tag-comment|--no-added-tag-comment] [uri|file] =for Marpa::R2::Display::End =head1 Description Writes its input to C, reformatted and indented according to the HTML structure. With no arguments, C looks for its input on C. If it has an argument that looks like a URI, C treats that argument as a URI. If it has an argument that does not look like a URI, C uses that argument as the name of its input file. C considers its argument to "look like a URI", if it starts with alphanumerics followed by a colon. When reformatting and indenting, C takes measures to avoid introducing whitespace that will affect the way in which the HTML displays. The standards differ on whitespace treatment; when the standards agree they often allow considerable latitude to the browsers; and specific implementions will exploit the allowed latitude in different ways, or exceed it. All of which is to say that C's attempts to avoid introducing whitespace are not always successful. C supplies missing start and end tags. If C cannot find required start and end tags, it supplies them. C's grammar is very liberal in its interpretation of what is valid HTML. Finally, if this is not sufficient to turn the input into valid HTML, C will treat problem sections of the input as noise or "cruft", ignoring them in determining the structure of the document. C never rejects its input, whatever its contents. When C adds a missing start tag, it follows the new start tag with a comment. When C adds a missing end tag, it preceeds the new end tag with a comment. When C classifies characters as "cruft", it adds a comment to that effect before the "cruft". C
 and C