1
0
mirror of https://github.com/danog/blackfriday.git synced 2024-11-26 20:14:43 +01:00

Add some documentation to reference struct

This commit is contained in:
Vytautas Šaltenis 2016-09-03 13:16:41 +03:00
parent 6947216efb
commit 43ba539936

View File

@ -535,13 +535,50 @@ func firstPass(p *parser, input []byte) []byte {
//
// are not yet supported.
// References are parsed and stored in this struct.
// reference holds all information necessary for a reference-style links or
// footnotes.
//
// Consider this markdown with reference-style links:
//
// [link][ref]
//
// [ref]: /url/ "tooltip title"
//
// It will be ultimately converted to this HTML:
//
// <p><a href=\"/url/\" title=\"title\">link</a></p>
//
// And a reference structure will be populated as follows:
//
// p.refs["ref"] = &reference{
// link: "/url/",
// title: "tooltip title",
// }
//
// Alternatively, reference can contain an information about a footnote.
// Consider this markdown:
//
// Text needing a footnote.[^a]
//
// [^a]: This is the note
//
// A reference structure will be populated as follows:
//
// p.refs["a"] = &reference{
// link: "a",
// title: "This is the note",
// noteID: <some positive int>,
// }
//
// TODO: As you can see, it begs for splitting into two dedicated structures
// for refs and for footnotes.
type reference struct {
link []byte
title []byte
noteID int // 0 if not a footnote ref
hasBlock bool
text []byte
text []byte // only gets populated by refOverride feature with Reference.Text
}
func (r *reference) String() string {