hugo: github.com/gohugoio/hugo/parser/pageparser Index | Files

package pageparser

import "github.com/gohugoio/hugo/parser/pageparser"

Package pageparser provides a parser for Hugo content files (Markdown, HTML etc.) in Hugo. This implementation is highly inspired by the great talk given by Rob Pike called "Lexical Scanning in Go" It's on YouTube, Google it!. See slides here: http://cuddle.googlecode.com/hg/talk/lex.html

Package pageparser provides a parser for Hugo content files (Markdown, HTML etc.) in Hugo. This implementation is highly inspired by the great talk given by Rob Pike called "Lexical Scanning in Go" It's on YouTube, Google it!. See slides here: http://cuddle.googlecode.com/hg/talk/lex.html

Package pageparser provides a parser for Hugo content files (Markdown, HTML etc.) in Hugo. This implementation is highly inspired by the great talk given by Rob Pike called "Lexical Scanning in Go" It's on YouTube, Google it!. See slides here: http://cuddle.googlecode.com/hg/talk/lex.html

Package pageparser provides a parser for Hugo content files (Markdown, HTML etc.) in Hugo. This implementation is highly inspired by the great talk given by Rob Pike called "Lexical Scanning in Go" It's on YouTube, Google it!. See slides here: http://cuddle.googlecode.com/hg/talk/lex.html

Index

Package Files

item.go itemtype_string.go pagelexer.go pagelexer_intro.go pagelexer_shortcode.go pageparser.go

func FormatFromFrontMatterType Uses

func FormatFromFrontMatterType(typ ItemType) metadecoders.Format

type Config Uses

type Config struct {
    EnableEmoji bool
}

type ContentFrontMatter Uses

type ContentFrontMatter struct {
    Content           []byte
    FrontMatter       map[string]interface{}
    FrontMatterFormat metadecoders.Format
}

func ParseFrontMatterAndContent Uses

func ParseFrontMatterAndContent(r io.Reader) (ContentFrontMatter, error)

ParseFrontMatterAndContent is a convenience method to extract front matter and content from a content page.

type Item Uses

type Item struct {
    Type ItemType
    Pos  int
    Val  []byte
    // contains filtered or unexported fields
}

func (Item) IsDone Uses

func (i Item) IsDone() bool

func (Item) IsEOF Uses

func (i Item) IsEOF() bool

func (Item) IsError Uses

func (i Item) IsError() bool

func (Item) IsFrontMatter Uses

func (i Item) IsFrontMatter() bool

func (Item) IsInlineShortcodeName Uses

func (i Item) IsInlineShortcodeName() bool

func (Item) IsLeftShortcodeDelim Uses

func (i Item) IsLeftShortcodeDelim() bool

func (Item) IsNonWhitespace Uses

func (i Item) IsNonWhitespace() bool

func (Item) IsRightShortcodeDelim Uses

func (i Item) IsRightShortcodeDelim() bool

func (Item) IsShortcodeClose Uses

func (i Item) IsShortcodeClose() bool

func (Item) IsShortcodeMarkupDelimiter Uses

func (i Item) IsShortcodeMarkupDelimiter() bool

func (Item) IsShortcodeName Uses

func (i Item) IsShortcodeName() bool

func (Item) IsShortcodeParam Uses

func (i Item) IsShortcodeParam() bool

func (Item) IsShortcodeParamVal Uses

func (i Item) IsShortcodeParamVal() bool

func (Item) IsText Uses

func (i Item) IsText() bool

func (Item) String Uses

func (i Item) String() string

func (Item) ValStr Uses

func (i Item) ValStr() string

func (Item) ValTyped Uses

func (i Item) ValTyped() interface{}

type ItemType Uses

type ItemType int
const (

    // page items
    TypeLeadSummaryDivider ItemType // <!--more-->,  # more
    TypeFrontMatterYAML
    TypeFrontMatterTOML
    TypeFrontMatterJSON
    TypeFrontMatterORG
    TypeEmoji
    TypeIgnore // // The BOM Unicode byte order marker and possibly others

)

func (ItemType) String Uses

func (i ItemType) String() string

type Items Uses

type Items []Item

type Iterator Uses

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

An Iterator has methods to iterate a parsed page with support going back if needed.

func (*Iterator) Backup Uses

func (t *Iterator) Backup()

backs up one token.

func (*Iterator) Consume Uses

func (t *Iterator) Consume(cnt int)

Consume is a convencience method to consume the next n tokens, but back off Errors and EOF.

func (*Iterator) Current Uses

func (t *Iterator) Current() Item

Current will repeatably return the current item.

func (*Iterator) Input Uses

func (t *Iterator) Input() []byte

Input returns the input source.

func (*Iterator) IsValueNext Uses

func (t *Iterator) IsValueNext() bool

check for non-error and non-EOF types coming next

func (*Iterator) LineNumber Uses

func (t *Iterator) LineNumber() int

LineNumber returns the current line number. Used for logging.

func (*Iterator) Next Uses

func (t *Iterator) Next() Item

consumes and returns the next item

func (*Iterator) Peek Uses

func (t *Iterator) Peek() Item

look at, but do not consume, the next item repeated, sequential calls will return the same item

func (*Iterator) PeekWalk Uses

func (t *Iterator) PeekWalk(walkFn func(item Item) bool)

PeekWalk will feed the next items in the iterator to walkFn until it returns false.

type Result Uses

type Result interface {
    // Iterator returns a new Iterator positioned at the beginning of the parse tree.
    Iterator() *Iterator
    // Input returns the input to Parse.
    Input() []byte
}

Result holds the parse result.

func Parse Uses

func Parse(r io.Reader, cfg Config) (Result, error)

Parse parses the page in the given reader according to the given Config. TODO(bep) now that we have improved the "lazy order" init, it *may* be some potential saving in doing a buffered approach where the first pass does the frontmatter only.

func ParseMain Uses

func ParseMain(r io.Reader, cfg Config) (Result, error)

ParseMain parses starting with the main section. Used in tests.

Package pageparser imports 10 packages (graph) and is imported by 33 packages. Updated 2020-03-11. Refresh now. Tools for package owners.