idnits 2.17.1 draft-gieben-pandoc2rfc-01.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 3 instances of too long lines in the document, the longest one being 3 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (April 10, 2013) is 4033 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Informational ---------------------------------------------------------------------------- ** Obsolete normative reference: RFC 2629 (Obsoleted by RFC 7749) Summary: 2 errors (**), 0 flaws (~~), 1 warning (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 RFC Beautification Working Group R. Gieben 3 Internet-Draft Google 4 Intended status: Informational April 10, 2013 5 Expires: October 12, 2013 7 Writing I-Ds and RFCs using Pandoc 8 draft-gieben-pandoc2rfc-01 10 Abstract 12 This document presents a technique for using a Markdown syntax 13 variant, called Pandoc, as a source format for documents in the 14 Internet-Drafts (I-Ds) and Request for Comments (RFC) series. 16 Status of This Memo 18 This Internet-Draft is submitted in full conformance with the 19 provisions of BCP 78 and BCP 79. 21 Internet-Drafts are working documents of the Internet Engineering 22 Task Force (IETF). Note that other groups may also distribute 23 working documents as Internet-Drafts. The list of current Internet- 24 Drafts is at http://datatracker.ietf.org/drafts/current/. 26 Internet-Drafts are draft documents valid for a maximum of six months 27 and may be updated, replaced, or obsoleted by other documents at any 28 time. It is inappropriate to use Internet-Drafts as reference 29 material or to cite them other than as "work in progress." 31 This Internet-Draft will expire on October 12, 2013. 33 Copyright Notice 35 Copyright (c) 2013 IETF Trust and the persons identified as the 36 document authors. All rights reserved. 38 This document is subject to BCP 78 and the IETF Trust's Legal 39 Provisions Relating to IETF Documents 40 (http://trustee.ietf.org/license-info) in effect on the date of 41 publication of this document. Please review these documents 42 carefully, as they describe your rights and restrictions with respect 43 to this document. Code Components extracted from this document must 44 include Simplified BSD License text as described in Section 4.e of 45 the Trust Legal Provisions and are provided without warranty as 46 described in the Simplified BSD License. 48 Table of Contents 49 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 50 2. Pandoc to RFC . . . . . . . . . . . . . . . . . . . . . . . . 2 51 2.1. Dependencies . . . . . . . . . . . . . . . . . . . . . . 4 52 3. Building an Internet-Draft . . . . . . . . . . . . . . . . . 4 53 4. Supported Features . . . . . . . . . . . . . . . . . . . . . 5 54 5. Unsupported Features . . . . . . . . . . . . . . . . . . . . 6 55 6. Pandoc Style . . . . . . . . . . . . . . . . . . . . . . . . 6 56 6.1. Figure/Artwork . . . . . . . . . . . . . . . . . . . . . 6 57 6.2. Tables . . . . . . . . . . . . . . . . . . . . . . . . . 6 58 6.3. References . . . . . . . . . . . . . . . . . . . . . . . 7 59 6.4. Indexes . . . . . . . . . . . . . . . . . . . . . . . . . 7 60 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 8 61 8. Security Considerations . . . . . . . . . . . . . . . . . . . 8 62 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 8 63 10. Normative References . . . . . . . . . . . . . . . . . . . . 8 64 Appendix A. Changelog . . . . . . . . . . . . . . . . . . . . . 8 65 A.1. -00 . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 66 A.2. -01 . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 67 Appendix B. Cheat Sheet . . . . . . . . . . . . . . . . . . . . 9 68 Appendix C. XSLT . . . . . . . . . . . . . . . . . . . . . . . . 9 69 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 25 71 1. Introduction 73 This document presents a technique for using Pandoc syntax as a 74 source format for documents in the Internet-Drafts (I-Ds) and Request 75 for Comments (RFC) series. 77 Pandoc [Pandoc] is an "almost plain text" format and therefor 78 particularly well suited for editing RFC-like documents. The syntax 79 itself is a superset of the syntax championed by Markdown [Markdown]. 81 Pandoc2rfc generates XML compatible with [RFC2629]. 83 2. Pandoc to RFC 85 During the last few years people have been developing markup 86 languages that are very easy to remember and type. These languages 87 have become known as "almost plain text"-markup languages. One of 88 the first was the Markdown ([Markdown]) syntax. One that was 89 developed later and incorporates Markdown syntax and a number of 90 extensions is Pandoc ([Pandoc]). The power of Pandoc comes from the 91 fact that it can be translated to numerous output formats, including, 92 but not limited to: HTML, EPUB, (plain) Markdown and DocBook XML. 94 Pandoc2rfc allows authors to write in (the simple) Pandoc syntax 95 which is then transformed to XML and given to xml2rfc. The 96 conversions are, in some way amusing, as we start off with (almost) 97 plain text, use elaborate XML and end up with plain text again. 99 +-------------------+ pandoc +---------+ 100 | ALMOST PLAIN TEXT | ------> | DOCBOOK | 101 +-------------------+ +---------+ 102 | | 103 non-existent | | xsltproc 104 faster way | | 105 v v 106 +------------+ xml2rfc +---------+ 107 | PLAIN TEXT | <-------- | XML | 108 +------------+ +---------+ 110 Attempt to justify Pandoc2rfc. 112 Figure 1 114 The XML generated (the output after the "xsltproc" step in Figure 1) 115 is suitable for inclusion in either the "middle" or "back" section of 116 an RFC. 118 Even though Pandoc2rfc abstracts away a lot of XML details, there are 119 still a few places left where some XML needs to be edited. Most 120 notably in the "front" section of an RFC. 122 The simplest way to start is to create a template XML file and 123 include the appropriate XML for this "front" section: 125 126 128 129 130 ]> 132 133 134 Writing I-Ds and RFCs using Pandoc 135 136 137 &pandocMiddle; 138 139 140 141 &rfc.2629; 142 143 &pandocBack; 145 146 148 A very minimal template.xml. 150 Figure 2 152 In this case you need to edit three documents: 154 1. "middle.txt" - contains the main body of text; 156 2. "back.txt" - holds appendices; 158 3. this "template.xml" - probably a fairly static file, among other 159 things, it holds the authors and the references. 161 The up to date source code for Pandoc2rfc can be found at 162 [Pandoc2rfc], this includes the stylesheet "transform.xsl" used for 163 the transformation. 165 2.1. Dependencies 167 Pandoc2rfc needs "xsltproc" [XSLT] and "pandoc" [Pandoc] to be 168 installed. The conversion to xml2rfc XML is done with a stylesheet 169 based on XSLT version 1.0 [W3C.REC-xslt-19991116]. See Figure 4 in 170 Appendix C for the contents of that stylesheet. 172 When using the template from Figure 2 xml2rfc version 2 must be used. 174 3. Building an Internet-Draft 176 Assuming the setup from Section 2, we can build an I-D as follows (in 177 a Unix-like environment): 179 pandoc -st docbook middle.txt | xsltproc --nonet transform.xsl - \ 180 > middle.xml 181 pandoc -st docbook back.txt | xsltproc --nonet transform.xsl - \ 182 > back.xml 184 # Create text output 185 xml2rfc template.xml -f draft.txt --text 187 # ... or create HTML output 188 xml2rfc template.xml -f draft.html --html 190 # ... or create (self-contained) XML output 191 xml2rfc template.xml -f draft.xml --exp 192 Building an I-D with Pandoc2rfc. 194 Figure 3 196 Note that the output file names ("middle.xml" and "back.xml") must 197 match the names used as the XML entities in "template.xml". The 198 Pandoc2rfc source repository includes a shell script that 199 incorporates the above transformations. Creating a "draft.txt" or a 200 "draft.xml" can be done with "pandoc2rfc *.txt" and "pandoc2rfc -X 201 *.txt" respectively. 203 4. Supported Features 205 Almost everything xml2rfc can do is supported, see Table 1 in 206 Appendix B for a "cheat sheet". 208 o Sections with an anchor and title attributes 210 o Lists 212 * style="symbols", use "* " for each item; 214 * style="numbers", use digits: "1. " for each item; 216 * style="empty", use "#. " for each item; 218 * style="format %i", use roman lowercase numerals: "ii. "; 220 * style="format (%d)", use roman uppercase numerals "II. "; 222 * style="letters", use lower- or uppercase letters: "a. " and 223 "A. " (note: two spaces); 225 * style="hanging", use the Pandoc definition list syntax; 227 o Spanx style="verb", style="emph" and style="strong", respectively 228 use: "`text`", "_text_" or "**text**"; 230 o Block quote - not supported by xml2rfc, so this is converted to 231 "" paragraph; 233 o Figure/artwork with an anchor and postamble (Section 6.1); 235 o Tables with an anchor and postamble (Section 6.2); 237 o References (Section 6.3) 239 * external (eref); 240 * internal (xref): 242 + section (handled by Pandoc); 244 + figures (handled by XSLT); 246 + tables (handled by XSLT). 248 o Citations, by using internal references; 250 o Indexes, by (ab)using footnotes (Section 6.4). 252 5. Unsupported Features 254 o Pandoc markup in the caption for figures/artwork. Pandoc markup 255 for table captions _is_ supported; 257 o Crefs: for comments, but you can use HTML comments: "" 258 in the Pandoc source files; 260 o Preamble in figures and tables. 262 6. Pandoc Style 264 In some cases the Pandoc syntax is slightly misused to get the 265 desired output, in the following paragraphs we will detail these. 266 Also the meta data feature (Pandoc's "Title Block" extension) of 267 Pandoc is not used in Pandoc2rfc. This information must be put in 268 the "template.xml". 270 6.1. Figure/Artwork 272 Indent the paragraph with 4 spaces as mandated by Pandoc. Note that 273 xml2rfc supports a caption with "". If you add a "@Figure: 274 some text" as the last line, the artwork gets a "" with 275 the text after "@Figure: ". It will also be possible to reference 276 the artwork. If such a caption is supplied the artwork will be 277 centered on the page. If a caption is needed but the figure should 278 not be centered use "@figure: ". 280 6.2. Tables 282 A table can be entered by using Pandoc's table syntax. You can 283 choose multiple styles as input, but they all are converted to the 284 same style (plain "") table in xml2rfc. 286 The table caption is _always_ translated to a "". The 287 "" tag isn't supported. If a table has a caption, it will 288 also be possible to reference the table. 290 6.3. References 292 Pandoc provides a syntax that can be used for references. Its syntax 293 is repeated in this paragraph. Any reference like: "[Click 294 here](URI)", is an external reference. An internal (i.e. see 295 Section X) reference is typeset with: "[Click here](#localid)" or 296 "[](#localid)". 298 For referencing RFCs (and other citations), you will need add the 299 reference source in the template, as an external XML entity, Figure 2 300 provides an example. After that you can use: "[](#RFC2629)" 302 Note that referencing figures/artworks and tables is done slightly 303 different. The reason for this is that Pandoc does not have native 304 support/syntax for this. We work around it, by "faking" the 305 reference in the XSLT. Thus for referencing figures/artworks and 306 tables, you need: 308 o To take the first 10 characters of the caption (i.e. this is the 309 text _after_ the string "Table: " or "@Figure: "); 311 o Translate spaces and single quotes ' to a minus "-"; 313 o Translate uppercase letters to lowercase; 315 o For tables prefix the anchor with "tab:" and for figures use 316 "fig:". 318 The figure from Section 2 will get "fig:a-very-min" as an anchor. 320 Note that duplicate anchors are an XML validation error which will 321 make xml2rfc fail. These are not detected during the XSL 322 transformation. 324 6.4. Indexes 326 The footnote syntax of Pandoc is slightly abused to support an index. 327 Sub items are also supported. Use an exclamation mark ("!") to 328 separate them: 330 [^1]: item!sub item 332 7. Acknowledgements 334 The following people have helped shape Pandoc2rfc: Benno Overeinder, 335 Erlend Hamnaberg, Matthijs Mekking and Trygve Laugstoel. 337 This document was prepared using Pandoc2rfc. 339 8. Security Considerations 341 This document raises no security issues. 343 9. IANA Considerations 345 This document has no actions for IANA. 347 10. Normative References 349 [Markdown] 350 Gruber, J., "Markdown", 2004, 351 . 353 [Pandoc2rfc] 354 Gieben, R., "Pandoc2rfc git repository", October 2012, 355 . 357 [Pandoc] MacFarlane, J., "Pandoc, a universal document converter", 358 2006, . 360 [RFC2629] Rose, M.T., "Writing I-Ds and RFCs using XML", RFC 2629, 361 June 1999. 363 [W3C.REC-xslt-19991116] 364 Clark, J., "XSL Transformations (XSLT) Version 1.0", World 365 Wide Web Consortium Recommendation REC-xslt-19991116, 366 November 1999, 367 . 369 [XSLT] Veillard, D., "The XSLT C library for GNOME", 2006, 370 . 372 Appendix A. Changelog 374 [This section should be removed by the RFC editor before publishing] 376 A.1. -00 378 1. Initial document. 380 A.2. -01 382 1. Lots of updates; 384 2. Added the stylesheet use in an appendix. 386 Appendix B. Cheat Sheet 388 +--------------------+------------------+---------------------------+ 389 | Textual construct | Pandoc syntax | xml2rfc Syntax | 390 +--------------------+------------------+---------------------------+ 391 | Section Header | "# Section" | "
" | 392 | Unordered List | "* item" | "" | 393 | Unordered List | "#. item" | "" | 394 | Ordered List | "1. item" | "" | 395 | Ordered List | "a. item" | "" | 396 | Ordered List | "ii. item" | "" | 398 | Ordered List | "II. item" | "" | 400 | Ordered List | "A. item" | "" | 402 | Definition List | Definition | "" | 403 | Emphasis | "_text_" | "" | 404 | Strong Emphasis | "**text**" | "" | 405 | Verbatim | "`text`" | "" | 406 | Block Quote | "> quote" | "" | 407 | Index | Footnotes | "" | 408 | Table | Tables | "" | 409 | Figure/Artwork | Code Blocks | "
" | 410 | External Reference | "[Click](URI)" | "" | 411 | Internal Reference | "[](#id)" | "" | 412 | Figure Reference | "[](#fig:...)" | "" | 413 | Table Reference | "[](#tab:...)" | "" | 414 | Citations | "[](#RFC2119)" | "" | 415 +--------------------+------------------+---------------------------+ 417 The most important textual constructs that can be used in Pandoc2rfc. 419 Table 1 421 Appendix C. XSLT 423 This is the XSLT with Git version 424 "f0cc985e291ae25a24c91934b8192930df1ad6f6", that is used for the 425 transformation. 427 428 429 433 436 437 438 439 440 441 442 443 444 This document was prepared using Pandoc2rfc 445 https://github.com/miekg/pandoc2rfc 446 447 448 449 450 451 452 456 457 458 459 460 461 462 463 464 466 467 468 470 471 472 473 474 477 478 479 480 481 482 483 485
486 487 489 490 491 492 493 494
495
496 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 526 527 528 529 530 533 534 535 536 537 538 539 540 541 542 543 544 545 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 771 772 775 776 777 778 779 782 783 784 785 786 787 788 789 790 793 794 795 796 797 798 799 800 801 804 805 806 807 808 809 810 811 814 815
816 817 818 819 fig: 820 825 826 827 828 center 829 830 831 832 833 834 835 836 837 838 839 fig: 840 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859
860
861 862 863 864 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 tab: 908 912 913 914 915 916 tab: 917 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 941 942 943 944 945 949 950 951 952 953 954 955 956 957 958 959 960 961 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1060 1061 1062 1063 1064 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1128 1129 1130 1131 1132 1136 1137 1138 1139 1140 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154
1156 XSLT used for the transformation. 1158 Figure 4 1160 Author's Address 1162 R. (Miek) Gieben 1163 Google 1165 Email: miek@google.com