slide = next_slide(slide);
sc++;
- } else if(CHECK_BIT(bits, IS_TILDE_CODE) &&
+ } else if((CHECK_BIT(bits, IS_TILDE_CODE) ||
+ CHECK_BIT(bits, IS_GFM_CODE)) &&
CHECK_BIT(bits, IS_EMPTY)) {
// remove tilde code markers
(text->reset)(text);
static int unordered_list_level = 0;
static int unordered_list_level_offset[] = {-1, -1, -1, -1};
static int num_tilde_characters = 0;
+ static int num_backticks = 0;
int i = 0; // increment
int bits = 0; // markdown bits
return bits;
}
+ // IS_GFM_CODE
+ if (wcsncmp(text->value, L"```", 3) == 0) {
+ int backticks_in_line = next_nonbacktick(text, 0);
+ if (backticks_in_line >= num_backticks) {
+ if (num_backticks > 0) {
+ num_backticks = 0;
+ } else {
+ num_backticks = backticks_in_line;
+ }
+ SET_BIT(bits, IS_EMPTY);
+ SET_BIT(bits, IS_GFM_CODE);
+ return bits;
+ }
+ }
+
+ if (num_backticks > 0) {
+ SET_BIT(bits, IS_CODE);
+ SET_BIT(bits, IS_GFM_CODE);
+ return bits;
+ }
+
// IS_STOP
if((offset < CODE_INDENT || !CHECK_BIT(prev, IS_CODE)) &&
(!wcsncmp(&text->value[offset], L"<br>", 4) ||
return i;
}
+int next_nonbacktick(cstring_t *text, int i) {
+ while ((i < text->size) && text->value[i] == L'`')
+ i++;
+
+ return i;
+}
+