Warning, /education/cantor/thirdparty/discount-2.2.6-patched/tests/tables.t is written in an unsupported language. File is not indexed.

0001 . tests/functions.sh
0002 
0003 title "tables"
0004 
0005 rc=0
0006 MARKDOWN_FLAGS=
0007 
0008 try 'single-column table' \
0009     '|hello
0010 |-----
0011 |sailor' \
0012     '<table>
0013 <thead>
0014 <tr>
0015 <th>hello</th>
0016 </tr>
0017 </thead>
0018 <tbody>
0019 <tr>
0020 <td>sailor</td>
0021 </tr>
0022 </tbody>
0023 </table>'
0024 
0025 
0026 try 'two-column table' \
0027     '
0028   a  |  b
0029 -----|------
0030 hello|sailor' \
0031     '<table>
0032 <thead>
0033 <tr>
0034 <th>a  </th>
0035 <th>  b</th>
0036 </tr>
0037 </thead>
0038 <tbody>
0039 <tr>
0040 <td>hello</td>
0041 <td>sailor</td>
0042 </tr>
0043 </tbody>
0044 </table>'
0045 
0046 try 'three-column table' \
0047 'a|b|c
0048 -|-|-
0049 hello||sailor'\
0050     '<table>
0051 <thead>
0052 <tr>
0053 <th>a</th>
0054 <th>b</th>
0055 <th>c</th>
0056 </tr>
0057 </thead>
0058 <tbody>
0059 <tr>
0060 <td>hello</td>
0061 <td></td>
0062 <td>sailor</td>
0063 </tr>
0064 </tbody>
0065 </table>'
0066 
0067 try 'two-column table with empty cells' \
0068     '
0069   a  |  b
0070 -----|------
0071 hello|
0072      |sailor' \
0073     '<table>
0074 <thead>
0075 <tr>
0076 <th>a  </th>
0077 <th>  b</th>
0078 </tr>
0079 </thead>
0080 <tbody>
0081 <tr>
0082 <td>hello</td>
0083 <td></td>
0084 </tr>
0085 <tr>
0086 <td></td>
0087 <td>sailor</td>
0088 </tr>
0089 </tbody>
0090 </table>'
0091 
0092 try 'two-column table with alignment' \
0093     '
0094   a  |  b
0095 ----:|:-----
0096 hello|sailor' \
0097     '<table>
0098 <thead>
0099 <tr>
0100 <th style="text-align:right;">a  </th>
0101 <th style="text-align:left;">  b</th>
0102 </tr>
0103 </thead>
0104 <tbody>
0105 <tr>
0106 <td style="text-align:right;">hello</td>
0107 <td style="text-align:left;">sailor</td>
0108 </tr>
0109 </tbody>
0110 </table>'
0111     
0112 try 'table with extra data column' \
0113     '
0114   a  |  b
0115 -----|------
0116 hello|sailor|boy' \
0117     '<table>
0118 <thead>
0119 <tr>
0120 <th>a  </th>
0121 <th>  b</th>
0122 </tr>
0123 </thead>
0124 <tbody>
0125 <tr>
0126 <td>hello</td>
0127 <td>sailor|boy</td>
0128 </tr>
0129 </tbody>
0130 </table>'
0131 
0132 
0133 try -fnotables 'tables with -fnotables' \
0134     'a|b
0135 -|-
0136 hello|sailor' \
0137     '<p>a|b
0138 -|-
0139 hello|sailor</p>'
0140 
0141 try 'deceptive non-table text' \
0142     'a | b | c
0143 
0144 text' \
0145     '<p>a | b | c</p>
0146 
0147 <p>text</p>'
0148 
0149 try 'table headers only' \
0150     'a|b|c
0151 -|-|-' \
0152     '<p>a|b|c
0153 -|-|-</p>'
0154 
0155 try 'escaped title line' \
0156     'A\|B
0157 --|-
0158 C |D' \
0159     '<table>
0160 <thead>
0161 <tr>
0162 <th>A|B</th>
0163 </tr>
0164 </thead>
0165 <tbody>
0166 <tr>
0167 <td>C |D</td>
0168 </tr>
0169 </tbody>
0170 </table>'
0171 
0172 
0173 try 'escaped dashes line' \
0174     'A |B
0175 -\|-
0176 C |D' \
0177     '<p>A |B
0178 -|-
0179 C |D</p>'
0180 
0181 try 'escaped content line' \
0182     'A |B
0183 --|-
0184 C\|D' \
0185     '<table>
0186 <thead>
0187 <tr>
0188 <th>A </th>
0189 <th>B</th>
0190 </tr>
0191 </thead>
0192 <tbody>
0193 <tr>
0194 <td>C|D</td>
0195 <td></td>
0196 </tr>
0197 </tbody>
0198 </table>'
0199 
0200 try 'content line w/o dashes' \
0201     'A |B
0202 --|-
0203 CD' \
0204     '<p>A |B
0205 &ndash;|-
0206 CD</p>'
0207 
0208 try 'table followed by text' \
0209     '
0210 A|B
0211 -|-
0212 C|D
0213 
0214 foo?' \
0215 '<table>
0216 <thead>
0217 <tr>
0218 <th>A</th>
0219 <th>B</th>
0220 </tr>
0221 </thead>
0222 <tbody>
0223 <tr>
0224 <td>C</td>
0225 <td>D</td>
0226 </tr>
0227 </tbody>
0228 </table>
0229 
0230 
0231 <p>foo?</p>'
0232 
0233 try "table with flanking |'s" \
0234 '
0235 |A|B|
0236 |-|-|
0237 |D|C|' \
0238 '<table>
0239 <thead>
0240 <tr>
0241 <th>A</th>
0242 <th>B</th>
0243 </tr>
0244 </thead>
0245 <tbody>
0246 <tr>
0247 <td>D</td>
0248 <td>C</td>
0249 </tr>
0250 </tbody>
0251 </table>'
0252 
0253 try "table with leading |'s and alignment" \
0254 '|AA|BB|CC
0255 |:-|::|-:
0256 |aa|bb|cc' \
0257 '<table>
0258 <thead>
0259 <tr>
0260 <th style="text-align:left;">AA</th>
0261 <th style="text-align:center;">BB</th>
0262 <th style="text-align:right;">CC</th>
0263 </tr>
0264 </thead>
0265 <tbody>
0266 <tr>
0267 <td style="text-align:left;">aa</td>
0268 <td style="text-align:center;">bb</td>
0269 <td style="text-align:right;">cc</td>
0270 </tr>
0271 </tbody>
0272 </table>'
0273 
0274 
0275 summary $0
0276 exit $rc