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
Index ¶
- func FormatFromFrontMatterType(typ ItemType) metadecoders.Format
- type Config
- type ContentFrontMatter
- type Item
- func (i Item) IsDone() bool
- func (i Item) IsEOF() bool
- func (i Item) IsError() bool
- func (i Item) IsFrontMatter() bool
- func (i Item) IsInlineShortcodeName() bool
- func (i Item) IsLeftShortcodeDelim() bool
- func (i Item) IsNonWhitespace() bool
- func (i Item) IsRightShortcodeDelim() bool
- func (i Item) IsShortcodeClose() bool
- func (i Item) IsShortcodeMarkupDelimiter() bool
- func (i Item) IsShortcodeName() bool
- func (i Item) IsShortcodeParam() bool
- func (i Item) IsShortcodeParamVal() bool
- func (i Item) IsText() bool
- func (i Item) String() string
- func (i Item) ValStr() string
- func (i Item) ValTyped() interface{}
- type ItemType
- type Items
- type Iterator
- func (t *Iterator) Backup()
- func (t *Iterator) Consume(cnt int)
- func (t *Iterator) Current() Item
- func (t *Iterator) Input() []byte
- func (t *Iterator) IsValueNext() bool
- func (t *Iterator) LineNumber() int
- func (t *Iterator) Next() Item
- func (t *Iterator) Peek() Item
- func (t *Iterator) PeekWalk(walkFn func(item Item) bool)
- type Result
Functions ¶
func FormatFromFrontMatterType ¶
func FormatFromFrontMatterType(typ ItemType) metadecoders.Format
Types ¶
type Config ¶
type Config struct { EnableEmoji bool }
type ContentFrontMatter ¶
type ContentFrontMatter struct { Content []byte FrontMatter map[string]interface{} FrontMatterFormat metadecoders.Format }
func ParseFrontMatterAndContent ¶
func ParseFrontMatterAndContent(r io.Reader) (ContentFrontMatter, error)
ParseFrontMatterAndContent is a convenience method to extract front matter and content from a content page.
type Item ¶
func (Item) IsDone ¶
func (Item) IsEOF ¶
func (Item) IsError ¶
func (Item) IsFrontMatter ¶
func (Item) IsInlineShortcodeName ¶
func (Item) IsLeftShortcodeDelim ¶
func (Item) IsNonWhitespace ¶
func (Item) IsRightShortcodeDelim ¶
func (Item) IsShortcodeClose ¶
func (Item) IsShortcodeMarkupDelimiter ¶
func (Item) IsShortcodeName ¶
func (Item) IsShortcodeParam ¶
func (Item) IsShortcodeParamVal ¶
func (Item) IsText ¶
func (Item) String ¶
func (Item) ValStr ¶
func (Item) ValTyped ¶
func (i Item) ValTyped() interface{}
type ItemType ¶
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 ¶
type Items ¶
type Items []Item
type Iterator ¶
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 ¶
func (t *Iterator) Backup()
backs up one token.
func (*Iterator) Consume ¶
Consume is a convenience method to consume the next n tokens, but back off Errors and EOF.
func (*Iterator) Current ¶
Current will repeatably return the current item.
func (*Iterator) Input ¶
Input returns the input source.
func (*Iterator) IsValueNext ¶
check for non-error and non-EOF types coming next
func (*Iterator) LineNumber ¶
LineNumber returns the current line number. Used for logging.
func (*Iterator) Next ¶
consumes and returns the next item
func (*Iterator) Peek ¶
look at, but do not consume, the next item repeated, sequential calls will return the same item
func (*Iterator) PeekWalk ¶
PeekWalk will feed the next items in the iterator to walkFn until it returns false.
type Result ¶
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 ¶
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 ¶
ParseMain parses starting with the main section. Used in tests.
Source Files ¶
doc.go item.go itemtype_string.go pagelexer.go pagelexer_intro.go pagelexer_shortcode.go pageparser.go
- Version
- v0.93.2
- Published
- Mar 4, 2022
- Platform
- js/wasm
- Imports
- 10 packages
- Last checked
- 26 minutes ago –
Tools for package owners.