### Install blackfriday-tool Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Install the blackfriday-tool command-line utility using go get. This also installs the blackfriday package. ```bash go get github.com/russross/blackfriday-tool ``` -------------------------------- ### Install blackfriday v2 Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Use this command to add the package to your Go module and install it. Ensure you are using a modern Go release in module mode. ```bash go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### Fenced Code Block Example Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Demonstrates how to use fenced code blocks with language specification for syntax highlighting. ```go func getTrue() bool { return true } ``` -------------------------------- ### Markdown Table Syntax Example Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 This is an example of the simple syntax used to create tables in Markdown input. ```markdown Name | Age --------|------ Bob | 27 Alice | 23 ``` -------------------------------- ### Definition List Example Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Shows the syntax for creating definition lists, with terms followed by a colon and their definitions. Terms must be separated by a blank line. ```markdown Cat : Fluffy animal everyone likes Internet : Vector of transmission for pictures of cats ``` -------------------------------- ### Footnote Example Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Illustrates how to create footnotes using bracketed references in the text and corresponding definitions at the end. ```markdown This is a footnote.[^1] [^1]: the footnote text. ``` -------------------------------- ### Import blackfriday v2 Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Import the blackfriday package into your Go project. This can be done directly in your code, followed by a `go get` command. ```go import "github.com/russross/blackfriday/v2" ``` -------------------------------- ### Markdown Execution with No Extensions Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Example of calling Run with no extensions enabled using WithNoExtensions(). ```go output := Run(input, WithNoExtensions()) ``` -------------------------------- ### SPRenderer Process Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Process is the entry point for the Smartypants renderer, taking an io.Writer and a byte slice of text to process. ```go func (r *SPRenderer) Process(w io.Writer, text []byte) ``` -------------------------------- ### Run Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 The main entry point to Blackfriday. It parses and renders a block of markdown-encoded text. Options can be provided to customize the parsing and rendering behavior. ```APIDOC ## Run ### Description Parses and renders a block of markdown-encoded text. It can be customized with various options. ### Function Signature ```go func Run(input []byte, opts ...Option) []byte ``` ### Parameters * **input** ([]byte) - The markdown-encoded text to parse and render. * **opts** (...Option) - Variadic arguments to customize the default behavior. Use `With*` functions to specify extensions, renderers, etc. ### Request Example ```go output := Run(input) ``` ### Response * **[]byte** - The rendered HTML output. ``` -------------------------------- ### Markdown Execution with Custom Options Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Demonstrates overriding default behavior by providing multiple With* arguments. Later arguments override earlier ones. ```go output := Run(input, WithNoExtensions(), WithExtensions(exts), WithRenderer(yourRenderer)) ``` -------------------------------- ### Run Markdown Parser Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 The main entry point to Blackfriday. It parses and renders a block of markdown-encoded text. Use variadic Option arguments to customize behavior. ```go func Run(input []byte, opts ...Option) []byte ``` -------------------------------- ### Basic Markdown Execution Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Simplest invocation of Run, parsing input with CommonExtensions and rendering with default HTMLRenderer. ```go output := Run(input) ``` -------------------------------- ### Package Version Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Version string of the package. Appears in the rendered document when CompletePage flag is on. ```go const Version = "2.0" ``` -------------------------------- ### Basic Markdown Parsing in Go Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Use this for the most sensible markdown processing. It enables a set of popular extensions by default. ```go output := blackfriday.Run(input) ``` -------------------------------- ### Node Walk Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Initiates a traversal of the subtree rooted at the node, using the provided visitor function. ```go func (n *Node) Walk(visitor NodeVisitor) ``` -------------------------------- ### Run Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 The simplest way to invoke Blackfriday is to call the Run function. It will take a text input and produce a text output in HTML (or other format). ```APIDOC ## Run ### Description This function processes a byte slice of markdown input and returns a byte slice of the processed output, typically in HTML format. It accepts optional configuration options. ### Function Signature `func Run(input []byte, opts ...Option) []byte` ### Parameters #### Input - **input** ([]byte) - The markdown text to process. - **opts** (...Option) - Optional configuration options for the processor, such as extensions or renderers. ### Returns - **[]byte** - The processed output, usually in HTML format. ``` -------------------------------- ### SPRenderer.Process Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 The entry point for the Smartypants renderer to process a given byte slice of text and write the output to a specified writer. ```APIDOC ## func (*SPRenderer) Process ### Description Process is the entry point of the Smartypants renderer. ### Signature ```go func (r *SPRenderer) Process(w io.Writer, text []byte) ``` ``` -------------------------------- ### Basic Markdown Parsing with No Extensions Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Use this for the bare Markdown specification, disabling all extensions. ```go output := blackfriday.Run(input, blackfriday.WithNoExtensions()) ``` -------------------------------- ### Node InsertBefore Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Inserts a sibling node immediately before the current node. Panics if either node is nil. ```go func (n *Node) InsertBefore(sibling *Node) ``` -------------------------------- ### HTMLRenderer.RenderHeader Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Writes the HTML document preamble and table of contents (if requested) to the specified writer. ```go func (r *HTMLRenderer) RenderHeader(w io.Writer, ast *Node) ``` -------------------------------- ### Node String Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Returns a string representation of the node. ```go func (n *Node) String() string ``` -------------------------------- ### NewHTMLRenderer Function Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Creates and configures an HTMLRenderer object using provided parameters. ```go func NewHTMLRenderer(params HTMLRendererParameters) *HTMLRenderer ``` -------------------------------- ### Define Tab Sizes Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Constants for defining tab stop sizes. ```go const ( TabSizeDefault = 4 TabSizeDouble = 8 ) ``` -------------------------------- ### Reference Struct Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Reference holds the details for a link, including the URL (Link), alternate text (Title), and optional override text for the [refid][] syntax (Text). ```go type Reference struct { // Link is usually the URL the reference points to. Link string // Title is the alternate text describing the link in more detail. Title string // Text is the optional text to override the ref with if the syntax used was // [refid][] Text string } ``` -------------------------------- ### HTMLRenderer.RenderNode Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Renders a single node of the syntax tree to the specified writer. It controls the walker's traversal pattern. ```go func (r *HTMLRenderer) RenderNode(w io.Writer, node *Node, entering bool) WalkStatus ``` -------------------------------- ### Sanitize Untrusted Markdown Content with Bluemonday Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Integrate Blackfriday with Bluemonday for sanitizing user-supplied markdown to prevent malicious content. ```go import ( "github.com/microcosm-cc/bluemonday" "github.com/russross/blackfriday/v2" ) // ... unsafe := blackfriday.Run(input) html := bluemonday.UGCPolicy().SanitizeBytes(unsafe) ``` -------------------------------- ### Define Markdown Extensions Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 These constants represent the supported markdown parsing extensions. OR these values together to select multiple extensions. ```go const ( NoExtensions Extensions = 0 NoIntraEmphasis Extensions = 1 << iota // Ignore emphasis markers inside words Tables // Render tables FencedCode // Render fenced code blocks Autolink // Detect embedded URLs that are not explicitly marked Strikethrough // Strikethrough text using ~~test~~ LaxHTMLBlocks // Loosen up HTML block parsing rules SpaceHeadings // Be strict about prefix heading rules HardLineBreak // Translate newlines into line breaks TabSizeEight // Expand tabs to eight spaces instead of four Footnotes // Pandoc-style footnotes NoEmptyLineBeforeBlock // No need to insert an empty line to start a (code, quote, ordered list, unordered list) block HeadingIDs // specify heading IDs with {#id} Titleblock // Titleblock ala pandoc AutoHeadingIDs // Create the heading ID from the text BackslashLineBreak // Translate trailing backslashes into line breaks DefinitionLists // Render definition lists CommonHTMLFlags HTMLFlags = UseXHTML | Smartypants | SmartypantsFractions | SmartypantsDashes | SmartypantsLatexDashes CommonExtensions Extensions = NoIntraEmphasis | Tables | FencedCode | Autolink | Strikethrough | SpaceHeadings | HeadingIDs | BackslashLineBreak | DefinitionLists ) ``` -------------------------------- ### NewHTMLRenderer Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Creates and configures an HTMLRenderer object, which satisfies the Renderer interface. This is the primary way to obtain an HTML renderer instance. ```APIDOC ## NewHTMLRenderer ### Description Creates and configures an HTMLRenderer object, which satisfies the Renderer interface. ### Function Signature ```go func NewHTMLRenderer(params HTMLRendererParameters) *HTMLRenderer ``` ### Parameters #### Parameters - **params** (HTMLRendererParameters) - Required - Configuration options for the HTML renderer. ``` -------------------------------- ### Markdown Processor Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 A more sophisticated way to use Blackfriday is to create a Markdown processor and to call Parse, which returns a syntax tree for the input document. You can leverage Blackfriday's parsing for content extraction from markdown documents. You can assign a custom renderer and set various options to the Markdown processor. ```APIDOC ## Markdown Processor ### Description This section describes how to create and use a Markdown processor for more advanced control over parsing and rendering. It allows for custom renderers and options to be set. ### Creating a Processor Use the `New` function to create a new Markdown processor instance. #### Function Signature `func New(opts ...Option) *Markdown` ### Parsing Markdown Once a processor is created, use the `Parse` method to convert markdown input into an Abstract Syntax Tree (AST). #### Method Signature `func (p *Markdown) Parse(input []byte) *Node` ### Parameters #### New - **opts** (...Option) - Optional configurations for the Markdown processor, such as extensions or renderers. #### Parse - **input** ([]byte) - The markdown text to parse. ### Returns - **New**: `*Markdown` - A pointer to the newly created Markdown processor. - **Parse**: `*Node` - A pointer to the root node of the generated AST. ``` -------------------------------- ### Markdown Parse Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Parses an input Markdown document into a syntax tree. The returned root node can be rendered or analyzed. ```go func (p *Markdown) Parse(input []byte) *Node ``` -------------------------------- ### WithRenderer Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Allows for the replacement of the default renderer with a custom implementation. ```APIDOC ## func WithRenderer ### Description Allows you to override the default renderer. ### Signature ```go func WithRenderer(r Renderer) Option ``` ``` -------------------------------- ### Markdown Processor Creation Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Constructs a new Markdown processor instance. Options can be provided to customize the parser's behavior and the renderer. ```APIDOC ## New ### Description Constructs a Markdown processor. Options can be used to customize parser behavior and the renderer. ### Method `New` ### Endpoint `New(opts ...Option) *Markdown` ### Parameters * `opts` (...Option) - Options to configure the Markdown processor. ### Response * `*Markdown` - A pointer to the newly created Markdown processor. ``` -------------------------------- ### HTMLRenderer.RenderFooter Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Writes the HTML document footer to the specified writer. ```go func (r *HTMLRenderer) RenderFooter(w io.Writer, ast *Node) ``` -------------------------------- ### HTMLRenderer.RenderHeader Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Writes the HTML document preamble and the table of contents if requested by the renderer's flags. ```APIDOC ## HTMLRenderer.RenderHeader ### Description Writes the HTML document preamble and TOC if requested. ### Method ```go func (r *HTMLRenderer) RenderHeader(w io.Writer, ast *Node) ``` ### Parameters #### Parameters - **w** (io.Writer) - The writer to output the HTML preamble to. - **ast** (*Node) - The root node of the parsed Markdown syntax tree. ``` -------------------------------- ### WithExtensions Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Allows customization of the Markdown processor by enabling specific extensions. Multiple extensions can be combined using bitwise OR operations. ```APIDOC ## func WithExtensions ### Description Allows you to pick some of the many extensions provided by Blackfriday. You can bitwise OR them. ### Signature ```go func WithExtensions(e Extensions) Option ``` ``` -------------------------------- ### HTMLRenderer.RenderFooter Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Writes the HTML document footer. ```APIDOC ## HTMLRenderer.RenderFooter ### Description Writes the HTML document footer. ### Method ```go func (r *HTMLRenderer) RenderFooter(w io.Writer, ast *Node) ``` ### Parameters #### Parameters - **w** (io.Writer) - The writer to output the HTML footer to. - **ast** (*Node) - The root node of the parsed Markdown syntax tree. ``` -------------------------------- ### New Markdown Processor Function Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Constructs a new Markdown processor, allowing customization of parser behavior and renderer via options. ```go func New(opts ...Option) *Markdown ``` -------------------------------- ### Renderer Interface Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 The Renderer interface defines methods for rendering Markdown nodes. It includes RenderNode for processing individual nodes, RenderHeader for outputting content before the main document body, and RenderFooter for content after the main body. This interface is primarily for implementing new rendering formats. ```go type Renderer interface { // RenderNode is the main rendering method. It will be called once for // every leaf node and twice for every non-leaf node (first with // entering=true, then with entering=false). The method should write its // rendition of the node to the supplied writer w. RenderNode(w io.Writer, node *Node, entering bool) WalkStatus // RenderHeader is a method that allows the renderer to produce some // content preceding the main body of the output document. The header is // understood in the broad sense here. For example, the default HTML // renderer will write not only the HTML document preamble, but also the // table of contents if it was requested. // // The method will be passed an entire document tree, in case a particular // implementation needs to inspect it to produce output. // // The output should be written to the supplied writer w. If your // implementation has no header to write, supply an empty implementation. RenderHeader(w io.Writer, ast *Node) // RenderFooter is a symmetric counterpart of RenderHeader. RenderFooter(w io.Writer, ast *Node) } ``` -------------------------------- ### Markdown Parsing Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 The Parse method is the primary entry point for converting Markdown input into a syntax tree. This tree can then be used for rendering or further analysis. ```APIDOC ## Parse ### Description Parses an input markdown document and produces a syntax tree for its contents. This tree can then be rendered or analyzed. ### Method `Parse` ### Endpoint `(*Markdown) Parse(input []byte) *Node` ### Parameters * `input` ([]byte) - The markdown document to parse. ### Response * `*Node` - The root node of the generated syntax tree. ``` -------------------------------- ### ListType Constants Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines bitwise flags for list and list item rendering, useful for custom output formats. ```go const ( ListTypeOrdered ListType = 1 << iota ListTypeDefinition ListTypeTerm ListItemContainsBlock ListItemBeginningOfList // TODO: figure out if this is of any use now ListItemEndOfList ) ``` -------------------------------- ### WithExtensions Option Function Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 WithExtensions creates an Option that allows selecting specific extensions provided by Blackfriday. Multiple extensions can be combined using a bitwise OR operation. ```go func WithExtensions(e Extensions) Option ``` -------------------------------- ### Extensions Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 A bitwise OR'ed collection of enabled Blackfriday extensions, controlling various parsing behaviors. ```APIDOC ## Extensions ### Description A bitmask type used to enable or disable specific Blackfriday markdown extensions. ### Constants * **NoExtensions** (Extensions) - No extensions enabled. * **NoIntraEmphasis** (Extensions) - Ignore emphasis markers inside words. * **Tables** (Extensions) - Render tables. * **FencedCode** (Extensions) - Render fenced code blocks. * **Autolink** (Extensions) - Detect embedded URLs that are not explicitly marked. * **Strikethrough** (Extensions) - Strikethrough text using ~~test~~. * **LaxHTMLBlocks** (Extensions) - Loosen up HTML block parsing rules. * **SpaceHeadings** (Extensions) - Be strict about prefix heading rules. * **HardLineBreak** (Extensions) - Translate newlines into line breaks. * **TabSizeEight** (Extensions) - Expand tabs to eight spaces instead of four. * **Footnotes** (Extensions) - Pandoc-style footnotes. * **NoEmptyLineBeforeBlock** (Extensions) - No need to insert an empty line to start a block. * **HeadingIDs** (Extensions) - Specify heading IDs with {#id}. * **Titleblock** (Extensions) - Titleblock ala pandoc. * **AutoHeadingIDs** (Extensions) - Create the heading ID from the text. * **BackslashLineBreak** (Extensions) - Translate trailing backslashes into line breaks. * **DefinitionLists** (Extensions) - Render definition lists. ### Common Usage * **CommonHTMLFlags** (HTMLFlags) - A predefined set of HTML flags for common use. * **CommonExtensions** (Extensions) - A predefined set of common extensions. ``` -------------------------------- ### NewSmartypantsRenderer Function Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 NewSmartypantsRenderer is a constructor function for creating a Smartypants renderer object, accepting HTMLFlags to configure its behavior. ```go func NewSmartypantsRenderer(flags HTMLFlags) *SPRenderer ``` -------------------------------- ### NewSmartypantsRenderer Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Constructs and returns a new Smartypants renderer object, which can be used to process text with smart typography. ```APIDOC ## func NewSmartypantsRenderer ### Description NewSmartypantsRenderer constructs a Smartypants renderer object. ### Signature ```go func NewSmartypantsRenderer(flags HTMLFlags) *SPRenderer ``` ``` -------------------------------- ### HTMLRendererParameters Struct Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines parameters for customizing the HTML renderer's behavior, including URL prefixes, heading IDs, and flags. ```go type HTMLRendererParameters struct { // Prepend this text to each relative URL. AbsolutePrefix string // Add this text to each footnote anchor, to ensure uniqueness. FootnoteAnchorPrefix string // Show this text inside the tag for a footnote return link, if the // HTML_FOOTNOTE_RETURN_LINKS flag is enabled. If blank, the string // [return] is used. FootnoteReturnLinkContents string // If set, add this text to the front of each Heading ID, to ensure // uniqueness. HeadingIDPrefix string // If set, add this text to the back of each Heading ID, to ensure uniqueness. HeadingIDSuffix string // Increase heading levels: if the offset is 1,

