Documentation ¶
Overview ¶
Package adf translates Atlassian Document Format (ADF) to other formats like markdown.
See: https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/
Index ¶
- Constants
- func IsChildNode(identifier NodeType) bool
- func IsParentNode(identifier NodeType) bool
- type ADF
- type Connector
- type JiraMarkdownTranslator
- type MarkNode
- type MarkdownTranslator
- type MarkdownTranslatorOption
- type Node
- type NodeType
- type NodeValue
- type TagCloser
- type TagOpener
- type TagOpenerCloser
- type Translator
Constants ¶
const ( NodeTypeParent = NodeType("parent") NodeTypeChild = NodeType("child") NodeTypeUnknown = NodeType("unknown") NodeBlockquote = NodeType("blockquote") NodeBulletList = NodeType("bulletList") NodeCodeBlock = NodeType("codeBlock") NodeHeading = NodeType("heading") NodeOrderedList = NodeType("orderedList") NodePanel = NodeType("panel") NodeParagraph = NodeType("paragraph") NodeTable = NodeType("table") NodeMedia = NodeType("media") ChildNodeText = NodeType("text") ChildNodeListItem = NodeType("listItem") ChildNodeTableRow = NodeType("tableRow") ChildNodeTableHeader = NodeType("tableHeader") ChildNodeTableCell = NodeType("tableCell") InlineNodeCard = NodeType("inlineCard") InlineNodeEmoji = NodeType("emoji") InlineNodeMention = NodeType("mention") InlineNodeHardBreak = NodeType("hardBreak") MarkEm = NodeType("em") MarkLink = NodeType("link") MarkCode = NodeType("code") MarkStrike = NodeType("strike") MarkStrong = NodeType("strong") )
Node types.
Variables ¶
This section is empty.
Functions ¶
func IsChildNode ¶
IsChildNode checks if the node is a child node.
func IsParentNode ¶
IsParentNode checks if the node is a parent node.
Types ¶
type ADF ¶
type ADF struct { Version int `json:"version"` DocType string `json:"type"` Content []*Node `json:"content"` }
ADF is an Atlassian document format object.
func (*ADF) ReplaceAll ¶
ReplaceAll replaces all occurrences of an old string in a text node with a new one.
type Connector ¶
type Connector interface { GetType() NodeType GetAttributes() interface{} }
Connector is a connector interface.
type JiraMarkdownTranslator ¶
type JiraMarkdownTranslator struct {
*MarkdownTranslator
}
JiraMarkdownTranslator is a jira markdown translator.
func NewJiraMarkdownTranslator ¶
func NewJiraMarkdownTranslator() *JiraMarkdownTranslator
NewJiraMarkdownTranslator constructs jira markdown translator.
func (*JiraMarkdownTranslator) Close ¶
func (tr *JiraMarkdownTranslator) Close(n Connector) string
Close implements TagCloser interface.
type MarkNode ¶
type MarkNode struct { MarkType NodeType `json:"type,omitempty"` Attributes interface{} `json:"attrs,omitempty"` }
MarkNode is a mark node type.
func (MarkNode) GetAttributes ¶
func (n MarkNode) GetAttributes() interface{}
GetAttributes gets node attributes.
type MarkdownTranslator ¶
type MarkdownTranslator struct {
// contains filtered or unexported fields
}
MarkdownTranslator is a markdown translator.
func NewMarkdownTranslator ¶
func NewMarkdownTranslator(opts ...MarkdownTranslatorOption) *MarkdownTranslator
NewMarkdownTranslator constructs markdown translator.
func (*MarkdownTranslator) Close ¶
func (tr *MarkdownTranslator) Close(n Connector) string
Close implements TagCloser interface.
type MarkdownTranslatorOption ¶
type MarkdownTranslatorOption func(*MarkdownTranslator)
MarkdownTranslatorOption is a functional option for MarkdownTranslator.
func WithMarkdownCloseHooks ¶
func WithMarkdownCloseHooks(hooks nodeTypeHook) MarkdownTranslatorOption
WithMarkdownCloseHooks sets close hooks of a markdown translator.
func WithMarkdownOpenHooks ¶
func WithMarkdownOpenHooks(hooks nodeTypeHook) MarkdownTranslatorOption
WithMarkdownOpenHooks sets open hooks of a markdown translator.
type Node ¶
type Node struct { NodeType NodeType `json:"type"` Content []*Node `json:"content,omitempty"` Attributes interface{} `json:"attrs,omitempty"` NodeValue }
Node is an ADF content node.
func (Node) GetAttributes ¶
func (n Node) GetAttributes() interface{}
GetAttributes gets node attributes.
type NodeType ¶
type NodeType string
NodeType is an Atlassian document node type.
func GetADFNodeType ¶
GetADFNodeType returns the type of ADF node.
type NodeValue ¶
type NodeValue struct { Text string `json:"text,omitempty"` Marks []MarkNode `json:"marks,omitempty"` }
NodeValue is an actual ADF node content.
type TagOpenerCloser ¶
TagOpenerCloser wraps tag opener and closer.
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator transforms ADF to a new format.
func NewTranslator ¶
func NewTranslator(adf *ADF, tr TagOpenerCloser) *Translator
NewTranslator constructs an ADF translator.
func (*Translator) Translate ¶
func (a *Translator) Translate() string
Translate translates ADF to a new format.