From e1d1593f514a4975e015ed3fdd69f9c1c5c3142d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 18 Jan 2016 09:33:43 -0800 Subject: Automatic code reformat. --- api_test/main.c | 164 ++++++++++++++++++++++++++----------------------------- src/chunk.h | 8 +-- src/commonmark.c | 15 ++--- src/render.c | 22 ++++---- 4 files changed, 101 insertions(+), 108 deletions(-) mode change 100755 => 100644 src/render.c diff --git a/api_test/main.c b/api_test/main.c index 1e93a75..cd9ffb5 100644 --- a/api_test/main.c +++ b/api_test/main.c @@ -525,33 +525,31 @@ static void render_xml(test_batch_runner *runner) { cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT); xml = cmark_render_xml(doc, CMARK_OPT_DEFAULT); - STR_EQ(runner, xml, - "\n" - "\n" - "\n" - " \n" - " foo \n" - " \n" - " bar\n" - " \n" - " \n" - " \n" - " paragraph 2\n" - " \n" - "\n", + STR_EQ(runner, xml, "\n" + "\n" + "\n" + " \n" + " foo \n" + " \n" + " bar\n" + " \n" + " \n" + " \n" + " paragraph 2\n" + " \n" + "\n", "render document"); free(xml); cmark_node *paragraph = cmark_node_first_child(doc); xml = cmark_render_xml(paragraph, CMARK_OPT_DEFAULT | CMARK_OPT_SOURCEPOS); - STR_EQ(runner, xml, - "\n" - "\n" - "\n" - " foo \n" - " \n" - " bar\n" - " \n" - "\n", + STR_EQ(runner, xml, "\n" + "\n" + "\n" + " foo \n" + " \n" + " bar\n" + " \n" + "\n", "render first paragraph with source pos"); free(xml); cmark_node_free(doc); @@ -567,34 +565,32 @@ static void render_man(test_batch_runner *runner) { "- sed do eiusmod tempor incididunt\n" " ut labore et dolore magna aliqua.\n"; cmark_node *doc = - cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT); + cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT); man = cmark_render_man(doc, CMARK_OPT_DEFAULT, 20); - STR_EQ(runner, man, - ".PP\n" - "foo \\f[I]bar\\f[]\n" - ".IP \\[bu] 2\n" - "Lorem ipsum dolor\n" - "sit amet,\n" - "consectetur\n" - "adipiscing elit,\n" - ".IP \\[bu] 2\n" - "sed do eiusmod\n" - "tempor incididunt ut\n" - "labore et dolore\n" - "magna aliqua.\n", + STR_EQ(runner, man, ".PP\n" + "foo \\f[I]bar\\f[]\n" + ".IP \\[bu] 2\n" + "Lorem ipsum dolor\n" + "sit amet,\n" + "consectetur\n" + "adipiscing elit,\n" + ".IP \\[bu] 2\n" + "sed do eiusmod\n" + "tempor incididunt ut\n" + "labore et dolore\n" + "magna aliqua.\n", "render document with wrapping"); free(man); man = cmark_render_man(doc, CMARK_OPT_DEFAULT, 0); - STR_EQ(runner, man, - ".PP\n" - "foo \\f[I]bar\\f[]\n" - ".IP \\[bu] 2\n" - "Lorem ipsum dolor sit amet,\n" - "consectetur adipiscing elit,\n" - ".IP \\[bu] 2\n" - "sed do eiusmod tempor incididunt\n" - "ut labore et dolore magna aliqua.\n", + STR_EQ(runner, man, ".PP\n" + "foo \\f[I]bar\\f[]\n" + ".IP \\[bu] 2\n" + "Lorem ipsum dolor sit amet,\n" + "consectetur adipiscing elit,\n" + ".IP \\[bu] 2\n" + "sed do eiusmod tempor incididunt\n" + "ut labore et dolore magna aliqua.\n", "render document without wrapping"); free(man); cmark_node_free(doc); @@ -610,38 +606,36 @@ static void render_latex(test_batch_runner *runner) { "- sed do eiusmod tempor incididunt\n" " ut labore et dolore magna aliqua.\n"; cmark_node *doc = - cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT); + cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT); latex = cmark_render_latex(doc, CMARK_OPT_DEFAULT, 20); - STR_EQ(runner, latex, - "foo \\emph{bar} \\$\\%\n" - "\n" - "\\begin{itemize}\n" - "\\item Lorem ipsum\n" - "dolor sit amet,\n" - "consectetur\n" - "adipiscing elit,\n" - "\n" - "\\item sed do eiusmod\n" - "tempor incididunt ut\n" - "labore et dolore\n" - "magna aliqua.\n" - "\n" - "\\end{itemize}\n", + STR_EQ(runner, latex, "foo \\emph{bar} \\$\\%\n" + "\n" + "\\begin{itemize}\n" + "\\item Lorem ipsum\n" + "dolor sit amet,\n" + "consectetur\n" + "adipiscing elit,\n" + "\n" + "\\item sed do eiusmod\n" + "tempor incididunt ut\n" + "labore et dolore\n" + "magna aliqua.\n" + "\n" + "\\end{itemize}\n", "render document with wrapping"); free(latex); latex = cmark_render_latex(doc, CMARK_OPT_DEFAULT, 0); - STR_EQ(runner, latex, - "foo \\emph{bar} \\$\\%\n" - "\n" - "\\begin{itemize}\n" - "\\item Lorem ipsum dolor sit amet,\n" - "consectetur adipiscing elit,\n" - "\n" - "\\item sed do eiusmod tempor incididunt\n" - "ut labore et dolore magna aliqua.\n" - "\n" - "\\end{itemize}\n", + STR_EQ(runner, latex, "foo \\emph{bar} \\$\\%\n" + "\n" + "\\begin{itemize}\n" + "\\item Lorem ipsum dolor sit amet,\n" + "consectetur adipiscing elit,\n" + "\n" + "\\item sed do eiusmod tempor incididunt\n" + "ut labore et dolore magna aliqua.\n" + "\n" + "\\end{itemize}\n", "render document without wrapping"); free(latex); cmark_node_free(doc); @@ -657,19 +651,18 @@ static void render_commonmark(test_batch_runner *runner) { "- sed do eiusmod tempor incididunt\n" " ut labore et dolore magna aliqua.\n"; cmark_node *doc = - cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT); + cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT); commonmark = cmark_render_commonmark(doc, CMARK_OPT_DEFAULT, 26); - STR_EQ(runner, commonmark, - "> \\- foo *bar* \\*bar\\*\n" - "\n" - " - Lorem ipsum dolor sit\n" - " amet, consectetur\n" - " adipiscing elit,\n" - " - sed do eiusmod tempor\n" - " incididunt ut labore\n" - " et dolore magna\n" - " aliqua.\n", + STR_EQ(runner, commonmark, "> \\- foo *bar* \\*bar\\*\n" + "\n" + " - Lorem ipsum dolor sit\n" + " amet, consectetur\n" + " adipiscing elit,\n" + " - sed do eiusmod tempor\n" + " incididunt ut labore\n" + " et dolore magna\n" + " aliqua.\n", "render document with wrapping"); free(commonmark); commonmark = cmark_render_commonmark(doc, CMARK_OPT_DEFAULT, 0); @@ -685,8 +678,7 @@ static void render_commonmark(test_batch_runner *runner) { cmark_node *text = cmark_node_new(CMARK_NODE_TEXT); cmark_node_set_literal(text, "Hi"); commonmark = cmark_render_commonmark(text, CMARK_OPT_DEFAULT, 0); - STR_EQ(runner, commonmark, "Hi\n", - "render single inline node"); + STR_EQ(runner, commonmark, "Hi\n", "render single inline node"); free(commonmark); cmark_node_free(text); diff --git a/src/chunk.h b/src/chunk.h index 7007492..b25831b 100644 --- a/src/chunk.h +++ b/src/chunk.h @@ -48,8 +48,8 @@ static CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) { cmark_chunk_rtrim(c); } -static CMARK_INLINE bufsize_t - cmark_chunk_strchr(cmark_chunk *ch, int c, bufsize_t offset) { +static CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c, + bufsize_t offset) { const unsigned char *p = (unsigned char *)memchr(ch->data + offset, c, ch->len - offset); return p ? (bufsize_t)(p - ch->data) : ch->len; @@ -96,8 +96,8 @@ static CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) { return c; } -static CMARK_INLINE cmark_chunk - cmark_chunk_dup(const cmark_chunk *ch, bufsize_t pos, bufsize_t len) { +static CMARK_INLINE cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, + bufsize_t pos, bufsize_t len) { cmark_chunk c = {ch->data + pos, len, 0}; return c; } diff --git a/src/commonmark.c b/src/commonmark.c index cb30601..60b745c 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -23,8 +23,9 @@ static inline void outc(cmark_renderer *renderer, cmark_escaping escape, int32_t c, unsigned char nextc) { bool needs_escaping = false; - bool follows_digit = renderer->buffer->size > 0 && - cmark_isdigit(renderer->buffer->ptr[renderer->buffer->size - 1]); + bool follows_digit = + renderer->buffer->size > 0 && + cmark_isdigit(renderer->buffer->ptr[renderer->buffer->size - 1]); const size_t ENCODED_SIZE = 20; char encoded[ENCODED_SIZE]; @@ -35,11 +36,11 @@ static inline void outc(cmark_renderer *renderer, cmark_escaping escape, c == '>' || c == '\\' || c == '`' || c == '!' || (c == '&' && isalpha(nextc)) || (c == '!' && nextc == '[') || (renderer->begin_content && (c == '-' || c == '+' || c == '=') && - // begin_content doesn't get set to false til we've passed digits - // at the beginning of line, so... - !follows_digit) || + // begin_content doesn't get set to false til we've passed digits + // at the beginning of line, so... + !follows_digit) || (renderer->begin_content && (c == '.' || c == ')') && follows_digit && - (nextc == 0 || cmark_isspace(nextc))))) || + (nextc == 0 || cmark_isspace(nextc))))) || (escape == URL && (c == '`' || c == '<' || c == '>' || isspace(c) || c == '\\' || c == ')' || c == '(')) || (escape == TITLE && @@ -178,7 +179,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, if (!(node->type == CMARK_NODE_ITEM && node->prev == NULL && entering)) { tmp = get_containing_block(node); renderer->in_tight_list_item = - tmp && // tmp might be NULL if there is no containing block + tmp && // tmp might be NULL if there is no containing block ((tmp->type == CMARK_NODE_ITEM && cmark_node_get_list_tight(tmp->parent)) || (tmp && tmp->parent && tmp->parent->type == CMARK_NODE_ITEM && diff --git a/src/render.c b/src/render.c old mode 100755 new mode 100644 index 2c941bf..fea9b3a --- a/src/render.c +++ b/src/render.c @@ -64,7 +64,7 @@ static void S_out(cmark_renderer *renderer, const char *source, bool wrap, nextc = source[i + len]; if (c == 32 && wrap) { if (!renderer->begin_line) { - last_nonspace = renderer->buffer->size; + last_nonspace = renderer->buffer->size; cmark_strbuf_putc(renderer->buffer, ' '); renderer->column += 1; renderer->begin_line = false; @@ -73,11 +73,11 @@ static void S_out(cmark_renderer *renderer, const char *source, bool wrap, while (source[i + 1] == ' ') { i++; } - // We don't allow breaks that make a digit the first character - // because this causes problems with commonmark output. - if (!cmark_isdigit(source[i + 1])) { + // We don't allow breaks that make a digit the first character + // because this causes problems with commonmark output. + if (!cmark_isdigit(source[i + 1])) { renderer->last_breakable = last_nonspace; - } + } } } else if (c == 10) { @@ -93,13 +93,13 @@ static void S_out(cmark_renderer *renderer, const char *source, bool wrap, // finished parsing a digit. Reason: in commonmark // we need to escape a potential list marker after // a digit: - renderer->begin_content = renderer->begin_content && - cmark_isdigit(c) == 1; + renderer->begin_content = + renderer->begin_content && cmark_isdigit(c) == 1; } else { (renderer->outc)(renderer, escape, c, nextc); renderer->begin_line = false; - renderer->begin_content = renderer->begin_content && - cmark_isdigit(c) == 1; + renderer->begin_content = + renderer->begin_content && cmark_isdigit(c) == 1; } // If adding the character went beyond width, look for an @@ -153,8 +153,8 @@ char *cmark_render(cmark_node *root, int options, int width, char *result; cmark_iter *iter = cmark_iter_new(root); - cmark_renderer renderer = {&buf, &pref, 0, width, 0, 0, true, - true, false, false, + cmark_renderer renderer = {&buf, &pref, 0, width, 0, + 0, true, true, false, false, outc, S_cr, S_blankline, S_out}; while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) { -- cgit v1.2.3