becomes

etc. // Negative offset is also valid. // Resulting levels are clipped between 1 and 6. HeadingLevelOffset int Title string // Document title (used if CompletePage is set) CSS string // Optional CSS file URL (used if CompletePage is set) Icon string // Optional icon file URL (used if CompletePage is set) Flags HTMLFlags // Flags allow customizing this renderer's behavior } ``` -------------------------------- ### NewNode Function Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Allocates and returns a new Node of the specified type. ```go func NewNode(typ NodeType) *Node ``` -------------------------------- ### WithRenderer Option Function Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 WithRenderer creates an Option that allows replacing the default renderer with a custom implementation. ```go func WithRenderer(r Renderer) Option ``` -------------------------------- ### NodeType String Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 The String method for NodeType is a simple function signature declaration. ```go func (t NodeType) String() string ``` -------------------------------- ### Markdown Structure Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines the Markdown processor type, which holds extensions and runtime state. It should be constructed using New. ```go type Markdown struct { // contains filtered or unexported fields } ``` -------------------------------- ### HTML Sanitizer Policy for Code Blocks Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Configures the bluemonday HTML sanitizer to allow 'class' attributes on 'code' elements, specifically for language classes in fenced code blocks. ```go p := bluemonday.UGCPolicy() p.AllowAttrs("class").Matching(regexp.MustCompile("^language-[a-zA-Z0-9]+$")).OnElements("code") html := p.SanitizeBytes(unsafe) ``` -------------------------------- ### WithRefOverride Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Sets an optional callback function that is invoked whenever a link reference is resolved. This allows for custom logic before consulting the document's defined references. ```APIDOC ## func WithRefOverride ### Description Sets an optional function callback that is called every time a reference is resolved. In Markdown, the link reference syntax can be made to resolve a link to a reference instead of an inline URL, in one of the following ways: * [link text][refid] * [refid][] Usually, the refid is defined at the bottom of the Markdown document. If this override function is provided, the refid is passed to the override function first, before consulting the defined refids at the bottom. If the override function indicates an override did not occur, the refids at the bottom will be used to fill in the link details. ### Signature ```go func WithRefOverride(o ReferenceOverrideFunc) Option ``` ``` -------------------------------- ### HTMLRenderer.RenderNode Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Renders a single node of the syntax tree. This method is called by the walker and can control the traversal behavior. ```APIDOC ## HTMLRenderer.RenderNode ### Description Default renderer for a single node of a syntax tree. It can control the walker's traversal pattern. ### Method ```go func (r *HTMLRenderer) RenderNode(w io.Writer, node *Node, entering bool) WalkStatus ``` ### Parameters #### Parameters - **w** (io.Writer) - The writer to output the rendered node to. - **node** (*Node) - The current node to render. - **entering** (bool) - True if entering the node's tag, false if exiting. ### Return Value - **WalkStatus** - Controls the walker's behavior (e.g., GoToNext, SkipChildren, Terminate). ``` -------------------------------- ### SPRenderer Struct Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 SPRenderer is a struct that holds the state for a Smartypants renderer. ```go type SPRenderer struct { // contains filtered or unexported fields } ``` -------------------------------- ### WalkStatus Constants Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Constants for WalkStatus: GoToNext for default traversal, SkipChildren to bypass node children, and Terminate to end traversal. ```go const ( // GoToNext is the default traversal of every node. GoToNext WalkStatus = iota // SkipChildren tells walker to skip all children of current node. SkipChildren // Terminate tells walker to terminate the traversal. Terminate ) ``` -------------------------------- ### WithNoExtensions Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Disables all extensions and custom behaviors, reverting the Markdown processor to its default state. ```APIDOC ## func WithNoExtensions ### Description Turns off all extensions and custom behavior. ### Signature ```go func WithNoExtensions() Option ``` ``` -------------------------------- ### Node AppendChild Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Adds a child node to the end of the current node's children list. Panics if either node is nil. ```go func (n *Node) AppendChild(child *Node) ``` -------------------------------- ### CodeBlockData Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Contains fields relevant to a CodeBlock node type, including information about whether it's fenced and its associated info string. ```APIDOC ## CodeBlockData ### Description Structure holding data specific to code blocks parsed by Blackfriday. ### Fields * **IsFenced** (bool) - True if the code block is fenced, false if indented. * **Info** ([]byte) - The info string associated with the code block (e.g., language identifier). * **FenceChar** (byte) - The character used for fencing (e.g., '`'). * **FenceLength** (int) - The length of the fence. * **FenceOffset** (int) - The offset of the fence in the input. ``` -------------------------------- ### HeadingData Struct Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Contains fields relevant to a Heading node type, including its level, ID, and whether it's a title block. ```go type HeadingData struct { Level int // This holds the heading level number HeadingID string // This might hold heading ID, if present IsTitleblock bool // Specifies whether it's a title block } ``` -------------------------------- ### HTMLFlags Constants Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines constants for customizing the HTML renderer's behavior, such as skipping elements, modifying links, and enabling smart punctuation. ```go const ( HTMLFlagsNone HTMLFlags = 0 SkipHTML HTMLFlags = 1 << iota // Skip preformatted HTML blocks SkipImages // Skip embedded images SkipLinks // Skip all links Safelink // Only link to trusted protocols NofollowLinks // Only link with rel="nofollow" NoreferrerLinks // Only link with rel="noreferrer" NoopenerLinks // Only link with rel="noopener" HrefTargetBlank // Add a blank target CompletePage // Generate a complete HTML page UseXHTML // Generate XHTML output instead of HTML FootnoteReturnLinks // Generate a link at the end of a footnote to return to the source Smartypants // Enable smart punctuation substitutions SmartypantsFractions // Enable smart fractions (with Smartypants) SmartypantsDashes // Enable smart dashes (with Smartypants) SmartypantsLatexDashes // Enable LaTeX-style dashes (with Smartypants) SmartypantsAngledQuotes // Enable angled double quotes (with Smartypants) for double quotes rendering SmartypantsQuotesNBSP // Enable « French guillemets » (with Smartypants) TOC // Generate a table of contents ) ``` -------------------------------- ### ListType Type Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines the base type for list-related flags. ```go type ListType int ``` -------------------------------- ### NodeVisitor Function Type Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 NodeVisitor is a callback function type used for traversing the syntax tree. It is invoked twice per node: once when entering a branch (entering=true) and once after all children have been processed (entering=false). ```go type NodeVisitor func(node *Node, entering bool) WalkStatus ``` -------------------------------- ### HTMLRenderer Type Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines the HTMLRenderer struct, which implements the Renderer interface for HTML output. ```go type HTMLRenderer struct { HTMLRendererParameters // contains filtered or unexported fields } ``` -------------------------------- ### WithRefOverride Option Function Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 WithRefOverride sets an optional callback function that is invoked whenever a link reference is resolved. This function is called before consulting the document's defined references. If the override function indicates no override occurred, the default reference resolution logic is applied. ```go func WithRefOverride(o ReferenceOverrideFunc) Option ``` -------------------------------- ### LinkData Structure Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines the structure for link-related data within a Markdown node, including destination, title, and footnote information. ```go type LinkData struct { Destination []byte // Destination is what goes into a href Title []byte // Title is the tooltip thing that goes in a title attribute NoteID int // NoteID contains a serial number of a footnote, zero if it's not a footnote Footnote *Node // If it's a footnote, this is a direct link to the footnote Node. Otherwise nil. } ``` -------------------------------- ### Option Function Type Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Option is a function type used to customize the default behavior of the Markdown processor. ```go type Option func(*Markdown) ``` -------------------------------- ### NodeType Constants Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Constants representing different types of nodes in the Markdown syntax tree. ```go const ( Document NodeType = iota BlockQuote List Item Paragraph Heading HorizontalRule Emph Strong Del Link Image Text HTMLBlock CodeBlock Softbreak Hardbreak Code HTMLSpan Table TableCell TableHead TableBody TableRow ) ``` -------------------------------- ### Node Structure Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines a node in the Markdown syntax tree, including its type, parent/child/sibling relationships, and literal content. ```go type Node struct { Type NodeType // Determines the type of the node Parent *Node // Points to the parent FirstChild *Node // Points to the first child, if any LastChild *Node // Points to the last child, if any Prev *Node // Previous sibling; nil if it's the first child Next *Node // Next sibling; nil if it's the last child Literal []byte // Text contents of the leaf nodes HeadingData // Populated if Type is Heading ListData // Populated if Type is List CodeBlockData // Populated if Type is CodeBlock LinkData // Populated if Type is Link TableCellData // Populated if Type is TableCell // contains filtered or unexported fields } ``` -------------------------------- ### Node Manipulation Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Provides methods for manipulating nodes within the syntax tree, such as appending children, inserting before a sibling, or unlinking a node. ```APIDOC ## Node Methods ### Description Methods for manipulating nodes within the abstract syntax tree. ### Methods * **AppendChild** (`child *Node`) Appends a node as a child of the current node. * **InsertBefore** (`sibling *Node`) Inserts a node immediately before the current node. * **Unlink** () Removes the current node from the tree. * **Walk** (`visitor NodeVisitor`) Initiates a traversal of the subtree rooted at the current node. ``` -------------------------------- ### Extensions Type Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Extensions is a type representing a bitwise OR'ed collection of enabled Blackfriday extensions. ```go type Extensions int ``` -------------------------------- ### WithNoExtensions Option Function Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 WithNoExtensions creates an Option that disables all extensions and custom behaviors, reverting to default processing. ```go func WithNoExtensions() Option ``` -------------------------------- ### WalkStatus Control Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 WalkStatus is an integer type that allows NodeVisitor to control the tree traversal during Markdown parsing. Different WalkStatus values dictate the next step in the traversal process. ```APIDOC ## WalkStatus ### Description WalkStatus controls the traversal of the Markdown abstract syntax tree (AST). It is returned by a NodeVisitor and influences the behavior of the `Node.Walk` method. ### Constants - **GoToNext** (WalkStatus): The default traversal behavior, visiting all children of the current node. - **SkipChildren** (WalkStatus): Instructs the walker to skip all children of the current node and proceed to the next sibling. - **Terminate** (WalkStatus): Instructs the walker to terminate the entire traversal process. ``` -------------------------------- ### Sanitize Anchor Name Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Returns a sanitized anchor name for the given text, implementing the algorithm specified in the package comment. ```go func SanitizedAnchorName(text string) string ``` -------------------------------- ### CodeBlockData Structure Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 CodeBlockData contains fields relevant to a CodeBlock node type, specifying whether it's fenced or indented, and holding info string and fence details. ```go type CodeBlockData struct { IsFenced bool // Specifies whether it's a fenced code block or an indented one Info []byte // This holds the info string FenceChar byte FenceLength int FenceOffset int } ``` -------------------------------- ### HTMLFlags Type Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines the integer type used for HTML renderer flags, controlling optional behaviors. ```go type HTMLFlags int ``` -------------------------------- ### ListData Structure Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines the structure for list-related data within a Markdown node, including list flags, bullet characters, and footnote status. ```go type ListData struct { ListFlags ListType Tight bool // Skip

