Computes table of contents of a html page using h1 and h2 tags - 2018, go
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
Thierry 36e9fb4813 Add details to README 4年前
src Add details to README 4年前
.gitignore Add details to README 4年前
README Add details to README 4年前
config.yml Add details to README 4年前
config.yml.dist Add details to README 4年前


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

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


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 :

dir: /path/to/dir/containing/html/files
- 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.

- 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