From 5710ef6220df0b0cbfbef73bc1b8a0b12031d02b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20G=C3=B6hler?= Date: Wed, 28 Oct 2015 00:25:59 +0100 Subject: [PATCH] fixed coding style + minor changes --- long-lines.md | 9 +++++++++ sample.md | 16 +++++++--------- src/parser.c | 34 +++++++++++++++++----------------- src/viewer.c | 8 ++++---- 4 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 long-lines.md diff --git a/long-lines.md b/long-lines.md new file mode 100644 index 0000000..ea4c6e9 --- /dev/null +++ b/long-lines.md @@ -0,0 +1,9 @@ +%title: The Road Not Taken +%author: Robert Frost + +Two roads diverged in a yellow wood, and sorry I could not travel both. And be one traveler, long I stood, and looked down one as far as I could. To where it bent in the undergrowth. + +Then took the other, as just as fair, and having perhaps the better claim. Because it was grassy and wanted wear, though as for that the passing there Had worn them really about the same. And both that morning equally lay, in leaves no step had trodden black. + +Oh, I kept the first for another day! Yet knowing how way leads on to way. I doubted if I should ever come back, I shall be telling this with a sigh. Somewhere ages and ages hence: Two roads diverged in a wood, and I. I took the one less traveled by, and that has made all the difference. + diff --git a/sample.md b/sample.md index 8f6b053..42b6930 100644 --- a/sample.md +++ b/sample.md @@ -106,21 +106,19 @@ You can also use [pandoc](http://pandoc.org/demo/example9/pandocs-markdown.html) Use at least three ~ chars to open and at least as many or more ~ for closing. -~~~~~ -~~~ -int main(int argc, char \*argv[]) { - printf("%s\\n", "Hello world!"); -} -~~~ -~~~~~~~ +\~~~ {.numberLines} +\int main(int argc, char \*argv[]) { +\ printf("%s\\n", "Hello world!"); +\} +\~~~~~~~~~~~~~~~~~~ becomes -~~~ +~~~ {.numberLines} int main(int argc, char \*argv[]) { printf("%s\\n", "Hello world!"); } -~~~ +~~~~~~~~~~~~~~~~~~ Pandoc attributes (like ".numberlines" etc.) will be ignored diff --git a/src/parser.c b/src/parser.c index d81a2cb..f0d4ed3 100644 --- a/src/parser.c +++ b/src/parser.c @@ -90,8 +90,9 @@ deck_t *markdown_load(FILE *input) { sc++; } else if(CHECK_BIT(bits, IS_TILDE_CODE) && CHECK_BIT(bits, IS_EMPTY)) { - // remove tilde code markers - (text->reset)(text); + // remove tilde code markers + (text->reset)(text); + } else { // if slide ! has line @@ -346,23 +347,23 @@ int markdown_analyse(cstring_t *text, int prev) { // IS_TILDE_CODE if (wcsncmp(text->value, L"~~~", 3) == 0) { - int tildes_in_line = next_nontilde(text, 0); - if (tildes_in_line >= num_tilde_characters) { - if (num_tilde_characters > 0) { - num_tilde_characters = 0; - } else { - num_tilde_characters = tildes_in_line; - } - SET_BIT(bits, IS_EMPTY); - SET_BIT(bits, IS_TILDE_CODE); - return bits; - } + int tildes_in_line = next_nontilde(text, 0); + if (tildes_in_line >= num_tilde_characters) { + if (num_tilde_characters > 0) { + num_tilde_characters = 0; + } else { + num_tilde_characters = tildes_in_line; + } + SET_BIT(bits, IS_EMPTY); + SET_BIT(bits, IS_TILDE_CODE); + return bits; + } } if (num_tilde_characters > 0) { - SET_BIT(bits, IS_CODE); - SET_BIT(bits, IS_TILDE_CODE); - return bits; + SET_BIT(bits, IS_CODE); + SET_BIT(bits, IS_TILDE_CODE); + return bits; } // IS_STOP @@ -647,7 +648,6 @@ int next_nonblank(cstring_t *text, int i) { return i; } - int prev_blank(cstring_t *text, int i) { while ((i > 0) && !iswspace((text->value)[i])) i--; diff --git a/src/viewer.c b/src/viewer.c index 0021e79..a05f42c 100644 --- a/src/viewer.c +++ b/src/viewer.c @@ -577,10 +577,10 @@ void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colo // IS_CODE if(CHECK_BIT(line->bits, IS_CODE)) { - if (!CHECK_BIT(line->bits, IS_TILDE_CODE)) { - // set static offset for code - offset = CODE_INDENT; - } + if (!CHECK_BIT(line->bits, IS_TILDE_CODE)) { + // set static offset for code + offset = CODE_INDENT; + } // reverse color for code blocks if(colors) -- 2.20.1