Skip to content

Commit 3220042

Browse files
authored
Create md-literal-lines.test.sh
1 parent 3cad751 commit 3220042

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/bin/bash
2+
3+
tests:put input <<EOF
4+
# @file Literal MD tests
5+
# @brief Test for files
6+
# @description
7+
# | 3 leading blanks before | should be trimmed because line start is not '#|'
8+
#
9+
#|This line is taken literally, including the 5 spaces at the end
10+
#| This has 5 leading spaces
11+
12+
# @section Test literal md for section description
13+
# @description
14+
#
15+
# Combined with code fence
16+
# ~~~json
17+
#|{
18+
#| "key": "value"
19+
#|}
20+
# ~~~
21+
# @endsection
22+
23+
# @description Check literal in function descriptions.
24+
# Use table syntax.
25+
#
26+
# **Note:**
27+
# The literal marker '#|' has rudimentary detection for tables.
28+
# 1. Any space before the first standalone '|' is trimmed when not in literal mode (using `#|`)
29+
# 2. When a line starts with #| and ends with `|[ ]*$`,
30+
# the pipe from the literal marker `#|` will not be stripped.
31+
#
32+
# Table with slight indention
33+
#| | literal | table |
34+
#| | :---: | :---: |
35+
#| | keep? | yes |
36+
#
37+
# Indented, but not in literal mode
38+
# | literal | table |
39+
# | :---: | :---: |
40+
# | keep? | yes |
41+
#
42+
# Directly at line start
43+
#|| literal | table |
44+
#|| :---: | :---: |
45+
#|| keep? | yes |
46+
#
47+
# Without duplicate left pipes
48+
#| literal | table |
49+
#| :---: | :---: |
50+
#| keep? | yes |
51+
function literal-table {
52+
echo abc
53+
}
54+
EOF
55+
56+
tests:put expected <<EOF
57+
# Literal MD tests
58+
59+
Test for files
60+
61+
## Overview
62+
63+
| 3 leading blanks before | should be trimmed because line start is not '#|'
64+
65+
This line is taken literally, including the 5 spaces at the end
66+
This has 5 leading spaces
67+
68+
## Index
69+
70+
* [Test literal md for section description](#test-literal-md-for-section-description)
71+
* [literal-table](#literal-table)
72+
73+
## Test literal md for section description
74+
75+
Combined with code fence
76+
~~~json
77+
{
78+
"key": "value"
79+
}
80+
~~~
81+
82+
## literal-table
83+
84+
Check literal in function descriptions.
85+
Use table syntax.
86+
87+
**Note:**
88+
The literal marker '#|' has rudimentary detection for tables.
89+
1. Any space before the first standalone '|' is trimmed when not in literal mode (using `#|`)
90+
2. When a line starts with #| and ends with `|[ ]*$`,
91+
the pipe from the literal marker `#|` will not be stripped.
92+
93+
Table with slight indention
94+
| | literal | table |
95+
| | :---: | :---: |
96+
| | keep? | yes |
97+
98+
Indented, but not in literal mode
99+
| literal | table |
100+
| :---: | :---: |
101+
| keep? | yes |
102+
103+
Directly at line start
104+
|| literal | table |
105+
|| :---: | :---: |
106+
|| keep? | yes |
107+
108+
Without duplicate left pipes
109+
| literal | table |
110+
| :---: | :---: |
111+
| keep? | yes |
112+
113+
EOF
114+
115+
assert

0 commit comments

Comments
 (0)