-int markdown_analyse(cstring_t *text) {
- int c, i, bits,
- offset, eol,
- equals, hashes, stars, minus, plus,
- spaces, other;
-
- // count leading spaces
- offset = next_nonblank(text, 0);
-
- // IS_CODE
- if(offset >= 4) {
- SET_BIT(bits, IS_CODE);
- return bits;
- }
-
- // strip trailing spaces
- for(eol = text->size; eol > offset && isspace(text->text[eol - 1]); eol--);
-
- for(i = offset; i < eol; i++) {
-
- switch(text->text[i]) {
- case '=': equals++; break;
- case '#': hashes++; break;
- case '*': stars++; break;
- case '-': minus++; break;
- case '+': plus++; break;
- case ' ': spaces++; break;
- default: other++; break;
- }
- }
-
- // IS_HR
- if((minus >= 3 && equals + hashes + stars + plus == 0) ||
- (stars >= 3 && equals + hashes + minus + plus == 0)) {
-
- SET_BIT(bits, IS_HR);
- return bits;
- }
-
- //TODO all the other markdown tags