diff --git a/Syntax.md b/Syntax.md index ad4ddd6..4c1eb3e 100644 --- a/Syntax.md +++ b/Syntax.md @@ -446,8 +446,11 @@ citation to the references, but does not show up in the document as a citation. The first seen modifier determines the type (suppressed, normative or informative). Multiple citation can separated with a semicolon: `[@RFC1034; @RFC1035]`. -If you reference an RFC or I-D the reference will be added automatically (no need to muck about -with an `` block. +If you reference an RFC, I-D or W3C document the reference will be added automatically (no need to +muck about with an `` block. This is to say: + +Any reference starting with *RFC*, *I-D.* or *W3C.* will be automatically added to the correct +reference section. For I-Ds you may want to add a draft sequence number, which can be done as such: `[@?I-D.blah#06]`. If you reference an I-D *without* a sequence number it will create a reference to the *last* I-D in diff --git a/xml/bibliography.go b/xml/bibliography.go index 58260ea..b9392c4 100644 --- a/xml/bibliography.go +++ b/xml/bibliography.go @@ -39,7 +39,10 @@ func (r *Renderer) bibliographyItem(w io.Writer, node *mast.BibliographyItem) { tag := "" switch { case bytes.HasPrefix(node.Anchor, []byte("RFC")): - tag = makeXiInclude(toolsIetfOrg, fmt.Sprintf("reference.RFC.%s.xml", node.Anchor[3:])) + tag = makeXiInclude(ToolsRFC, fmt.Sprintf("reference.RFC.%s.xml", node.Anchor[3:])) + + case bytes.HasPrefix(node.Anchor, []byte("W3C.")): + tag = makeXiInclude(ToolsW3C, fmt.Sprintf("reference.RFC.%s.xml", node.Anchor[3:])) case bytes.HasPrefix(node.Anchor, []byte("I-D.")): hash := bytes.Index(node.Anchor, []byte("#")) @@ -48,7 +51,7 @@ func (r *Renderer) bibliographyItem(w io.Writer, node *mast.BibliographyItem) { node.Anchor[hash] = '-' defer func() { node.Anchor[hash] = '#' }() // never know if this will be used again } - tag = makeXiInclude(toolsIetfOrg, fmt.Sprintf("reference.I-D.draft-%s.xml", node.Anchor[4:])) + tag = makeXiInclude(ToolsID, fmt.Sprintf("reference.I-D.draft-%s.xml", node.Anchor[4:])) } r.outs(w, tag) r.cr(w) @@ -59,4 +62,8 @@ func makeXiInclude(url, reference string) string { return fmt.Sprintf("", url, reference) } -var toolsIetfOrg = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml" +var ( + ToolsRFC = "https://xml2rfc.ietf.org/public/rfc/bibxml/" + ToolsID = "https://xml2rfc.ietf.org/public/rfc/bibxml-ids/" + ToolsW3C = "https://xml2rfc.ietf.org/public/rfc/bibxml-w3c/" +) diff --git a/xml2/bibliography.go b/xml2/bibliography.go index 4400395..6615a1a 100644 --- a/xml2/bibliography.go +++ b/xml2/bibliography.go @@ -7,6 +7,7 @@ import ( "github.com/gomarkdown/markdown/ast" "github.com/mmarkdown/mmark/mast" + "github.com/mmarkdown/mmark/xml" ) func (r *Renderer) bibliography(w io.Writer, node *mast.Bibliography, entering bool) { @@ -40,7 +41,11 @@ func (r *Renderer) bibliographyItem(w io.Writer, node *mast.BibliographyItem) { tag := "" switch { case bytes.HasPrefix(node.Anchor, []byte("RFC")): - tag = makeRFCInclude(toolsIetfOrg, fmt.Sprintf("reference.RFC.%s.xml", node.Anchor[3:])) + tag = makeRFCInclude(xml.ToolsRFC, fmt.Sprintf("reference.RFC.%s.xml", node.Anchor[3:])) + + case bytes.HasPrefix(node.Anchor, []byte("W3C.")): + tag = makeRFCInclude(xml.ToolsW3C, fmt.Sprintf("reference.RFC.%s.xml", node.Anchor[3:])) + case bytes.HasPrefix(node.Anchor, []byte("I-D.")): hash := bytes.Index(node.Anchor, []byte("#")) if hash > 0 { @@ -48,7 +53,7 @@ func (r *Renderer) bibliographyItem(w io.Writer, node *mast.BibliographyItem) { node.Anchor[hash] = '-' defer func() { node.Anchor[hash] = '#' }() // never know if this will be used again } - tag = makeRFCInclude(toolsIetfOrg, fmt.Sprintf("reference.I-D.draft-%s.xml", node.Anchor[4:])) + tag = makeRFCInclude(xml.ToolsID, fmt.Sprintf("reference.I-D.draft-%s.xml", node.Anchor[4:])) } r.outs(w, tag) r.cr(w) @@ -57,5 +62,3 @@ func (r *Renderer) bibliographyItem(w io.Writer, node *mast.BibliographyItem) { func makeRFCInclude(url, reference string) string { return fmt.Sprintf("", url, reference) } - -var toolsIetfOrg = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml"