File tree Expand file tree Collapse file tree 7 files changed +62
-5
lines changed
Expand file tree Collapse file tree 7 files changed +62
-5
lines changed Original file line number Diff line number Diff line change 671671
672672And then reference the same ` (#myid) ` , the formatter (` xml2rfc ` ) will do the right thing.
673673
674+ #### Cross Reference Text Suffixes
675+
676+ Just like [ ] ( #reference-text-suffices ) , you can add a suffix text to a reference, to influence how
677+ xml2rfc will render it, see < https://www.rfc-editor.org/materials/FAQ-xml2rfcv3.html#section-3.11 >
678+ it will allow you to set the format attribute. The following is supported:
679+
680+ * counter
681+ * title
682+ * default
683+
684+ * ` (#myid, use counter) ` -> format="counter"
685+ * ` (#myid, use title) ` -> format="title"
686+
687+ Translation of these strings _ is_ supported for a few languages, ` (#myid, gebruik titel) ` (Dutch) is
688+ supported for instance.
689+
690+ Also note these strings need to be literary typed as shown here (we may become more lenient in the
691+ future).
692+
674693### Super- and Subscript
675694
676695For superscript use ` ^ ` and for subscripts use ` ~ ` . For example:
Original file line number Diff line number Diff line change 44
55require (
66 github.com/BurntSushi/toml v1.2.0
7- github.com/gomarkdown/markdown v0.0.0-20220825072242-90efaac57fb4
7+ github.com/gomarkdown/markdown v0.0.0-20220830015526-01a3c37d6f50
88 github.com/google/go-cmp v0.2.0
99)
Original file line number Diff line number Diff line change @@ -2,5 +2,7 @@ github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0
22github.com/BurntSushi/toml v1.2.0 /go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ =
33github.com/gomarkdown/markdown v0.0.0-20220825072242-90efaac57fb4 h1:YOfiTywt9f60GzIFrnor09U0Q3PySmqnyIqvK0o6fzI =
44github.com/gomarkdown/markdown v0.0.0-20220825072242-90efaac57fb4 /go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA =
5+ github.com/gomarkdown/markdown v0.0.0-20220830015526-01a3c37d6f50 h1:tSuUky4sFWjiIIEOefDDBjx5BUIT3kZwcXHM2CNDdTk =
6+ github.com/gomarkdown/markdown v0.0.0-20220830015526-01a3c37d6f50 /go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA =
57github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ =
68github.com/google/go-cmp v0.2.0 /go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M =
Original file line number Diff line number Diff line change @@ -20,15 +20,21 @@ func New(language string) Lang {
2020 WrittenBy : "Written by" ,
2121 See : "see" ,
2222 Section : "section" ,
23+ UseCounter : "use counter" ,
24+ UseTitle : "use title" ,
2325 },
2426 "nl" : {
27+ And : "en" ,
2528 Bibliography : "Bibliografie" ,
2629 Footnotes : "Voetnoten" ,
2730 Index : "Index" ,
2831 See : "zie" ,
2932 Section : "sectie" ,
33+ UseCounter : "gebruik nummer" ,
34+ UseTitle : "gebruik titel" ,
3035 },
3136 "de" : {
37+ And : "und" ,
3238 Bibliography : "Literaturverzeichnis" ,
3339 Footnotes : "Fußnoten" ,
3440 Index : "Index" ,
@@ -71,9 +77,11 @@ type Term struct {
7177 Index string
7278 WrittenBy string
7379
74- // The references
75- See string
76- Section string
80+ // for cross references
81+ See string
82+ Section string
83+ UseCounter string
84+ UseTitle string
7785}
7886
7987func (l Lang ) Footnotes () string {
@@ -139,3 +147,19 @@ func (l Lang) Section() string {
139147 }
140148 return t .Section
141149}
150+
151+ func (l Lang ) UseCounter () string {
152+ t , ok := l .m [l .language ]
153+ if ! ok {
154+ return l .m ["en" ].UseCounter
155+ }
156+ return t .UseCounter
157+ }
158+
159+ func (l Lang ) UseTitle () string {
160+ t , ok := l .m [l .language ]
161+ if ! ok {
162+ return l .m ["en" ].UseTitle
163+ }
164+ return t .UseTitle
165+ }
Original file line number Diff line number Diff line change @@ -567,7 +567,17 @@ func (r *Renderer) callout(w io.Writer, callout *ast.Callout) {
567567
568568func (r * Renderer ) crossReference (w io.Writer , cr * ast.CrossReference , entering bool ) {
569569 if entering {
570- r .outTag (w , "<xref" , []string {"target=\" " + string (cr .Destination ) + "\" " })
570+ attr := []string {fmt .Sprintf (`target="%s"` , cr .Destination )}
571+ if len (cr .Suffix ) > 0 {
572+ switch {
573+ case string (cr .Suffix ) == r .opts .Language .UseCounter ():
574+ attr = append (attr , `format="counter"` )
575+
576+ case string (cr .Suffix ) == r .opts .Language .UseTitle ():
577+ attr = append (attr , `format="title"` )
578+ }
579+ }
580+ r .outTag (w , "<xref" , attr )
571581 return
572582 }
573583 r .outs (w , "</xref>" )
Original file line number Diff line number Diff line change 1+ See (#myid, use counter), to check.
Original file line number Diff line number Diff line change 1+ <t >See <xref target =" myid" format =" counter" ></xref >, to check.</t >
You can’t perform that action at this time.
0 commit comments