expects single line, checks if it's a codefence and extracts language */
| 1422 | |
| 1423 | /* expects single line, checks if it's a codefence and extracts language */ |
| 1424 | static size_t |
| 1425 | parse_codefence(uint8_t *data, size_t size, hoedown_buffer *lang, size_t *width, uint8_t *chr) |
| 1426 | { |
| 1427 | size_t i, w, lang_start; |
| 1428 | |
| 1429 | i = w = is_codefence(data, size, width, chr); |
| 1430 | if (i == 0) |
| 1431 | return 0; |
| 1432 | |
| 1433 | while (i < size && _isspace(data[i])) |
| 1434 | i++; |
| 1435 | |
| 1436 | lang_start = i; |
| 1437 | |
| 1438 | while (i < size && !_isspace(data[i])) |
| 1439 | i++; |
| 1440 | |
| 1441 | lang->data = data + lang_start; |
| 1442 | lang->size = i - lang_start; |
| 1443 | |
| 1444 | /* Avoid parsing a codespan as a fence */ |
| 1445 | i = lang_start + 2; |
| 1446 | while (i < size && !(data[i] == *chr && data[i-1] == *chr && data[i-2] == *chr)) i++; |
| 1447 | if (i < size) return 0; |
| 1448 | |
| 1449 | return w; |
| 1450 | } |
| 1451 | |
| 1452 | /* is_atxheader • returns whether the line is a hash-prefixed header */ |
| 1453 | static int |
no test coverage detected