kramdown-rfc icon indicating copy to clipboard operation
kramdown-rfc copied to clipboard

Feature Request: Cross-doc references

Open MikeBishop opened this issue 7 years ago • 3 comments

This might be beyond the scope of kramdown, but in a repo containing multiple documents which contain references amongst each other, it's easy for the section numbers of cross-references to get out of sync. In the same way that {{section-anchor}} always tracks where that section is landing in the current version of the draft, I'd love to be able to use something like {{DOCNAME#section-anchor}} to consistently reference a particular section in a companion document.

MikeBishop avatar Oct 11 '18 21:10 MikeBishop

That would need be a great feature. <relref> in RFCXML v3 is almost addressing this, but requires a numeric section reference. (There is also a "relative" attribute, but its description doesn't make sense to me.)

Since the numbering is generated by xml2rfc (and kramdown-rfc probably should not second-guess this), this would easier to do if xml2rfc left a "side file" with the mapping from reference anchors to section numbers. @levkowetz -- is this something you could imagine adding to xml2rfc?

cabo avatar Oct 11 '18 22:10 cabo

Sure. The biggest issue at the moment is that I don't see one single place in the code to insert this; for full availability it would have to be added in multiple places.

For the v3 formatters, the preptool would be the ideal place for this. But the preptool isn't run for v2 formatters, and there's no equivalent conditioning step.

The v2 formatters don't pre-compute the section numbers, they calculate the counters on the fly while generating the output, so keeping track of the anchors and section numbers in that case would be a much more invasive code change than for v3, where the information could just be extracted from the prepped xml.

If there was a guarantee that the section numbers would be the same, then one could do a preptool run to generate the anchor-to-section-number lookup, and use that with v2. I think that it will be the same in almost all cases, but ...

One set of anchors and numbers that will not be the same between v2 and v3, in general, are table and figure numbers. If you don't take active steps to avoid table and figure numbers, you will get them in v3 even if you didn't in v2.

With all those caveats, I could still take a first run at this based on the preptool-generated numbers.

levkowetz avatar Oct 17 '18 13:10 levkowetz

In rfc2629.xslt, relative section references can use symbolic names, but of course that requires that the processor can inspect the XML source of the target document. We've used that in the HTTP specs for ages.

That said, kramdown could do this as well (pull in the MD source of the target document and compute the section number accordingly).

reschke avatar Nov 26 '18 20:11 reschke