Computes table of contents of a html page using h1 and h2 tags - 2018, go
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
Thierry 36e9fb4813 Add details to README 5 lat temu
src Add details to README 5 lat temu
.gitignore Add details to README 5 lat temu
README Add details to README 5 lat temu
config.yml Add details to README 5 lat temu
config.yml.dist Add details to README 5 lat temu

README

Adds a toc (table of contents) to html pages.
Uses h1 and h2 tags.

h1 tags can have embedded a name tags
h2 tags are supposed to contain only text
Developed to learn go

SUMMARY
For a brief description of options :
pagetoc -help

Options can either come from command line or from a configuration file

1. Taking parameters from config files :
pagetoc -config test1
will use the parameters defined in section "test1"

2. Using command line arguments :
pagetoc -dir /path/to/html/files -excludes page1.html:page2.html


DETAILED USAGE

Configuration file is expressed using yaml syntax ; must be called "config.yml"
It is organized in different sections.
Each section contains the values of options.
Example of a section :

test1:
dir: /path/to/dir/containing/html/files
excludes:
- file1.html
- file2.html
toc-css-class: toc
insert-after: </center>
action: save
create-backup: true

To run the program using the options of section "test1" :
pagetoc -config test1

Option "action"
- "save" will generate toc and override the original document ; see also "backup" option.
- "print-toc" will print the generated table of contents for each processed html document ; original documents not modified.
- "print-full" will print the generated html for each processed html document ; original documents not modified.
- "none" : does not modify the documents, just prints a list of processed files.

Options "dir" and "file"
One of these two options must be specified, but not both.
They must contain absolute paths.
If option "dir" is specified, all the .html files located in the directory will be processed.
If option "file" is specified, only one file will be processed.

Option "excludes"
Only relevant if "dir" option is used.

TODO
- ReplaceAllString inappropriate, only one string should be replaced
- replace 0644 by original filemode when re-writing files
- change option mechanism : when config is used with other options,
options should be taken from config
and the other options should override them