Documentation
¶
Index ¶
Constants ¶
const MaxBlocksPerUpdate = 100
MaxBlocksPerUpdate is the maximum number of blocks that can be added in a single request.
See https://developers.notion.com/reference/patch-block-children
const MaxNestedBlockLevelsPerUpdate = 2
MaxNestedBlockLevelsPerUpdate is the maximum number of nesting levels that can be added in a single request.
See https://developers.notion.com/reference/patch-block-children
const MaxRichTextContentLength = 2000
MaxRichTextContentLength is the maximum length of a single rich text content object. See https://developers.notion.com/reference/request-limits#limits-for-property-values
Variables ¶
var ErrDiscardLink = errors.New("discard link")
Functions ¶
func IsDangerousURL ¶
IsDangerousURL returns true if the given url seems a potentially dangerous url, otherwise false. Copied from https://sourcegraph.com/github.com/yuin/goldmark/-/blob/renderer/html/html.go?L997
func NewNodeRenderer ¶
func NewNodeRenderer(ctx context.Context, block BlockUpdater, opts ...Option) goldmark.NodeRenderer
NewNodeRenderer returns a new NodeRenderer that ingests Markdown and applies converted Notion blocks to BlockUpdater.
Callers that just want to process Markdown should use markdown.NewProcessor instead.
Types ¶
type BlockUpdater ¶
type BlockUpdater interface { // AddChildren should add the given children to the desired parent block. // // The caller calls it while respecting MaxBlocksPerUpdate and // MaxRichTextContentLength - implementations can assume the set of children // being added is of a reasonable size and adhere's to Notion's API limits. AddChildren(ctx context.Context, children []notionapi.Block) error }
BlockUpdater implements the desired handling for Notion blocks converted from Markdown. It should represent a single parent block, to which all children are added.
type DiscardLinkResolver ¶
type DiscardLinkResolver struct{}
DiscardLinkResolver discards all links, using ErrDiscardLink to indicate all links should be rendered as plain text.
func (DiscardLinkResolver) ResolveLink ¶
func (DiscardLinkResolver) ResolveLink(link string) (string, error)
type LinkResolver ¶
type LinkResolver interface { // ResolveLink accepts a link and returns it as-is or modified as desired, // for example to resolve an appropriate absolute link to the relevant // resource (e.g. another Notion document or a blob view). // // If ErrDiscardLink is returned, the link is converted into a plain text // element. ResolveLink(link string) (string, error) }
LinkResolver can be implemented to modify Markdown links.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option applies configuration of the renderer. It is intentionally unexported such that only this package can export Options.
func WithDebugHandler ¶
func WithLinkResolver ¶
func WithLinkResolver(links LinkResolver) Option
WithLinkResolver configures a LinkResolver to use. Otherwise, a default no-op one is used that uses links as-is.