s around list item data if true BulletChar byte // '*', '+' or '-' in bullet lists Delimiter byte // '.' or ')' after the number in ordered lists RefLink []byte // If not nil, turns this list item into a footnote item and triggers different rendering IsFootnotesList bool // This is a list of footnotes } ``` -------------------------------- ### Node Unlink Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Removes the node from its parent and siblings. Panics if the node is nil. ```go func (n *Node) Unlink() ``` -------------------------------- ### Define WalkStatus Type Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines the WalkStatus integer type used for controlling tree traversal in NodeVisitor. ```go type WalkStatus int ``` -------------------------------- ### SanitizedAnchorName Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Blackfriday includes an algorithm for creating sanitized anchor names corresponding to a given input text. This algorithm is used to create anchors for headings when AutoHeadingIDs extension is enabled. ```APIDOC ## SanitizedAnchorName ### Description This function generates a URL-friendly anchor name from a given text string. It's used internally for creating heading anchors when the AutoHeadingIDs extension is enabled, and can be used by external packages to create compatible anchor names and links. ### Function Signature `func SanitizedAnchorName(text string) string` ### Parameters #### Input Text - **text** (string) - The input text for which to generate a sanitized anchor name. ### Returns - **string** - The sanitized anchor name. ``` -------------------------------- ### Node Type Information Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Methods to determine the nature of a node within the syntax tree. ```APIDOC ## Node Type Checks ### Description Methods to check the properties of a node. ### Methods * **IsContainer** () Returns `true` if the node can contain children. * **IsLeaf** () Returns `true` if the node is a leaf node (cannot contain children). ``` -------------------------------- ### Node IsContainer Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Returns true if the node can contain child nodes. ```go func (n *Node) IsContainer() bool ``` -------------------------------- ### Define Table Cell Alignment Flags Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 These constants represent possible flag values for table cell alignment. Only one value is used; they are not ORed together. ```go const ( TableAlignmentLeft CellAlignFlags = 1 << iota TableAlignmentRight TableAlignmentCenter = (TableAlignmentLeft | TableAlignmentRight) ) ``` -------------------------------- ### NodeType Type Definition Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Defines the type for nodes in the syntax tree, corresponding to Markdown features. ```go type NodeType int ``` -------------------------------- ### SanitizedAnchorName Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Returns a sanitized anchor name for the given text, implementing the algorithm specified in the package comment. ```APIDOC ## SanitizedAnchorName ### Description Generates a URL-friendly anchor name from a given text string. ### Function Signature ```go func SanitizedAnchorName(text string) string ``` ### Parameters * **text** (string) - The input text to sanitize. ### Response * **string** - The sanitized anchor name. ``` -------------------------------- ### Node IsLeaf Method Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Returns true if the node is a leaf node (cannot contain children). ```go func (n *Node) IsLeaf() bool ``` -------------------------------- ### TableCellData Struct Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 TableCellData contains fields relevant to a TableCell node, specifically indicating if the cell is a header (IsHeader) and its alignment (Align). ```go type TableCellData struct { IsHeader bool // This tells if it's under the header row Align CellAlignFlags // This holds the value for align attribute } ``` -------------------------------- ### ReferenceOverrideFunc Function Type Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 ReferenceOverrideFunc is a callback type that accepts a reference string and returns a pointer to a Reference and a boolean indicating if an override occurred. If overridden is false, the default reference logic is used. ```go type ReferenceOverrideFunc func(reference string) (ref *Reference, overridden bool) ``` -------------------------------- ### CellAlignFlags Source: https://pkg.go.dev/github.com/russross/blackfriday/v2 Represents alignment types within a table cell. These are bitwise flags, but only a single value should be used. ```APIDOC ## CellAlignFlags ### Description An integer type representing alignment options for table cells. ### Constants * **TableAlignmentLeft** (CellAlignFlags) - Left alignment. * **TableAlignmentRight** (CellAlignFlags) - Right alignment. * **TableAlignmentCenter** (CellAlignFlags) - Center alignment (combination of Left and Right). ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.