Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make parsing slightly faster and fix a comment. No changes in functionality. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | markdown-footnotes |
Files: | files | file ages | folders |
SHA3-256: |
a36dd09d17f3057f077c46be9c4b1a9f |
User & Date: | george 2022-02-16 23:08:02 |
References
2022-02-18
| ||
15:23 | Improved diff alignment following an indentation change. The objective of this change is to improve the diff output for of the [a36dd09d17f3057f] check-in. ... (check-in: 868d1608 user: drh tags: trunk) | |
Context
2022-02-17
| ||
00:17 | Clean-up and rephrase some comments. ... (check-in: a62c8768 user: george tags: markdown-footnotes) | |
2022-02-16
| ||
23:08 | Make parsing slightly faster and fix a comment. No changes in functionality. ... (check-in: a36dd09d user: george tags: markdown-footnotes) | |
22:11 |
Include REQUEST_URI into footnotes' hyperlinks.
This should make links work even if base href (in a page's header)
is not consistent with the REQUEST_URI .
If FOOTNOTES_WITHOUT_URI macro is defined while
compiling src/markdown_html.c then bare "#fragment"
hyperlinks (without REQUEST_URI ) are generated.
...
(check-in: 2c1f8f35 user: george tags: markdown-footnotes)
| |
Changes
Changes to src/markdown.c.
︙ | ︙ | |||
1166 1167 1168 1169 1170 1171 1172 | /* char_link -- '[': parsing a link or an image */ static size_t char_link( struct Blob *ob, struct render *rndr, char *data, size_t offset, | | < < < < < < < < < < < | | | | | > > > > > > > | | < > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 | /* char_link -- '[': parsing a link or an image */ static size_t char_link( struct Blob *ob, struct render *rndr, char *data, size_t offset, size_t size /* parse_inline() ensures that size > 0 */ ){ const int is_img = (offset && data[-1] == '!'); size_t i = 1, txt_e; struct Blob *content = 0; struct Blob *link = 0; struct Blob *title = 0; const struct footnote *fn = 0; int ret; /* checking whether the correct renderer exists */ if( (is_img && !rndr->make.image) || (!is_img && !rndr->make.link) ){ return 0; } /* looking for the matching closing bracket */ txt_e = matching_bracket_offset(data, data+size); if( !txt_e ) return 0; i = txt_e + 1; ret = 0; /* error if we don't get to the callback */ /* free-standing footnote refernece */ if(!is_img && size>3 && data[1]=='^'){ fn = get_footnote(rndr, data+2, txt_e-2); if( !fn ) { rndr->notes.misref.nUsed++; fn = &rndr->notes.misref; } }else{ /* skip "inter-bracket-whitespace" - any amount of whitespace or newline */ /* (this is much more laxist than original markdown syntax) */ while( i<size && (data[i]==' ' || data[i]=='\t' || data[i]=='\n') ){ i++; } /* allocate temporary buffers to store content, link and title */ title = new_work_buffer(rndr); content = new_work_buffer(rndr); link = new_work_buffer(rndr); if( i<size && data[i]=='(' ){ if( i+2<size && data[i+1]=='^' ){ /* span-bounded inline footnote */ const size_t k = matching_bracket_offset(data+i, data+size); if( !k ) goto char_link_cleanup; fn = add_inline_footnote(rndr, data+(i+2), k-2); i += k+1; }else{ /* inline style link */ size_t span_end = i; while( span_end<size && !(data[span_end]==')' && (span_end==i || data[span_end-1]!='\\')) ){ span_end++; } if( span_end>=size || get_link_inline(link, title, data+i+1, span_end-(i+1))<0 ){ goto char_link_cleanup; } i = span_end+1; } /* reference style link or span-bounded footnote reference */ }else if( i<size && data[i]=='[' ){ char *id_data; size_t id_size, id_end = i; int bFootnote; while( id_end<size && data[id_end]!=']' ){ id_end++; } if( id_end>=size ) goto char_link_cleanup; bFootnote = data[i+1]=='^'; if( i+1==id_end || (bFootnote && i+2==id_end) ){ /* implicit id - use the contents */ id_data = data+1; id_size = txt_e-1; }else{ /* explicit id - between brackets */ id_data = data+i+1; id_size = id_end-(i+1); if( bFootnote ){ id_data++; id_size--; } } if( bFootnote ){ fn = get_footnote(rndr, id_data, id_size); if( !fn ) { rndr->notes.misref.nUsed++; fn = &rndr->notes.misref; } }else if( get_link_ref(rndr, link, title, id_data, id_size)<0 ){ goto char_link_cleanup; } i = id_end+1; /* shortcut reference style link */ }else{ if( get_link_ref(rndr, link, title, data+1, txt_e-1)<0 ){ goto char_link_cleanup; } /* rewinding an "inter-bracket-whitespace" */ i = txt_e+1; } } /* building content: img alt is escaped, link content is parsed */ if( txt_e>1 && content ){ if( is_img ) blob_append(content, data+1, txt_e-1); else parse_inline(content, rndr, data+1, txt_e-1); } /* calling the relevant rendering function */ |
︙ | ︙ |