transformer

package
v0.4.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnvMatcher = regexp.MustCompile(`(\$[A-Z0-9_]+)`)

Functions

func ConvertTextForSubenv

func ConvertTextForSubenv(node goldast.Node, reader goldtext.Reader, treatments *Treatment)

func FindEndOfSection

func FindEndOfSection(startNode *goldast.Heading) goldast.Node

Given the startNode (being the section node itself), returns the node which terminates the section.

func NewRundownASTTransformer

func NewRundownASTTransformer() parser.ASTTransformer

Rundown AST Transformer converts Rundown Elements in the markdown tree into proper rundown nodes, and applies any effects.

func PopulateSectionMetadata

func PopulateSectionMetadata(start *ast.SectionPointer, end *ast.SectionEnd, reader goldtext.Reader)

Types

type GatherProcessor

type GatherProcessor struct {
	// contains filtered or unexported fields
}

func NewGatherProcessor

func NewGatherProcessor(replacingNode goldast.Node, newNode goldast.Node) *GatherProcessor

Gathers nodes directly descending from replacingNode and putting them into newNode. If newNode is nil, then replacingNode and all children are deleted instead.

func (*GatherProcessor) Begin

func (p *GatherProcessor) Begin(openingTag *RundownHtmlTag)

func (*GatherProcessor) End

func (p *GatherProcessor) End(node goldast.Node, reader goldtext.Reader, openingTag *RundownHtmlTag, treatments *Treatment) bool

func (*GatherProcessor) Process

func (p *GatherProcessor) Process(node goldast.Node, reader goldtext.Reader, treatments *Treatment) bool

type NodeProcessor

type NodeProcessor interface {
	Begin(openingTag *ast.RundownBlock)

	// Process a Markdown Node. Returns true to indicate the processor is done and should be removed.
	Process(node goldast.Node, reader goldtext.Reader, treatments *Treatment) bool

	// Indicates to the processor it should end itself.
	End(node goldast.Node, reader goldtext.Reader, treatments *Treatment)
}

NodeProcessors allow us to apply effects to subsequent nodes or "child" nodes of a Rundown tag.

func ConvertToRundownNode

func ConvertToRundownNode(node *ast.RundownBlock, reader goldtext.Reader, treatments *Treatment) NodeProcessor

type OpenTags

type OpenTags struct {
	// contains filtered or unexported fields
}

type RundownHtmlTag

type RundownHtmlTag struct {
	// contains filtered or unexported fields
}

func ExtractRundownElement

func ExtractRundownElement(node goldast.Node, reader goldtext.Reader, currentTag string) *RundownHtmlTag

type SectionProcessor

type SectionProcessor struct {
	SectionPointer *ast.SectionPointer
	// contains filtered or unexported fields
}

SectionProcessor inserts a SectionEndPointer at the end of a section. Sections defined on a heading are terminated at the next heading of equal or structurally higher level. Sections defined as being wrapped inside a rundown tag are terminated at the end of the rundown tag.

func (*SectionProcessor) Begin

func (p *SectionProcessor) Begin(openingTag *RundownHtmlTag)

func (*SectionProcessor) End

func (p *SectionProcessor) End(node goldast.Node, reader goldtext.Reader, openingTag *RundownHtmlTag, treatments *Treatment) bool

func (*SectionProcessor) Process

func (p *SectionProcessor) Process(node goldast.Node, reader goldtext.Reader, treatments *Treatment) bool

type SubEnvProcessor

type SubEnvProcessor struct {
	// contains filtered or unexported fields
}

SubEnv Processor replaces all mentions of $ENV_VAR with a EnvironmentSubstitution node.

func (*SubEnvProcessor) Begin

func (p *SubEnvProcessor) Begin(node *ast.RundownBlock)

func (*SubEnvProcessor) End

func (p *SubEnvProcessor) End(node goldast.Node, reader goldtext.Reader, treatments *Treatment) bool

func (*SubEnvProcessor) Process

func (p *SubEnvProcessor) Process(node goldast.Node, reader goldtext.Reader, treatments *Treatment) bool

type Treatment

type Treatment struct {
	// contains filtered or unexported fields
}

Treatment is used to indicate a node should be modified, but batches these modifications for after we've walked the AST, otherwise the walker gets confused.

func NewTreatment

func NewTreatment(reader goldtext.Reader) *Treatment

func (*Treatment) AppendChild

func (t *Treatment) AppendChild(parent goldast.Node, child goldast.Node)

func (*Treatment) DissolveRundownBlock

func (t *Treatment) DissolveRundownBlock(block goldast.Node)

Deletes a rundown block, moving it's children into it's parent.

func (*Treatment) Ignore

func (t *Treatment) Ignore(nodeToIgnore goldast.Node)

func (*Treatment) IsIgnored

func (t *Treatment) IsIgnored(nodeInQuestion goldast.Node) bool

func (*Treatment) NewNodes

func (t *Treatment) NewNodes() []goldast.Node

Returns the newly added nodes since the last call.

func (*Treatment) Process

func (t *Treatment) Process(reader goldtext.Reader)

func (*Treatment) Remove

func (t *Treatment) Remove(nodeToRemove goldast.Node) goldast.Node

Remove a node. Returns what the next node will be after this node is removed.

func (*Treatment) Replace

func (t *Treatment) Replace(nodeToReplace goldast.Node, replacement goldast.Node)

func (*Treatment) ReplaceWithChildren

func (t *Treatment) ReplaceWithChildren(nodeToReplace goldast.Node, replacement goldast.Node, nodeWithChildren goldast.Node)

Replaces the node, and adds children to it from the given node.

Jump to

Keyboard shortcuts

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