asciidoctor-rfc 0.2.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +116 -6
- data/asciidoctor-rfc.gemspec +15 -1
- data/lib/asciidoctor/rfc/common/base.rb +74 -7
- data/lib/asciidoctor/rfc/common/front.rb +1 -1
- data/lib/asciidoctor/rfc/v2/base.rb +87 -38
- data/lib/asciidoctor/rfc/v2/blocks.rb +29 -2
- data/lib/asciidoctor/rfc/v2/converter.rb +0 -1
- data/lib/asciidoctor/rfc/v2/inline_anchor.rb +2 -8
- data/lib/asciidoctor/rfc/v2/lists.rb +7 -4
- data/lib/asciidoctor/rfc/v2/table.rb +1 -1
- data/lib/asciidoctor/rfc/v3/base.rb +41 -43
- data/lib/asciidoctor/rfc/v3/blocks.rb +29 -2
- data/lib/asciidoctor/rfc/v3/converter.rb +0 -2
- data/lib/asciidoctor/rfc/v3/inline_anchor.rb +2 -6
- data/lib/asciidoctor/rfc/version.rb +1 -1
- data/spec/asciidoctor/rfc/v2/comments_spec.rb +7 -3
- data/spec/asciidoctor/rfc/v2/date_spec.rb +23 -0
- data/spec/asciidoctor/rfc/v2/dlist_spec.rb +107 -9
- data/spec/asciidoctor/rfc/v2/image_spec.rb +17 -0
- data/spec/asciidoctor/rfc/v2/inline_formatting_spec.rb +12 -0
- data/spec/asciidoctor/rfc/v2/listing_spec.rb +22 -0
- data/spec/asciidoctor/rfc/v2/literal_spec.rb +22 -2
- data/spec/asciidoctor/rfc/v2/preamble_spec.rb +72 -0
- data/spec/asciidoctor/rfc/v2/references_spec.rb +3 -1
- data/spec/asciidoctor/rfc/v2/table_spec.rb +104 -4
- data/spec/asciidoctor/rfc/v2/text_spec.rb +89 -0
- data/spec/asciidoctor/rfc/v2/ulist_spec.rb +40 -0
- data/spec/asciidoctor/rfc/v3/dlist_spec.rb +103 -1
- data/spec/asciidoctor/rfc/v3/image_spec.rb +18 -0
- data/spec/asciidoctor/rfc/v3/listing_spec.rb +26 -0
- data/spec/asciidoctor/rfc/v3/literal_spec.rb +20 -1
- data/spec/asciidoctor/rfc/v3/preamble_spec.rb +150 -0
- data/spec/asciidoctor/rfc/v3/references_spec.rb +35 -34
- data/spec/asciidoctor/rfc/v3/series_info_spec.rb +39 -0
- data/spec/examples/README.adoc +162 -0
- data/spec/examples/davies-template-bare-06.adoc +3 -0
- data/spec/examples/draft-ietf-core-block-xx.mkd +935 -0
- data/spec/examples/draft-ietf-core-block-xx.mkd.adoc +1013 -0
- data/spec/examples/draft-ietf-core-block-xx.xml.orig +1251 -0
- data/spec/examples/example-v2.adoc +6 -2
- data/spec/examples/example-v3.adoc +5 -1
- data/spec/examples/hoffmanv2.xml.adoc +247 -0
- data/spec/examples/hoffmanv2.xml.orig +339 -0
- data/spec/examples/hoffmanv3.xml.orig +346 -0
- data/spec/examples/mib-doc-template-xml-06.adoc +5 -1
- data/spec/examples/rfc2100.md.adoc +2 -3
- data/spec/examples/rfc3514.md.adoc +3 -2
- data/spec/examples/rfc5841.md.adoc +1 -1
- data/spec/examples/rfc748.md.adoc +7 -6
- data/spec/examples/rfc7511.md.adoc +15 -15
- data/spec/examples/skel.mkd +32 -0
- data/spec/examples/skel.mkd.adoc +50 -0
- data/spec/examples/skel.xml.orig +105 -0
- data/spec/examples/stupid-s.mkd +569 -0
- data/spec/examples/stupid-s.mkd.adoc +771 -0
- data/spec/examples/stupid-s.xml.orig +880 -0
- data/spec/spec_helper.rb +1 -1
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35f7a1bd23b6de975c31f813b3c706bacd397143
|
4
|
+
data.tar.gz: cf7b2e21d14bfe6adcea630187d47ecf894299ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c482a9f84673ef72e87ede4096ee1584a90c1df3be25cdc73e49cc243a3e336289d8b1f58cd036625fac5e8fa5a7006d41e523bc8d6fde26cac6edbc01a0fb7e
|
7
|
+
data.tar.gz: 9f8d197aa2f9ec92af349ca550a6f4b8a423ca090d597481932fefc2694c835c744feee74b2fb16870d6eb98e120cd5d337a8bd8ecf872c2d1361a37536a0881
|
data/README.adoc
CHANGED
@@ -62,7 +62,7 @@ David Waitzman <dwaitzman@BBN.COM>
|
|
62
62
|
:abbrev: IP Datagrams on Avian Carriers
|
63
63
|
:obsoletes: 10, 120
|
64
64
|
:updates: 2010, 2120
|
65
|
-
:status:
|
65
|
+
:status: informational
|
66
66
|
:name: internet-draft-avian-transmission-00
|
67
67
|
:ipr: trust200902
|
68
68
|
:area: Internet
|
@@ -103,7 +103,27 @@ paradoxically, generally increases with increased carrier age. A
|
|
103
103
|
typical MTU is 256 milligrams. Some datagram padding may be needed.<<RFC7253>>
|
104
104
|
|
105
105
|
[bibliography]
|
106
|
-
== References
|
106
|
+
== Normative References
|
107
|
+
++++
|
108
|
+
<reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
|
109
|
+
<front>
|
110
|
+
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
|
111
|
+
<author initials="S." surname="Bradner" fullname="S. Bradner">
|
112
|
+
<organization/>
|
113
|
+
</author>
|
114
|
+
<date year="1997" month="March"/>
|
115
|
+
<abstract>
|
116
|
+
<t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
|
117
|
+
</abstract>
|
118
|
+
</front>
|
119
|
+
<seriesInfo name="BCP" value="14"/>
|
120
|
+
<seriesInfo name="RFC" value="2119"/>
|
121
|
+
<seriesInfo name="DOI" value="10.17487/RFC2119"/>
|
122
|
+
</reference>
|
123
|
+
++++
|
124
|
+
|
125
|
+
[bibliography]
|
126
|
+
== Informative References
|
107
127
|
++++
|
108
128
|
<reference anchor='RFC7253' target='https://tools.ietf.org/html/rfc7253'>
|
109
129
|
<front>
|
@@ -213,6 +233,14 @@ Permit smart quotes, when they are specified explicitly in Asciidoc (as `"`...`"
|
|
213
233
|
When disabled, smart quotes are rendered as straight quotes, and Asciidoc's default conversion
|
214
234
|
of straight apostrophes to smart is undone.
|
215
235
|
|
236
|
+
|`:inline-definition-lists:`
|
237
|
+
|Optional. Default value `false`. Allowed values: `true`, `false`.
|
238
|
+
Only applies to v2. By default, `<vspace blankLines="1">` is inserted after
|
239
|
+
the definition in a v2 definition list, to satisfy the requirement from `idnits` validation
|
240
|
+
that definition terms be separated by a carriage return from the definition. That is, by
|
241
|
+
default inline definition lists are rendered as paragraphing definition lists. If the option is
|
242
|
+
on, the additional `vspace` element is not added, and inline definition lists are left as is..
|
243
|
+
|
216
244
|
|===
|
217
245
|
|
218
246
|
|
@@ -295,6 +323,57 @@ metadata.
|
|
295
323
|
|
296
324
|
|===
|
297
325
|
|
326
|
+
=== Processing Instructions
|
327
|
+
The `xml2rfc` tool accepts processing instructions of the form `<?rfc keyword='value'?>`:
|
328
|
+
see https://xml2rfc.tools.ietf.org/authoring/README.html#processing.instructions .
|
329
|
+
(Of these, `sort-refs`, `sym-refs` and `toc-include` are also present in the
|
330
|
+
v3 RFC XML specifcation, as attributes of the
|
331
|
+
root `rfc` element: <<v3documentattributes,v3-specific document attributes>>.)
|
332
|
+
Those processing instructions which apply to the entire document can also be
|
333
|
+
specified for this gem as document options.
|
334
|
+
|
335
|
+
|===
|
336
|
+
|keyword |meaning
|
337
|
+
|
338
|
+
|artworkdelimiter | when producing txt or nroff files, use this string to delimit artwork
|
339
|
+
|artworklines | when producing txt or nroff files, add this many blank lines around artwork
|
340
|
+
|authorship | render author information
|
341
|
+
|autobreaks | automatically force page breaks to avoid widows and orphans (not perfect)
|
342
|
+
|background | when producing a html file, use this image
|
343
|
+
|colonspace | put two spaces instead of one after each colon (":") in txt or nroff files
|
344
|
+
|comments | render <cref> information
|
345
|
+
|compact | when producing a txt/nroff file, try to conserve vertical whitespace (the default value is the current value of the rfcedstyle PI)
|
346
|
+
|docmapping | use hierarchical tags (e.g., <h1>, <h2>, etc.) for (sub)section titles
|
347
|
+
|editing | insert editing marks for ease of discussing draft versions
|
348
|
+
|emoticonic | automatically replaces input sequences such as \|*text\| by, e.g., <strong>text</strong> in html output
|
349
|
+
|footer | override the center footer string
|
350
|
+
|header | override the leftmost header string
|
351
|
+
|inline | if comments is "yes", then render comments inline; otherwise render them in an "Editorial Comments" section
|
352
|
+
|iprnotified | include boilerplate from Section 10.4(d) of http://tools.ietf.org/html/rfc2026
|
353
|
+
|linkmailto | generate mailto: URL, as appropriate
|
354
|
+
|linefile | a string like "35:file.xml" or just "35" (file name then defaults to the containing file's real name or to the latest linefile specification that changed it) that will be used to override xml2rfc's reckoning of the current input position (right after this PI) for warning and error reporting purposes (line numbers are 1-based)
|
355
|
+
|notedraftinprogress | generates "(work in progress)", as appropriate
|
356
|
+
|private | produce a private memo rather than an RFC or Internet-Draft
|
357
|
+
|refparent | title of the top-level section containing all references
|
358
|
+
|rfcedstyle | attempt to closely follow finer details from the latest observable RFC-Editor style so as to minimize the probability of being sent back corrections after submission; this directive is a kludge whose exact behavior is likely to change on a regular basis to match the current flavor of the month; presently, it will capitalize the adjective "This" in automatically generated headings, use the variant "acknowledgement" spelling instead of Merriam Webster's main "acknowledgment" dictionary entry, use the "eMail" spelling instead of Knuth's more modern "email" spelling, only put one blank line instead of two before top sections, omit "Intellectual Property and Copyright Statements" and "Author's Address" from the table of content, and not limit the indentation to a maximum tag length in <references> sections.
|
359
|
+
|rfcprocack | if there already is an automatically generated Acknowledg(e)ment section, pluralize its title and add a short sentence acknowledging that xml2rfc was used in the document's production to process an input XML source file in RFC-2629 format
|
360
|
+
|slides | when producing a html file, produce multiple files for a slide show
|
361
|
+
|sort-refs | (`sortrefs`) sort references
|
362
|
+
|strict | try to enforce the ID-nits conventions and DTD validity
|
363
|
+
|subcompact | if compact is "yes", then you can make things a little less compact by setting this to "no" (the default value is the current value of the compact PI)
|
364
|
+
|sym-refs | (`symrefs`) use anchors rather than numbers for references
|
365
|
+
|text-list-symbols | modify the list of symbols used (when generated text) for list type="symbols". For example, specifying "abcde" will cause "a" to be used for 1st level, "b" for the 2nd level, etc, cycling back to the first character "a" at the 6th level. Specifying "o*" will cause the characters "o" and "*" to be alternated for each successive level.
|
366
|
+
|toc-include | (`toc`) generate a table-of-contents
|
367
|
+
|tocappendix | control whether the word "Appendix" appears in the table-of-content
|
368
|
+
|tocdepth | if toc is "yes", then this determines the depth of the table-of-contents
|
369
|
+
|tocindent | if toc is "yes", then setting this to "yes" will indent subsections in the table-of-contents
|
370
|
+
|tocnarrow | affects horizontal spacing in the table-of-content
|
371
|
+
|tocompact | if toc is "yes", then setting this to "no" will make it a little less compact
|
372
|
+
|topblock | put the famous header block on the first page
|
373
|
+
|useobject | when producing a html file, use the <object> html element with inner replacement content instead of the <img> html element, when a source xml element includes an src attribute
|
374
|
+
|===
|
375
|
+
|
376
|
+
Exceptionally, `compact`, `toc-include`, `sym-refs`, `sort-refs` and `strict` are is set by default to `yes`, `subcompact` to `no`, and `toc-depth` to 4.
|
298
377
|
|
299
378
|
=== Document Name / Number (Mandatory)
|
300
379
|
|
@@ -318,6 +397,9 @@ When `doctype` is set to:
|
|
318
397
|
|
319
398
|
Set the `status` attribute to set the current status of this document.
|
320
399
|
|
400
|
+
The following values are allowed: `standard`, `informational`, `experimental`, `bcp`, `fyi`,
|
401
|
+
`full-standard` (v3 only), `historic` (v2 only).
|
402
|
+
|
321
403
|
* In v3, this sets the first `front/seriesInfo` element with `@status` as one
|
322
404
|
of: `standard`, `informational`, `experimental`, `bcp`, `fyi`, `full-standard`.
|
323
405
|
* In v2, this sets the `rfc@category` value as one of `std`, `info`, `exp`, `bcp`, `historic`.
|
@@ -392,6 +474,7 @@ These attributes are only supported for the v2 converter.
|
|
392
474
|
| `rfc@seriesNo`
|
393
475
|
|===
|
394
476
|
|
477
|
+
[#v3documentattributes]
|
395
478
|
=== Document Attributes for v3 only
|
396
479
|
|
397
480
|
These attributes are only supported for the v3 converter.
|
@@ -411,18 +494,18 @@ formatter should include an index in generated files. If the source file has no
|
|
411
494
|
|
412
495
|
|`:sort-refs:`
|
413
496
|
| Optional. Defaults to `false`. Values: `true` or `false`. Specifies whether
|
414
|
-
the prep tool should sort references.
|
497
|
+
the prep tool should sort references. Supported in v2 as a processing instruction.
|
415
498
|
| `rfc@sortRefs`
|
416
499
|
|
417
500
|
|`:sym-refs:`
|
418
501
|
| Optional. Defaults to `true`. Values: `true` or `false`. Specifies whether
|
419
502
|
formatter should use symbolic references (such as "`[RFC2119]`") or not
|
420
|
-
(such as "`[3]`").
|
503
|
+
(such as "`[3]`"). Supported in v2 as a processing instruction.
|
421
504
|
| `rfc@symRefs`
|
422
505
|
|
423
506
|
|`:toc-include:`
|
424
507
|
| Optional. Defaults to `true`. Values: `true` or `false`. Specifies whether
|
425
|
-
formatter should contain a table of contents.
|
508
|
+
formatter should contain a table of contents. Supported in v2 as a processing instruction.
|
426
509
|
| `rfc@tocInclude`
|
427
510
|
|
428
511
|
| `:link{_i_}: _URL_` or `:link{_i_}: _URL_ _REL_`
|
@@ -484,6 +567,9 @@ These will be mapped as follows:
|
|
484
567
|
|
485
568
|
|===
|
486
569
|
|
570
|
+
If any author names deviate from that pattern, e.g. with an honorific like Dr.,
|
571
|
+
they will not be recognised correctly by the Asciidoc API; use the `fullname`
|
572
|
+
document attribute instead.
|
487
573
|
|
488
574
|
==== Author Attributes
|
489
575
|
|
@@ -739,6 +825,7 @@ _Italic_ <2>
|
|
739
825
|
^superscript^ <6>
|
740
826
|
[bcp14]#MUST NOT# <7>
|
741
827
|
*MUST NOT* <8>
|
828
|
+
stem:[sqrt(4) = 2]
|
742
829
|
--
|
743
830
|
<1> That is, "+ " at the end of a line. v3: `<br/>`; v2: `<vspace/>`.
|
744
831
|
<2> v3: `<em>Italic</em>`; v2: `<spanx style="emph">Italic</spanx>`
|
@@ -748,6 +835,7 @@ _Italic_ <2>
|
|
748
835
|
<6> v3 only: `<sup>superscript</sup>`. Not supported in v2; rendered as `\^superscript^`
|
749
836
|
<7> v3 only: `<bcp14>MUST NOT</bcp14>`. Not supported in v2; rendered as `<spanx style="strong">MUST NOT</spanx>`.
|
750
837
|
<8> v3: if document flag `:no-rfc-bold-bcp14:` is present, then `<strong>MUST NOT</strong>`, else (by default) any BCP14/RFC2119 phrase in boldface and capitals is assumed to be intended to be tagged in `<bcp14>`. v2: `<spanx style="strong">MUST NOT</spanx>`.
|
838
|
+
<9> Stem expressions are treated identically to monospace expressions; they are not currently rendered as MathML or any other notation.
|
751
839
|
|
752
840
|
NOTE: The delimiters must occur within the one line; the following is invalid in Asciidoctor:
|
753
841
|
[source,asciidoc]
|
@@ -859,6 +947,21 @@ Postamble text <11>
|
|
859
947
|
<10> `figure/artwork@src`, `figure/artwork@alt`, `figure/artwork@width` (deprecated in v3), `figure/artwork@height` (deprecated in v3)
|
860
948
|
<11> v2 only: `figure/postamble` (only available in v2)
|
861
949
|
|
950
|
+
=== Mathematical examples
|
951
|
+
|
952
|
+
[source,asciidoc]
|
953
|
+
--
|
954
|
+
:stem:
|
955
|
+
|
956
|
+
[stem]
|
957
|
+
++++
|
958
|
+
sqrt(4) = 2
|
959
|
+
++++
|
960
|
+
--
|
961
|
+
|
962
|
+
Mathematical examples are treated identically to literals, and are rendered as `artwork` in both v2 and v3;
|
963
|
+
however their default alignment is set as `center`. As with inline stem expressions, they are treated identically
|
964
|
+
to monospace expressions; they are not currently rendered as MathML or any other notation.
|
862
965
|
|
863
966
|
=== Unordered and Ordered Lists
|
864
967
|
|
@@ -910,6 +1013,10 @@ A:: B <3>
|
|
910
1013
|
NOTE: Asciidoctor does not permit anchors on either definition list terms,
|
911
1014
|
or definition list definitions: the anchors in the following are ignored.
|
912
1015
|
|
1016
|
+
NOTE: In RFC XML v2, `idnits` considers inline definition lists invalid; the gem
|
1017
|
+
renders them as paragraphed definition lists. The gem option `:inline-definition-lists`
|
1018
|
+
disables this behaviour.
|
1019
|
+
|
913
1020
|
[source,asciidoc]
|
914
1021
|
--
|
915
1022
|
[[id1]] A:: [[id2]]B
|
@@ -973,6 +1080,10 @@ to populate `displayreference` elements, mapping the reference anchors to displa
|
|
973
1080
|
a list entry `[[[ref1,alt1]]]` means that any instances of the anchor `ref1` should be displayed as `alt1`,
|
974
1081
|
and is rendered as `<displayreference target="ref1" to="alt1"/>`.
|
975
1082
|
|
1083
|
+
RFC requires two separate bibliographies, one for normative and one for informative references;
|
1084
|
+
either can be omitted. All bibliography sections in the must be styled with the prefix `[bibliography]`,
|
1085
|
+
and must appear in sequence, before any appendices.
|
1086
|
+
|
976
1087
|
[source,asciidoc]
|
977
1088
|
--
|
978
1089
|
[[id]] <1>
|
@@ -995,7 +1106,6 @@ and is rendered as `<displayreference target="ref1" to="alt1"/>`.
|
|
995
1106
|
<3> `back/references/reference`
|
996
1107
|
|
997
1108
|
|
998
|
-
|
999
1109
|
=== Appendices
|
1000
1110
|
|
1001
1111
|
[source,asciidoc]
|
data/asciidoctor-rfc.gemspec
CHANGED
@@ -10,8 +10,22 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ["Ribose Inc."]
|
11
11
|
spec.email = ["open.source@ribose.com"]
|
12
12
|
|
13
|
-
spec.summary =
|
13
|
+
spec.summary = 'asciidoctor-rfc lets you write Internet-Drafts and RFCs in AsciiDoc.'
|
14
14
|
spec.description = <<~DESCRIPTION
|
15
|
+
asciidoctor-rfc lets you write Internet-Drafts and RFCs in a native
|
16
|
+
"asciidoctor" syntax.
|
17
|
+
|
18
|
+
RFC XML ("xml2rfc" Vocabulary XML, RFC7322) is the XML-based language used for
|
19
|
+
writing Internet-Drafts and RFCs, but not everyone likes hand-crafting XML,
|
20
|
+
especially when the focus should be on the content.
|
21
|
+
|
22
|
+
Specifically, the gem provides two things. First, an "asciidoctor" like syntax
|
23
|
+
that lets you utilize close to all features of native RFC XML, and maps most
|
24
|
+
asciidoctor textual syntax (like tables) into RFC XML features. Then, RFC XML
|
25
|
+
v3 (RFC 7991) and v2 (RFC 7749) backends that lets you render your AsciiDoc
|
26
|
+
into, you guessed it, RFC XML v3 and v2.
|
27
|
+
|
28
|
+
This gem is in active development.
|
15
29
|
DESCRIPTION
|
16
30
|
|
17
31
|
spec.homepage = "https://github.com/riboseinc/asciidoctor-rfc"
|
@@ -148,13 +148,75 @@ module Asciidoctor
|
|
148
148
|
result << send(b.context, b)
|
149
149
|
end
|
150
150
|
else
|
151
|
-
result
|
151
|
+
result = paragraph(node)
|
152
152
|
end
|
153
153
|
result
|
154
154
|
end
|
155
155
|
|
156
|
-
def dash(camel_cased_word)
|
157
|
-
|
156
|
+
#def dash(camel_cased_word)
|
157
|
+
# camel_cased_word.gsub(/([a-z])([A-Z])/, '\1-\2').downcase
|
158
|
+
#end
|
159
|
+
|
160
|
+
def common_rfc_pis(node)
|
161
|
+
# Below are generally applicable Processing Instructions (PIs)
|
162
|
+
# that most I-Ds might want to use, common to v2 and v3.
|
163
|
+
# These are set only if explicitly specified, with the exception
|
164
|
+
# of compact and subcompact
|
165
|
+
rfc_pis = {
|
166
|
+
artworkdelimiter: node.attr("artworkdelimiter"),
|
167
|
+
artworklines: node.attr("artworklines"),
|
168
|
+
authorship: node.attr("authorship"),
|
169
|
+
autobreaks: node.attr("autobreaks"),
|
170
|
+
background: node.attr("background"),
|
171
|
+
colonspace: node.attr("colonspace"),
|
172
|
+
comments: node.attr("comments"),
|
173
|
+
docmapping: node.attr("docmapping"),
|
174
|
+
editing: node.attr("editing"),
|
175
|
+
emoticonic: node.attr("emoticonic"),
|
176
|
+
footer: node.attr("footer"),
|
177
|
+
header: node.attr("header"),
|
178
|
+
inline: node.attr("inline"),
|
179
|
+
iprnotified: node.attr("iprnotified"),
|
180
|
+
linkmailto: node.attr("linkmailto"),
|
181
|
+
linefile: node.attr("linefile"),
|
182
|
+
notedraftinprogress: node.attr("notedraftinprogress"),
|
183
|
+
private: node.attr("private"),
|
184
|
+
refparent: node.attr("refparent"),
|
185
|
+
rfcedstyle: node.attr("rfcedstyle"),
|
186
|
+
slides: node.attr("slides"),
|
187
|
+
"text-list-symbols": node.attr("text-list-symbols"),
|
188
|
+
tocappendix: node.attr("tocappendix"),
|
189
|
+
tocindent: node.attr("tocindent"),
|
190
|
+
tocnarrow: node.attr("tocnarrow"),
|
191
|
+
tocompact: node.attr("tocompact"),
|
192
|
+
topblock: node.attr("topblock"),
|
193
|
+
useobject: node.attr("useobject"),
|
194
|
+
|
195
|
+
# give errors regarding ID-nits and DTD validation
|
196
|
+
strict: node.attr("strict") || "yes",
|
197
|
+
|
198
|
+
# Vertical whitespace control
|
199
|
+
# (using these PIs as follows is recommended by the RFC Editor)
|
200
|
+
|
201
|
+
# do not start each main section on a new page
|
202
|
+
compact: node.attr("compact") || "yes",
|
203
|
+
# keep one blank line between list items
|
204
|
+
subcompact: node.attr("subcompact") || "no",
|
205
|
+
|
206
|
+
# TOC control
|
207
|
+
# generate a ToC
|
208
|
+
toc: node.attr("toc-include") == "false" ? "no" : "yes",
|
209
|
+
|
210
|
+
# the number of levels of subsections in ToC. default: 3
|
211
|
+
tocdepth: node.attr("toc-depth") || "4",
|
212
|
+
|
213
|
+
# use anchors rather than numbers for references
|
214
|
+
symrefs: node.attr("sym-refs") || "yes",
|
215
|
+
# sort references
|
216
|
+
sortrefs: node.attr("sort-refs") || "yes",
|
217
|
+
}
|
218
|
+
|
219
|
+
attr_code(rfc_pis)
|
158
220
|
end
|
159
221
|
|
160
222
|
# if node contains blocks, flatten them into a single line
|
@@ -172,16 +234,21 @@ module Asciidoctor
|
|
172
234
|
# if node contains blocks, flatten them into a single line; and extract only raw text
|
173
235
|
def flatten_rawtext(node)
|
174
236
|
result = []
|
175
|
-
if node.blocks?
|
237
|
+
if node.respond_to?(:blocks) && node.blocks?
|
176
238
|
node.blocks.each { |b| result << flatten_rawtext(b) }
|
177
239
|
elsif node.respond_to?(:lines)
|
178
240
|
node.lines.each do |x|
|
179
|
-
|
241
|
+
if node.respond_to?(:context) && (node.context == :literal || node.context == :listing)
|
242
|
+
result << x.gsub(/</, "<").gsub(/>/, ">")
|
243
|
+
else
|
244
|
+
# strip not only HTML tags <tag>, but also Asciidoc crossreferences <<xref>>
|
245
|
+
result << x.gsub(/<[^>]*>+/, "")
|
246
|
+
end
|
180
247
|
end
|
181
248
|
elsif node.respond_to?(:text)
|
182
|
-
result << node.text.gsub(/<[^>]
|
249
|
+
result << node.text.gsub(/<[^>]*>+/, "")
|
183
250
|
else
|
184
|
-
result << node.content.gsub(/<[^>]
|
251
|
+
result << node.content.gsub(/<[^>]*>+/, "")
|
185
252
|
end
|
186
253
|
result.reject(&:empty?)
|
187
254
|
end
|
@@ -35,6 +35,7 @@ module Asciidoctor
|
|
35
35
|
$seen_back_matter = false
|
36
36
|
$seen_abstract = false
|
37
37
|
$smart_quotes = (node.attr("smart-quotes") != "false")
|
38
|
+
$inline_definition_lists = (node.attr("inline-definition-lists") == "true")
|
38
39
|
|
39
40
|
result = []
|
40
41
|
result << '<?xml version="1.0" encoding="UTF-8"?>'
|
@@ -46,11 +47,16 @@ module Asciidoctor
|
|
46
47
|
"true" => "yes",
|
47
48
|
}[node.attr("consensus")] || node.attr("consensus")
|
48
49
|
|
50
|
+
category = node.attr("status")
|
51
|
+
category = "info" if category == "informational"
|
52
|
+
category = "std" if category == "standard"
|
53
|
+
category = "exp" if category == "experimental"
|
54
|
+
|
49
55
|
rfc_attributes = {
|
50
56
|
ipr: node.attr("ipr"),
|
51
57
|
obsoletes: node.attr("obsoletes"),
|
52
58
|
updates: node.attr("updates"),
|
53
|
-
category:
|
59
|
+
category: category,
|
54
60
|
consensus: consensus_value,
|
55
61
|
submissionType: node.attr("submission-type") || "IETF",
|
56
62
|
iprExtract: node.attr("ipr-extract"),
|
@@ -158,7 +164,7 @@ module Asciidoctor
|
|
158
164
|
|
159
165
|
result << noko do |xml|
|
160
166
|
xml.t **attr_code(t_attributes) do |xml_t|
|
161
|
-
xml_t << node.content.gsub("\n", "<vspace/>\n")
|
167
|
+
xml_t << node.content.gsub("\n\n", "<vspace blankLines=\"1\"/>").gsub("\n", "<vspace/>\n")
|
162
168
|
end
|
163
169
|
end
|
164
170
|
|
@@ -171,12 +177,17 @@ module Asciidoctor
|
|
171
177
|
# Content
|
172
178
|
#
|
173
179
|
# [bibliography]
|
174
|
-
# ==
|
175
|
-
#
|
176
|
-
#
|
180
|
+
# == References
|
181
|
+
#
|
182
|
+
# [bibliography]
|
183
|
+
# === Normative|Informative References
|
184
|
+
# ++++
|
185
|
+
# RFC XML references
|
186
|
+
# ++++
|
177
187
|
def section(node)
|
178
188
|
result = []
|
179
|
-
if node.attr("style") == "bibliography"
|
189
|
+
if node.attr("style") == "bibliography" ||
|
190
|
+
node.parent.context == :section && node.parent.attr("style") == "bibliography"
|
180
191
|
$xreftext = {}
|
181
192
|
$processing_reflist = true
|
182
193
|
|
@@ -184,11 +195,25 @@ module Asciidoctor
|
|
184
195
|
title: node.title,
|
185
196
|
}
|
186
197
|
|
198
|
+
node.blocks.each do |block|
|
199
|
+
if block.context == :section
|
200
|
+
result << node.content
|
201
|
+
elsif block.context == :pass
|
202
|
+
# we are assuming a single contiguous :pass block of XML
|
203
|
+
result << noko do |xml|
|
204
|
+
xml.references **attr_code(references_attributes) do |xml_references|
|
205
|
+
xml_references << reflist(block).join
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
=begin
|
187
211
|
result << noko do |xml|
|
188
212
|
xml.references **attr_code(references_attributes) do |xml_references|
|
189
213
|
node.blocks.each { |b| xml_references << reflist(b).join }
|
190
214
|
end
|
191
215
|
end
|
216
|
+
=end
|
192
217
|
|
193
218
|
result = result.unshift("</middle><back>") unless $seen_back_matter
|
194
219
|
$processing_reflist = false
|
@@ -248,9 +273,10 @@ module Asciidoctor
|
|
248
273
|
xmldoc = Nokogiri::XML(doc) do |config|
|
249
274
|
config.noent
|
250
275
|
end
|
251
|
-
|
276
|
+
|
252
277
|
# any crefs that are direct children of section should become children of the preceding
|
253
278
|
# paragraph, if it exists; otherwise, they need to be wrapped in a paragraph
|
279
|
+
crefs = xmldoc.xpath("//cref")
|
254
280
|
crefs.each do |cref|
|
255
281
|
if cref.parent.name == "section"
|
256
282
|
prev = cref.previous_element
|
@@ -263,6 +289,10 @@ module Asciidoctor
|
|
263
289
|
end
|
264
290
|
end
|
265
291
|
end
|
292
|
+
|
293
|
+
xmldoc.root = merge_vspace(xmldoc.root)
|
294
|
+
|
295
|
+
# smart quotes: handle smart apostrophe
|
266
296
|
unless $smart_quotes
|
267
297
|
xmldoc.traverse do |node|
|
268
298
|
if node.text?
|
@@ -281,38 +311,53 @@ module Asciidoctor
|
|
281
311
|
xmldoc.to_xml(encoding: "US-ASCII")
|
282
312
|
end
|
283
313
|
|
314
|
+
def merge_vspace(node)
|
315
|
+
nodes = []
|
316
|
+
newnodes = []
|
317
|
+
node.children.each do |element|
|
318
|
+
nodes << element
|
319
|
+
end
|
320
|
+
|
321
|
+
counter = 0
|
322
|
+
while counter < nodes.size do
|
323
|
+
if nodes[counter].name == "vspace"
|
324
|
+
blankLines = 0
|
325
|
+
while counter < nodes.size && nodes[counter].name == "vspace" do
|
326
|
+
if nodes[counter][:blankLines].nil?
|
327
|
+
blankLines += 1
|
328
|
+
else
|
329
|
+
blankLines += nodes[counter][:blankLines].to_i + 1
|
330
|
+
end
|
331
|
+
if counter+1 < nodes.size && nodes[counter+1].text?
|
332
|
+
if nodes[counter+1].text =~ /\A[\n ]+\Z/m
|
333
|
+
counter += 1
|
334
|
+
end
|
335
|
+
end
|
336
|
+
counter += 1
|
337
|
+
end
|
338
|
+
counter -= 1 if counter == nodes.size
|
339
|
+
newnodes << noko do |xml|
|
340
|
+
xml.vspace **attr_code(blankLines: (blankLines - 1))
|
341
|
+
end.join
|
342
|
+
else
|
343
|
+
newnodes << merge_vspace(nodes[counter])
|
344
|
+
nodes[counter].remove
|
345
|
+
counter += 1
|
346
|
+
end
|
347
|
+
|
348
|
+
node.children.remove
|
349
|
+
newnodes.each do |item|
|
350
|
+
node.add_child(item)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
node
|
354
|
+
end
|
355
|
+
|
284
356
|
def set_pis(node, doc)
|
285
357
|
# Below are generally applicable Processing Instructions (PIs)
|
286
358
|
# that most I-Ds might want to use. (Here they are set differently than
|
287
359
|
# their defaults in xml2rfc v1.32)
|
288
|
-
rfc_pis =
|
289
|
-
# give errors regarding ID-nits and DTD validation
|
290
|
-
strict: "yes",
|
291
|
-
|
292
|
-
# TOC control
|
293
|
-
# generate a ToC
|
294
|
-
toc: node.attr("toc-include") == "false" ? "no" : "yes",
|
295
|
-
|
296
|
-
# the number of levels of subsections in ToC. default: 3
|
297
|
-
tocdepth: node.attr("toc-depth") || "4",
|
298
|
-
|
299
|
-
# References control
|
300
|
-
|
301
|
-
# use symbolic references tags, i.e, [RFC2119] instead of [1]
|
302
|
-
symrefs: "yes",
|
303
|
-
|
304
|
-
# sort the reference entries alphabetically
|
305
|
-
sortrefs: "yes",
|
306
|
-
|
307
|
-
# Vertical whitespace control
|
308
|
-
# (using these PIs as follows is recommended by the RFC Editor)
|
309
|
-
|
310
|
-
# do not start each main section on a new page
|
311
|
-
compact: "yes",
|
312
|
-
|
313
|
-
# keep one blank line between list items
|
314
|
-
subcompact: "no",
|
315
|
-
}
|
360
|
+
rfc_pis = common_rfc_pis(node)
|
316
361
|
|
317
362
|
doc.create_internal_subset("rfc", nil, "rfc2629.dtd")
|
318
363
|
rfc_pis.each_pair do |k, v|
|
@@ -325,13 +370,17 @@ module Asciidoctor
|
|
325
370
|
doc
|
326
371
|
end
|
327
372
|
|
328
|
-
# replace any <t>text</t> instances with <vspace/>text
|
373
|
+
# replace any <t>text</t> instances with <vspace blankLines="1"/>text
|
329
374
|
def para_to_vspace(doc)
|
330
375
|
xmldoc = Nokogiri::XML("<fragment>#{doc}</fragment>")
|
331
376
|
paras = xmldoc.xpath("/fragment/t")
|
332
377
|
paras.each do |para|
|
333
|
-
|
334
|
-
para.
|
378
|
+
# we do not insert vspace if the para contains a list: space will go there anyway
|
379
|
+
unless para.element_children.size == 1 && para.element_children[0].name == "list"
|
380
|
+
vspace = Nokogiri::XML::Element.new("vspace", xmldoc.document)
|
381
|
+
vspace["blankLines"] = "1"
|
382
|
+
para.before(vspace)
|
383
|
+
end
|
335
384
|
para.replace(para.children)
|
336
385
|
end
|
337
386
|
xmldoc.root.children.to_xml(encoding: "US-ASCII")
|