Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Commit d67d86a

Browse files
committed
Add RFC7511
Add <br/> detection for XML output.
1 parent cf654ee commit d67d86a

File tree

6 files changed

+753
-11
lines changed

6 files changed

+753
-11
lines changed

block.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,7 @@ func (p *parser) fencedCode(out *bytes.Buffer, data []byte, doRender bool) int {
12401240
beg = end
12411241
}
12421242
var caption bytes.Buffer
1243-
line := beg
1244-
j := beg
1243+
line, j := beg, beg
12451244
if bytes.HasPrefix(bytes.TrimSpace(data[j:]), []byte("Figure: ")) {
12461245
for line < len(data) {
12471246
j++
@@ -1254,8 +1253,8 @@ func (p *parser) fencedCode(out *bytes.Buffer, data []byte, doRender bool) int {
12541253
}
12551254
line = j
12561255
}
1257-
if beg+8 < j-1 {
1258-
p.inline(&caption, data[beg+8:j-1])
1256+
if beg+8+indent < j-1 {
1257+
p.inline(&caption, data[beg+indent+8:j-1])
12591258
}
12601259
}
12611260

@@ -1780,11 +1779,17 @@ func (p *parser) code(out *bytes.Buffer, data []byte) int {
17801779
work.Write(data[beg:i])
17811780
}
17821781
}
1783-
caption := ""
1784-
line := i
1785-
j := i
1782+
var caption []byte
1783+
line, j := i, i
1784+
17861785
// In the case of F> there may be spaces in front of it
17871786
if bytes.HasPrefix(bytes.TrimSpace(data[j:]), []byte("Figure: ")) {
1787+
indent := j
1788+
for data[indent] == ' ' && indent < len(data) {
1789+
indent++
1790+
}
1791+
indent = indent - j
1792+
17881793
for line < len(data) {
17891794
j++
17901795
// find the end of this line
@@ -1797,8 +1802,8 @@ func (p *parser) code(out *bytes.Buffer, data []byte) int {
17971802
line = j
17981803
}
17991804
// save for later processing.
1800-
if i+8 < j-1 {
1801-
caption = string(data[i+8 : j-1]) // +8 for 'Figure: '
1805+
if i+8+indent < j-1 {
1806+
caption = data[i+8+indent : j-1] // +8 for 'Figure: '
18021807
}
18031808
}
18041809

@@ -1827,11 +1832,11 @@ func (p *parser) code(out *bytes.Buffer, data []byte) int {
18271832
if co != "" {
18281833
var callout bytes.Buffer
18291834
callouts(p, &callout, work.Bytes(), 0, co)
1830-
p.inline(&capb, []byte(caption))
1835+
p.inline(&capb, caption)
18311836
p.r.BlockCode(out, callout.Bytes(), "", capb.Bytes(), p.insideFigure, true)
18321837
} else {
18331838
p.callouts = nil
1834-
p.inline(&capb, []byte(caption))
1839+
p.inline(&capb, caption)
18351840
p.r.BlockCode(out, work.Bytes(), "", capb.Bytes(), p.insideFigure, false)
18361841
}
18371842

issue_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,19 @@ As (@good) says
5757
}
5858
doTestsBlockXML(t, tests, commonXmlExtensions)
5959
}
60+
61+
func TestIssue82(t *testing.T) {
62+
tests := []string{
63+
`Option Type
64+
65+
: 8-bit identifier of the type of option.
66+
67+
~~~~~
68+
HEX act chg rest
69+
~~~~~
70+
Figure: Scenic Routing Option Type`,
71+
"<dl>\n<dt>Option Type</dt>\n<dd><t>\n8-bit identifier of the type of option.\n</t></dd>\n</dl>\n<figure>\n<name>Scenic Routing Option Type</name>\n<artwork>\nHEX act chg rest\n</artwork>\n</figure>\n",
72+
}
73+
74+
doTestsBlockXML(t, tests, commonXmlExtensions)
75+
}

rfc/rfc7511.md

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
% Title = "Scenic Routing for IPv6"
2+
% abbrev = "Scenic Routing for IPv6"
3+
% category = "info"
4+
% docName = "rfc-7511"
5+
% ipr= "trust200902"
6+
% area = "Internet"
7+
% workgroup = "Network Working Group"
8+
%
9+
% date = 2015-04-01T00:00:00Z
10+
%
11+
% [[author]]
12+
% initials="M."
13+
% surname="Wilhelm"
14+
% fullname="Maximilian Wilhelm"
15+
% [author.address]
16+
% email = "[email protected]"
17+
% phone = "+49 176 62 05 94 27"
18+
% [author.address.postal]
19+
% city = "Paderborn, NRW"
20+
% country = "Germany"
21+
22+
.# Abstract
23+
24+
This document specifies a new routing scheme for the current version
25+
of the Internet Protocol version 6 (IPv6) in the spirit of "Green
26+
IT", whereby packets will be routed to get as much fresh-air time as
27+
possible.
28+
29+
{mainmatter}
30+
31+
# Introduction
32+
33+
In times of Green IT, a lot of effort is put into reducing the energy
34+
consumption of routers, switches, servers, hosts, etc., to preserve
35+
our environment. This document looks at Green IT from a different
36+
angle and focuses on network packets being routed and switched around
37+
the world.
38+
39+
Most likely, no one ever thought about the millions of packets being
40+
disassembled into bits every second and forced through copper wires
41+
or being shot through dark fiber lines by powerful lasers at
42+
continuously increasing speeds. Although RFC 5841 [@!RFC5841] provided
43+
some thoughts about Packet Moods and began to represent them as a TCP
44+
option, this doesn't help the packets escape their torturous routine.
45+
46+
This document defines another way to deal with Green IT for traffic
47+
and network engineers and will hopefully aid the wellbeing of a
48+
myriad of network packets around the world. It proposes Scenic
49+
Routing, which incorporates the green-ness of a network path into the
50+
routing decision. A routing engine implementing Scenic Routing
51+
should therefore choose paths based on Avian IP Carriers [@?RFC1149]
52+
and/or wireless technologies so the packets will get out of the
53+
miles/kilometers of dark fibers that are in the ground and get as
54+
much fresh-air time and sunlight as possible.
55+
56+
As of the widely known acceptance of the current version of the
57+
Internet Protocol (IPv6), this document only focuses on version 6 and
58+
ignores communication still based on Vintage IP [@?RFC0791].
59+
60+
## Conventions and Terminology
61+
62+
The key words "**MUST**", "**MUST NOT**", "**REQUIRED**", "**SHALL**", "**SHALL NOT**",
63+
"**SHOULD**", "**SHOULD NOT**", "**RECOMMENDED**", "**MAY**", and "**OPTIONAL**" in this
64+
document are to be interpreted as described in RFC 2119 [@!RFC2119].
65+
66+
Additionally, the key words "**MIGHT**", "**COULD**", "**MAY WISH TO**", "**WOULD
67+
PROBABLY**", "**SHOULD CONSIDER**", and "**MUST (BUT WE KNOW YOU WON'T)**" in
68+
this document are to interpreted as described in RFC 6919 [@!RFC6919].
69+
70+
# Scenic Routing
71+
72+
Scenic Routing can be enabled with a new option for IPv6 datagrams.
73+
74+
## Scenic Routing Option (SRO)
75+
76+
The Scenic Routing Option (SRO) is placed in the IPv6 Hop-by-Hop
77+
Options Header that must be examined by every node along a packet's
78+
delivery path [@!RFC2460].
79+
80+
The SRO can be included in any IPv6 datagram, but multiple SROs **MUST
81+
NOT** be present in the same IPv6 datagram. The SRO has no alignment
82+
requirement.
83+
84+
If the SRO is set for a packet, every node en route from the packet
85+
source to the packet's final destination **MUST** preserve the option.
86+
87+
The following Hop-by-Hop Option is proposed according to the
88+
specification in Section 4.2 of RFC 2460 [@!RFC2460].
89+
90+
{#fig-scenic-routing-option-layout}
91+
~~~
92+
0 1 2 3
93+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
94+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95+
| Option Type | Option Length |
96+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97+
| SRO Param | |
98+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
99+
~~~
100+
Figure: Scenic Routing Option Layout
101+
102+
Option Type
103+
: <br/>8-bit identifier of the type of option. The option identifier
104+
0x0A (On Air) is proposed for Scenic Routing.
105+
106+
{#fig-option-type}
107+
~~~~~
108+
HEX act chg rest
109+
--- --- --- -----
110+
0A 00 0 01010 Scenic Routing
111+
~~~~~
112+
Figure: Scenic Routing Option Type
113+
114+
The highest-order two bits are set to 00 so any node not
115+
implementing Scenic Routing will skip over this option and
116+
continue processing the header. The third-highest-order bit
117+
indicates that the SRO does not change en route to the packet's
118+
final destination.
119+
120+
Option Length
121+
: <br/>8-bit unsigned integer. The length of the option in octets
122+
(excluding the Option Type and Option Length fields). The value
123+
**MUST** be greater than 0.
124+
125+
SRO Param
126+
: <br/>8-bit identifier indicating Scenic Routing parameters encoded as a bit string.
127+
128+
{#fig-bit-string-layout}
129+
~~~~~
130+
+-+-+-+-+-+-+-+-+
131+
| SR A W AA X Y |
132+
+-+-+-+-+-+-+-+-+
133+
~~~~~
134+
Figure: SRO Param Bit String Layout
135+
136+
The highest-order two bits (SR) define the urgency of Scenic
137+
Routing:
138+
139+
{style="empty"}
140+
- 00 - Scenic Routing **MUST NOT** be used for this packet.
141+
- 01 - Scenic Routing **MIGHT** be used for this packet.
142+
- 10 - Scenic Routing **SHOULD** be used for this packet.
143+
- 11 - Scenic Routing **MUST** be used for this packet.
144+
145+
The following BIT (A) defines if Avian IP Carriers should be used:
146+
147+
{style="empty"}
148+
- 0 - Don't use Avian IP Carrier links (maybe the packet is
149+
afraid of pigeons).
150+
- 1 - Avian IP Carrier links may be used.
151+
152+
The following BIT (W) defines if wireless links should be used:
153+
154+
{style="empty"}
155+
- 0 - Don't use wireless links (maybe the packet is afraid of
156+
radiation).
157+
- 1 - Wireless links may be used.
158+
159+
The following two bits (AA) define the affinity for link types:
160+
161+
{style="empty"}
162+
- 00 - No affinity.
163+
- 01 - Avian IP Carriers **SHOULD** be preferred.
164+
- 10 - Wireless links **SHOULD** be preferred.
165+
- 11 - RESERVED
166+
167+
The lowest-order two bits (XY) are currently unused and reserved
168+
for future use.
169+
170+
# Implications
171+
172+
## Routing Implications
173+
174+
If Scenic Routing is requested for a packet, the path with the known
175+
longest Avian IP Carrier and/or wireless portion **MUST** be used.
176+
177+
Backbone operators who desire to be fully compliant with Scenic
178+
Routing **MAY WISH TO** -- well, they **SHOULD** -- have separate MPLS paths
179+
ready that provide the most fresh-air time for a given path and are
180+
to be used when Scenic Routing is requested by a packet. If such a
181+
path exists, the path MUST be used in favor of any other path, even
182+
if another path is considered cheaper according to the path costs
183+
used regularly, without taking Scenic Routing into account.
184+
185+
## Implications for Hosts
186+
187+
Host systems implementing this option of receiving packets with
188+
Scenic Routing requested **MUST** honor this request and **MUST** activate
189+
Scenic Routing for any packets sent back to the originating host for
190+
the current connection.
191+
192+
If Scenic Routing is requested for connections of local origin, the
193+
host MUST obey the request and route the packet(s) over a wireless
194+
link or use Avian IP Carriers (if available and as requested within
195+
the SRO Params).
196+
197+
System administrators **MIGHT** want to configure sensible default
198+
parameters for Scenic Routing, when Scenic Routing has been widely
199+
adopted by operating systems. System administrators **SHOULD** deploy
200+
Scenic Routing information where applicable.
201+
202+
## Proxy Servers
203+
204+
If a host is running a proxy server or any other packet-relaying
205+
application, an application implementing Scenic Routing **MUST** set the
206+
same SRO Params on the outgoing packet as seen on the incoming
207+
packet.
208+
209+
Developers **SHOULD CONSIDER** Scenic Routing when designing and
210+
implementing any network service.
211+
212+
# Security Considerations
213+
214+
The security considerations of RFC 6214 [@!RFC6214] apply for links
215+
provided by Avian IP Carriers.
216+
217+
General security considerations of wireless communication apply for
218+
links using wireless technologies.
219+
220+
As the user is able to influence where flows and packets are being
221+
routed within the network, this **MIGHT** influence traffic-engineering
222+
considerations and network operators **MAY WISH TO** take this into
223+
account before enabling Scenic Routing on their devices.
224+
225+
# IANA Considerations
226+
227+
This document defines a new IPv6 Hop-by-Hop Option, the Scenic
228+
Routing Option, described in Section 2.1. If this work is
229+
standardized, IANA is requested to assign a value from the
230+
"Destination Options and Hop-by-Hop Options" registry for the purpose
231+
of Scenic Routing.
232+
233+
There are no IANA actions requested at this time.
234+
235+
# Related Work
236+
237+
As Scenic Routing is heavily dependent on network paths and routing
238+
information, it might be worth looking at designing extensions for
239+
popular routing protocols like BGP or OSPF to leverage the full
240+
potential of Scenic Routing in large networks built upon lots of
241+
wireless links and/or Avian IP Carriers. When incorporating
242+
information about links compatible with Scenic Routing, the routing
243+
algorithms could easily calculate the optimal paths providing the
244+
most fresh-air time for a packet for any given destination.
245+
246+
This would even allow preference for wireless paths going alongside
247+
popular or culturally important places. This way, the packets don't
248+
only avoid the dark fibers, but they get to see the world outside of
249+
the Internet and are exposed to different cultures around the globe,
250+
which may help build an understanding of cultural differences and
251+
promote acceptance of these differences.
252+
253+
{backmatter}
254+
255+
# Acknowledgements
256+
257+
The author wishes to thank all those poor friends who were kindly
258+
forced to read this document and that provided some nifty comments.

0 commit comments

Comments
 (0)