<?xml version="1.0" encoding="<%=ps[:coding]||"UTF-8"%>"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc version <%=
    Gem.loaded_specs["kramdown-rfc2629"].version rescue nil 
    %> (Ruby <%= RUBY_VERSION %>) -->

<% if $options.v3 %>
<!DOCTYPE rfc <%= ps["doctype-reference"] %> [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
<% else %>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<% end %>
<% ps.arr("bibxml") do |tag, sys| -%>
<!ENTITY <%= tag %> SYSTEM "<%= sys %>">
<% end -%>
<% ps.arr("entity", false) do |en, ev| -%>
<!ENTITY <%=en%> "<%=ev%>">
<% end -%>
]>

<%
  ps.rest.fetch("consensus") do
    # consensus not given -- default intelligently
    cat = ps.has("category") || ps.has("cat")
    MUST_CONSENSUS = {"std" => true, "bcp" => true}
    ps["consensus"] = true if MUST_CONSENSUS[cat]
  end
  rfcattrs = ps.attrs("ipr", "docName=docname", "category=cat",
                      "consensus", "submissionType=submissiontype=stream", "xml:lang=lang",
                      "number", "obsoletes", "updates", "seriesNo=seriesno")
  TRUE_FALSE = {nil => "true", false => "false", true => "true",
                "yes" => "true", "no" => "false"}
  YES_NO = {"true" => "yes", "false" => "no"}
  pis = KramdownRFC::ParameterSet.new({})
  ps.arr("pi", false) do |pi, val|
    pis[pi] = TRUE_FALSE[val] || val
  end
  if $options.v3
    piattrs = pis.attrs("tocDepth=tocdepth", "tocInclude=toc",
                        "sortRefs=sortrefs", "symRefs=symrefs", "indexInclude=index")
    if piattrs != ""
      rfcattrs << " " << piattrs
    end
  end
  pis.rest.each do |pi, val|
    v = YES_NO[val] || pis.escattr(val)
-%>
<?rfc <%=pi%>="<%=v%>"?>
<% end -%>

<rfc <%=rfcattrs%>>
<% ps.arr("v3xml2rfc", false) do |pi, val|
    Array(val).each do |el|
-%>
  <?v3xml2rfc <%=pi%>="<%=ps.escattr(el)%>"?>
<%  end
   end -%>
  <front>
    <%= ps.ele("title", ps.attr("abbrev=titleabbrev")) %>

<% ps.arr("author") do |au|
   aups = KramdownRFC::authorps_from_hash(au)
 -%>
<%= KramdownRFC::person_element_from_aups("author", aups) -%>
<%   aups.warn_if_leftovers  -%>
<% end -%>

    <date <%= KramdownRFC::dateattrs(ps[:date]||Date.today) %>/>

    <%= ps.ele("area") %>
    <%= ps.ele("workgroup=wg") %>
    <%= ps.ele("keyword=kw") %>

    <abstract>

<%= sechash.delete("abstract") %>

    </abstract>

<% if $options.v3 -%>
<%  venue = ps[:venue] -%>
<%  if venue -%>
<%    venue = KramdownRFC::ParameterSet.new(venue) -%>
    <note title="About This Document" removeInRFC="true">
<%   if (dn = ps.av[:docName]) &&
       (dt = dn.rpartition('-')[0]) != ""
-%>
      <t>
<%   if latest = venue[:latest] -%>
        The latest revision of this draft can be found at <eref target="<%=latest%>"/>.
<%   end -%>
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/<%=dt%>/"/>.
      </t>
<%   end -%>
<%   mail = venue[:mail] -%>
<%   homepage = venue[:home] -%>
<%   gtype = venue[:type] -%>
<%   if mail || homepage -%>
      <t>
<%   end -%>
<%   if mail
       mail_local, mail_host = mail.split("@", 2)
     end
     if mail_host -%>
