package tools

import "git.sr.ht/~bouncepaw/mycomarkup/v5/tools"

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

Index

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.

Source Files

heading_visitor.go linkvisitor.go migrate_headings.go migrate_rocket_links.go opengraph.go

Version
v5.6.0 (latest)
Published
Nov 29, 2023
Platform
linux/amd64
Imports
8 packages
Last checked
16 hours ago

Tools for package owners.