html_toc

package module
v0.0.0-...-43132bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2022 License: GPL-2.0 Imports: 2 Imported by: 0

README

Go HTML TOC

DISCLAIMER: This script doesn't handle correctly headings that contains other tags. It is made to work only on plain headings that's created by a rich text or markdown editor.

Extracts relevant table of contents data out of your HTML markup and add permalinks to your markup's headings.

Takes your HTML markup, outputs a string in JSON format of the relevant data (level, content and slug) and inserts permalinks to the markup's headings.

Found bugs?

Please contact me at at@aranggitoar.com.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSamePageSlug

func CreateSamePageSlug(s string) string

CreateSamePageSlug creates slug out of a title.

func CreateTOC

func CreateTOC(s string) (string, string)

TODO: Separate the anchor tag (for permalink) insertion logic. CreateTOC creates a table of contents out of the markup and a markup with permalink on the headings. Returns the table of contents in a JSON format and the edited markup.

func InsertAnchorTag

func InsertAnchorTag(s string) string

InsertAnchorTag inserts anchor tags inside a heading.

func RemoveAnchorTag

func RemoveAnchorTag(s string) string

RemoveAnchorTag removes anchor tags inside a heading.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL