From b17ed569c4a9c22ef75bd6ffaf4a50a9bb8ec379 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20G=C3=B6hler?= Date: Sun, 7 Feb 2016 00:32:42 +0100 Subject: [PATCH] continue fenced code blocks across empty lines, #96 --- src/parser.c | 5 +++++ src/viewer.c | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/parser.c b/src/parser.c index 9d8e2ef..c2ccb0a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -340,6 +340,11 @@ int markdown_analyse(cstring_t *text, int prev) { // return IS_EMPTY on null pointers if(!text || !text->value) { SET_BIT(bits, IS_EMPTY); + + // continue fenced code blocks across empty lines + if(num_tilde_characters > 0) + SET_BIT(bits, IS_CODE); + return bits; } diff --git a/src/viewer.c b/src/viewer.c index ea33584..43a0733 100644 --- a/src/viewer.c +++ b/src/viewer.c @@ -510,16 +510,25 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors) { - if(!line->text->value) { - return; - } - int i; // increment int offset = 0; // text offset // move the cursor in position wmove(window, y, x); + if(!line->text->value) { + + // fill rest off line with spaces if we are in a code block + if(CHECK_BIT(line->bits, IS_CODE) && colors) { + wattron(window, COLOR_PAIR(CP_BLACK)); + for(i = getcurx(window) - x; i < max_cols; i++) + wprintw(window, "%s", " "); + } + + // do nothing + return; + } + // IS_UNORDERED_LIST_3 if(CHECK_BIT(line->bits, IS_UNORDERED_LIST_3)) { offset = next_nonblank(line->text, 0); -- 2.20.1