Documentation
¶
Index ¶
- type Line
- type LineType
- type MarkdownFile
- func (md *MarkdownFile) AddSection(line string)
- func (md *MarkdownFile) AddSectionAtIndex(line string, index int)
- func (md MarkdownFile) GetFrontMatter(key string, defaultValue interface{}) (value interface{})
- func (md *MarkdownFile) GetSection(sectionType SectionType, text string) (section *Section)
- func (md *MarkdownFile) Read() (err error)
- func (md *MarkdownFile) SearchSection(searchString string) (sections []*Section)
- func (md *MarkdownFile) SearchSectionWithType(searchString string, sectionType SectionType) (sections []*Section)
- func (md *MarkdownFile) Write(str ...string) (err error)
- type Section
- type SectionType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MarkdownFile ¶
type MarkdownFile struct {
Path string
Title string // First "H1" section
FrontMatter map[interface{}]interface{}
Sections []Section
}
func (*MarkdownFile) AddSection ¶
func (md *MarkdownFile) AddSection(line string)
AddSection adds a new section to the end of the markdown file
func (*MarkdownFile) AddSectionAtIndex ¶
func (md *MarkdownFile) AddSectionAtIndex(line string, index int)
AddSectionAtIndex adds a new section at the specified index
func (MarkdownFile) GetFrontMatter ¶
func (md MarkdownFile) GetFrontMatter(key string, defaultValue interface{}) (value interface{})
Returns the value of the specified front matter key or the default value if the key does not exist
func (*MarkdownFile) GetSection ¶
func (md *MarkdownFile) GetSection(sectionType SectionType, text string) (section *Section)
GetSection returns the first section of the specified type with the specified text
func (*MarkdownFile) Read ¶
func (md *MarkdownFile) Read() (err error)
Read reads the markdown file and parses it into sections (also reads the Front Matter)
func (*MarkdownFile) SearchSection ¶
func (md *MarkdownFile) SearchSection(searchString string) (sections []*Section)
SearchSection returns a list of sections that contain the search string (with fuzzy search)
func (*MarkdownFile) SearchSectionWithType ¶
func (md *MarkdownFile) SearchSectionWithType(searchString string, sectionType SectionType) (sections []*Section)
SearchSection returns a list of sections with specified section type that contain the search string (with fuzzy search)
func (*MarkdownFile) Write ¶
func (md *MarkdownFile) Write(str ...string) (err error)
If a string is provided, write to that file. Otherwise, write to the original file
type Section ¶
type Section struct {
SectionType SectionType
Text string // The text after the first space (Without the "#..")
Lines []Line
// contains filtered or unexported fields
}
A "section" is a part of the markdown file that starts with any of the H1-H6 headers A NullSection is a section that has no "section" (It's the first part of the file if no title at the beginning)
func (*Section) AddLineAtIndex ¶
AddLineAtIndex adds a new line at the specified index in the specified section
type SectionType ¶
type SectionType string
Sections
var ( H1 SectionType = "#" H2 SectionType = "##" H3 SectionType = "###" H4 SectionType = "####" H5 SectionType = "#####" H6 SectionType = "######" NullSection SectionType = "" )