Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Sundown submodule.

  • Loading branch information...
commit b177d19828418cefd32ea261cdd38444c02a034e 1 parent a72ae36
Frank Smit authored
3  .gitmodules
View
@@ -0,0 +1,3 @@
+[submodule "vendor/sundown"]
+ path = vendor/sundown
+ url = git://github.com/tanoku/sundown.git
20 setup.py
View
@@ -1,5 +1,6 @@
import os
import sys
+import glob
import shutil
import os.path
@@ -42,6 +43,22 @@ def run(self):
print('Cython is not installed. Please install Cython first.')
+class SundownCommand(BaseCommand):
+ description = 'update Sundown files'
+ def run(self):
+ files = []
+ dest = os.path.join(dirname, 'src/sundown')
+ os.system('git submodule update')
+
+ for path in ['vendor/sundown/src/*', 'vendor/sundown/html/*']:
+ files += glob.glob(os.path.join(dirname, path))
+
+ for path in files:
+ if os.path.exists(path):
+ print('copy %s -> %s' % (path, dest))
+ shutil.copy(path, dest)
+
+
setup(
name='misaka',
version='1.0.2',
@@ -53,7 +70,8 @@ def run(self):
long_description=open(os.path.join(dirname, 'README.rst')).read(),
cmdclass={
'clean': CleanCommand,
- 'cython': CythonCommand
+ 'cython': CythonCommand,
+ 'sundown': SundownCommand
},
ext_modules=[Extension('misaka', [
'src/misaka.c',
2  src/sundown/buffer.c
View
@@ -120,7 +120,7 @@ bufprintf(struct buf *buf, const char *fmt, ...)
if (buf->size >= buf->asize && bufgrow(buf, buf->size + 1) < 0)
return;
-
+
va_start(ap, fmt);
n = _buf_vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap);
va_end(ap);
2  src/sundown/html.c
View
@@ -509,7 +509,7 @@ toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
bufprintf(ob, "<a href=\"#toc_%d\">", options->toc_data.header_count++);
if (text)
- bufput(ob, text->data, text->size);
+ escape_html(ob, text->data, text->size);
BUFPUTSL(ob, "</a>\n");
}
11 src/sundown/markdown.c
View
@@ -1970,10 +1970,13 @@ parse_table_header(
header_end = i;
+ while (header_end > 0 && _isspace(data[header_end - 1]))
+ header_end--;
+
if (data[0] == '|')
pipes--;
- if (i > 2 && data[i - 1] == '|')
+ if (header_end && data[header_end - 1] == '|')
pipes--;
*columns = pipes + 1;
@@ -2247,8 +2250,8 @@ is_ref(const uint8_t *data, size_t beg, size_t end, size_t *last, struct link_re
line_end = title_end;
title_end = i; } }
- if (!line_end)
- return 0; /* garbage after the link */
+ if (!line_end || link_end == link_offset)
+ return 0; /* garbage after the link empty link */
/* a valid ref has been found, filling-in return structures */
if (last)
@@ -2258,6 +2261,8 @@ is_ref(const uint8_t *data, size_t beg, size_t end, size_t *last, struct link_re
struct link_ref *ref;
ref = add_link_ref(refs, data + id_offset, id_end - id_offset);
+ if (!ref)
+ return 0;
ref->link = bufnew(link_end - link_offset);
bufput(ref->link, data + link_offset, link_end - link_offset);
1  vendor/sundown
@@ -0,0 +1 @@
+Subproject commit 3361ebcd22089fe64860f96a7b6acaf18a55746e
Please sign in to comment.
Something went wrong with that request. Please try again.