meta

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package meta implements markdown frontmatter parsing for simple slides configuration

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meta

type Meta struct {
	Theme  string
	Author string
	Date   string
	Paging string
}

Meta contains all of the data to be parsed out of a markdown file's header section

func New

func New() *Meta

New creates a new instance of the slideshow meta header object

func (*Meta) Parse added in v0.5.0

func (m *Meta) Parse(header string) (*Meta, bool)

Parse parses metadata from a slideshows header slide including theme information

If no front matter is provided, it will fallback to the default theme and return false to acknowledge that there is no front matter in this slide

Example
package main

import (
	"fmt"

	"github.com/maaslalani/slides/internal/meta"
)

func main() {
	header := `
---
theme: "dark"
author: "Gopher"
date: "Apr. 4, 2021"
paging: "%d"
---
`
	// Parse the header from the markdown
	// file
	m, _ := meta.New().Parse(header)

	// Print the return theme
	// meta
	fmt.Println(m.Theme)
	fmt.Println(m.Author)
	fmt.Println(m.Date)
	fmt.Println(m.Paging)
}
Output:

Jump to

Keyboard shortcuts

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