parent
add8743c5f
commit
d9aa3bf040
5 changed files with 84 additions and 84 deletions
|
@ -31,8 +31,8 @@ struct hoedown_buffer {
|
|||
|
||||
typedef struct hoedown_buffer hoedown_buffer;
|
||||
|
||||
/* BUFPUTSL: optimized hoedown_buffer_puts of a string literal */
|
||||
#define BUFPUTSL(output, literal) \
|
||||
/* HOEDOWN_BUFPUTSL: optimized hoedown_buffer_puts of a string literal */
|
||||
#define HOEDOWN_BUFPUTSL(output, literal) \
|
||||
hoedown_buffer_put(output, literal, sizeof(literal) - 1)
|
||||
|
||||
/* hoedown_buffer_new: allocation of a new buffer */
|
||||
|
|
|
@ -85,14 +85,14 @@ hoedown_escape_href(hoedown_buffer *ob, const uint8_t *src, size_t size)
|
|||
/* amp appears all the time in URLs, but needs
|
||||
* HTML-entity escaping to be inside an href */
|
||||
case '&':
|
||||
BUFPUTSL(ob, "&");
|
||||
HOEDOWN_BUFPUTSL(ob, "&");
|
||||
break;
|
||||
|
||||
/* the single quote is a valid URL character
|
||||
* according to the standard; it needs HTML
|
||||
* entity escaping too */
|
||||
case '\'':
|
||||
BUFPUTSL(ob, "'");
|
||||
HOEDOWN_BUFPUTSL(ob, "'");
|
||||
break;
|
||||
|
||||
/* the space can be escaped to %20 or a plus
|
||||
|
|
132
src/html.c
132
src/html.c
|
@ -68,9 +68,9 @@ rndr_autolink(hoedown_buffer *ob, const hoedown_buffer *link, enum hoedown_autol
|
|||
type != HOEDOWN_AUTOLINK_EMAIL)
|
||||
return 0;
|
||||
|
||||
BUFPUTSL(ob, "<a href=\"");
|
||||
HOEDOWN_BUFPUTSL(ob, "<a href=\"");
|
||||
if (type == HOEDOWN_AUTOLINK_EMAIL)
|
||||
BUFPUTSL(ob, "mailto:");
|
||||
HOEDOWN_BUFPUTSL(ob, "mailto:");
|
||||
escape_href(ob, link->data, link->size);
|
||||
|
||||
if (options->link_attributes) {
|
||||
|
@ -78,7 +78,7 @@ rndr_autolink(hoedown_buffer *ob, const hoedown_buffer *link, enum hoedown_autol
|
|||
options->link_attributes(ob, link, opaque);
|
||||
hoedown_buffer_putc(ob, '>');
|
||||
} else {
|
||||
BUFPUTSL(ob, "\">");
|
||||
HOEDOWN_BUFPUTSL(ob, "\">");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -92,7 +92,7 @@ rndr_autolink(hoedown_buffer *ob, const hoedown_buffer *link, enum hoedown_autol
|
|||
escape_html(ob, link->data, link->size);
|
||||
}
|
||||
|
||||
BUFPUTSL(ob, "</a>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</a>");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -107,10 +107,10 @@ rndr_blockcode(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_buf
|
|||
if (lang && lang->size) {
|
||||
size_t i, cls = 0;
|
||||
if (options->flags & HOEDOWN_HTML_PRETTIFY) {
|
||||
BUFPUTSL(ob, "<pre><code class=\"prettyprint");
|
||||
HOEDOWN_BUFPUTSL(ob, "<pre><code class=\"prettyprint");
|
||||
cls++;
|
||||
} else {
|
||||
BUFPUTSL(ob, "<pre><code class=\"");
|
||||
HOEDOWN_BUFPUTSL(ob, "<pre><code class=\"");
|
||||
}
|
||||
|
||||
for (i = 0; i < lang->size; ++i, ++cls) {
|
||||
|
@ -130,26 +130,26 @@ rndr_blockcode(hoedown_buffer *ob, const hoedown_buffer *text, const hoedown_buf
|
|||
}
|
||||
}
|
||||
|
||||
BUFPUTSL(ob, "\">");
|
||||
HOEDOWN_BUFPUTSL(ob, "\">");
|
||||
} else if (options->flags & HOEDOWN_HTML_PRETTIFY) {
|
||||
BUFPUTSL(ob, "<pre><code class=\"prettyprint\">");
|
||||
HOEDOWN_BUFPUTSL(ob, "<pre><code class=\"prettyprint\">");
|
||||
} else {
|
||||
BUFPUTSL(ob, "<pre><code>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<pre><code>");
|
||||
}
|
||||
|
||||
if (text)
|
||||
escape_html(ob, text->data, text->size);
|
||||
|
||||
BUFPUTSL(ob, "</code></pre>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</code></pre>\n");
|
||||
}
|
||||
|
||||
static void
|
||||
rndr_blockquote(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
||||
{
|
||||
if (ob->size) hoedown_buffer_putc(ob, '\n');
|
||||
BUFPUTSL(ob, "<blockquote>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "<blockquote>\n");
|
||||
if (text) hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</blockquote>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</blockquote>\n");
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -157,11 +157,11 @@ rndr_codespan(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
|||
{
|
||||
hoedown_html_renderopt *options = opaque;
|
||||
if (options->flags & HOEDOWN_HTML_PRETTIFY)
|
||||
BUFPUTSL(ob, "<code class=\"prettyprint\">");
|
||||
HOEDOWN_BUFPUTSL(ob, "<code class=\"prettyprint\">");
|
||||
else
|
||||
BUFPUTSL(ob, "<code>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<code>");
|
||||
if (text) escape_html(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</code>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</code>");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -171,9 +171,9 @@ rndr_strikethrough(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
|||
if (!text || !text->size)
|
||||
return 0;
|
||||
|
||||
BUFPUTSL(ob, "<del>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<del>");
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</del>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</del>");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -183,9 +183,9 @@ rndr_double_emphasis(hoedown_buffer *ob, const hoedown_buffer *text, void *opaqu
|
|||
if (!text || !text->size)
|
||||
return 0;
|
||||
|
||||
BUFPUTSL(ob, "<strong>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<strong>");
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</strong>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</strong>");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -194,9 +194,9 @@ static int
|
|||
rndr_emphasis(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
||||
{
|
||||
if (!text || !text->size) return 0;
|
||||
BUFPUTSL(ob, "<em>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<em>");
|
||||
if (text) hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</em>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</em>");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -206,9 +206,9 @@ rndr_underline(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
|||
if (!text || !text->size)
|
||||
return 0;
|
||||
|
||||
BUFPUTSL(ob, "<u>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<u>");
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</u>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</u>");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -219,9 +219,9 @@ rndr_highlight(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
|||
if (!text || !text->size)
|
||||
return 0;
|
||||
|
||||
BUFPUTSL(ob, "<mark>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<mark>");
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</mark>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</mark>");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -232,9 +232,9 @@ rndr_quote(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
|||
if (!text || !text->size)
|
||||
return 0;
|
||||
|
||||
BUFPUTSL(ob, "<q>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<q>");
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</q>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</q>");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -272,13 +272,13 @@ rndr_link(hoedown_buffer *ob, const hoedown_buffer *link, const hoedown_buffer *
|
|||
if (link != NULL && (options->flags & HOEDOWN_HTML_SAFELINK) != 0 && !hoedown_autolink_is_safe(link->data, link->size))
|
||||
return 0;
|
||||
|
||||
BUFPUTSL(ob, "<a href=\"");
|
||||
HOEDOWN_BUFPUTSL(ob, "<a href=\"");
|
||||
|
||||
if (link && link->size)
|
||||
escape_href(ob, link->data, link->size);
|
||||
|
||||
if (title && title->size) {
|
||||
BUFPUTSL(ob, "\" title=\"");
|
||||
HOEDOWN_BUFPUTSL(ob, "\" title=\"");
|
||||
escape_html(ob, title->data, title->size);
|
||||
}
|
||||
|
||||
|
@ -287,11 +287,11 @@ rndr_link(hoedown_buffer *ob, const hoedown_buffer *link, const hoedown_buffer *
|
|||
options->link_attributes(ob, link, opaque);
|
||||
hoedown_buffer_putc(ob, '>');
|
||||
} else {
|
||||
BUFPUTSL(ob, "\">");
|
||||
HOEDOWN_BUFPUTSL(ob, "\">");
|
||||
}
|
||||
|
||||
if (content && content->size) hoedown_buffer_put(ob, content->data, content->size);
|
||||
BUFPUTSL(ob, "</a>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</a>");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ rndr_list(hoedown_buffer *ob, const hoedown_buffer *text, int flags, void *opaqu
|
|||
static void
|
||||
rndr_listitem(hoedown_buffer *ob, const hoedown_buffer *text, int flags, void *opaque)
|
||||
{
|
||||
BUFPUTSL(ob, "<li>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<li>");
|
||||
if (text) {
|
||||
size_t size = text->size;
|
||||
while (size && text->data[size - 1] == '\n')
|
||||
|
@ -315,7 +315,7 @@ rndr_listitem(hoedown_buffer *ob, const hoedown_buffer *text, int flags, void *o
|
|||
|
||||
hoedown_buffer_put(ob, text->data, size);
|
||||
}
|
||||
BUFPUTSL(ob, "</li>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</li>\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -334,7 +334,7 @@ rndr_paragraph(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
|||
if (i == text->size)
|
||||
return;
|
||||
|
||||
BUFPUTSL(ob, "<p>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<p>");
|
||||
if (options->flags & HOEDOWN_HTML_HARD_WRAP) {
|
||||
size_t org;
|
||||
while (i < text->size) {
|
||||
|
@ -358,7 +358,7 @@ rndr_paragraph(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
|||
} else {
|
||||
hoedown_buffer_put(ob, &text->data[i], text->size - i);
|
||||
}
|
||||
BUFPUTSL(ob, "</p>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</p>\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -380,9 +380,9 @@ static int
|
|||
rndr_triple_emphasis(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
||||
{
|
||||
if (!text || !text->size) return 0;
|
||||
BUFPUTSL(ob, "<strong><em>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<strong><em>");
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</em></strong>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</em></strong>");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -400,15 +400,15 @@ rndr_image(hoedown_buffer *ob, const hoedown_buffer *link, const hoedown_buffer
|
|||
hoedown_html_renderopt *options = opaque;
|
||||
if (!link || !link->size) return 0;
|
||||
|
||||
BUFPUTSL(ob, "<img src=\"");
|
||||
HOEDOWN_BUFPUTSL(ob, "<img src=\"");
|
||||
escape_href(ob, link->data, link->size);
|
||||
BUFPUTSL(ob, "\" alt=\"");
|
||||
HOEDOWN_BUFPUTSL(ob, "\" alt=\"");
|
||||
|
||||
if (alt && alt->size)
|
||||
escape_html(ob, alt->data, alt->size);
|
||||
|
||||
if (title && title->size) {
|
||||
BUFPUTSL(ob, "\" title=\"");
|
||||
HOEDOWN_BUFPUTSL(ob, "\" title=\"");
|
||||
escape_html(ob, title->data, title->size); }
|
||||
|
||||
hoedown_buffer_puts(ob, USE_XHTML(options) ? "\"/>" : "\">");
|
||||
|
@ -450,57 +450,57 @@ static void
|
|||
rndr_table(hoedown_buffer *ob, const hoedown_buffer *header, const hoedown_buffer *body, void *opaque)
|
||||
{
|
||||
if (ob->size) hoedown_buffer_putc(ob, '\n');
|
||||
BUFPUTSL(ob, "<table><thead>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "<table><thead>\n");
|
||||
if (header)
|
||||
hoedown_buffer_put(ob, header->data, header->size);
|
||||
BUFPUTSL(ob, "</thead><tbody>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</thead><tbody>\n");
|
||||
if (body)
|
||||
hoedown_buffer_put(ob, body->data, body->size);
|
||||
BUFPUTSL(ob, "</tbody></table>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</tbody></table>\n");
|
||||
}
|
||||
|
||||
static void
|
||||
rndr_tablerow(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
||||
{
|
||||
BUFPUTSL(ob, "<tr>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "<tr>\n");
|
||||
if (text)
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</tr>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</tr>\n");
|
||||
}
|
||||
|
||||
static void
|
||||
rndr_tablecell(hoedown_buffer *ob, const hoedown_buffer *text, int flags, void *opaque)
|
||||
{
|
||||
if (flags & HOEDOWN_TABLE_HEADER) {
|
||||
BUFPUTSL(ob, "<th");
|
||||
HOEDOWN_BUFPUTSL(ob, "<th");
|
||||
} else {
|
||||
BUFPUTSL(ob, "<td");
|
||||
HOEDOWN_BUFPUTSL(ob, "<td");
|
||||
}
|
||||
|
||||
switch (flags & HOEDOWN_TABLE_ALIGNMASK) {
|
||||
case HOEDOWN_TABLE_ALIGN_CENTER:
|
||||
BUFPUTSL(ob, " style=\"text-align: center\">");
|
||||
HOEDOWN_BUFPUTSL(ob, " style=\"text-align: center\">");
|
||||
break;
|
||||
|
||||
case HOEDOWN_TABLE_ALIGN_L:
|
||||
BUFPUTSL(ob, " style=\"text-align: left\">");
|
||||
HOEDOWN_BUFPUTSL(ob, " style=\"text-align: left\">");
|
||||
break;
|
||||
|
||||
case HOEDOWN_TABLE_ALIGN_R:
|
||||
BUFPUTSL(ob, " style=\"text-align: right\">");
|
||||
HOEDOWN_BUFPUTSL(ob, " style=\"text-align: right\">");
|
||||
break;
|
||||
|
||||
default:
|
||||
BUFPUTSL(ob, ">");
|
||||
HOEDOWN_BUFPUTSL(ob, ">");
|
||||
}
|
||||
|
||||
if (text)
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
|
||||
if (flags & HOEDOWN_TABLE_HEADER) {
|
||||
BUFPUTSL(ob, "</th>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</th>\n");
|
||||
} else {
|
||||
BUFPUTSL(ob, "</td>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</td>\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -508,9 +508,9 @@ static int
|
|||
rndr_superscript(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
||||
{
|
||||
if (!text || !text->size) return 0;
|
||||
BUFPUTSL(ob, "<sup>");
|
||||
HOEDOWN_BUFPUTSL(ob, "<sup>");
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</sup>");
|
||||
HOEDOWN_BUFPUTSL(ob, "</sup>");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -527,14 +527,14 @@ rndr_footnotes(hoedown_buffer *ob, const hoedown_buffer *text, void *opaque)
|
|||
hoedown_html_renderopt *options = opaque;
|
||||
|
||||
if (ob->size) hoedown_buffer_putc(ob, '\n');
|
||||
BUFPUTSL(ob, "<div class=\"footnotes\">\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "<div class=\"footnotes\">\n");
|
||||
hoedown_buffer_puts(ob, USE_XHTML(options) ? "<hr/>\n" : "<hr>\n");
|
||||
BUFPUTSL(ob, "<ol>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "<ol>\n");
|
||||
|
||||
if (text)
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
|
||||
BUFPUTSL(ob, "\n</ol>\n</div>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "\n</ol>\n</div>\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -564,7 +564,7 @@ rndr_footnote_def(hoedown_buffer *ob, const hoedown_buffer *text, unsigned int n
|
|||
} else if (text) {
|
||||
hoedown_buffer_put(ob, text->data, text->size);
|
||||
}
|
||||
BUFPUTSL(ob, "</li>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</li>\n");
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -589,23 +589,23 @@ toc_header(hoedown_buffer *ob, const hoedown_buffer *text, int level, void *opaq
|
|||
|
||||
if (level > options->toc_data.current_level) {
|
||||
while (level > options->toc_data.current_level) {
|
||||
BUFPUTSL(ob, "<ul>\n<li>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "<ul>\n<li>\n");
|
||||
options->toc_data.current_level++;
|
||||
}
|
||||
} else if (level < options->toc_data.current_level) {
|
||||
BUFPUTSL(ob, "</li>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</li>\n");
|
||||
while (level < options->toc_data.current_level) {
|
||||
BUFPUTSL(ob, "</ul>\n</li>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</ul>\n</li>\n");
|
||||
options->toc_data.current_level--;
|
||||
}
|
||||
BUFPUTSL(ob,"<li>\n");
|
||||
HOEDOWN_BUFPUTSL(ob,"<li>\n");
|
||||
} else {
|
||||
BUFPUTSL(ob,"</li>\n<li>\n");
|
||||
HOEDOWN_BUFPUTSL(ob,"</li>\n<li>\n");
|
||||
}
|
||||
|
||||
hoedown_buffer_printf(ob, "<a href=\"#toc_%d\">", options->toc_data.header_count++);
|
||||
if (text) escape_html(ob, text->data, text->size);
|
||||
BUFPUTSL(ob, "</a>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</a>\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -623,7 +623,7 @@ toc_finalize(hoedown_buffer *ob, void *opaque)
|
|||
hoedown_html_renderopt *options = opaque;
|
||||
|
||||
while (options->toc_data.current_level > 0) {
|
||||
BUFPUTSL(ob, "</li>\n</ul>\n");
|
||||
HOEDOWN_BUFPUTSL(ob, "</li>\n</ul>\n");
|
||||
options->toc_data.current_level--;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ smartypants_squote(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t pr
|
|||
/* Tom's, isn't, I'm, I'd */
|
||||
if ((t1 == 's' || t1 == 't' || t1 == 'm' || t1 == 'd') &&
|
||||
(size == 3 || word_boundary(text[2]))) {
|
||||
BUFPUTSL(ob, "’");
|
||||
HOEDOWN_BUFPUTSL(ob, "’");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ smartypants_squote(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t pr
|
|||
(t1 == 'l' && t2 == 'l') ||
|
||||
(t1 == 'v' && t2 == 'e')) &&
|
||||
(size == 4 || word_boundary(text[3]))) {
|
||||
BUFPUTSL(ob, "’");
|
||||
HOEDOWN_BUFPUTSL(ob, "’");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -170,17 +170,17 @@ smartypants_cb__parens(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_
|
|||
uint8_t t2 = tolower(text[2]);
|
||||
|
||||
if (t1 == 'c' && t2 == ')') {
|
||||
BUFPUTSL(ob, "©");
|
||||
HOEDOWN_BUFPUTSL(ob, "©");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (t1 == 'r' && t2 == ')') {
|
||||
BUFPUTSL(ob, "®");
|
||||
HOEDOWN_BUFPUTSL(ob, "®");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (size >= 4 && t1 == 't' && t2 == 'm' && text[3] == ')') {
|
||||
BUFPUTSL(ob, "™");
|
||||
HOEDOWN_BUFPUTSL(ob, "™");
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
@ -194,12 +194,12 @@ static size_t
|
|||
smartypants_cb__dash(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size)
|
||||
{
|
||||
if (size >= 3 && text[1] == '-' && text[2] == '-') {
|
||||
BUFPUTSL(ob, "—");
|
||||
HOEDOWN_BUFPUTSL(ob, "—");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (size >= 2 && text[1] == '-') {
|
||||
BUFPUTSL(ob, "–");
|
||||
HOEDOWN_BUFPUTSL(ob, "–");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -234,12 +234,12 @@ static size_t
|
|||
smartypants_cb__period(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size)
|
||||
{
|
||||
if (size >= 3 && text[1] == '.' && text[2] == '.') {
|
||||
BUFPUTSL(ob, "…");
|
||||
HOEDOWN_BUFPUTSL(ob, "…");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (size >= 5 && text[1] == ' ' && text[2] == '.' && text[3] == ' ' && text[4] == '.') {
|
||||
BUFPUTSL(ob, "…");
|
||||
HOEDOWN_BUFPUTSL(ob, "…");
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ smartypants_cb__number(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_
|
|||
if (word_boundary(previous_char) && size >= 3) {
|
||||
if (text[0] == '1' && text[1] == '/' && text[2] == '2') {
|
||||
if (size == 3 || word_boundary(text[3])) {
|
||||
BUFPUTSL(ob, "½");
|
||||
HOEDOWN_BUFPUTSL(ob, "½");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ smartypants_cb__number(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_
|
|||
if (text[0] == '1' && text[1] == '/' && text[2] == '4') {
|
||||
if (size == 3 || word_boundary(text[3]) ||
|
||||
(size >= 5 && tolower(text[3]) == 't' && tolower(text[4]) == 'h')) {
|
||||
BUFPUTSL(ob, "¼");
|
||||
HOEDOWN_BUFPUTSL(ob, "¼");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ smartypants_cb__number(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_
|
|||
if (text[0] == '3' && text[1] == '/' && text[2] == '4') {
|
||||
if (size == 3 || word_boundary(text[3]) ||
|
||||
(size >= 6 && tolower(text[3]) == 't' && tolower(text[4]) == 'h' && tolower(text[5]) == 's')) {
|
||||
BUFPUTSL(ob, "¾");
|
||||
HOEDOWN_BUFPUTSL(ob, "¾");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ static size_t
|
|||
smartypants_cb__dquote(hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size)
|
||||
{
|
||||
if (!smartypants_quotes(ob, previous_char, size > 0 ? text[1] : 0, 'd', &smrt->in_dquote))
|
||||
BUFPUTSL(ob, """);
|
||||
HOEDOWN_BUFPUTSL(ob, """);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -903,7 +903,7 @@ char_autolink_www(hoedown_buffer *ob, hoedown_markdown *rndr, uint8_t *data, siz
|
|||
|
||||
if ((link_len = hoedown_autolink__www(&rewind, link, data, offset, size, HOEDOWN_AUTOLINK_SHORT_DOMAINS)) > 0) {
|
||||
link_url = rndr_newbuf(rndr, BUFFER_SPAN);
|
||||
BUFPUTSL(link_url, "http://");
|
||||
HOEDOWN_BUFPUTSL(link_url, "http://");
|
||||
hoedown_buffer_put(link_url, link->data, link->size);
|
||||
|
||||
ob->size -= rewind;
|
||||
|
|
Loading…
Reference in a new issue