Update to latest Hoedown.

This commit is contained in:
Frank Smit 2017-01-15 20:45:19 +01:00
parent f3d83eca19
commit 488cda2c88
4 changed files with 43 additions and 10 deletions

View File

@ -11,6 +11,7 @@ Date format is year-month-day.
- Add a new renderer class with XSS protections. By Changaco. (`#60`_)
- Add Python 2.6 support. By sprin. (`#48`_)
- Add Termux_ installation instructions to documentation.
- Update Hoedown source files.
.. _#60: https://github.com/FSX/misaka/pull/60
.. _#48: https://github.com/FSX/misaka/pull/48

View File

@ -77,6 +77,7 @@ static size_t char_autolink_url(hoedown_buffer *ob, hoedown_document *doc, uint8
static size_t char_autolink_email(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size);
static size_t char_autolink_www(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size);
static size_t char_link(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size);
static size_t char_image(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size);
static size_t char_superscript(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size);
static size_t char_math(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size);
@ -86,6 +87,7 @@ enum markdown_char_t {
MD_CHAR_CODESPAN,
MD_CHAR_LINEBREAK,
MD_CHAR_LINK,
MD_CHAR_IMAGE,
MD_CHAR_LANGLE,
MD_CHAR_ESCAPE,
MD_CHAR_ENTITY,
@ -103,6 +105,7 @@ static char_trigger markdown_char_ptrs[] = {
&char_codespan,
&char_linebreak,
&char_link,
&char_image,
&char_langle_tag,
&char_escape,
&char_entity,
@ -402,9 +405,23 @@ tag_length(uint8_t *data, size_t size, hoedown_autolink_type *autolink)
/* a valid tag can't be shorter than 3 chars */
if (size < 3) return 0;
/* begins with a '<' optionally followed by '/', followed by letter or number */
if (data[0] != '<') return 0;
i = (data[1] == '/') ? 2 : 1;
/* HTML comment, laxist form */
if (size > 5 && data[1] == '!' && data[2] == '-' && data[3] == '-') {
i = 5;
while (i < size && !(data[i - 2] == '-' && data[i - 1] == '-' && data[i] == '>'))
i++;
i++;
if (i <= size)
return i;
}
/* begins with a '<' optionally followed by '/', followed by letter or number */
i = (data[1] == '/') ? 2 : 1;
if (!isalnum(data[i]))
return 0;
@ -928,7 +945,12 @@ char_escape(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t off
}
else hoedown_buffer_putc(ob, data[1]);
} else if (size == 1) {
hoedown_buffer_putc(ob, data[0]);
if (doc->md.normal_text) {
work.data = data;
work.size = 1;
doc->md.normal_text(ob, &work, &doc->data);
}
else hoedown_buffer_putc(ob, data[0]);
}
return 2;
@ -1076,6 +1098,17 @@ char_autolink_url(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size
return link_len;
}
static size_t
char_image(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size) {
size_t ret;
if (size < 2 || data[1] != '[') return 0;
ret = char_link(ob, doc, data + 1, offset + 1, size - 1);
if (!ret) return 0;
return ret + 1;
}
/* char_link • '[': parsing a link, a footnote or an image */
static size_t
char_link(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offset, size_t size)
@ -1288,9 +1321,6 @@ char_link(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offse
/* calling the relevant rendering function */
if (is_img) {
if (ob->size && ob->data[ob->size - 1] == '!')
ob->size -= 1;
ret = doc->md.image(ob, u_link, title, content, &doc->data);
} else {
ret = doc->md.link(ob, content, u_link, title, &doc->data);
@ -2793,8 +2823,10 @@ hoedown_document_new(
if (doc->md.linebreak)
doc->active_char['\n'] = MD_CHAR_LINEBREAK;
if (doc->md.image || doc->md.link || doc->md.footnotes || doc->md.footnote_ref)
if (doc->md.image || doc->md.link || doc->md.footnotes || doc->md.footnote_ref) {
doc->active_char['['] = MD_CHAR_LINK;
doc->active_char['!'] = MD_CHAR_IMAGE;
}
doc->active_char['<'] = MD_CHAR_LANGLE;
doc->active_char['\\'] = MD_CHAR_ESCAPE;

View File

@ -314,7 +314,7 @@ smartypants_cb__ltag(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t
size_t tag, i = 0;
/* This is a comment. Copy everything verbatim until --> or EOF is seen. */
if (i + 4 < size && memcmp(text, "<!--", 4) == 0) {
if (i + 4 < size && memcmp(text + i, "<!--", 4) == 0) {
i += 4;
while (i + 3 < size && memcmp(text + i, "-->", 3) != 0)
i++;

View File

@ -12,10 +12,10 @@ extern "C" {
* CONSTANTS *
*************/
#define HOEDOWN_VERSION "3.0.5"
#define HOEDOWN_VERSION "3.0.7"
#define HOEDOWN_VERSION_MAJOR 3
#define HOEDOWN_VERSION_MINOR 0
#define HOEDOWN_VERSION_REVISION 5
#define HOEDOWN_VERSION_REVISION 7
/*************