<%     default_links = {
                         "iab.org" => true,
                         "ietf.org" => true,
                         "irtf.org" => true,
                       }[mail_host]
       mail_subdomain, mail_domain = mail_host.split(".", 2)
       group = venue[:group] || mail_local # XXX
       arch = venue[:arch] || default_links && "https://mailarchive.ietf.org/arch/browse/#{mail_local}/"
       subscribe = venue[:subscribe] || default_links && "https://www.ietf.org/mailman/listinfo/#{mail_local}/"
       GROUPS = {"ietf" => "Working ", "irtf" => "Research "}
       gtype ||= "#{GROUPS[mail_subdomain]}Group" -%>
        Discussion of this document takes place on the
        <%=group%> <%=gtype%> mailing list (<eref target="mailto:<%=mail%>"/>)<% if arch -%>,
        which is archived at <eref target="<%=arch%>"/><% end -%>.
<% if subscribe -%>
        Subscribe at <eref target="<%=subscribe%>"/>.
<% end -%>
<%   end -%>
<%   if homepage -%>
        <%=gtype%> information can be found at <eref target="<%=homepage%>"/>.
<%   end -%>
<%   if mail || homepage -%>
      </t>
<%   end -%>
<%   if repo = venue[:repo] || ((gh = venue[:github]) && "https://github.com/#{gh}") -%>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="<%=repo%>"/>.</t>
<%   end -%>
<%= venue.ele("t=text", nil, nil, true) -%>
    </note>
<%  venue.warn_if_leftovers -%>
<%  end -%>
<% end -%>

<% sechash.keys.each do |k| -%>
<%   if k =~ /\A(to_be_removed_)?note_(.*)/ -%>

<% option = ""
       text = ""
       if $1
         if $options.v3
           option = " removeInRFC=\"true\""
         else
           text = "      <t>[This note is to be removed before publishing as an RFC.]</t>\n"
         end
       end
    -%>
    <note title="<%= $2.gsub("_", " ")%>"<%= option %>>
<%= text -%>

<%= sechash.delete(k) -%>

    </note>

<% end -%>
<% end -%>

  </front>

  <middle>

{:/nomarkdown}
{:quote: gi="blockquote"}
{:aside: gi="aside"}
{:cref: gi="cref"}
{:markers: sourcecode-markers="true"}
{:unnumbered: numbered="false"}
{:vspace: vspace="0"}
{:removeinrfc: removeinrfc="true"}
{:notoc: toc="exclude"}
{:compact: spacing="compact"}
{:noabbrev: noabbrev="true"}
{::nomarkdown}

<%= sechash.delete("middle") %>

  </middle>

  <back>

<% displayref.each do |k, v| -%>
    <displayreference target="<%=k%>" to="<%=v%>"/>
<% end -%>

<% shn = sechash.delete("normative")
   shi = sechash.delete("informative")
   shc = shn && shi
   if shc
-%>
<references title='References' anchor="sec-combined-references">
<% end -%>

<% if shn -%>
    <references title='Normative References' anchor="sec-normative-references">

<%= shn %>

    </references>
<% end -%>

<% if shi -%>
    <references title='Informative References' anchor="sec-informative-references">

<%= shi %>

    </references>
<% end -%>

<% if shc -%>
</references>
<% end -%>

<%= sechash.delete("back") %>
<% sh = sechash.delete("contributor") -%>
<% consec = ps.has("contributor") -%>
<% if sh || consec -%>
<%   if $options.v3 -%>
    <section anchor="contributors" numbered="false" toc="include" removeInRFC="false">
        <name>Contributors</name>
<%   else -%>
    <section anchor="contributors" numbered="false" title="Contributors">
<%     warn "*** To use YAML contributors, use --v3 (kdrfc -3)" if consec -%>
<%   end -%>
<%= sh -%>
<% if $options.v3 && consec
     ps.arr("contributor") do |au|
      if Hash === au
       aups = KramdownRFC::authorps_from_hash(au)
   -%>
<%= KramdownRFC::person_element_from_aups("contact", aups) -%>
<%= if contrib = aups["contribution"]
    <<CONTRIBUTION
{:/nomarkdown}
#{contrib}

{::nomarkdown}
CONTRIBUTION
    end -%>
<%   aups.warn_if_leftovers  -%>
<%   else -%>
<%=  <<TEXT
{:/nomarkdown}

#{au}

{::nomarkdown}
TEXT
-%>
<%   end -%>
<%  end -%>
<% end -%>
    </section>
<% end -%>

  </back>

<% if $source -%>
<!-- ##markdown-source:
<%= $source %>
-->
<% end -%>

</rfc>
