mmarkdown / mmark

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

Omit `day` attribute in `<date>` boilerplate element for RFCs #214

Closed str4d closed 11 months ago

str4d commented 11 months ago

What went wrong?

The RFC Editor has informed me that:

We publish RFCs with only month and year, with the exception of April 1 RFCs.

mmark renders the document date in the title boilerplate here: https://github.com/mmarkdown/mmark/blob/3944c1c00c36aa11468fcc21f32410f920be3463/render/xml/title.go#L177-L196 (at least, I think it's here; but that renderer hard-codes "January" as the month, and I can't find anywhere else that renders title dates).

This renderer does allow for the day attribute to be omitted (if it is zero); however, there is no syntax for encoding such a date into the Markdown source.

mmark should omit the day attribute from the <date> boilerplate element (for non-April-1 RFCs), and maybe also permit a date item in the title block that doesn't include a day.

What version of mmark are you using?

2.2.39

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

%%%
    title = "Foobar"
    submissionType = "IRTF"
    date = 2023-11-01

    [seriesInfo]
    name = "Internet-Draft"
    value = "foobar"
    stream = "IRTF"
    status = "informational"
%%%

renders:

<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="foobar" submissionType="IRTF" category="info" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true">

<front>
<title>Foobar</title><seriesInfo value="foobar" stream="IRTF" status="informational" name="Internet-Draft"></seriesInfo>
<date year="2023" month="November" day="1"></date>
<area>Internet</area>
<workgroup></workgroup>

</front>

</rfc>

If I try to explicitly set the day to zero (2023-11-00), I get the following error (and similarly if I leave off the day and use 2023-11):

Failure parsing title block: toml: line 4 (last key "date"): Invalid TOML Datetime: "2023-11-00".
Empty 'value' in [seriesInfo], resulting XML may fail to parse.
Empty 'stream' in [seriesInfo], resulting XML may fail to parse.
Empty 'status' in [seriesInfo], resulting XML may fail to parse.
Empty 'name' in [seriesInfo], resulting XML may fail to parse.

If I try to set the date field to "November 2023", I get the following error:

Failure parsing title block: parsing time "November 2023" as "2006-01-02T15:04:05Z07:00": cannot parse "November 2023" as "2006"
miekg commented 11 months ago

toml's date construct requires a full date which an I-D does need that, but an RFC doesn't.

think it's fine for the RFC editor to remove this attribute from the XML and there should be no workarounds from our side

miekg commented 11 months ago

maybe I can do something here

str4d commented 11 months ago

toml's date construct requires a full date which an I-D does need that, but an RFC doesn't.

Yep, I have confirmation from the RFC Editor that the day attribute indeed should be present for an I-D, but not for an RFC.

216 LGTM, thanks!