1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
|
<pre>Independent Submission R. Gieben
Request for Comments: 7328 Google
Category: Informational August 2014
ISSN: 2070-1721
<span class="h1">Writing I-Ds and RFCs Using Pandoc and a Bit of XML</span>
Abstract
This document presents a technique for using a Markdown syntax
variant, called Pandoc, and a bit of XML (as defined in <a href="./rfc2629">RFC 2629</a>) as
a source format for documents that are Internet-Drafts (I-Ds) or
RFCs.
The goal of this technique (which is called Pandoc2rfc) is to let an
author of an I-D focus on the main body of text without being
distracted too much by XML tags; however, it does not alleviate the
need to typeset some files in XML.
Status of This Memo
This document is not an Internet Standards Track specification; it is
published for informational purposes.
This is a contribution to the RFC Series, independently of any other
RFC stream. The RFC Editor has chosen to publish this document at
its discretion and makes no statement about its value for
implementation or deployment. Documents approved for publication by
the RFC Editor are not a candidate for any level of Internet
Standard; see <a href="./rfc5741#section-2">Section 2 of RFC 5741</a>.
Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
<a href="http://www.rfc-editor.org/info/rfc7328">http://www.rfc-editor.org/info/rfc7328</a>.
Copyright Notice
Copyright (c) 2014 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and the IETF Trust's Legal
Provisions Relating to IETF Documents
(<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document.
<span class="grey">Gieben Informational [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
Table of Contents
<a href="#section-1">1</a>. Introduction . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-2">2</a>
<a href="#section-2">2</a>. Pandoc to RFC . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-2">2</a>
<a href="#section-2.1">2.1</a>. Dependencies . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<a href="#section-3">3</a>. Building an Internet-Draft . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<a href="#section-4">4</a>. Supported Features . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<a href="#section-5">5</a>. Unsupported Features and Limitations . . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-6">6</a>. Pandoc Style . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-6.1">6.1</a>. Figures . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-6.2">6.2</a>. Tables . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-6.3">6.3</a>. References . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-6.4">6.4</a>. Index . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-7">7</a>. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-8">8</a>. Security Considerations . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-9">9</a>. References . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-9.1">9.1</a>. Normative References . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-9.2">9.2</a>. Informative References . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
<a href="#appendix-A">Appendix A</a>. Cheat Sheet . . . . . . . . . . . . . . . . . . . . <a href="#page-10">10</a>
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
This document presents a technique for using a Markdown [<a href="#ref-Markdown" title=""Markdown"">Markdown</a>]
syntax variant, called Pandoc [<a href="#ref-Pandoc" title=""Pandoc, a universal document converter"">Pandoc</a>], and a bit of XML [<a href="./rfc2629" title=""Writing I-Ds and RFCs using XML"">RFC2629</a>] as
a source format for documents that are Internet-Drafts (I-Ds) or
RFCs.
The goal of this technique is to let an author of an I-D focus on the
main body of text without being distracted too much by XML tags;
however, it does not alleviate the need to typeset some files in XML.
Pandoc is a format that is almost plain text and therefore
particularly well suited for editing RFC-like documents. The syntax
itself is a superset of the syntax championed by Markdown.
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Pandoc to RFC</span>
Pandoc's syntax is easy to learn and write, and it can be translated
to numerous output formats, including, but not limited to: HTML,
EPUB, (plain) Markdown, and DocBook XML.
Pandoc2rfc allows authors to write in Pandoc syntax that is then
transformed to XML and given to xml2rfc. The conversions are, in a
way, amusing, as we start off with (almost) plain text, use elaborate
XML, and end up with plain text again.
<span class="grey">Gieben Informational [Page 2]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
+-------------------+ pandoc +---------+
| ALMOST PLAIN TEXT | ------> | DOCBOOK |
+-------------------+ 1 +---------+
| |
non-existent | 2 | xsltproc
faster way | |
v v
+------------+ xml2rfc +---------+
| PLAIN TEXT | <-------- | XML |
+------------+ 3 +---------+
Figure 1: Attempt to justify Pandoc2rfc
The output of step 2 in Figure 1 is XML that is suitable for
inclusion in either the "middle" or "back" section of an RFC.
Even though Pandoc2rfc abstracts away a lot of XML details, there are
still places left where XML files needs to be edited -- most notably
in the "front" section of an RFC.
The simplest way to start using Pandoc2rfc is to create a template
XML file and include the appropriate XML for the "front", "middle",
and "back" section:
<span class="grey">Gieben Informational [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
<?xml version='1.0' ?>
<!DOCTYPE rfc SYSTEM '<a href="./rfc2629">rfc2629</a>.dtd' [
<!ENTITY pandocAbstract PUBLIC '' 'abstract.xml'>
<!ENTITY pandocMiddle PUBLIC '' 'middle.xml'>
<!ENTITY pandocBack PUBLIC '' 'back.xml'>
<!ENTITY rfc.2629 PUBLIC '' 'reference.RFC.2629.xml'>
]>
<rfc ipr='trust200902' docName='<a href="./draft-string-example">draft-string-example</a>'>
<front>
<title>Writing I-Ds and RFCs using Pandoc</title>
<author>
<organization/>
<address><uri>http://www.example.com</uri></address>
</author>
<date/>
<abstract>
&pandocAbstract;
</abstract>
</front>
<middle>
&pandocMiddle;
</middle>
<back>
<references title="Normative References">
&rfc.2629;
</references>
&pandocBack;
</back>
</rfc>
Figure 2: A minimal template.xml
In this case, you will need to edit four documents:
1. "abstract.mkd" - contains the abstract;
2. "middle.mkd" - contains the main body of text;
3. "back.mkd" - holds the appendices (if any);
4. and this "template.xml" -- probably a fairly static file; among
other things, it holds the author(s) and the references.
Up-to-date source code for Pandoc2rfc can be found at [<a href="#ref-Pandoc2rfc">Pandoc2rfc</a>];
this includes the style sheet "transform.xsl", which is used for the
XML transformation (also see <a href="#section-3">Section 3</a>).
<span class="grey">Gieben Informational [Page 4]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
<span class="h3"><a class="selflink" id="section-2.1" href="#section-2.1">2.1</a>. Dependencies</span>
Pandoc2rfc needs "xsltproc" [<a href="#ref-XSLT" title=""The XSLT C library for GNOME"">XSLT</a>] and "pandoc" [<a href="#ref-Pandoc" title=""Pandoc, a universal document converter"">Pandoc</a>] to be
installed. The conversion to xml2rfc XML is done with a style sheet
based on XSLT version 1.0 [<a href="#ref-W3C.REC-xslt-19991116">W3C.REC-xslt-19991116</a>].
When using the template from Figure 2, xml2rfc version 2 (or higher)
must be used.
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Building an Internet-Draft</span>
Assuming the setup from <a href="#section-2">Section 2</a>, we can build an I-D as follows (in
a Unix-like environment):
for i in abstract middle back; do
pandoc -st docbook $i.mkd | xsltproc --nonet transform.xsl - > $i.xml
done
xml2rfc template.xml -f draft.txt --text # create text output
xml2rfc template.xml -f draft.html --html # or create HTML output
xml2rfc template.xml -f draft.xml --exp # or create XML output
Figure 3: Building an I-D
Note that the output file names (abstract.xml, middle.xml, and
back.xml) must match the names used as the XML entities in
"template.xml". (See the "!ENTITY" lines in Figure 2.) The
Pandoc2rfc source repository includes a shell script that
incorporates the above transformations. Creating a "draft.txt" or a
"draft.xml" can be done with "pandoc2rfc *.mkd" and "pandoc2rfc -X
*.mkd", respectively.
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Supported Features</span>
The full description of Pandoc's syntax can be found in
[<a href="#ref-PandocGuide">PandocGuide</a>]. The following features of xml2rfc are supported by
Pandoc2rfc (also see Table 1 in <a href="#appendix-A">Appendix A</a> for a "cheat sheet"):
o Sections with an anchor and title attributes;
o Several list styles:
* style="symbols", use "* " for each item;
* style="numbers", use digits: "1. " for each item;
* style="empty", use "#. " for each item;
<span class="grey">Gieben Informational [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
* style="format %i", use lowercase Roman numerals: "ii. ";
* style="format (%d)", use uppercase Roman numerals "II. ";
* style="format ...", use strike-through text at the start in the
first element, "1. ~~REQ%d.~~ ";
* style="letters", use lower- or uppercase letters: "a. " and
"A. " (note: two spaces as mandated by Pandoc);
* style="hanging", use the Pandoc definition list syntax:
Term 1
: Definition 1
o Spanx style="verb", style="emph", and style="strong",
respectively, use: "`text`", "_text_" or "**text**";
o Block quote, which is converted to a paragraph within a "<list
style="empty">";
o Figures with an anchor and title (<a href="#section-6.1">Section 6.1</a>);
o Tables with an anchor and title (<a href="#section-6.2">Section 6.2</a>);
o References (<a href="#section-6.3">Section 6.3</a>)
* external ("<eref>");
* cross-reference ("<xref>"), to:
+ sections (handled by Pandoc);
+ figures (handled by XSLT);
+ tables (handled by XSLT).
o Index, by using footnotes and superscript text (<a href="#section-6.4">Section 6.4</a>);
o Citations, by using cross-references;
o Processing Instructions (PIs), which appear as "<?rfc?>", may be
used after a section header. They are carried over to the
generated XML.
o The "<vspace>" tag is supported and carried over to the generated
XML.
<span class="grey">Gieben Informational [Page 6]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Unsupported Features and Limitations</span>
With Pandoc2rfc, an author of an I-D can get a long way without
needing to input XML, but it is not a 100% solution. The initial
setup and the reference library still force the author to edit XML
files. The metadata feature (Pandoc's "Title Block" extension) is
not used in Pandoc2rfc. This information (authors, date, keyword,
and URLs) should be put in the "template.xml".
Some other quirks:
o Comments are supported via HTML comments in the Pandoc source
files.
o Citations are supported via cross-references; the citation syntax
of Pandoc is not used.
o Authors still need to know how to deal with possible errors from
xml2rfc.
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Pandoc Style</span>
The following sections detail how to use the Pandoc syntax for
figures, tables, and references to get the desired output.
<span class="h3"><a class="selflink" id="section-6.1" href="#section-6.1">6.1</a>. Figures</span>
Indent the paragraph with 4 spaces as mandated by Pandoc. If you add
an inline footnote _directly_ after the figure, the artwork gets a
title attribute with the text of that footnote (and a possible
anchor).
<span class="h3"><a class="selflink" id="section-6.2" href="#section-6.2">6.2</a>. Tables</span>
A table can be entered by using Pandoc's table syntax. You can
choose multiple styles as input, but they all are converted to the
same style table (plain "<texttable>") in xml2rfc. If you add an
inline footnote _directly_ after the table, it will get a title
attribute with the text of that footnote (and a possible anchor).
The built-in syntax of Pandoc to create a caption with "Table:"
should not be used.
<span class="h3"><a class="selflink" id="section-6.3" href="#section-6.3">6.3</a>. References</span>
Pandoc provides a syntax that can be used for references. Its syntax
is repeated in this paragraph. Any reference like
"[Click here](URI)" is an external reference. An internal reference
(i.e., "see Section X") is typeset with "[](#localid)".
<span class="grey">Gieben Informational [Page 7]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
For referencing RFCs (and other documents), you will need to add the
reference source in the template as an external XML entity; Figure 2
provides an example. After that, you can use the following syntax to
create a citation: "[](#<a href="./rfc2629">RFC2629</a>)" to cite <a href="./rfc2629">RFC 2629</a>.
There is no direct support for referencing tables, figures, and
artworks, but Pandoc2rfc employs the following "hack". If an inline
footnote is added after the figure or table, the text of the footnote
is used as the title. The first word up until a double colon "::"
will be used as the anchor. If a figure has an anchor, it will be
centered on the page.
Figure 2, for instance, is followed by this inline footnote:
^[fig:minimal::A minimal template.xml.]
<span class="h3"><a class="selflink" id="section-6.4" href="#section-6.4">6.4</a>. Index</span>
An index can be generated by using the following syntax:
^[ ^item^ subitem ]
where "subitem" is optional.
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Acknowledgements</span>
The following people have helped shape Pandoc2rfc: Benno Overeinder,
Erlend Hamnaberg, Matthijs Mekking, and Trygve Laugstoel.
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. Security Considerations</span>
This document raises no security issues.
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. References</span>
<span class="h3"><a class="selflink" id="section-9.1" href="#section-9.1">9.1</a>. Normative References</span>
[<a id="ref-RFC2629">RFC2629</a>] Rose, M., "Writing I-Ds and RFCs using XML", <a href="./rfc2629">RFC 2629</a>,
June 1999.
[<a id="ref-W3C.REC-xslt-19991116">W3C.REC-xslt-19991116</a>]
Clark, J., "XSL Transformations (XSLT) Version 1.0", World
Wide Web Consortium Recommendation REC-xslt-19991116,
November 1999,
<<a href="http://www.w3.org/TR/1999/REC-xslt-19991116">http://www.w3.org/TR/1999/REC-xslt-19991116</a>>.
[<a id="ref-XSLT">XSLT</a>] Veillard, D., "The XSLT C library for GNOME", 2006,
<<a href="http://xmlsoft.org/XSLT/xsltproc2.html">http://xmlsoft.org/XSLT/xsltproc2.html</a>>.
<span class="grey">Gieben Informational [Page 8]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
<span class="h3"><a class="selflink" id="section-9.2" href="#section-9.2">9.2</a>. Informative References</span>
[<a id="ref-Markdown">Markdown</a>] Gruber, J., "Markdown", 2004,
<<a href="http://daringfireball.net/projects/markdown/">http://daringfireball.net/projects/markdown/</a>>.
[<a id="ref-Pandoc">Pandoc</a>] MacFarlane, J., "Pandoc, a universal document converter",
2006, <<a href="http://johnmacfarlane.net/pandoc/">http://johnmacfarlane.net/pandoc/</a>>.
[<a id="ref-Pandoc2rfc">Pandoc2rfc</a>]
Gieben, R., "Pandoc2rfc git repository", October 2012,
<<a href="http://github.com/miekg/pandoc2rfc">http://github.com/miekg/pandoc2rfc</a>>.
[<a id="ref-PandocGuide">PandocGuide</a>]
MacFarlane, J., "Pandoc User's Guide", 2006,
<<a href="http://johnmacfarlane.net/pandoc/README.html">http://johnmacfarlane.net/pandoc/README.html</a>>.
<span class="grey">Gieben Informational [Page 9]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
<span class="grey"><a href="./rfc7328">RFC 7328</a> Pandoc2rfc August 2014</span>
<span class="h2"><a class="selflink" id="appendix-A" href="#appendix-A">Appendix A</a>. Cheat Sheet</span>
+---------------------+-----------------+--------------+
| Textual construct | Pandoc syntax | Text output |
+---------------------+-----------------+--------------+
| Section Header | "# Section" | 1. Section |
| Unordered List | "* item" | o item |
| Unordered List | "#. item" | item |
| Ordered List | "1. item" | 1. item |
| Ordered List | "a. item" | a. item |
| Ordered List | "ii. item" | i. item |
| Ordered List | "II. item" | (1) item |
| Ordered List | "A. item" | A. item |
| Ordered List | "1. ~~REQ%d.~~" | REQ1. |
| Emphasis | "_text_" | _text_ |
| Strong Emphasis | "**text**" | *text* |
| Verbatim | "`text`" | "text" |
| Block Quote | "> quote" | quote |
| External Reference | "[Click](URI)" | Click [1] |
| Internal Reference | "[](#id)" | <a href="#section-1">Section 1</a> |
| Figure Anchor | "^[fid::text]" | N/A |
| Figure Reference | "[](#fid)" | Figure 1 |
| Table Anchor | "^[tid::text]" | N/A |
| Table Reference | "[](#tid)" | Table 1 |
| Citations | "[](#<a href="./rfc2119">RFC2119</a>)" | [<a href="./rfc2119">RFC2119</a>] |
| Table | Tables | * |
| Figures | Code Blocks | * |
| Definition List | Definition | * |
| Index | ^[ ^item^ ] | * |
+---------------------+-----------------+--------------+
* This construct creates output too voluminous to show in the table.
Table 1: The most important textual constructs that
can be used in Pandoc2rfc
Author's Address
R. (Miek) Gieben
Google
EMail: miek@google.com
Gieben Informational [Page 10]
</pre>
|