mmarkdown / mmark

Mmark: a powerful markdown processor in Go geared towards the IETF
https://mmark.miek.nl
Other
480 stars 45 forks source link

Normative and Informative references are not wrapped in References section #197

Closed str4d closed 11 months ago

str4d commented 11 months ago

What went wrong?

One of the editorial changes that the RFC Editor made to an ID's XML generated from mmark was to make the normative and informative references subsections of a References section, to match the RFC style guide. mmark should perform this nesting itself when both normative and informative references are present.

What version of mmark are you using?

2.2.36

What is the most minimal markdown snippets that shows the problem?

# Introduction

Normative: [@!RFC2119]

Informative: [@?RFC7748]

{backmatter}

generates:

<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->

<section anchor="introduction"><name>Introduction</name>
<t>Normative: <xref target="RFC2119"></xref></t>
<t>Informative: <xref target="RFC7748"></xref></t>
</section>

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
</references>
<references><name>Informative References</name>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7748.xml"/>
</references>

</back>
str4d commented 11 months ago

I think the bug is here: https://github.com/mmarkdown/mmark/blob/3d25d9375c96315e75624f8f5b9d814d870e35fe/mparser/bibliography.go#L196-L216

If (norm != nil) && (inform != nil), a wrapping References section should be appended to where, and norm / inform should be appended to that.

str4d commented 11 months ago

With the commit above (in #199), the Markdown from the OP renders as:

<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->

<section anchor="introduction"><name>Introduction</name>
<t>Normative: <xref target="RFC2119"></xref></t>
<t>Informative: <xref target="RFC7748"></xref></t>
</section>

</middle>

<back>
<references><name>References</name>
<references><name>Normative References</name>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
</references>
<references><name>Informative References</name>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7748.xml"/>
</references>
</references>

</back>

which is exactly the change that the RFC Editor made to the ID in question.