Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samwho/anchorify
A simple Ruby script for automatically creating anchored headings and tables of contents in HTML documents.
https://github.com/samwho/anchorify
Last synced: about 2 months ago
JSON representation
A simple Ruby script for automatically creating anchored headings and tables of contents in HTML documents.
- Host: GitHub
- URL: https://github.com/samwho/anchorify
- Owner: samwho
- Created: 2011-08-01T01:13:12.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2011-08-01T17:41:21.000Z (over 13 years ago)
- Last Synced: 2024-10-14T20:43:29.358Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 97.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Anchorify
Anchorify is a simple script written in Ruby that parses an HTML
document to produce anchored headings and an optional table of contents.The script parses the input HTML document and searches for `` tags ("n" being a number from 1 to 6). It replaces these tags with an "anchored" version, like so:
```html
Hello, everybody!
# This gets changed to the following line
Hello, everybody!
```And the table of contents that goes with that would look like this:
```html
Hello, everybody!
```# Nested headings
For each new header level (`
`, `
` etc.), a new indented level is used
in the table of contents. For example:```html
Foo
Bar
Baz
Chunky Bacon
```Would generate a table of contents that looks like this:
```
Foo
Bar
Baz
Chunky Bacon
```# Installing
First of all, you need to make sure that you have Ruby and git installed
on your machine. To do this in Ubuntu, execute the following command:```
sudo apt-get install ruby git
```Then, nagivate to a directory you want to download the script to and
clone the git repo and make the script executable:```
git clone git://github.com/samwho/anchorify.git
cd anchorify
chmod +x anchorify
```# Usage
Using the script is easy. The only prerequisite is having ruby installed
on your system, then you just execute:```
anchorify example.html
```Where example.html is an HTML document. The output is printed to the
screen so if you want to save to another file you would do the following:```
anchorify example.html >> anchorified.html
```# Adding a table of contents
Adding a table of contents to your document is easy, simply put the pseudo
tag `` somewhere in your HTML document and the script will replace that
with the table of contents in the resulting HTML.