Add go dependencies for mdtoc
This commit is contained in:
parent
cb33c4ed26
commit
36959a4878
63 changed files with 12675 additions and 0 deletions
23
vendor/github.com/mmarkdown/mmark/mast/bibliography.go
generated
vendored
Normal file
23
vendor/github.com/mmarkdown/mmark/mast/bibliography.go
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package mast
|
||||
|
||||
import (
|
||||
"github.com/gomarkdown/markdown/ast"
|
||||
"github.com/mmarkdown/mmark/mast/reference"
|
||||
)
|
||||
|
||||
// Bibliography represents markdown bibliography node.
|
||||
type Bibliography struct {
|
||||
ast.Container
|
||||
|
||||
Type ast.CitationTypes
|
||||
}
|
||||
|
||||
// BibliographyItem contains a single bibliography item.
|
||||
type BibliographyItem struct {
|
||||
ast.Leaf
|
||||
|
||||
Anchor []byte
|
||||
Type ast.CitationTypes
|
||||
|
||||
Reference *reference.Reference // parsed reference XML
|
||||
}
|
||||
34
vendor/github.com/mmarkdown/mmark/mast/index.go
generated
vendored
Normal file
34
vendor/github.com/mmarkdown/mmark/mast/index.go
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package mast
|
||||
|
||||
import "github.com/gomarkdown/markdown/ast"
|
||||
|
||||
// DocumentIndex represents markdown document index node.
|
||||
type DocumentIndex struct {
|
||||
ast.Container
|
||||
}
|
||||
|
||||
// IndexItem contains an index for the indices section.
|
||||
type IndexItem struct {
|
||||
ast.Container
|
||||
|
||||
*ast.Index
|
||||
}
|
||||
|
||||
// IndexSubItem contains an sub item index for the indices section.
|
||||
type IndexSubItem struct {
|
||||
ast.Container
|
||||
|
||||
*ast.Index
|
||||
}
|
||||
|
||||
// IndexLetter has the Letter of this index item.
|
||||
type IndexLetter struct {
|
||||
ast.Container
|
||||
}
|
||||
|
||||
// IndexLink links to the index in the document.
|
||||
type IndexLink struct {
|
||||
*ast.Link
|
||||
|
||||
Primary bool
|
||||
}
|
||||
171
vendor/github.com/mmarkdown/mmark/mast/nodes.go
generated
vendored
Normal file
171
vendor/github.com/mmarkdown/mmark/mast/nodes.go
generated
vendored
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
package mast
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"sort"
|
||||
|
||||
"github.com/gomarkdown/markdown/ast"
|
||||
)
|
||||
|
||||
// some extra functions for manipulation the AST
|
||||
|
||||
// MoveChilderen moves the children from a to b *and* make the parent of each point to b.
|
||||
// Any children of b are obliterated.
|
||||
func MoveChildren(a, b ast.Node) {
|
||||
a.SetChildren(b.GetChildren())
|
||||
b.SetChildren(nil)
|
||||
|
||||
for _, child := range a.GetChildren() {
|
||||
child.SetParent(a)
|
||||
}
|
||||
}
|
||||
|
||||
// Some attribute helper functions.
|
||||
|
||||
// AttributeFromNode returns the attribute from the node, if it was there was one.
|
||||
func AttributeFromNode(node ast.Node) *ast.Attribute {
|
||||
if c := node.AsContainer(); c != nil && c.Attribute != nil {
|
||||
return c.Attribute
|
||||
}
|
||||
if l := node.AsLeaf(); l != nil && l.Attribute != nil {
|
||||
return l.Attribute
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AttributeInit will initialize an *Attribute on node if there wasn't one.
|
||||
func AttributeInit(node ast.Node) {
|
||||
if l := node.AsLeaf(); l != nil && l.Attribute == nil {
|
||||
l.Attribute = &ast.Attribute{Attrs: make(map[string][]byte)}
|
||||
return
|
||||
}
|
||||
if c := node.AsContainer(); c != nil && c.Attribute == nil {
|
||||
c.Attribute = &ast.Attribute{Attrs: make(map[string][]byte)}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteAttribute delete the attribute under key from a.
|
||||
func DeleteAttribute(node ast.Node, key string) {
|
||||
a := AttributeFromNode(node)
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "id":
|
||||
a.ID = nil
|
||||
case "class":
|
||||
// TODO
|
||||
default:
|
||||
delete(a.Attrs, key)
|
||||
}
|
||||
}
|
||||
|
||||
// SetAttribute sets the attribute under key to value.
|
||||
func SetAttribute(node ast.Node, key string, value []byte) {
|
||||
a := AttributeFromNode(node)
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
switch key {
|
||||
case "id":
|
||||
a.ID = value
|
||||
case "class":
|
||||
// TODO
|
||||
default:
|
||||
a.Attrs[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
// Attribute returns the attribute value under key. Use AttributeClass to retrieve
|
||||
// a class.
|
||||
func Attribute(node ast.Node, key string) []byte {
|
||||
a := AttributeFromNode(node)
|
||||
if a == nil {
|
||||
return nil
|
||||
}
|
||||
switch key {
|
||||
case "id":
|
||||
return a.ID
|
||||
case "class":
|
||||
// use AttributeClass.
|
||||
}
|
||||
|
||||
return a.Attrs[key]
|
||||
}
|
||||
|
||||
func AttributeBytes(attr *ast.Attribute) []byte {
|
||||
ret := &bytes.Buffer{}
|
||||
ret.WriteByte('{')
|
||||
if len(attr.ID) != 0 {
|
||||
ret.WriteByte('#')
|
||||
ret.Write(attr.ID)
|
||||
}
|
||||
for _, c := range attr.Classes {
|
||||
if ret.Len() > 1 {
|
||||
ret.WriteByte(' ')
|
||||
}
|
||||
ret.WriteByte('.')
|
||||
ret.Write(c)
|
||||
}
|
||||
|
||||
keys := []string{}
|
||||
for k := range attr.Attrs {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, k := range keys {
|
||||
if ret.Len() > 1 {
|
||||
ret.WriteByte(' ')
|
||||
}
|
||||
ret.WriteString(k)
|
||||
ret.WriteString(`="`)
|
||||
ret.Write(attr.Attrs[k])
|
||||
ret.WriteByte('"')
|
||||
}
|
||||
ret.WriteByte('}')
|
||||
return ret.Bytes()
|
||||
}
|
||||
|
||||
// AttributeClass returns true is class key is set.
|
||||
func AttributeClass(node ast.Node, key string) bool {
|
||||
a := AttributeFromNode(node)
|
||||
if a == nil {
|
||||
return false
|
||||
}
|
||||
for _, c := range a.Classes {
|
||||
if string(c) == key {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// AttributeFilter runs the attribute on node through filter and only allows elements for which filter returns true.
|
||||
func AttributeFilter(node ast.Node, filter func(key string) bool) {
|
||||
a := AttributeFromNode(node)
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
if !filter("id") {
|
||||
a.ID = nil
|
||||
}
|
||||
if !filter("class") {
|
||||
a.Classes = nil
|
||||
}
|
||||
for k, _ := range a.Attrs {
|
||||
if !filter(k) {
|
||||
delete(a.Attrs, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FilterFunc checks if s is an allowed key in an attribute.
|
||||
// If s is:
|
||||
// "id" the ID should be checked
|
||||
// "class" the classes should be allowed or disallowed
|
||||
// any other string means checking the individual attributes.
|
||||
// it returns true for elements that are allows, false otherwise.
|
||||
type FilterFunc func(s string) bool
|
||||
71
vendor/github.com/mmarkdown/mmark/mast/reference/reference.go
generated
vendored
Normal file
71
vendor/github.com/mmarkdown/mmark/mast/reference/reference.go
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// Package reference defines the elements of a <reference> block.
|
||||
package reference
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
// Author is the reference author.
|
||||
type Author struct {
|
||||
Fullname string `xml:"fullname,attr,omitempty"`
|
||||
Initials string `xml:"initials,attr,omitempty"`
|
||||
Surname string `xml:"surname,attr,omitempty"`
|
||||
Role string `xml:"role,attr,omitempty"`
|
||||
Organization *Organization `xml:"organization,omitempty"`
|
||||
Address *Address `xml:"address,omitempty"`
|
||||
}
|
||||
|
||||
type Organization struct {
|
||||
Abbrev string `xml:"abbrev,attr,omitempty"`
|
||||
Value string `xml:",chardata"`
|
||||
}
|
||||
|
||||
// this is copied from ../title.go; it might make sense to unify them, both especially, it we
|
||||
// want to allow reference to be given in TOML as well. See #55.
|
||||
// Author denotes an RFC author.
|
||||
|
||||
// Address denotes the address of an RFC author.
|
||||
type Address struct {
|
||||
Phone string `xml:"phone,omitempty"`
|
||||
Email string `xml:"email,omitempty"`
|
||||
URI string `xml:"uri,omitempty"`
|
||||
Postal AddressPostal `xml:"postal,omitempty"`
|
||||
}
|
||||
|
||||
// AddressPostal denotes the postal address of an RFC author.
|
||||
type AddressPostal struct {
|
||||
PostalLine []string `xml:"postalline,omitempty"`
|
||||
|
||||
Streets []string `xml:"street,omitempty"`
|
||||
Cities []string `xml:"city,omitempty"`
|
||||
Codes []string `xml:"code,omitempty"`
|
||||
Countries []string `xml:"country,omitempty"`
|
||||
Regions []string `xml:"region,omitempty"`
|
||||
}
|
||||
|
||||
// Date is the reference date.
|
||||
type Date struct {
|
||||
Year string `xml:"year,attr,omitempty"`
|
||||
Month string `xml:"month,attr,omitempty"`
|
||||
Day string `xml:"day,attr,omitempty"`
|
||||
}
|
||||
|
||||
// Front the reference <front>.
|
||||
type Front struct {
|
||||
Title string `xml:"title"`
|
||||
Authors []Author `xml:"author,omitempty"`
|
||||
Date Date `xml:"date"`
|
||||
}
|
||||
|
||||
// Format is the reference <format>. This is deprecated in RFC 7991, see Section 3.3.
|
||||
type Format struct {
|
||||
Type string `xml:"type,attr,omitempty"`
|
||||
Target string `xml:"target,attr"`
|
||||
}
|
||||
|
||||
// Reference is the entire <reference> structure.
|
||||
type Reference struct {
|
||||
XMLName xml.Name `xml:"reference"`
|
||||
Anchor string `xml:"anchor,attr"`
|
||||
Front Front `xml:"front"`
|
||||
Format *Format `xml:"format,omitempty"`
|
||||
Target string `xml:"target,attr"`
|
||||
}
|
||||
95
vendor/github.com/mmarkdown/mmark/mast/title.go
generated
vendored
Normal file
95
vendor/github.com/mmarkdown/mmark/mast/title.go
generated
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
package mast
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gomarkdown/markdown/ast"
|
||||
)
|
||||
|
||||
// Title represents the TOML encoded title block.
|
||||
type Title struct {
|
||||
ast.Leaf
|
||||
*TitleData
|
||||
Trigger string // either triggered by %%% or ---
|
||||
}
|
||||
|
||||
// NewTitle returns a pointer to TitleData with some defaults set.
|
||||
func NewTitle(trigger byte) *Title {
|
||||
t := &Title{
|
||||
TitleData: &TitleData{
|
||||
Area: "Internet",
|
||||
Ipr: "trust200902",
|
||||
Consensus: true,
|
||||
},
|
||||
}
|
||||
t.Trigger = string([]byte{trigger, trigger, trigger})
|
||||
return t
|
||||
}
|
||||
|
||||
const triggerDash = "---"
|
||||
|
||||
func (t *Title) IsTriggerDash() bool { return t.Trigger == triggerDash }
|
||||
|
||||
// TitleData holds all the elements of the title.
|
||||
type TitleData struct {
|
||||
Title string
|
||||
Abbrev string
|
||||
|
||||
SeriesInfo SeriesInfo
|
||||
Consensus bool
|
||||
Ipr string // See https://tools.ietf.org/html/rfc7991#appendix-A.1
|
||||
Obsoletes []int
|
||||
Updates []int
|
||||
SubmissionType string // IETF, IAB, IRTF or independent
|
||||
|
||||
Date time.Time
|
||||
Area string
|
||||
Workgroup string
|
||||
Keyword []string
|
||||
Author []Author
|
||||
}
|
||||
|
||||
// SeriesInfo holds details on the Internet-Draft or RFC, see https://tools.ietf.org/html/rfc7991#section-2.47
|
||||
type SeriesInfo struct {
|
||||
Name string // name of the document, values are "RFC", "Internet-Draft", and "DOI"
|
||||
Value string // either draft name, or number
|
||||
Status string // The status of this document, values: "standard", "informational", "experimental", "bcp", "fyi", and "full-standard"
|
||||
Stream string // "IETF" (default),"IAB", "IRTF" or "independent"
|
||||
}
|
||||
|
||||
// Author denotes an RFC author.
|
||||
type Author struct {
|
||||
Initials string
|
||||
Surname string
|
||||
Fullname string
|
||||
Organization string
|
||||
OrganizationAbbrev string `toml:"abbrev"`
|
||||
Role string
|
||||
ASCII string
|
||||
Address Address
|
||||
}
|
||||
|
||||
// Address denotes the address of an RFC author.
|
||||
type Address struct {
|
||||
Phone string
|
||||
Email string
|
||||
URI string
|
||||
Postal AddressPostal
|
||||
}
|
||||
|
||||
// AddressPostal denotes the postal address of an RFC author.
|
||||
type AddressPostal struct {
|
||||
Street string
|
||||
City string
|
||||
Code string
|
||||
Country string
|
||||
Region string
|
||||
PostalLine []string
|
||||
|
||||
// Plurals when these need to be specified multiple times.
|
||||
Streets []string
|
||||
Cities []string
|
||||
Codes []string
|
||||
Countries []string
|
||||
Regions []string
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue