tools

package
v5.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package tools provides visitors for external usage and will provide other tools one day.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeadingVisitor

func HeadingVisitor(ctx mycocontext.Context) (
	visitor func(block blocks.Block),
	result func() []blocks.Heading,
)

HeadingVisitor creates a visitor that visits all headings.

func LinkVisitor

func LinkVisitor(ctx mycocontext.Context) (
	visitor func(block blocks.Block),
	result func() []links.Link,
)

LinkVisitor creates a visitor which extracts all the links from the document in context.

We consider inline link, rocket link, image gallery and transclusion targets to be links.

func MigrateHeadings

func MigrateHeadings(old string) string

MigrateHeadings replaces all instances of the old heading syntax with the new one it can find in the given document and returns the modified version.

func MigrateRocketLinks(old string) string

MigrateRocketLinks replaces all instances of the old rocket link syntax with the new one it can find in the given document and returns the modified version.

func OpenGraphVisitors

func OpenGraphVisitors(ctx mycocontext.Context) (
	resultHTML func() string,
	descVisitor func(blocks.Block),
	imgVisitor func(blocks.Block),
)

OpenGraphVisitors returns visitors you should pass to BlockTree. They will figure out what should go to the final opengraph. Call resultHTML to get that result.

description is the first root paragraph of the document. If there is no such paragraph, the description is empty string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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