draft-ietf-netmod-artwork-folding-12.txt | rfc8792.txt | |||
---|---|---|---|---|
NETMOD Working Group K. Watsen | Internet Engineering Task Force (IETF) K. Watsen | |||
Internet-Draft Watsen Networks | Request for Comments: 8792 Watsen Networks | |||
Intended status: Informational E. Auerswald | Category: Informational E. Auerswald | |||
Expires: July 23, 2020 Individual Contributor | ISSN: 2070-1721 Individual Contributor | |||
A. Farrel | A. Farrel | |||
Old Dog Consulting | Old Dog Consulting | |||
Q. Wu | Q. Wu | |||
Huawei Technologies | Huawei Technologies | |||
January 20, 2020 | June 2020 | |||
Handling Long Lines in Inclusions in Internet-Drafts and RFCs | Handling Long Lines in Content of Internet-Drafts and RFCs | |||
draft-ietf-netmod-artwork-folding-12 | ||||
Abstract | Abstract | |||
This document defines two strategies for handling long lines in | This document defines two strategies for handling long lines in | |||
width-bounded text content. One strategy is based on the historical | width-bounded text content. One strategy, called the "single | |||
use of a single backslash ('\') character to indicate where line- | backslash" strategy, is based on the historical use of a single | |||
folding has occurred, with the continuation occurring with the first | backslash ('\') character to indicate where line-folding has | |||
non-space (' ') character on the next line. The second strategy | occurred, with the continuation occurring with the first character | |||
extends the first strategy by adding a second backslash character to | that is not a space character (' ') on the next line. The second | |||
identify where the continuation begins and is thereby able to handle | strategy, called the "double backslash" strategy, extends the first | |||
cases not supported by the first strategy. Both strategies use a | strategy by adding a second backslash character to identify where the | |||
self-describing header enabling automated reconstitution of the | continuation begins and is thereby able to handle cases not supported | |||
original content. | by the first strategy. Both strategies use a self-describing header | |||
enabling automated reconstitution of the original content. | ||||
Editorial Note (To be removed by RFC Editor) | ||||
Please be aware that this document uses throughout the five-character | ||||
text sequence located between the following two double-quotes: "(' | ||||
')". It has been observed that some renderings of this text sequence | ||||
produces a natural line break at the space character in the middle, | ||||
thus causing "('" to appear at the end of the first line and "')" to | ||||
appear at the beginning of the next line. Such a line-break is | ||||
confusing and should not occur in the RFC output formats. | ||||
Status of This Memo | Status of This Memo | |||
This Internet-Draft is submitted in full conformance with the | This document is not an Internet Standards Track specification; it is | |||
provisions of BCP 78 and BCP 79. | published for informational purposes. | |||
Internet-Drafts are working documents of the Internet Engineering | ||||
Task Force (IETF). Note that other groups may also distribute | ||||
working documents as Internet-Drafts. The list of current Internet- | ||||
Drafts is at https://datatracker.ietf.org/drafts/current/. | ||||
Internet-Drafts are draft documents valid for a maximum of six months | This document is a product of the Internet Engineering Task Force | |||
and may be updated, replaced, or obsoleted by other documents at any | (IETF). It represents the consensus of the IETF community. It has | |||
time. It is inappropriate to use Internet-Drafts as reference | received public review and has been approved for publication by the | |||
material or to cite them other than as "work in progress." | Internet Engineering Steering Group (IESG). Not all documents | |||
approved by the IESG are candidates for any level of Internet | ||||
Standard; see Section 2 of RFC 7841. | ||||
This Internet-Draft will expire on July 23, 2020. | Information about the current status of this document, any errata, | |||
and how to provide feedback on it may be obtained at | ||||
https://www.rfc-editor.org/info/rfc8792. | ||||
Copyright Notice | Copyright Notice | |||
Copyright (c) 2020 IETF Trust and the persons identified as the | Copyright (c) 2020 IETF Trust and the persons identified as the | |||
document authors. All rights reserved. | document authors. All rights reserved. | |||
This document is subject to BCP 78 and the IETF Trust's Legal | This document is subject to BCP 78 and the IETF Trust's Legal | |||
Provisions Relating to IETF Documents | Provisions Relating to IETF Documents | |||
(https://trustee.ietf.org/license-info) in effect on the date of | (https://trustee.ietf.org/license-info) in effect on the date of | |||
publication of this document. Please review these documents | publication of this document. Please review these documents | |||
carefully, as they describe your rights and restrictions with respect | carefully, as they describe your rights and restrictions with respect | |||
to this document. Code Components extracted from this document must | to this document. Code Components extracted from this document must | |||
include Simplified BSD License text as described in Section 4.e of | include Simplified BSD License text as described in Section 4.e of | |||
the Trust Legal Provisions and are provided without warranty as | the Trust Legal Provisions and are provided without warranty as | |||
described in the Simplified BSD License. | described in the Simplified BSD License. | |||
Table of Contents | Table of Contents | |||
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 | 1. Introduction | |||
2. Applicability Statement . . . . . . . . . . . . . . . . . . . 4 | 2. Applicability Statement | |||
3. Requirements Language . . . . . . . . . . . . . . . . . . . . 4 | 3. Requirements Language | |||
4. Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 | 4. Goals | |||
4.1. Automated Folding of Long Lines in Text Content . . . . . 4 | 4.1. Automated Folding of Long Lines in Text Content | |||
4.2. Automated Reconstitution of the Original Text Content . . 5 | 4.2. Automated Reconstitution of the Original Text Content | |||
5. Limitations . . . . . . . . . . . . . . . . . . . . . . . . . 5 | 5. Limitations | |||
5.1. Not Recommended for Graphical Artwork . . . . . . . . . . 5 | 5.1. Not Recommended for Graphical Artwork | |||
5.2. Doesn't Work as Well as Format-Specific Options . . . . . 6 | 5.2. Doesn't Work as Well as Format-Specific Options | |||
6. Two Folding Strategies . . . . . . . . . . . . . . . . . . . 6 | 6. Two Folding Strategies | |||
6.1. Comparison . . . . . . . . . . . . . . . . . . . . . . . 6 | 6.1. Comparison | |||
6.2. Recommendation . . . . . . . . . . . . . . . . . . . . . 7 | 6.2. Recommendation | |||
7. The Single Backslash Strategy ('\') . . . . . . . . . . . . . 7 | 7. The Single Backslash Strategy ('\') | |||
7.1. Folded Structure . . . . . . . . . . . . . . . . . . . . 7 | 7.1. Folded Structure | |||
7.1.1. Header . . . . . . . . . . . . . . . . . . . . . . . 7 | 7.1.1. Header | |||
7.1.2. Body . . . . . . . . . . . . . . . . . . . . . . . . 7 | 7.1.2. Body | |||
7.2. Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 7 | 7.2. Algorithm | |||
7.2.1. Folding . . . . . . . . . . . . . . . . . . . . . . . 8 | 7.2.1. Folding | |||
7.2.2. Unfolding . . . . . . . . . . . . . . . . . . . . . . 9 | 7.2.2. Unfolding | |||
8. The Double Backslash Strategy ('\\') . . . . . . . . . . . . 10 | 8. The Double Backslash Strategy ('\\') | |||
8.1. Folded Structure . . . . . . . . . . . . . . . . . . . . 10 | 8.1. Folded Structure | |||
8.1.1. Header . . . . . . . . . . . . . . . . . . . . . . . 10 | 8.1.1. Header | |||
8.1.2. Body . . . . . . . . . . . . . . . . . . . . . . . . 10 | 8.1.2. Body | |||
8.2. Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 10 | 8.2. Algorithm | |||
8.2.1. Folding . . . . . . . . . . . . . . . . . . . . . . . 11 | 8.2.1. Folding | |||
8.2.2. Unfolding . . . . . . . . . . . . . . . . . . . . . . 12 | 8.2.2. Unfolding | |||
9. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 12 | 9. Examples | |||
9.1. Example Showing Boundary Conditions . . . . . . . . . . . 13 | 9.1. Example Showing Boundary Conditions | |||
9.1.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 13 | 9.1.1. Using '\' | |||
9.1.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 13 | 9.1.2. Using '\\' | |||
9.2. Example Showing Multiple Wraps of a Single Line . . . . . 13 | 9.2. Example Showing Multiple Wraps of a Single Line | |||
9.2.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 14 | 9.2.1. Using '\' | |||
9.2.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 14 | 9.2.2. Using '\\' | |||
9.3. Example Showing "Smart" Folding . . . . . . . . . . . . . 14 | 9.3. Example Showing "Smart" Folding | |||
9.3.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 14 | 9.3.1. Using '\' | |||
9.3.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 15 | 9.3.2. Using '\\' | |||
9.4. Example Showing "Forced" Folding . . . . . . . . . . . . 16 | 9.4. Example Showing "Forced" Folding | |||
9.4.1. Using '\' . . . . . . . . . . . . . . . . . . . . . . 17 | 9.4.1. Using '\' | |||
9.4.2. Using '\\' . . . . . . . . . . . . . . . . . . . . . 17 | 9.4.2. Using '\\' | |||
10. Security Considerations . . . . . . . . . . . . . . . . . . . 18 | 10. Security Considerations | |||
11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 18 | 11. IANA Considerations | |||
12. References . . . . . . . . . . . . . . . . . . . . . . . . . 18 | 12. References | |||
12.1. Normative References . . . . . . . . . . . . . . . . . . 18 | 12.1. Normative References | |||
12.2. Informative References . . . . . . . . . . . . . . . . . 19 | 12.2. Informative References | |||
Appendix A. Bash Shell Script: rfcfold . . . . . . . . . . . . . 20 | Appendix A. Bash Shell Script: rfcfold | |||
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 30 | Acknowledgements | |||
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 30 | Authors' Addresses | |||
1. Introduction | 1. Introduction | |||
[RFC7994] sets out the requirements for plain-text RFCs and states | [RFC7994] sets out the requirements for plain-text RFCs and states | |||
that each line of an RFC (and hence of an Internet-Draft) must be | that each line of an RFC (and hence of an Internet-Draft) must be | |||
limited to 72 characters followed by the character sequence that | limited to 72 characters followed by the character sequence that | |||
denotes an end-of-line (EOL). | denotes an end-of-line (EOL). | |||
Internet-Drafts and RFCs often include example text or code | Internet-Drafts and RFCs often include example text or code | |||
fragments. Many times the example text or code exceeds the 72 | fragments. Many times, the example text or code exceeds the | |||
character line-length limit. The `xml2rfc` [xml2rfc] utility, at the | 72-character line-length limit. The 'xml2rfc' utility [xml2rfc], at | |||
time of this document's publication, does not attempt to wrap the | the time of this document's publication, does not attempt to wrap the | |||
content of such inclusions, simply issuing a warning whenever lines | content of such inclusions, simply issuing a warning whenever lines | |||
exceed 69 characters. Historically, there has been no RFC-Editor- | exceed 69 characters. Historically, there has been no convention | |||
recommended convention in place for how to handle long lines in such | recommended by the RFC Editor in place for how to handle long lines | |||
inclusions, other than advising authors to clearly indicate what | in such inclusions, other than advising authors to clearly indicate | |||
manipulation has occurred. | what manipulation has occurred. | |||
This document defines two strategies for handling long lines in | This document defines two strategies for handling long lines in | |||
width-bounded text content. One strategy is based on the historical | width-bounded text content. One strategy, called the "single | |||
use of a single backslash ('\') character to indicate where line- | backslash" strategy, is based on the historical use of a single | |||
folding has occurred, with the continuation occurring with the first | backslash ('\') character to indicate where line-folding has | |||
non-space (' ') character on the next line. The second strategy | occurred, with the continuation occurring with the first character | |||
extends the first strategy by adding a second backslash character to | that is not a space character (' ') on the next line. The second | |||
identify where the continuation begins and is thereby able to handle | strategy, called the "double backslash" strategy, extends the first | |||
cases not supported by the first strategy. Both strategies use a | strategy by adding a second backslash character to identify where the | |||
self-describing header enabling automated reconstitution of the | continuation begins and is thereby able to handle cases not supported | |||
original content. | by the first strategy. Both strategies use a self-describing header | |||
enabling automated reconstitution of the original content. | ||||
The strategies defined in this document work on any text content, but | The strategies defined in this document work on any text content but | |||
are primarily intended for a structured sequence of lines, such as | are primarily intended for a structured sequence of lines, such as | |||
would be referenced by the <sourcecode> element defined in | would be referenced by the <sourcecode> element defined in | |||
Section 2.48 of [RFC7991], rather than for two-dimensional imagery, | Section 2.48 of [RFC7991], rather than for two-dimensional imagery, | |||
such as would be referenced by the <artwork> element defined in | such as would be referenced by the <artwork> element defined in | |||
Section 2.5 of [RFC7991]. | Section 2.5 of [RFC7991]. | |||
Note that text files are represented as lines having their first | Note that text files are represented as lines having their first | |||
character in column 1, and a line length of N where the last | character in column 1, and a line length of N where the last | |||
character is in the Nth column and is immediately followed by an end | character is in the Nth column and is immediately followed by an end- | |||
of line character sequence. | of-line character sequence. | |||
2. Applicability Statement | 2. Applicability Statement | |||
The formats and algorithms defined in this document may be used in | The formats and algorithms defined in this document may be used in | |||
any context, whether for IETF documents or in other situations where | any context, whether for IETF documents or in other situations where | |||
structured folding is desired. | structured folding is desired. | |||
Within the IETF, this work primarily targets the xml2rfc v3 | Within the IETF, this work primarily targets the xml2rfc v3 | |||
<sourcecode> element (Section 2.48 of [RFC7991]) and the xml2rfc v2 | <sourcecode> element (Section 2.48 of [RFC7991]) and the xml2rfc v2 | |||
<artwork> element (Section 2.5 of [RFC7749]) that, for lack of a | <artwork> element (Section 2.5 of [RFC7749]), which, for lack of a | |||
better option, is currently used for both source code and artwork. | better option, is used in xml2rfc v2 for both source code and | |||
This work may also be used for the xml2rfc v3 <artwork> element | artwork. This work may also be used for the xml2rfc v3 <artwork> | |||
(Section 2.5 of [RFC7991]) but, as described in Section 5.1, it is | element (Section 2.5 of [RFC7991]), but as described in Section 5.1, | |||
generally not recommended. | it is generally not recommended. | |||
3. Requirements Language | 3. Requirements Language | |||
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", | |||
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and | "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and | |||
"OPTIONAL" in this document are to be interpreted as described in BCP | "OPTIONAL" in this document are to be interpreted as described in | |||
14 [RFC2119] [RFC8174] when, and only when, they appear in all | BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all | |||
capitals, as shown here. | capitals, as shown here. | |||
4. Goals | 4. Goals | |||
4.1. Automated Folding of Long Lines in Text Content | 4.1. Automated Folding of Long Lines in Text Content | |||
Automated folding of long lines is needed in order to support drafts | Automated folding of long lines is needed in order to support | |||
that are dynamically compiled to include content with potentially | documents that are dynamically compiled to include content with | |||
unconstrained line lengths. For instance, the build process may wish | potentially unconstrained line lengths. For instance, the build | |||
to include content from other local files or dynamically generated by | process may wish to include content from other local files or content | |||
some external process. Both of these cases are discussed next. | that is dynamically generated by some external process. Both of | |||
these cases are discussed next. | ||||
Many drafts need to include the content from local files (e.g., XML, | Many documents need to include the content from local files (e.g., | |||
JSON, ABNF, ASN.1). Prior to including a file's content, the build | XML, JSON, ABNF, ASN.1). Prior to including a file's content, the | |||
process SHOULD first validate these source files using format- | build process SHOULD first validate these source files using format- | |||
specific validators. In order for such tooling to be able to process | specific validators. In order for such tooling to be able to process | |||
the files, the files must be in their original/natural state, which | the files, the files must be in their original/natural state, which | |||
may entail them having some long lines. Thus, these source files | may entail them having some long lines. Thus, these source files | |||
need to be folded before inclusion into the XML document, in order to | need to be folded before inclusion into the XML document, in order to | |||
satisfy `xml2rfc` line length limits. | satisfy 'xml2rfc' line-length limits. | |||
Similarly, drafts sometimes contain dynamically generated output, | Similarly, documents sometimes contain dynamically generated output, | |||
typically from an external process operating on the same source files | typically from an external process operating on the same source files | |||
discussed in the previous paragraph. For instance, such processes | discussed in the previous paragraph. For instance, such processes | |||
may translate the input format to another format or render a report | may translate the input format to another format, or they may render | |||
over or a view of the input file. In some cases, the dynamically | a report on, or a view of, the input file. In some cases, the | |||
generated output may contain lines exceeding the `xml2rfc` line | dynamically generated output may contain lines exceeding the | |||
length limits. | 'xml2rfc' line-length limits. | |||
In both cases, folding is required and SHOULD be automated to reduce | In both cases, folding is required and SHOULD be automated to reduce | |||
effort and errors resulting from manual processing. | effort and errors resulting from manual processing. | |||
4.2. Automated Reconstitution of the Original Text Content | 4.2. Automated Reconstitution of the Original Text Content | |||
Automated reconstitution of the exact original text content is needed | Automated reconstitution of the exact original text content is needed | |||
to support validation of text-based content extracted from documents. | to support validation of text-based content extracted from documents. | |||
For instance, already YANG [RFC7950] modules are extracted from | For instance, YANG modules [RFC7950] are already extracted from | |||
Internet-Drafts and validated as part of the draft-submission | Internet-Drafts and validated as part of the submission process. | |||
process. Additionally, the desire to validate instance examples | Additionally, the desire to validate instance examples (i.e., XML/ | |||
(i.e., XML/JSON documents) contained within Internet-Drafts has been | JSON documents) contained within Internet-Drafts has been discussed | |||
discussed ([yang-doctors-thread]). | [yang-doctors-thread]. | |||
5. Limitations | 5. Limitations | |||
5.1. Not Recommended for Graphical Artwork | 5.1. Not Recommended for Graphical Artwork | |||
While the solution presented in this document works on any kind of | While the solution presented in this document works on any kind of | |||
text-based content, it is most useful on content that represents | text-based content, it is most useful on content that represents | |||
source code (XML, JSON, etc.) or, more generally, on content that has | source code (XML, JSON, etc.) or, more generally, on content that has | |||
not been laid out in two dimensions (e.g., diagrams). | not been laid out in two dimensions (e.g., diagrams). | |||
Fundamentally, the issue is whether the text content remains readable | Fundamentally, the issue is whether the text content remains readable | |||
once folded. Text content that is unpredictable is especially | once folded. Text content that is unpredictable is especially | |||
susceptible to looking bad when folded; falling into this category | susceptible to looking bad when folded; falling into this category | |||
are most UML diagrams, YANG tree diagrams, and ASCII art in general. | are most Unified Modeling Language (UML) diagrams, YANG tree | |||
diagrams, and ASCII art in general. | ||||
It is NOT RECOMMENDED to use the solution presented in this document | It is NOT RECOMMENDED to use the solution presented in this document | |||
on graphical artwork. | on graphical artwork. | |||
5.2. Doesn't Work as Well as Format-Specific Options | 5.2. Doesn't Work as Well as Format-Specific Options | |||
The solution presented in this document works generically for all | The solution presented in this document works generically for all | |||
text-based content, as it only views content as plain text. However, | text-based content, as it only views content as plain text. However, | |||
various formats sometimes have built-in mechanisms that are better | various formats sometimes have built-in mechanisms that are better | |||
suited to prevent long lines. | suited to prevent long lines. | |||
For instance, both the `pyang` [pyang] and `yanglint` [yanglint] | For instance, both the 'pyang' and 'yanglint' utilities [pyang] | |||
utilities have the command line option "--tree-line-length" that can | [yanglint] have the command-line option "tree-line-length", which can | |||
be used to indicate a desired maximum line length for when generating | be used to indicate a desired maximum line length when generating | |||
tree diagrams [RFC8340]. | YANG tree diagrams [RFC8340]. | |||
In another example, some source formats (e.g., YANG [RFC7950]) allow | In another example, some source formats (e.g., YANG [RFC7950]) allow | |||
any quoted string to be broken up into substrings separated by a | any quoted string to be broken up into substrings separated by a | |||
concatenation character (e.g., '+'), any of which can be on a | concatenation character (e.g., '+'), any of which can be on a | |||
different line. | different line. | |||
It is RECOMMENDED that authors do as much as possible within the | It is RECOMMENDED that authors do as much as possible within the | |||
selected format to avoid long lines. | selected format to avoid long lines. | |||
6. Two Folding Strategies | 6. Two Folding Strategies | |||
This document defines two nearly identical strategies for folding | This document defines two nearly identical strategies for folding | |||
text-based content. | text-based content. | |||
The Single Backslash Strategy ('\'): Uses a backslash ('\') | The Single Backslash Strategy ('\'): | |||
character at the end of the line where folding occurs, and | Uses a backslash ('\') character at the end of the line where | |||
assumes that the continuation begins at the first character | folding occurs, and assumes that the continuation begins at the | |||
that is not a space character (' ') on the following line. | first character that is not a space character (' ') on the | |||
following line. | ||||
The Double Backslash Strategy ('\\'): Uses a backslash ('\') | The Double Backslash Strategy ('\\'): | |||
character at the end of the line where folding occurs, and | Uses a backslash ('\') character at the end of the line where | |||
assumes that the continuation begins after a second backslash | folding occurs, and assumes that the continuation begins after a | |||
('\') character on the following line. | second backslash ('\') character on the following line. | |||
6.1. Comparison | 6.1. Comparison | |||
The first strategy produces more readable output, however it is | The first strategy produces output that is more readable. However, | |||
significantly more likely to encounter unfoldable input (e.g., a long | (1) it is significantly more likely to encounter unfoldable input | |||
line containing only space characters) and, for long lines that can | (e.g., a long line containing only space characters), and (2) for | |||
be folded, automation implementations may encounter scenarios that | long lines that can be folded, automation implementations may | |||
will produce errors without special care. | encounter scenarios that, without special care, will produce errors. | |||
The second strategy produces less readable output, but is unlikely to | The second strategy produces output that is less readable, but it is | |||
encounter unfoldable input, there are no long lines that cannot be | unlikely to encounter unfoldable input, there are no long lines that | |||
folded, and no special care is required for when folding a long line. | cannot be folded, and no special care is required when folding a long | |||
line. | ||||
6.2. Recommendation | 6.2. Recommendation | |||
It is RECOMMENDED for implementations to first attempt to fold | It is RECOMMENDED that implementations first attempt to fold content | |||
content using the single backslash strategy and, only in the unlikely | using the single backslash strategy and, only in the unlikely event | |||
event that it cannot fold the input or the folding logic is unable to | that it cannot fold the input or the folding logic is unable to cope | |||
cope with a contingency occurring on the desired folding column, then | with a contingency occurring on the desired folding column, then fall | |||
fallback to the double backslash strategy. | back to the double backslash strategy. | |||
7. The Single Backslash Strategy ('\') | 7. The Single Backslash Strategy ('\') | |||
7.1. Folded Structure | 7.1. Folded Structure | |||
Text content that has been folded as specified by this strategy MUST | Text content that has been folded as specified by this strategy MUST | |||
adhere to the following structure. | adhere to the following structure. | |||
7.1.1. Header | 7.1.1. Header | |||
The header is two lines long. | The header is two lines long. | |||
The first line is the following 46-character string that MAY be | The first line is the following 36-character string; this string MAY | |||
surrounded by any number of printable characters. This first line | be surrounded by any number of printable characters. This first line | |||
cannot itself be folded. | cannot itself be folded. | |||
NOTE: '\' line wrapping per BCP XXX (RFC XXXX) | NOTE: '\' line wrapping per RFC 8792 | |||
[Note to RFC Editor: Please replace XXX and XXXX with the numbers | ||||
assigned to this document and delete this note. Please make this | ||||
change in multiple places in this document.] | ||||
The second line is an empty line, containing only the end-of-line | The second line is an empty line, containing only the end-of-line | |||
character sequence. This line provides visual separation for | character sequence. This line provides visual separation for | |||
readability. | readability. | |||
7.1.2. Body | 7.1.2. Body | |||
The character encoding is the same as described in Section 2 of | The character encoding is the same as the encoding described in | |||
[RFC7994], except that, per [RFC7991], tab characters are prohibited. | Section 2 of [RFC7994], except that, per [RFC7991], tab characters | |||
are prohibited. | ||||
Lines that have a backslash ('\') occurring as the last character in | Lines that have a backslash ('\') occurring as the last character in | |||
a line are considered "folded". | a line are considered "folded". | |||
Exceptionally long lines may be folded multiple times. | Exceptionally long lines MAY be folded multiple times. | |||
7.2. Algorithm | 7.2. Algorithm | |||
This section describes a process for folding and unfolding long lines | This section describes a process for folding and unfolding long lines | |||
when they are encountered in text content. | when they are encountered in text content. | |||
The steps are complete, but implementations MAY achieve the same | The steps are complete, but implementations MAY achieve the same | |||
result in other ways. | result in other ways. | |||
When a larger document contains multiple instances of text content | When a larger document contains multiple instances of text content | |||
that may need to be folded or unfolded, another process must insert/ | that may need to be folded or unfolded, another process must | |||
extract the individual text content instances to/from the larger | insert/extract the individual text content instances to/from the | |||
document prior to utilizing the algorithms described in this section. | larger document prior to utilizing the algorithms described in this | |||
For example, the `xiax` utility [xiax] does this. | section. For example, the 'xiax' utility [xiax] does this. | |||
7.2.1. Folding | 7.2.1. Folding | |||
Determine the desired maximum line length from input to the line- | Determine the desired maximum line length from input to the line- | |||
wrapping process, such as from a command line parameter. If no value | wrapping process, such as from a command-line parameter. If no value | |||
is explicitly specified, the value "69" SHOULD be used. | is explicitly specified, the value "69" SHOULD be used. | |||
Ensure that the desired maximum line length is not less than the | Ensure that the desired maximum line length is not less than the | |||
minimum header, which is 46 characters. If the desired maximum line | minimum header, which is 36 characters. If the desired maximum line | |||
length is less than this minimum, exit (this text-based content | length is less than this minimum, exit (this text-based content | |||
cannot be folded). | cannot be folded). | |||
Scan the text content for horizontal tab characters. If any | Scan the text content for horizontal tab characters. If any | |||
horizontal tab characters appear, either resolve them to space | horizontal tab characters appear, either resolve them to space | |||
characters or exit, forcing the input provider to convert them to | characters or exit, forcing the input provider to convert them to | |||
space characters themselves first. | space characters themselves first. | |||
Scan the text content to ensure at least one line exceeds the desired | Scan the text content to ensure that at least one line exceeds the | |||
maximum. If no line exceeds the desired maximum, exit (this text | desired maximum. If no line exceeds the desired maximum, exit (this | |||
content does not need to be folded). | text content does not need to be folded). | |||
Scan the text content to ensure no existing lines already end with a | Scan the text content to ensure that no existing lines already end | |||
backslash ('\') character, as this could lead to an ambiguous result. | with a backslash ('\') character, as this could lead to an ambiguous | |||
If such a line is found, and its width is less than the desired | result. If such a line is found, and its width is less than the | |||
maximum, then it SHOULD be flagged for forced folding (folding even | desired maximum, then it SHOULD be flagged for "forced" folding | |||
though unnecessary). If the folding implementation doesn't support | (folding even though unnecessary). If the folding implementation | |||
forced foldings, it MUST exit. | doesn't support forced foldings, it MUST exit. | |||
If this text content needs to and can be folded, insert the header | If this text content needs to, and can, be folded, insert the header | |||
described in Section 7.1.1, ensuring that any additional printable | described in Section 7.1.1, ensuring that any additional printable | |||
characters surrounding the header do not result in a line exceeding | characters surrounding the header do not result in a line exceeding | |||
the desired maximum. | the desired maximum. | |||
For each line in the text content, from top-to-bottom, if the line | For each line in the text content, from top to bottom, if the line | |||
exceeds the desired maximum, or requires a forced folding, then fold | exceeds the desired maximum or requires a forced folding, then fold | |||
the line by: | the line by performing the following steps: | |||
1. Determine where the fold will occur. This location MUST be | 1. Determine where the fold will occur. This location MUST be | |||
before or at the desired maximum column, and MUST NOT be chosen | before or at the desired maximum column and MUST NOT be chosen | |||
such that the character immediately after the fold is a space (' | such that the character immediately after the fold is a space | |||
') character. For forced foldings, the location is between the | (' ') character. For forced foldings, the location is between | |||
'\' and the end of line sequence. If no such location can be | the '\' and the end-of-line sequence. If no such location can be | |||
found, then exit (this text content cannot be folded). | found, then exit (this text content cannot be folded). | |||
2. At the location where the fold is to occur, insert a backslash | 2. At the location where the fold is to occur, insert a backslash | |||
('\') character followed by the end of line character sequence. | ('\') character followed by the end-of-line character sequence. | |||
3. On the following line, insert any number of space (' ') | 3. On the following line, insert any number of space (' ') | |||
characters, subject to the resulting line not exceeding the | characters, provided that the resulting line does not exceed the | |||
desired maximum. | desired maximum. | |||
The result of the previous operation is that the next line starts | The result of the previous operation is that the next line starts | |||
with an arbitrary number of space (' ') characters, followed by the | with an arbitrary number of space (' ') characters, followed by the | |||
character that was previously occupying the position where the fold | character that was previously occupying the position where the fold | |||
occurred. | occurred. | |||
Continue in this manner until reaching the end of the text content. | Continue in this manner until reaching the end of the text content. | |||
Note that this algorithm naturally addresses the case where the | Note that this algorithm naturally addresses the case where the | |||
remainder of a folded line is still longer than the desired maximum, | remainder of a folded line is still longer than the desired maximum | |||
and hence needs to be folded again, ad infinitum. | and, hence, needs to be folded again, ad infinitum. | |||
The process described in this section is illustrated by the | The process described in this section is illustrated by the | |||
"fold_it_1()" function in Appendix A. | "fold_it_1()" function in Appendix A. | |||
7.2.2. Unfolding | 7.2.2. Unfolding | |||
Scan the beginning of the text content for the header described in | Scan the beginning of the text content for the header described in | |||
Section 7.1.1. If the header is not present, exit (this text content | Section 7.1.1. If the header is not present, exit (this text content | |||
does not need to be unfolded). | does not need to be unfolded). | |||
Remove the 2-line header from the text content. | Remove the two-line header from the text content. | |||
For each line in the text content, from top-to-bottom, if the line | For each line in the text content, from top to bottom, if the line | |||
has a backslash ('\') character immediately followed by the end of | has a backslash ('\') character immediately followed by the end-of- | |||
line character sequence, then the line can be unfolded. Remove the | line character sequence, then the line can be unfolded. Remove the | |||
backslash ('\') character, the end of line character sequence, and | backslash ('\') character, the end-of-line character sequence, and | |||
any leading space (' ') characters, which will bring up the next | any leading space (' ') characters, which will bring up the next | |||
line. Then continue to scan each line in the text content starting | line. Then continue to scan each line in the text content starting | |||
with the current line (in case it was multiply folded). | with the current line (in case it was multiply folded). | |||
Continue in this manner until reaching the end of the text content. | Continue in this manner until reaching the end of the text content. | |||
The process described in this section is illustrated by the | The process described in this section is illustrated by the | |||
"unfold_it_1()" function in Appendix A. | "unfold_it_1()" function in Appendix A. | |||
8. The Double Backslash Strategy ('\\') | 8. The Double Backslash Strategy ('\\') | |||
8.1. Folded Structure | 8.1. Folded Structure | |||
Text content that has been folded as specified by this strategy MUST | Text content that has been folded as specified by this strategy MUST | |||
adhere to the following structure. | adhere to the following structure. | |||
8.1.1. Header | 8.1.1. Header | |||
The header is two lines long. | The header is two lines long. | |||
The first line is the following 47-character string that MAY be | The first line is the following 37-character string; this string MAY | |||
surrounded by any number of printable characters. This first line | be surrounded by any number of printable characters. This first line | |||
cannot itself be folded. | cannot itself be folded. | |||
NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) | NOTE: '\\' line wrapping per RFC 8792 | |||
[Note to RFC Editor: Please replace XXX and XXXX with the numbers | ||||
assigned to this document and delete this note. Please make this | ||||
change in multiple places in this document.] | ||||
The second line is an empty line, containing only the end-of-line | The second line is an empty line, containing only the end-of-line | |||
character sequence. This line provides visual separation for | character sequence. This line provides visual separation for | |||
readability. | readability. | |||
8.1.2. Body | 8.1.2. Body | |||
The character encoding is the same as described in Section 2 of | The character encoding is the same as the encoding described in | |||
[RFC7994], except that, per [RFC7991], tab characters are prohibited. | Section 2 of [RFC7994], except that, per [RFC7991], tab characters | |||
are prohibited. | ||||
Lines that have a backslash ('\') occurring as the last character in | Lines that have a backslash ('\') occurring as the last character in | |||
a line immediately followed by the end of line character sequence, | a line immediately followed by the end-of-line character sequence, | |||
when the subsequent line starts with a backslash ('\') as the first | when the subsequent line starts with a backslash ('\') as the first | |||
non-space (' ') character, are considered "folded". | character that is not a space character (' '), are considered | |||
"folded". | ||||
Exceptionally long lines may be folded multiple times. | Exceptionally long lines MAY be folded multiple times. | |||
8.2. Algorithm | 8.2. Algorithm | |||
This section describes a process for folding and unfolding long lines | This section describes a process for folding and unfolding long lines | |||
when they are encountered in text content. | when they are encountered in text content. | |||
The steps are complete, but implementations MAY achieve the same | The steps are complete, but implementations MAY achieve the same | |||
result in other ways. | result in other ways. | |||
When a larger document contains multiple instances of text content | When a larger document contains multiple instances of text content | |||
that may need to be folded or unfolded, another process must insert/ | that may need to be folded or unfolded, another process must | |||
extract the individual text content instances to/from the larger | insert/extract the individual text content instances to/from the | |||
document prior to utilizing the algorithms described in this section. | larger document prior to utilizing the algorithms described in this | |||
For example, the `xiax` utility [xiax] does this. | section. For example, the 'xiax' utility [xiax] does this. | |||
8.2.1. Folding | 8.2.1. Folding | |||
Determine the desired maximum line length from input to the line- | Determine the desired maximum line length from input to the line- | |||
wrapping process, such as from a command line parameter. If no value | wrapping process, such as from a command-line parameter. If no value | |||
is explicitly specified, the value "69" SHOULD be used. | is explicitly specified, the value "69" SHOULD be used. | |||
Ensure that the desired maximum line length is not less than the | Ensure that the desired maximum line length is not less than the | |||
minimum header, which is 47 characters. If the desired maximum line | minimum header, which is 37 characters. If the desired maximum line | |||
length is less than this minimum, exit (this text-based content | length is less than this minimum, exit (this text-based content | |||
cannot be folded). | cannot be folded). | |||
Scan the text content for horizontal tab characters. If any | Scan the text content for horizontal tab characters. If any | |||
horizontal tab characters appear, either resolve them to space | horizontal tab characters appear, either resolve them to space | |||
characters or exit, forcing the input provider to convert them to | characters or exit, forcing the input provider to convert them to | |||
space characters themselves first. | space characters themselves first. | |||
Scan the text content to see if any line exceeds the desired maximum. | Scan the text content to see if any line exceeds the desired maximum. | |||
If no line exceeds the desired maximum, exit (this text content does | If no line exceeds the desired maximum, exit (this text content does | |||
not need to be folded). | not need to be folded). | |||
Scan the text content to ensure no existing lines already end with a | Scan the text content to ensure that no existing lines already end | |||
backslash ('\') character while the subsequent line starts with a | with a backslash ('\') character while the subsequent line starts | |||
backslash ('\') character as the first non-space (' ') character, as | with a backslash ('\') character as the first character that is not a | |||
this could lead to an ambiguous result. If such a line is found, and | space character (' '), as this could lead to an ambiguous result. If | |||
its width is less than the desired maximum, then it SHOULD be flagged | such a line is found and its width is less than the desired maximum, | |||
for forced folding (folding even though unnecessary). If the folding | then it SHOULD be flagged for forced folding (folding even though | |||
implementation doesn't support forced foldings, it MUST exit. | unnecessary). If the folding implementation doesn't support forced | |||
foldings, it MUST exit. | ||||
If this text content needs to and can be folded, insert the header | If this text content needs to, and can, be folded, insert the header | |||
described in Section 8.1.1, ensuring that any additional printable | described in Section 8.1.1, ensuring that any additional printable | |||
characters surrounding the header do not result in a line exceeding | characters surrounding the header do not result in a line exceeding | |||
the desired maximum. | the desired maximum. | |||
For each line in the text content, from top-to-bottom, if the line | For each line in the text content, from top to bottom, if the line | |||
exceeds the desired maximum, or requires a forced folding, then fold | exceeds the desired maximum or requires a forced folding, then fold | |||
the line by: | the line by performing the following steps: | |||
1. Determine where the fold will occur. This location MUST be | 1. Determine where the fold will occur. This location MUST be | |||
before or at the desired maximum column. For forced foldings, | before or at the desired maximum column. For forced foldings, | |||
the location is between the '\' and the end of line sequence on | the location is between the '\' and the end-of-line sequence on | |||
the first line. | the first line. | |||
2. At the location where the fold is to occur, insert a first | 2. At the location where the fold is to occur, insert a first | |||
backslash ('\') character followed by the end of line character | backslash ('\') character followed by the end-of-line character | |||
sequence. | sequence. | |||
3. On the following line, insert any number of space (' ') | 3. On the following line, insert any number of space (' ') | |||
characters, subject to the resulting line not exceeding the | characters, provided that the resulting line does not exceed the | |||
desired maximum, followed by a second backslash ('\') character. | desired maximum, followed by a second backslash ('\') character. | |||
The result of the previous operation is that the next line starts | The result of the previous operation is that the next line starts | |||
with an arbitrary number of space (' ') characters, followed by a | with an arbitrary number of space (' ') characters, followed by a | |||
backslash ('\') character, immediately followed by the character that | backslash ('\') character, immediately followed by the character that | |||
was previously occupying the position where the fold occurred. | was previously occupying the position where the fold occurred. | |||
Continue in this manner until reaching the end of the text content. | Continue in this manner until reaching the end of the text content. | |||
Note that this algorithm naturally addresses the case where the | Note that this algorithm naturally addresses the case where the | |||
remainder of a folded line is still longer than the desired maximum, | remainder of a folded line is still longer than the desired maximum | |||
and hence needs to be folded again, ad infinitum. | and, hence, needs to be folded again, ad infinitum. | |||
The process described in this section is illustrated by the | The process described in this section is illustrated by the | |||
"fold_it_2()" function in Appendix A. | "fold_it_2()" function in Appendix A. | |||
8.2.2. Unfolding | 8.2.2. Unfolding | |||
Scan the beginning of the text content for the header described in | Scan the beginning of the text content for the header described in | |||
Section 8.1.1. If the header is not present, exit (this text content | Section 8.1.1. If the header is not present, exit (this text content | |||
does not need to be unfolded). | does not need to be unfolded). | |||
Remove the 2-line header from the text content. | Remove the two-line header from the text content. | |||
For each line in the text content, from top-to-bottom, if the line | For each line in the text content, from top to bottom, if the line | |||
has a backslash ('\') character immediately followed by the end of | has a backslash ('\') character immediately followed by the end-of- | |||
line character sequence, and if the next line has a backslash ('\') | line character sequence and if the next line has a backslash ('\') | |||
character as the first non-space (' ') character, then the lines can | character as the first character that is not a space character (' '), | |||
be unfolded. Remove the first backslash ('\') character, the end of | then the lines can be unfolded. Remove the first backslash ('\') | |||
line character sequence, any leading space (' ') characters, and the | character, the end-of-line character sequence, any leading space | |||
second backslash ('\') character, which will bring up the next line. | (' ') characters, and the second backslash ('\') character, which | |||
Then continue to scan each line in the text content starting with the | will bring up the next line. Then, continue to scan each line in the | |||
current line (in case it was multiply folded). | text content starting with the current line (in case it was multiply | |||
folded). | ||||
Continue in this manner until reaching the end of the text content. | Continue in this manner until reaching the end of the text content. | |||
The process described in this section is illustrated by the | The process described in this section is illustrated by the | |||
"unfold_it_2()" function in Appendix A. | "unfold_it_2()" function in Appendix A. | |||
9. Examples | 9. Examples | |||
The following self-documenting examples illustrate folded text-based | The following self-documenting examples illustrate folded text-based | |||
content. | content. | |||
The source text content cannot be presented here, as it would again | The source text content cannot be presented here, as it would again | |||
be folded. Alas, only the results can be provided. | be folded. Alas, only the results can be provided. | |||
9.1. Example Showing Boundary Conditions | 9.1. Example Showing Boundary Conditions | |||
This example illustrates boundary conditions. The input contains | This example illustrates boundary conditions. The input contains | |||
seven lines, each line one character longer than the previous line. | seven lines, each line one character longer than the previous line. | |||
Numbers for counting purposes. The default desired maximum column | Numbers are used for counting purposes. The default desired maximum | |||
value "69" is used. | column value "69" is used. | |||
9.1.1. Using '\' | 9.1.1. Using '\' | |||
========== NOTE: '\' line wrapping per BCP XXX (RFC XXXX) =========== | ========== NOTE: '\' line wrapping per RFC 8792 =========== | |||
123456789012345678901234567890123456789012345678901234567890123456 | 123456789012345678901234567890123456789012345678901234567890123456 | |||
1234567890123456789012345678901234567890123456789012345678901234567 | 1234567890123456789012345678901234567890123456789012345678901234567 | |||
12345678901234567890123456789012345678901234567890123456789012345678 | 12345678901234567890123456789012345678901234567890123456789012345678 | |||
123456789012345678901234567890123456789012345678901234567890123456789 | 123456789012345678901234567890123456789012345678901234567890123456789 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
90 | 90 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
901 | 901 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
9012 | 9012 | |||
9.1.2. Using '\\' | 9.1.2. Using '\\' | |||
========== NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) ========== | ========== NOTE: '\\' line wrapping per RFC 8792 ========== | |||
123456789012345678901234567890123456789012345678901234567890123456 | 123456789012345678901234567890123456789012345678901234567890123456 | |||
1234567890123456789012345678901234567890123456789012345678901234567 | 1234567890123456789012345678901234567890123456789012345678901234567 | |||
12345678901234567890123456789012345678901234567890123456789012345678 | 12345678901234567890123456789012345678901234567890123456789012345678 | |||
123456789012345678901234567890123456789012345678901234567890123456789 | 123456789012345678901234567890123456789012345678901234567890123456789 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
\90 | \90 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
\901 | \901 | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
\9012 | \9012 | |||
9.2. Example Showing Multiple Wraps of a Single Line | 9.2. Example Showing Multiple Wraps of a Single Line | |||
This example illustrates what happens when a very long line needs to | This example illustrates what happens when a very long line needs to | |||
be folded multiple times. The input contains one line containing 280 | be folded multiple times. The input contains one line containing 280 | |||
characters. Numbers for counting purposes. The default desired | characters. Numbers are used for counting purposes. The default | |||
maximum column value "69" is used. | desired maximum column value "69" is used. | |||
9.2.1. Using '\' | 9.2.1. Using '\' | |||
========== NOTE: '\' line wrapping per BCP XXX (RFC XXXX) =========== | ========== NOTE: '\' line wrapping per RFC 8792 =========== | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
90123456789012345678901234567890123456789012345678901234567890123456\ | 90123456789012345678901234567890123456789012345678901234567890123456\ | |||
78901234567890123456789012345678901234567890123456789012345678901234\ | 78901234567890123456789012345678901234567890123456789012345678901234\ | |||
56789012345678901234567890123456789012345678901234567890123456789012\ | 56789012345678901234567890123456789012345678901234567890123456789012\ | |||
34567890 | 34567890 | |||
9.2.2. Using '\\' | 9.2.2. Using '\\' | |||
========== NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) ========== | ========== NOTE: '\\' line wrapping per RFC 8792 ========== | |||
12345678901234567890123456789012345678901234567890123456789012345678\ | 12345678901234567890123456789012345678901234567890123456789012345678\ | |||
\9012345678901234567890123456789012345678901234567890123456789012345\ | \9012345678901234567890123456789012345678901234567890123456789012345\ | |||
\6789012345678901234567890123456789012345678901234567890123456789012\ | \6789012345678901234567890123456789012345678901234567890123456789012\ | |||
\3456789012345678901234567890123456789012345678901234567890123456789\ | \3456789012345678901234567890123456789012345678901234567890123456789\ | |||
\01234567890 | \01234567890 | |||
9.3. Example Showing "Smart" Folding | 9.3. Example Showing "Smart" Folding | |||
This example illustrates how readability can be improved via "smart" | This example illustrates how readability can be improved via "smart" | |||
folding, whereby folding occurs at format-specific locations and | folding, whereby folding occurs at format-specific locations and | |||
format-specific indentations are used. | format-specific indentations are used. | |||
The text content was manually folded, since the script in the | The text content was manually folded, since the script in Appendix A | |||
appendix does not implement smart folding. | does not implement smart folding. | |||
Note that the headers are surrounded by different printable | Note that the headers are surrounded by different printable | |||
characters than shown in the script-generated examples. | characters than those shown in the script-generated examples. | |||
9.3.1. Using '\' | 9.3.1. Using '\' | |||
[NOTE: '\' line wrapping per BCP XXX (RFC XXXX)] | [NOTE: '\' line wrapping per RFC 8792] | |||
<yang-library | <yang-library | |||
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | |||
xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | |||
<module-set> | <module-set> | |||
<name>config-modules</name> | <name>config-modules</name> | |||
<module> | <module> | |||
<name>ietf-interfaces</name> | <name>ietf-interfaces</name> | |||
<revision>2018-02-20</revision> | <revision>2018-02-20</revision> | |||
<namespace>\ | <namespace>\ | |||
urn:ietf:params:xml:ns:yang:ietf-interfaces\ | urn:ietf:params:xml:ns:yang:ietf-interfaces\ | |||
</namespace> | </namespace> | |||
</module> | </module> | |||
... | ... | |||
</module-set> | </module-set> | |||
... | ... | |||
</yang-library> | </yang-library> | |||
Below is the equivalent to the above, but it was folded using the | Below is the equivalent of the above, but it was folded using the | |||
script in the appendix. | script in Appendix A. | |||
========== NOTE: '\' line wrapping per BCP XXX (RFC XXXX) =========== | ========== NOTE: '\' line wrapping per RFC 8792 =========== | |||
<yang-library | <yang-library | |||
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | |||
xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | |||
<module-set> | <module-set> | |||
<name>config-modules</name> | <name>config-modules</name> | |||
<module> | <module> | |||
<name>ietf-interfaces</name> | <name>ietf-interfaces</name> | |||
<revision>2018-02-20</revision> | <revision>2018-02-20</revision> | |||
<namespace>urn:ietf:params:xml:ns:yang:ietf-interfaces</namesp\ | <namespace>urn:ietf:params:xml:ns:yang:ietf-interfaces</namesp\ | |||
ace> | ace> | |||
</module> | </module> | |||
... | ... | |||
</module-set> | </module-set> | |||
... | ... | |||
</yang-library> | </yang-library> | |||
9.3.2. Using '\\' | 9.3.2. Using '\\' | |||
[NOTE: '\\' line wrapping per BCP XXX (RFC XXXX)] | [NOTE: '\\' line wrapping per RFC 8792] | |||
<yang-library | <yang-library | |||
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | |||
xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | |||
<module-set> | <module-set> | |||
<name>config-modules</name> | <name>config-modules</name> | |||
<module> | <module> | |||
<name>ietf-interfaces</name> | <name>ietf-interfaces</name> | |||
<revision>2018-02-20</revision> | <revision>2018-02-20</revision> | |||
<namespace>\ | <namespace>\ | |||
\urn:ietf:params:xml:ns:yang:ietf-interfaces\ | \urn:ietf:params:xml:ns:yang:ietf-interfaces\ | |||
\</namespace> | \</namespace> | |||
</module> | </module> | |||
... | ... | |||
</module-set> | </module-set> | |||
... | ... | |||
</yang-library> | </yang-library> | |||
Below is the equivalent to the above, but it was folded using the | Below is the equivalent of the above, but it was folded using the | |||
script in the appendix. | script in Appendix A. | |||
========== NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) ========== | ========== NOTE: '\\' line wrapping per RFC 8792 ========== | |||
<yang-library | <yang-library | |||
xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library" | |||
xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> | |||
<module-set> | <module-set> | |||
<name>config-modules</name> | <name>config-modules</name> | |||
<module> | <module> | |||
<name>ietf-interfaces</name> | <name>ietf-interfaces</name> | |||
<revision>2018-02-20</revision> | <revision>2018-02-20</revision> | |||
skipping to change at page 17, line 5 ¶ | skipping to change at line 734 ¶ | |||
</module-set> | </module-set> | |||
... | ... | |||
</yang-library> | </yang-library> | |||
9.4. Example Showing "Forced" Folding | 9.4. Example Showing "Forced" Folding | |||
This example illustrates how invalid sequences in lines that do not | This example illustrates how invalid sequences in lines that do not | |||
have to be folded can be handled via forced folding, whereby the | have to be folded can be handled via forced folding, whereby the | |||
folding occurs even though unnecessary. | folding occurs even though unnecessary. | |||
The following line exceeds a 68-char max, thus demands folding | The following line exceeds a 68-char max and, thus, demands folding: | |||
123456789012345678901234567890123456789012345678901234567890123456789 | 123456789012345678901234567890123456789012345678901234567890123456789 | |||
This line ends with a backslash \ | This line ends with a backslash \ | |||
This line ends with a backslash \ | This line ends with a backslash \ | |||
\ This line begins with a backslash | \ This line begins with a backslash | |||
Following is an indented 3x3 block of backslashes: | The following is an indented 3x3 block of backslashes: | |||
\\\ | \\\ | |||
\\\ | \\\ | |||
\\\ | \\\ | |||
The samples below were manually folded, since the script in the | The samples below were manually folded, since the script in the | |||
appendix does not implement forced folding. | appendix does not implement forced folding. | |||
Note that the headers are prefixed by a pound ('#') character, rather | Note that the headers are prefixed by a pound ('#') character, rather | |||
than surrounded by equal ('=') characters as shown in the script- | than surrounded by 'equals' ('=') characters as shown in the script- | |||
generated examples. | generated examples. | |||
9.4.1. Using '\' | 9.4.1. Using '\' | |||
# NOTE: '\' line wrapping per BCP XXX (RFC XXXX) | # NOTE: '\' line wrapping per RFC 8792 | |||
The following line exceeds a 68-char max, thus demands folding | The following line exceeds a 68-char max and, thus, demands folding: | |||
1234567890123456789012345678901234567890123456789012345678901234567\ | 1234567890123456789012345678901234567890123456789012345678901234567\ | |||
89 | 89 | |||
This line ends with a backslash \\ | This line ends with a backslash \\ | |||
This line ends with a backslash \\ | This line ends with a backslash \\ | |||
\ This line begins with a backslash | \ This line begins with a backslash | |||
Following is an indented 3x3 block of backslashes: | The following is an indented 3x3 block of backslashes: | |||
\\\\ | \\\\ | |||
\\\\ | \\\\ | |||
\\\ | \\\ | |||
9.4.2. Using '\\' | 9.4.2. Using '\\' | |||
# NOTE: '\\' line wrapping per BCP XXX (RFC XXXX) | ||||
The following line exceeds a 68-char max, thus demands folding | # NOTE: '\\' line wrapping per RFC 8792 | |||
The following line exceeds a 68-char max and, thus, demands folding: | ||||
1234567890123456789012345678901234567890123456789012345678901234567\ | 1234567890123456789012345678901234567890123456789012345678901234567\ | |||
\89 | \89 | |||
This line ends with a backslash \ | This line ends with a backslash \ | |||
This line ends with a backslash \\ | This line ends with a backslash \\ | |||
\ | \ | |||
\ This line begins with a backslash | \ This line begins with a backslash | |||
Following is an indented 3x3 block of backslashes: | The following is an indented 3x3 block of backslashes: | |||
\\\\ | \\\\ | |||
\ | \ | |||
\\\\ | \\\\ | |||
\ | \ | |||
\\\ | \\\ | |||
10. Security Considerations | 10. Security Considerations | |||
This BCP has no Security Considerations. | This document has no security considerations. | |||
11. IANA Considerations | 11. IANA Considerations | |||
This BCP has no IANA Considerations. | This document has no IANA actions. | |||
12. References | 12. References | |||
12.1. Normative References | 12.1. Normative References | |||
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | |||
Requirement Levels", BCP 14, RFC 2119, | Requirement Levels", BCP 14, RFC 2119, | |||
DOI 10.17487/RFC2119, March 1997, | DOI 10.17487/RFC2119, March 1997, | |||
<https://www.rfc-editor.org/info/rfc2119>. | <https://www.rfc-editor.org/info/rfc2119>. | |||
skipping to change at page 19, line 10 ¶ | skipping to change at line 826 ¶ | |||
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC | [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC | |||
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, | 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, | |||
May 2017, <https://www.rfc-editor.org/info/rfc8174>. | May 2017, <https://www.rfc-editor.org/info/rfc8174>. | |||
12.2. Informative References | 12.2. Informative References | |||
[bash] "GNU Bash Manual", | [bash] "GNU Bash Manual", | |||
<https://www.gnu.org/software/bash/manual>. | <https://www.gnu.org/software/bash/manual>. | |||
[pyang] "An extensible YANG (RFC 6020/7950) validator.", | [pyang] "pyang", <https://pypi.org/project/pyang/>. | |||
<https://pypi.org/project/pyang/>. | ||||
[RFC7749] Reschke, J., "The "xml2rfc" Version 2 Vocabulary", | [RFC7749] Reschke, J., "The "xml2rfc" Version 2 Vocabulary", | |||
RFC 7749, DOI 10.17487/RFC7749, February 2016, | RFC 7749, DOI 10.17487/RFC7749, February 2016, | |||
<https://www.rfc-editor.org/info/rfc7749>. | <https://www.rfc-editor.org/info/rfc7749>. | |||
[RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", | [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", | |||
RFC 7950, DOI 10.17487/RFC7950, August 2016, | RFC 7950, DOI 10.17487/RFC7950, August 2016, | |||
<https://www.rfc-editor.org/info/rfc7950>. | <https://www.rfc-editor.org/info/rfc7950>. | |||
[RFC7994] Flanagan, H., "Requirements for Plain-Text RFCs", | [RFC7994] Flanagan, H., "Requirements for Plain-Text RFCs", | |||
RFC 7994, DOI 10.17487/RFC7994, December 2016, | RFC 7994, DOI 10.17487/RFC7994, December 2016, | |||
<https://www.rfc-editor.org/info/rfc7994>. | <https://www.rfc-editor.org/info/rfc7994>. | |||
[RFC8340] Bjorklund, M. and L. Berger, Ed., "YANG Tree Diagrams", | [RFC8340] Bjorklund, M. and L. Berger, Ed., "YANG Tree Diagrams", | |||
BCP 215, RFC 8340, DOI 10.17487/RFC8340, March 2018, | BCP 215, RFC 8340, DOI 10.17487/RFC8340, March 2018, | |||
<https://www.rfc-editor.org/info/rfc8340>. | <https://www.rfc-editor.org/info/rfc8340>. | |||
[xiax] "The `xiax` Python Package", | [xiax] "The 'xiax' Python Package", | |||
<https://pypi.org/project/xiax/>. | <https://pypi.org/project/xiax/>. | |||
[xml2rfc] "Xml2rfc generates RFCs and IETF drafts from document | [xml2rfc] "xml2rfc", <https://pypi.org/project/xml2rfc/>. | |||
source in XML according to the IETF xml2rfc v2 and v3 | ||||
vocabularies.", <https://pypi.org/project/xml2rfc/>. | ||||
[yang-doctors-thread] | [yang-doctors-thread] | |||
"[yang-doctors] automating yang doctor reviews", | Watsen, K., "[yang-doctors] automating yang doctor | |||
<https://mailarchive.ietf.org/arch/msg/yang-doctors/ | reviews", message to the yang-doctors mailing list, 18 | |||
DCfBqgfZPAD7afzeDFlQ1Xm2X3g>. | April 2018, <https://mailarchive.ietf.org/arch/msg/yang- | |||
doctors/DCfBqgfZPAD7afzeDFlQ1Xm2X3g>. | ||||
[yanglint] | [yanglint] "yanglint", commit 1b7d73d, February 2020, | |||
"A feature-rich tool for validation and conversion of the | ||||
schemas and YANG modeled data.", | ||||
<https://github.com/CESNET/libyang#yanglint>. | <https://github.com/CESNET/libyang#yanglint>. | |||
Appendix A. Bash Shell Script: rfcfold | Appendix A. Bash Shell Script: rfcfold | |||
This non-normative appendix section includes a Bash [bash] shell | This non-normative appendix includes a Bash shell script [bash] that | |||
script that can both fold and unfold text content using both the | can both fold and unfold text content using both the single and | |||
single and double backslash strategies described in Section 7 and | double backslash strategies described in Sections 7 and 8, | |||
Section 8 respectively. | respectively. This shell script, called 'rfcfold', is maintained at | |||
<https://github.com/ietf-tools/rfcfold>. | ||||
This script is intended to be applied to a single text content | This script is intended to be applied to a single text content | |||
instance. If it is desired to fold or unfold text content instances | instance. If it is desired to fold or unfold text content instances | |||
within a larger document (e.g., an Internet draft or RFC), then | within a larger document (e.g., an Internet-Draft or RFC), then | |||
another tool must be used to extract the content from the larger | another tool must be used to extract the content from the larger | |||
document before utilizing this script. | document before utilizing this script. | |||
For readability purposes, this script forces the minimally supported | For readability purposes, this script forces the minimum supported | |||
line length to be eight characters longer than the raw header text | line length to be eight characters longer than the raw header text | |||
defined in Section 7.1.1 and Section 8.1.1 so as to ensure that the | defined in Sections 7.1.1 and 8.1.1 so as to ensure that the header | |||
header can be wrapped by a space (' ') character and three equal | can be wrapped by a space (' ') character and three 'equals' ('=') | |||
('=') characters on each side of the raw header text. | characters on each side of the raw header text. | |||
When a TAB character is detected in the input file, this script exits | When a tab character is detected in the input file, this script exits | |||
with the error message: | with the following error message: | |||
Error: infile contains a TAB character, which is not allowed. | Error: infile contains a tab character, which is not allowed. | |||
This script tests for the availability of GNU awk (gawk), in order to | This script tests for the availability of GNU awk (gawk), in order to | |||
test for ASCII-based control characters and non-ASCII characters in | test for ASCII-based control characters and non-ASCII characters in | |||
the input file (see below). Note that testing revealed flaws in the | the input file (see below). Note that testing revealed flaws in the | |||
default version of `awk` on some platforms. As the use of `gawk` is | default version of 'awk' on some platforms. As this script uses | |||
only used to issue warning messages, if `gawk` of not found, this | 'gawk' only to issue warning messages, if 'gawk' is not found, this | |||
script issues the debug message: | script issues the following debug message: | |||
Debug: no GNU Awk, skipping checks for special characters. | Debug: no GNU awk; skipping checks for special characters. | |||
When `gawk` is available (see above) and ASCII-based control | When 'gawk' is available (see above) and ASCII-based control | |||
characters are detected in the input file, this script issues the | characters are detected in the input file, this script issues the | |||
warning message: | following warning message: | |||
Warning: infile contains ASCII control characters (unsupported). | Warning: infile contains ASCII control characters (unsupported). | |||
When `gawk` is available (see above) and non-ASCII characters are | When 'gawk' is available (see above) and non-ASCII characters are | |||
detected in the input file, this script issues the warning message: | detected in the input file, this script issues the following warning | |||
message: | ||||
Warning: infile contains non-ASCII characters (unsupported). | Warning: infile contains non-ASCII characters (unsupported). | |||
This script does not implement the whitespace-avoidance logic | This script does not implement the whitespace-avoidance logic | |||
described in Section 7.2.1. In such case, the script will exit with | described in Section 7.2.1. In such a case, the script will exit | |||
the following message: | with the following error message: | |||
Error: infile has a space character occurring on the | Error: infile has a space character occurring on the folding | |||
folding column. This file cannot be folded using the | column. This file cannot be folded using the '\' strategy. | |||
'\' strategy. | ||||
While this script can unfold input that contains forced foldings, it | While this script can unfold input that contains forced foldings, it | |||
is unable to fold files that would require forced foldings. Forced | is unable to fold files that would require forced foldings. Forced | |||
folding is described in Section 7.2.1 and Section 8.2.1. When being | folding is described in Sections 7.2.1 and 8.2.1. When being asked | |||
asked to fold a file that would require forced folding, the script | to fold a file that would require forced folding, the script will | |||
will instead exit with the following message: | instead exit with one of the following error messages: | |||
For '\': | For '\': | |||
Error: infile has a line ending with a '\' character. | Error: infile has a line ending with a '\' character. This file | |||
This file cannot be folded using the '\' strategy without | cannot be folded using the '\' strategy without there being false | |||
there being false positives produced in the unfolding | positives produced in the unfolding (i.e., this script does not | |||
(i.e., this script does not force-fold such lines, as | force-fold such lines, as described in RFC 8792). | |||
described in BCP XXX, RFC XXXX). | ||||
For '\\': | For '\\': | |||
Error: infile has a line ending with a '\' character | Error: infile has a line ending with a '\' character followed by a | |||
followed by a '\' character as the first non-space | '\' character as the first non-space character on the next line. | |||
character on the next line. This script cannot fold | This script cannot fold this file using the '\\' strategy without | |||
this file using '\\' strategy without there being | there being false positives produced in the unfolding (i.e., this | |||
false positives produced in the unfolding (i.e., this | script does not force-fold such lines, as described in RFC 8792). | |||
script does not force-fold such lines, as described | ||||
in BCP XXX, RFC XXXX). | ||||
Shell-level end-of-line backslash ('\') characters have been | Shell-level end-of-line backslash ('\') characters have been | |||
purposely added to the script so as to ensure that the script is | purposely added to the script so as to ensure that the script is | |||
itself not folded in this document, thus simplifying the ability to | itself not folded in this document, thus simplifying the ability to | |||
copy/paste the script for local use. As should be evident by the | copy/paste the script for local use. As should be evident by the | |||
lack of the mandatory header described in Section 7.1.1, these | lack of the mandatory header described in Section 7.1.1, these | |||
backslashes do not designate a folded line, such as described in | backslashes do not designate a folded line (e.g., as described in | |||
Section 7. | Section 7). | |||
<CODE BEGINS> | ||||
<CODE BEGINS> file "rfcfold" | ||||
#!/bin/bash --posix | #!/bin/bash --posix | |||
# This script may need some adjustments to work on a given system. | # This script may need some adjustments to work on a given system. | |||
# For instance, the utility `gsed` may need to be installed. | # For instance, the utility 'gsed' may need to be installed. | |||
# Also, please be advised that `bash` (not `sh`) must be used. | # Also, please be advised that 'bash' (not 'sh') must be used. | |||
# Copyright (c) 2019 IETF Trust, Kent Watsen, and Erik Auerswald. | # Copyright (c) 2020 IETF Trust, Kent Watsen, and Erik Auerswald. | |||
# All rights reserved. | # All rights reserved. | |||
# | # | |||
# Redistribution and use in source and binary forms, with or without | # Redistribution and use in source and binary forms, with or without | |||
# modification, are permitted provided that the following conditions | # modification, are permitted provided that the following conditions | |||
# are met: | # are met: | |||
# | # | |||
# * Redistributions of source code must retain the above copyright | # * Redistributions of source code must retain the above copyright | |||
# notice, this list of conditions and the following disclaimer. | # notice, this list of conditions and the following disclaimer. | |||
# | # | |||
# * Redistributions in binary form must reproduce the above | # * Redistributions in binary form must reproduce the above | |||
skipping to change at page 22, line 23 ¶ | skipping to change at line 970 ¶ | |||
# provided with the distribution. | # provided with the distribution. | |||
# | # | |||
# * Neither the name of Internet Society, IETF or IETF Trust, nor | # * Neither the name of Internet Society, IETF or IETF Trust, nor | |||
# the names of specific contributors, may be used to endorse or | # the names of specific contributors, may be used to endorse or | |||
# promote products derived from this software without specific | # promote products derived from this software without specific | |||
# prior written permission. | # prior written permission. | |||
# | # | |||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
print_usage() { | print_usage() { | |||
printf "\n" | printf "\n" | |||
printf "Folds or unfolds the input text file according to BCP XXX" | printf "Folds or unfolds the input text file according to" | |||
printf " (RFC XXXX).\n" | printf " RFC 8792.\n" | |||
printf "\n" | printf "\n" | |||
printf "Usage: rfcfold [-h] [-d] [-q] [-s <strategy>] [-c <col>]" | printf "Usage: rfcfold [-h] [-d] [-q] [-s <strategy>] [-c <col>]" | |||
printf " [-r] -i <infile> -o <outfile>\n" | printf " [-r] -i <infile> -o <outfile>\n" | |||
printf "\n" | printf "\n" | |||
printf " -s: strategy to use, '1' or '2' (default: try 1," | printf " -s: strategy to use, '1' or '2' (default: try 1," | |||
printf " else 2)\n" | printf " else 2)\n" | |||
printf " -c: column to fold on (default: 69)\n" | printf " -c: column to fold on (default: 69)\n" | |||
printf " -r: reverses the operation\n" | printf " -r: reverses the operation\n" | |||
printf " -i: the input filename\n" | printf " -i: the input filename\n" | |||
printf " -o: the output filename\n" | printf " -o: the output filename\n" | |||
skipping to change at page 23, line 16 ¶ | skipping to change at line 1011 ¶ | |||
# global vars, do not edit | # global vars, do not edit | |||
strategy=0 # auto | strategy=0 # auto | |||
debug=0 | debug=0 | |||
quiet=0 | quiet=0 | |||
reversed=0 | reversed=0 | |||
infile="" | infile="" | |||
outfile="" | outfile="" | |||
maxcol=69 # default, may be overridden by param | maxcol=69 # default, may be overridden by param | |||
col_gvn=0 # maxcol overridden? | col_gvn=0 # maxcol overridden? | |||
hdr_txt_1="NOTE: '\\' line wrapping per BCP XXX (RFC XXXX)" | hdr_txt_1="NOTE: '\\' line wrapping per RFC 8792" | |||
hdr_txt_2="NOTE: '\\\\' line wrapping per BCP XXX (RFC XXXX)" | hdr_txt_2="NOTE: '\\\\' line wrapping per RFC 8792" | |||
equal_chars="=======================================================" | equal_chars="=======================================================" | |||
space_chars=" " | space_chars=" " | |||
temp_dir="" | temp_dir="" | |||
prog_name='rfcfold' | prog_name='rfcfold' | |||
# functions for diagnostic messages | # functions for diagnostic messages | |||
prog_msg() { | prog_msg() { | |||
if [[ "$quiet" -eq 0 ]]; then | if [[ "$quiet" -eq 0 ]]; then | |||
format_string="${prog_name}: $1: %s\n" | format_string="${prog_name}: $1: %s\n" | |||
shift | shift | |||
skipping to change at page 24, line 26 ¶ | skipping to change at line 1070 ¶ | |||
return 1 | return 1 | |||
fi | fi | |||
# where to fold | # where to fold | |||
foldcol=$(expr "$maxcol" - 1) # for the inserted '\' char | foldcol=$(expr "$maxcol" - 1) # for the inserted '\' char | |||
# ensure input file doesn't contain whitespace on the fold column | # ensure input file doesn't contain whitespace on the fold column | |||
grep -q "^\(.\{$foldcol\}\)\{1,\} " "$infile" | grep -q "^\(.\{$foldcol\}\)\{1,\} " "$infile" | |||
if [[ $? -eq 0 ]]; then | if [[ $? -eq 0 ]]; then | |||
err "infile '$infile' has a space character occurring on the"\ | err "infile '$infile' has a space character occurring on the"\ | |||
"folding column. This file cannot be folded using the"\ | "folding column. This file cannot be folded using the"\ | |||
"'\\' strategy." | "'\\' strategy." | |||
return 1 | return 1 | |||
fi | fi | |||
# center header text | # center header text | |||
length=$(expr ${#hdr_txt_1} + 2) | length=$(expr ${#hdr_txt_1} + 2) | |||
left_sp=$(expr \( "$maxcol" - "$length" \) / 2) | left_sp=$(expr \( "$maxcol" - "$length" \) / 2) | |||
right_sp=$(expr "$maxcol" - "$length" - "$left_sp") | right_sp=$(expr "$maxcol" - "$length" - "$left_sp") | |||
header=$(printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ | header=$(printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ | |||
"$hdr_txt_1" "$right_sp" "$equal_chars") | "$hdr_txt_1" "$right_sp" "$equal_chars") | |||
skipping to change at page 25, line 4 ¶ | skipping to change at line 1096 ¶ | |||
< "$infile" >> "$outfile" 2> /dev/null | < "$infile" >> "$outfile" 2> /dev/null | |||
if [[ $? -ne 0 ]]; then | if [[ $? -ne 0 ]]; then | |||
return 1 | return 1 | |||
fi | fi | |||
return 0 | return 0 | |||
} | } | |||
fold_it_2() { | fold_it_2() { | |||
# where to fold | # where to fold | |||
foldcol=$(expr "$maxcol" - 1) # for the inserted '\' char | foldcol=$(expr "$maxcol" - 1) # for the inserted '\' char | |||
# ensure input file doesn't contain the fold-sequence already | # ensure input file doesn't contain the fold-sequence already | |||
if [[ -n "$("$SED" -n '/\\$/{N;s/\\\n[ ]*\\/&/p;D}' "$infile")" ]] | if [[ -n "$("$SED" -n '/\\$/{N;s/\\\n[ ]*\\/&/p;D}' "$infile")" ]] | |||
then | then | |||
err "infile '$infile' has a line ending with a '\\' character"\ | err "infile '$infile' has a line ending with a '\\' character"\ | |||
"followed by a '\\' character as the first non-space"\ | "followed by a '\\' character as the first non-space"\ | |||
"character on the next line. This script cannot fold"\ | "character on the next line. This script cannot fold"\ | |||
"this file using '\\\\' strategy without there being"\ | "this file using the '\\\\' strategy without there being"\ | |||
"false positives produced in the unfolding." | "false positives produced in the unfolding." | |||
return 1 | return 1 | |||
fi | fi | |||
# center header text | # center header text | |||
length=$(expr ${#hdr_txt_2} + 2) | length=$(expr ${#hdr_txt_2} + 2) | |||
left_sp=$(expr \( "$maxcol" - "$length" \) / 2) | left_sp=$(expr \( "$maxcol" - "$length" \) / 2) | |||
right_sp=$(expr "$maxcol" - "$length" - "$left_sp") | right_sp=$(expr "$maxcol" - "$length" - "$left_sp") | |||
header=$(printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ | header=$(printf "%.*s %s %.*s" "$left_sp" "$equal_chars"\ | |||
"$hdr_txt_2" "$right_sp" "$equal_chars") | "$hdr_txt_2" "$right_sp" "$equal_chars") | |||
skipping to change at page 25, line 34 ¶ | skipping to change at line 1127 ¶ | |||
echo "" >> "$outfile" | echo "" >> "$outfile" | |||
"$SED" 's/\(.\{'"$foldcol"'\}\)\(..\)/\1\\\n\\\2/;t M;b;:M;P;D;'\ | "$SED" 's/\(.\{'"$foldcol"'\}\)\(..\)/\1\\\n\\\2/;t M;b;:M;P;D;'\ | |||
< "$infile" >> "$outfile" 2> /dev/null | < "$infile" >> "$outfile" 2> /dev/null | |||
if [[ $? -ne 0 ]]; then | if [[ $? -ne 0 ]]; then | |||
return 1 | return 1 | |||
fi | fi | |||
return 0 | return 0 | |||
} | } | |||
fold_it() { | fold_it() { | |||
# ensure input file doesn't contain a TAB | # ensure input file doesn't contain a tab | |||
grep -q $'\t' "$infile" | grep -q $'\t' "$infile" | |||
if [[ $? -eq 0 ]]; then | if [[ $? -eq 0 ]]; then | |||
err "infile '$infile' contains a TAB character, which is not"\ | err "infile '$infile' contains a tab character, which is not"\ | |||
"allowed." | "allowed." | |||
return 1 | return 1 | |||
fi | fi | |||
# folding of input containing ASCII control or non-ASCII characters | # folding of input containing ASCII control or non-ASCII characters | |||
# may result in a wrong folding column and is not supported | # may result in a wrong folding column and is not supported | |||
if type gawk > /dev/null 2>&1; then | if type gawk > /dev/null 2>&1; then | |||
env LC_ALL=C gawk '/[\000-\014\016-\037\177]/{exit 1}' "$infile"\ | env LC_ALL=C gawk '/[\000-\014\016-\037\177]/{exit 1}' "$infile"\ | |||
|| warn "infile '$infile' contains ASCII control characters"\ | || warn "infile '$infile' contains ASCII control characters"\ | |||
"(unsupported)." | "(unsupported)." | |||
env LC_ALL=C gawk '/[^\000-\177]/{exit 1}' "$infile"\ | env LC_ALL=C gawk '/[^\000-\177]/{exit 1}' "$infile"\ | |||
|| warn "infile '$infile' contains non-ASCII characters"\ | || warn "infile '$infile' contains non-ASCII characters"\ | |||
"(unsupported)." | "(unsupported)." | |||
else | else | |||
dbg "no GNU Awk, skipping checks for special characters." | dbg "no GNU awk; skipping checks for special characters." | |||
fi | fi | |||
# check if file needs folding | # check if file needs folding | |||
testcol=$(expr "$maxcol" + 1) | testcol=$(expr "$maxcol" + 1) | |||
grep -q ".\{$testcol\}" "$infile" | grep -q ".\{$testcol\}" "$infile" | |||
if [[ $? -ne 0 ]]; then | if [[ $? -ne 0 ]]; then | |||
dbg "nothing to do; copying infile to outfile." | dbg "nothing to do; copying infile to outfile." | |||
cp "$infile" "$outfile" | cp "$infile" "$outfile" | |||
return 255 | return 255 | |||
fi | fi | |||
skipping to change at page 26, line 30 ¶ | skipping to change at line 1171 ¶ | |||
if [[ "$strategy" -eq 2 ]]; then | if [[ "$strategy" -eq 2 ]]; then | |||
fold_it_2 | fold_it_2 | |||
return $? | return $? | |||
fi | fi | |||
quiet_sav="$quiet" | quiet_sav="$quiet" | |||
quiet=1 | quiet=1 | |||
fold_it_1 | fold_it_1 | |||
result=$? | result=$? | |||
quiet="$quiet_sav" | quiet="$quiet_sav" | |||
if [[ "$result" -ne 0 ]]; then | if [[ "$result" -ne 0 ]]; then | |||
dbg "Folding strategy '1' didn't succeed, trying strategy '2'..." | dbg "Folding strategy '1' didn't succeed; trying strategy '2'..." | |||
fold_it_2 | fold_it_2 | |||
return $? | return $? | |||
fi | fi | |||
return 0 | return 0 | |||
} | } | |||
unfold_it_1() { | unfold_it_1() { | |||
temp_dir=$(mktemp -d) | temp_dir=$(mktemp -d) | |||
# output all but the first two lines (the header) to wip file | # output all but the first two lines (the header) to wip file | |||
skipping to change at page 30, line 13 ¶ | skipping to change at line 1343 ¶ | |||
<CODE ENDS> | <CODE ENDS> | |||
Acknowledgements | Acknowledgements | |||
The authors thank the RFC Editor for confirming that there was | The authors thank the RFC Editor for confirming that there was | |||
previously no set convention, at the time of this document's | previously no set convention, at the time of this document's | |||
publication, for handling long lines in source code inclusions, thus | publication, for handling long lines in source code inclusions, thus | |||
instigating this work. | instigating this work. | |||
The authors thank the following folks for their various contributions | The authors thank the following folks for their various contributions | |||
while producing this document (sorted by first name): Benoit Claise, | while producing this document (sorted by first name): Ben Kaduk, | |||
Ben Kaduk, Gianmarco Bruno, Italo Busi, Joel Jaeggli, Jonathan | Benoit Claise, Gianmarco Bruno, Italo Busi, Joel Jaeggli, Jonathan | |||
Hansford, Lou Berger, Martin Bjorklund, and Rob Wilton. | Hansford, Lou Berger, Martin Bjorklund, and Rob Wilton. | |||
Authors' Addresses | Authors' Addresses | |||
Kent Watsen | Kent Watsen | |||
Watsen Networks | Watsen Networks | |||
EMail: kent+ietf@watsen.net | Email: kent+ietf@watsen.net | |||
Erik Auerswald | Erik Auerswald | |||
Individual Contributor | Individual Contributor | |||
EMail: auerswal@unix-ag.uni-kl.de | Email: auerswal@unix-ag.uni-kl.de | |||
Adrian Farrel | Adrian Farrel | |||
Old Dog Consulting | Old Dog Consulting | |||
EMail: adrian@olddog.co.uk | Email: adrian@olddog.co.uk | |||
Qin Wu | Qin Wu | |||
Huawei Technologies | Huawei Technologies | |||
EMail: bill.wu@huawei.com | Email: bill.wu@huawei.com | |||
End of changes. 131 change blocks. | ||||
348 lines changed or deleted | 334 lines changed or added | |||
This html diff was produced by rfcdiff 1.47. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |