Permalink
Browse files

Clean up whitespace.

  • Loading branch information...
1 parent b9168b0 commit ccb1308468ea19695fa7c43362150ad68b09f4e3 @spladug spladug committed Oct 9, 2012
Showing with 79 additions and 80 deletions.
  1. +18 −18 html/houdini_href_e.c
  2. +13 −13 html/houdini_html_e.c
  3. +21 −22 html/html.c
  4. +1 −1 html/html.h
  5. +1 −1 html/html_smartypants.c
  6. +1 −1 setup.py
  7. +19 −19 snudown.c
  8. +2 −2 src/markdown.c
  9. +3 −3 test_snudown.py
View
@@ -19,7 +19,7 @@
*
* We asume (lazily) that any RESERVED char that
* appears inside an URL is actually meant to
- * have its native function (i.e. as an URL
+ * have its native function (i.e. as an URL
* component/separator) and hence needs no escaping.
*
* There are two exceptions: the chacters & (amp)
@@ -32,21 +32,21 @@
*
*/
static const char HREF_SAFE[] = {
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-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amp appears all the time in URLs, but needs
* HTML-entity escaping to be inside an href */
- case '&':
+ case '&':
BUFPUTSL(ob, "&");
break;
@@ -91,7 +91,7 @@ houdini_escape_href(struct buf *ob, const uint8_t *src, size_t size)
case '\'':
BUFPUTSL(ob, "'");
break;
-
+
/* the space can be escaped to %20 or a plus
* sign. we're going with the generic escape
* for now. the plus thing is more commonly seen
View
@@ -18,21 +18,21 @@
*
*/
static const char HTML_ESCAPE_TABLE[] = {
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 0, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 0, 0, 1, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 4,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 6, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 7, 7, 0, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 0, 0, 1, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 4,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 6, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
View
@@ -394,24 +394,24 @@ rndr_html_tag(struct buf *ob, const struct buf *text, void *opaque,
size_t i, x, z, in_str = 0, seen_equals = 0, done, reset;
struct buf *attr = bufnew(16);
char c;
-
+
bufputc(ob, '<');
-
+
i = 1 + strlen(tagname);
-
+
if(tagtype == HTML_TAG_CLOSE) {
bufputc(ob, '/');
i += 1;
}
-
+
bufputs(ob, tagname);
-
+
if(tagtype != HTML_TAG_CLOSE) {
for(;i < text->size;i++) {
c = text->data[i];
done = 0;
reset = 0;
-
+
switch(c) {
case '>':
if(seen_equals && !in_str) {
@@ -459,12 +459,12 @@ rndr_html_tag(struct buf *ob, const struct buf *text, void *opaque,
}
}
}
-
+
if(done) {
bufputc(ob, ' ');
bufput(ob, attr->data, attr->size);
}
-
+
if(reset) {
seen_equals = 0;
in_str = 0;
@@ -474,11 +474,11 @@ rndr_html_tag(struct buf *ob, const struct buf *text, void *opaque,
}
}
}
-
+
bufrelease(attr);
-
+
bufputc(ob, '>');
-
+
}
static int
@@ -487,17 +487,16 @@ rndr_raw_html(struct buf *ob, const struct buf *text, void *opaque)
struct html_renderopt *options = opaque;
char** whitelist = options->html_element_whitelist;
int i, tagtype;
-
-
+
/* Items on the whitelist ignore all other flags and just output */
if (((options->flags & HTML_ALLOW_ELEMENT_WHITELIST) != 0) && whitelist) {
- for(i = 0; whitelist[i]; i++) {
+ for (i = 0; whitelist[i]; i++) {
tagtype = sdhtml_is_tag(text->data, text->size, whitelist[i]);
- if(tagtype != HTML_TAG_NONE) {
+ if (tagtype != HTML_TAG_NONE) {
rndr_html_tag(ob, text, opaque,
- whitelist[i],
- options->html_attr_whitelist,
- tagtype);
+ whitelist[i],
+ options->html_attr_whitelist,
+ tagtype);
return 1;
}
}
@@ -633,11 +632,11 @@ toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
}
bufprintf(ob, "<a href=\"#");
-
+
if (options->toc_id_prefix) {
bufprintf(ob, options->toc_id_prefix);
}
-
+
bufprintf(ob, "toc_%d\">", options->toc_data.header_count++);
if (text)
escape_html(ob, text->data, text->size);
@@ -656,7 +655,7 @@ static void
reset_toc(struct buf *ob, void *opaque)
{
struct html_renderopt *options = opaque;
-
+
memset(&(options->toc_data), 0, sizeof(options->toc_data));
}
@@ -669,7 +668,7 @@ toc_finalize(struct buf *ob, void *opaque)
BUFPUTSL(ob, "</li>\n</ul>\n");
options->toc_data.current_level--;
}
-
+
reset_toc(ob, opaque);
}
View
@@ -35,7 +35,7 @@ struct html_renderopt {
char* toc_id_prefix;
unsigned int flags;
-
+
char** html_element_whitelist;
char** html_attr_whitelist;
View
@@ -23,7 +23,7 @@
#include <ctype.h>
#if defined(_WIN32)
-#define snprintf _snprintf
+#define snprintf _snprintf
#endif
struct smartypants_data {
View
@@ -30,7 +30,7 @@ def c_files_in(directory):
test_suite="test_snudown.test_snudown",
ext_modules=[
Extension(
- name='snudown',
+ name='snudown',
sources=['snudown.c'] + c_files_in('src/') + c_files_in('html/'),
include_dirs=['src', 'html']
)
View
@@ -33,7 +33,7 @@ struct module_state {
static struct snudown_renderer sundown[RENDERER_COUNT];
-static char* html_element_whitelist[] = { "tr", "th", "td", "table", "tbody", "thead", "tfoot", "caption", NULL };
+static char* html_element_whitelist[] = {"tr", "th", "td", "table", "tbody", "thead", "tfoot", "caption", NULL};
static char* html_attr_whitelist[] = {"colspan", "rowspan", "cellspacing", "cellpadding", "scope", NULL};
static struct module_state usertext_toc_state;
@@ -52,14 +52,14 @@ static const unsigned int snudown_default_md_flags =
MKDEXT_STRIKETHROUGH |
MKDEXT_TABLES;
-static const unsigned int snudown_default_render_flags =
+static const unsigned int snudown_default_render_flags =
HTML_SKIP_HTML |
HTML_SKIP_IMAGES |
HTML_SAFELINK |
HTML_ESCAPE |
HTML_USE_XHTML;
-static const unsigned int snudown_wiki_render_flags =
+static const unsigned int snudown_wiki_render_flags =
HTML_SKIP_HTML |
HTML_SAFELINK |
HTML_ALLOW_ELEMENT_WHITELIST |
@@ -93,11 +93,11 @@ static struct sd_markdown* custom_render(struct module_state* state,
(struct html_renderopt *)&state->options,
renderflags);
}
-
+
state->options.html.link_attributes = &snudown_link_attr;
state->options.html.html_element_whitelist = html_element_whitelist;
state->options.html.html_attr_whitelist = html_attr_whitelist;
-
+
return sd_markdown_new(
markdownflags,
16,
@@ -146,39 +146,39 @@ snudown_md(PyObject *self, PyObject *args, PyObject *kwargs)
&target, &toc_id_prefix, &renderer, &enable_toc)) {
return NULL;
}
-
- if(renderer < 0 || renderer >= RENDERER_COUNT) {
+
+ if (renderer < 0 || renderer >= RENDERER_COUNT) {
PyErr_SetString(PyExc_ValueError, "Invalid renderer");
return NULL;
}
-
+
_snudown = sundown[renderer];
-
+
struct snudown_renderopt *options = &(_snudown.state->options);
options->nofollow = nofollow;
options->target = target;
-
+
/* Output buffer */
ob = bufnew(128);
-
+
flags = options->html.flags;
-
+
if (enable_toc) {
_snudown.toc_state->options.html.toc_id_prefix = toc_id_prefix;
sd_markdown_render(ob, ib.data, ib.size, _snudown.toc_renderer);
_snudown.toc_state->options.html.toc_id_prefix = NULL;
-
+
options->html.flags |= HTML_TOC;
}
-
+
options->html.toc_id_prefix = toc_id_prefix;
-
+
/* do the magic */
sd_markdown_render(ob, ib.data, ib.size, _snudown.main_renderer);
-
+
options->html.toc_id_prefix = NULL;
options->html.flags = flags;
-
+
/* make a Python string */
result_text = "";
if (ob->data)
@@ -202,10 +202,10 @@ PyMODINIT_FUNC initsnudown(void)
module = Py_InitModule3("snudown", snudown_methods, snudown_module__doc__);
if (module == NULL)
return;
-
+
init_default_render(module);
init_wiki_render(module);
-
+
/* Version */
PyModule_AddStringConstant(module, "__version__", SNUDOWN_VERSION);
}
View
@@ -1459,12 +1459,12 @@ parse_paragraph(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
while (i < size) {
for (end = i + 1; end < size && data[end - 1] != '\n'; end++) /* empty */;
-
+
if (prefix_quote(data + i, end - i) != 0) {
end = i;
break;
}
-
+
if (is_empty(data + i, size - i))
break;
View
@@ -40,7 +40,7 @@
'Words words /r/test words':
'<p>Words words <a href="/r/test">/r/test</a> words</p>\n',
-
+
'/r/':
'<p>/r/</p>\n',
@@ -141,10 +141,10 @@ def runTest(self):
repr(output))):
if a != b:
io = StringIO.StringIO()
- print >> io, "TEST FAILED:"
+ print >> io, "TEST FAILED:"
print >> io, " input: %s" % repr(self.input)
print >> io, " expected: %s" % repr(self.expected_output)
- print >> io, " actual: %s" % repr(output)
+ print >> io, " actual: %s" % repr(output)
print >> io, " %s" % (' ' * i + '^')
self.fail(io.getvalue())

0 comments on commit ccb1308

Please sign in to comment.