File: escape.t

package info (click to toggle)
libpod-markdown-perl 3.101000-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 444 kB
  • sloc: perl: 1,000; makefile: 2
file content (210 lines) | stat: -rw-r--r-- 3,661 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# vim: set ts=2 sts=2 sw=2 expandtab smarttab:
use utf8;
use strict;
use warnings;
use lib 't/lib';
use MarkdownTests;

convert_ok
  q{=head2 _Other_ *Characters* [Should](Be) `Escaped` in headers},
  q{## \_Other\_ \*Characters\* \[Should\](Be) \`Escaped\` in headers},
  'literal markdown chars escaped in headers';

convert_ok
  q{Inline C<< code _need not_ be escaped >>.},
  q{Inline `code _need not_ be escaped`.},
  'literal markdown chars allowed verbatim in code spans';

convert_ok
  q{=head3 Heading C<< code _need not_ be escaped, either >>.},
  q{### Heading `code _need not_ be escaped, either`.},
  'literal markdown chars allowed verbatim in code spans (in headings)';

convert_ok
  q{B<< Nested C<c*des> _should_ be escaped >> (but not code).},
  q{**Nested `c*des` \_should\_ be escaped** (but not code).},
  'literal markdown chars escaped in nested sequences';

convert_ok
  q{Inline F<< filename_should_not >> be escaped},
  q{Inline `filename_should_not` be escaped},
  'filenames (F<>) are code spans so no escaping needed';

convert_ok
  q{L<<< *chars* in_ `text|inside/"a link" >>>},
  q{[\*chars\* in\_ \`text](pod://inside#a&#x20;link)},
  'escape markdown characters in link text';

# Use heredoc to simplify the backslashes.
convert_ok
  <<'POD',
Inline L<< link *should* \_ be_escaped|/or\things(can)go\*wrong >>.
POD
  <<'MKDN',
Inline [link \*should\* \\\_ be\_escaped](#or\\things\(can\)go\\*wrong).
MKDN
  'link targets also escaped';

convert_ok
  <<'POD',
=head1 SYNOPSIS

    $ pod2markdown < POD_File > Markdown_File
POD
  <<'MKDN',
# SYNOPSIS

    $ pod2markdown < POD_File > Markdown_File
MKDN
  'verbatim paragraph indents and requires no escaping';

convert_ok
  <<'POD',
=head1 *Special* characters

html: < & <tag/> &entity;

    foo_bar is the result of 4 * 4

Regular characters like *asterisks* and __underscores__
should be escaped in regular text paragraphs.
Also [brackets],
lists:

+ a
+ b

- a
- b

* A line that starts with an asterisk
*should* be escaped to avoid incorrectly interpreting
the line as a list item.

# fake headings

### fake headings ###

Setext fake
===========

Another fake
------------

> Quote
> blocks
> 1. with
> 2. lists

1996. A year.

* Bird

* Magic

* List item

        `code` block

Hr's:

---

* * *

Inline `code`;
Links: [Foo] [1], [Bar](/baz)
An image: ![image](/foo)
backslash \

From http://daringfireball.net/projects/markdown/syntax:

\   backslash
`   backtick
*   asterisk
_   underscore
{}  curly braces
[]  square brackets
()  parentheses
#   hash mark
+   plus sign
-   minus sign (hyphen)
.   dot
!   exclamation mark
POD
  <<'MKDN',
# \*Special\* characters

html: < & &lt;tag/> &amp;entity;

    foo_bar is the result of 4 * 4

Regular characters like \*asterisks\* and \_\_underscores\_\_
should be escaped in regular text paragraphs.
Also \[brackets\],
lists:

\+ a
\+ b

\- a
\- b

\* A line that starts with an asterisk
\*should\* be escaped to avoid incorrectly interpreting
the line as a list item.

\# fake headings

\### fake headings ###

Setext fake
&#x3d;==========

Another fake
\------------

\> Quote
\> blocks
\> 1. with
\> 2. lists

1996\. A year.

\* Bird

\* Magic

\* List item

        `code` block

Hr's:

\---

\* \* \*

Inline \`code\`;
Links: \[Foo\] \[1\], \[Bar\](/baz)
An image: !\[image\](/foo)
backslash \\

From http://daringfireball.net/projects/markdown/syntax:

\\   backslash
\`   backtick
\*   asterisk
\_   underscore
{}  curly braces
\[\]  square brackets
()  parentheses
\#   hash mark
\+   plus sign
\-   minus sign (hyphen)
.   dot
!   exclamation mark
MKDN
  'literal markdown characters in pod escaped';

done_testing;