Web Page Summary Generator

This script runs locally or directly on the server and creates a static menu from the headers and subheads of the HTML page. This avoids tedious work.

For each title, it generates an identifier or takes into account any existing identifier, then builds a hierarchical menu from the headings and places links in the menu on the sections of the page.

You can change the page structure later and automatically refresh the menu .

Use

Scriptol syntax:

solp automenu [-hn] [path]filename

PHP syntax

php automenu.php [-hn] [path]filename

The option corresponds to the hierarchy level to be considered when building the menu. By default, the deepest level is h3, and you can specify from h2 to h6.

Control

The menu is presented in a set of fields with the caption "Summary." You can change this default label by changing the value of the legend variable in the source code:

text legend = "Summary"

In PHP code:

$legend="Summary"; 

To go further, for example, by replacing a set of fields with a layer or associating attributes with it, you need to edit the code in the main function.

How does it work

Creating a menu includes the following steps:

  1. Scan the page to identify previously used numbers so that you do not use the current number to generate an identifier.
  2. An identifier is generated and added to each header.
  3. The headers are retrieved from the page and placed in a table.
  4. From this table, the script builds a hierarchical menu with indents and links to text sections.
  5. This menu is placed after the <h1> tag. It can then be manually placed anywhere on the page.
  6. During the refresh, the menu changes at the same location .

Conditions and limitations

For best results, the page should be correctly formed with a header hierarchy (h1, h2, h3, etc.) that suits their purpose.
The result will be uncertain if these tags are used in sidebars or for purposes other than semantic structuring, which is a practice that should not be recommended.

Identifiers must have a tag name as a prefix. For example, h221, h322, etc. This is important for proper indentation. These names are automatically generated by the software if the identifier does not exist.

License and credits

The script, written by Denis Surot, is licensed under the GPL 3.0 license.

The script uses Jose Solorzano's Simple HTML parser (https://sourceforge.net/projects/php-html/). This parser is licensed under the MIT License.

Download

Download here: