BEHOLD! Their HTML_ brothers followed!
This commit is contained in:
parent
2bb26718f0
commit
241c2fb5f3
3 changed files with 40 additions and 40 deletions
44
src/html.c
44
src/html.c
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "escape.h"
|
||||
|
||||
#define USE_XHTML(opt) (opt->flags & HTML_USE_XHTML)
|
||||
#define USE_XHTML(opt) (opt->flags & HOEDOWN_HTML_USE_XHTML)
|
||||
|
||||
int
|
||||
hoedown_html_is_tag(const uint8_t *tag_data, size_t tag_size, const char *tagname)
|
||||
|
@ -16,7 +16,7 @@ hoedown_html_is_tag(const uint8_t *tag_data, size_t tag_size, const char *tagnam
|
|||
int closed = 0;
|
||||
|
||||
if (tag_size < 3 || tag_data[0] != '<')
|
||||
return HTML_TAG_NONE;
|
||||
return HOEDOWN_HTML_TAG_NONE;
|
||||
|
||||
i = 1;
|
||||
|
||||
|
@ -30,16 +30,16 @@ hoedown_html_is_tag(const uint8_t *tag_data, size_t tag_size, const char *tagnam
|
|||
break;
|
||||
|
||||
if (tag_data[i] != *tagname)
|
||||
return HTML_TAG_NONE;
|
||||
return HOEDOWN_HTML_TAG_NONE;
|
||||
}
|
||||
|
||||
if (i == tag_size)
|
||||
return HTML_TAG_NONE;
|
||||
return HOEDOWN_HTML_TAG_NONE;
|
||||
|
||||
if (isspace(tag_data[i]) || tag_data[i] == '>')
|
||||
return closed ? HTML_TAG_CLOSE : HTML_TAG_OPEN;
|
||||
return closed ? HOEDOWN_HTML_TAG_CLOSE : HOEDOWN_HTML_TAG_OPEN;
|
||||
|
||||
return HTML_TAG_NONE;
|
||||
return HOEDOWN_HTML_TAG_NONE;
|
||||
}
|
||||
|
||||
static inline void escape_html(struct hoedown_buffer *ob, const uint8_t *source, size_t length)
|
||||
|
@ -63,7 +63,7 @@ rndr_autolink(struct hoedown_buffer *ob, const struct hoedown_buffer *link, enum
|
|||
if (!link || !link->size)
|
||||
return 0;
|
||||
|
||||
if ((options->flags & HTML_SAFELINK) != 0 &&
|
||||
if ((options->flags & HOEDOWN_HTML_SAFELINK) != 0 &&
|
||||
!hoedown_autolink_issafe(link->data, link->size) &&
|
||||
type != HOEDOWN_AUTOLINK_EMAIL)
|
||||
return 0;
|
||||
|
@ -106,7 +106,7 @@ rndr_blockcode(struct hoedown_buffer *ob, const struct hoedown_buffer *text, con
|
|||
|
||||
if (lang && lang->size) {
|
||||
size_t i, cls = 0;
|
||||
if (options->flags & HTML_PRETTIFY) {
|
||||
if (options->flags & HOEDOWN_HTML_PRETTIFY) {
|
||||
BUFPUTSL(ob, "<pre><code class=\"prettyprint");
|
||||
cls++;
|
||||
} else {
|
||||
|
@ -131,7 +131,7 @@ rndr_blockcode(struct hoedown_buffer *ob, const struct hoedown_buffer *text, con
|
|||
}
|
||||
|
||||
BUFPUTSL(ob, "\">");
|
||||
} else if (options->flags & HTML_PRETTIFY) {
|
||||
} else if (options->flags & HOEDOWN_HTML_PRETTIFY) {
|
||||
BUFPUTSL(ob, "<pre><code class=\"prettyprint\">");
|
||||
} else {
|
||||
BUFPUTSL(ob, "<pre><code>");
|
||||
|
@ -156,7 +156,7 @@ static int
|
|||
rndr_codespan(struct hoedown_buffer *ob, const struct hoedown_buffer *text, void *opaque)
|
||||
{
|
||||
struct hoedown_html_renderopt *options = opaque;
|
||||
if (options->flags & HTML_PRETTIFY)
|
||||
if (options->flags & HOEDOWN_HTML_PRETTIFY)
|
||||
BUFPUTSL(ob, "<code class=\"prettyprint\">");
|
||||
else
|
||||
BUFPUTSL(ob, "<code>");
|
||||
|
@ -255,7 +255,7 @@ rndr_header(struct hoedown_buffer *ob, const struct hoedown_buffer *text, int le
|
|||
if (ob->size)
|
||||
hoedown_buffer_putc(ob, '\n');
|
||||
|
||||
if ((options->flags & HTML_TOC) && (level <= options->toc_data.nesting_level))
|
||||
if ((options->flags & HOEDOWN_HTML_TOC) && (level <= options->toc_data.nesting_level))
|
||||
hoedown_buffer_printf(ob, "<h%d id=\"toc_%d\">", level, options->toc_data.header_count++);
|
||||
else
|
||||
hoedown_buffer_printf(ob, "<h%d>", level);
|
||||
|
@ -269,7 +269,7 @@ rndr_link(struct hoedown_buffer *ob, const struct hoedown_buffer *link, const st
|
|||
{
|
||||
struct hoedown_html_renderopt *options = opaque;
|
||||
|
||||
if (link != NULL && (options->flags & HTML_SAFELINK) != 0 && !hoedown_autolink_issafe(link->data, link->size))
|
||||
if (link != NULL && (options->flags & HOEDOWN_HTML_SAFELINK) != 0 && !hoedown_autolink_issafe(link->data, link->size))
|
||||
return 0;
|
||||
|
||||
BUFPUTSL(ob, "<a href=\"");
|
||||
|
@ -335,7 +335,7 @@ rndr_paragraph(struct hoedown_buffer *ob, const struct hoedown_buffer *text, voi
|
|||
return;
|
||||
|
||||
BUFPUTSL(ob, "<p>");
|
||||
if (options->flags & HTML_HARD_WRAP) {
|
||||
if (options->flags & HOEDOWN_HTML_HARD_WRAP) {
|
||||
size_t org;
|
||||
while (i < text->size) {
|
||||
org = i;
|
||||
|
@ -422,23 +422,23 @@ rndr_raw_html(struct hoedown_buffer *ob, const struct hoedown_buffer *text, void
|
|||
|
||||
/* HTML_ESCAPE overrides SKIP_HTML, SKIP_STYLE, SKIP_LINKS and SKIP_IMAGES
|
||||
* It doens't see if there are any valid tags, just escape all of them. */
|
||||
if((options->flags & HTML_ESCAPE) != 0) {
|
||||
if((options->flags & HOEDOWN_HTML_ESCAPE) != 0) {
|
||||
escape_html(ob, text->data, text->size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((options->flags & HTML_SKIP_HTML) != 0)
|
||||
if ((options->flags & HOEDOWN_HTML_SKIP_HTML) != 0)
|
||||
return 1;
|
||||
|
||||
if ((options->flags & HTML_SKIP_STYLE) != 0 &&
|
||||
if ((options->flags & HOEDOWN_HTML_SKIP_STYLE) != 0 &&
|
||||
hoedown_html_is_tag(text->data, text->size, "style"))
|
||||
return 1;
|
||||
|
||||
if ((options->flags & HTML_SKIP_LINKS) != 0 &&
|
||||
if ((options->flags & HOEDOWN_HTML_SKIP_LINKS) != 0 &&
|
||||
hoedown_html_is_tag(text->data, text->size, "a"))
|
||||
return 1;
|
||||
|
||||
if ((options->flags & HTML_SKIP_IMAGES) != 0 &&
|
||||
if ((options->flags & HOEDOWN_HTML_SKIP_IMAGES) != 0 &&
|
||||
hoedown_html_is_tag(text->data, text->size, "img"))
|
||||
return 1;
|
||||
|
||||
|
@ -670,7 +670,7 @@ hoedown_html_toc_renderer(struct hoedown_callbacks *callbacks, struct hoedown_ht
|
|||
};
|
||||
|
||||
memset(options, 0x0, sizeof(struct hoedown_html_renderopt));
|
||||
options->flags = HTML_TOC;
|
||||
options->flags = HOEDOWN_HTML_TOC;
|
||||
options->toc_data.nesting_level = nesting_level;
|
||||
|
||||
memcpy(callbacks, &cb_default, sizeof(struct hoedown_callbacks));
|
||||
|
@ -724,14 +724,14 @@ hoedown_html_renderer(struct hoedown_callbacks *callbacks, struct hoedown_html_r
|
|||
/* Prepare the callbacks */
|
||||
memcpy(callbacks, &cb_default, sizeof(struct hoedown_callbacks));
|
||||
|
||||
if (render_flags & HTML_SKIP_IMAGES)
|
||||
if (render_flags & HOEDOWN_HTML_SKIP_IMAGES)
|
||||
callbacks->image = NULL;
|
||||
|
||||
if (render_flags & HTML_SKIP_LINKS) {
|
||||
if (render_flags & HOEDOWN_HTML_SKIP_LINKS) {
|
||||
callbacks->link = NULL;
|
||||
callbacks->autolink = NULL;
|
||||
}
|
||||
|
||||
if (render_flags & HTML_SKIP_HTML || render_flags & HTML_ESCAPE)
|
||||
if (render_flags & HOEDOWN_HTML_SKIP_HTML || render_flags & HOEDOWN_HTML_ESCAPE)
|
||||
callbacks->blockhtml = NULL;
|
||||
}
|
||||
|
|
32
src/html.h
32
src/html.h
|
@ -26,24 +26,24 @@ struct hoedown_html_renderopt {
|
|||
};
|
||||
|
||||
typedef enum {
|
||||
HTML_SKIP_HTML = (1 << 0),
|
||||
HTML_SKIP_STYLE = (1 << 1),
|
||||
HTML_SKIP_IMAGES = (1 << 2),
|
||||
HTML_SKIP_LINKS = (1 << 3),
|
||||
HTML_EXPAND_TABS = (1 << 4),
|
||||
HTML_SAFELINK = (1 << 5),
|
||||
HTML_TOC = (1 << 6),
|
||||
HTML_HARD_WRAP = (1 << 7),
|
||||
HTML_USE_XHTML = (1 << 8),
|
||||
HTML_ESCAPE = (1 << 9),
|
||||
HTML_PRETTIFY = (1 << 10),
|
||||
} html_render_mode;
|
||||
HOEDOWN_HTML_SKIP_HTML = (1 << 0),
|
||||
HOEDOWN_HTML_SKIP_STYLE = (1 << 1),
|
||||
HOEDOWN_HTML_SKIP_IMAGES = (1 << 2),
|
||||
HOEDOWN_HTML_SKIP_LINKS = (1 << 3),
|
||||
HOEDOWN_HTML_EXPAND_TABS = (1 << 4),
|
||||
HOEDOWN_HTML_SAFELINK = (1 << 5),
|
||||
HOEDOWN_HTML_TOC = (1 << 6),
|
||||
HOEDOWN_HTML_HARD_WRAP = (1 << 7),
|
||||
HOEDOWN_HTML_USE_XHTML = (1 << 8),
|
||||
HOEDOWN_HTML_ESCAPE = (1 << 9),
|
||||
HOEDOWN_HTML_PRETTIFY = (1 << 10),
|
||||
} hoedown_html_render_mode;
|
||||
|
||||
typedef enum {
|
||||
HTML_TAG_NONE = 0,
|
||||
HTML_TAG_OPEN,
|
||||
HTML_TAG_CLOSE,
|
||||
} html_tag;
|
||||
HOEDOWN_HTML_TAG_NONE = 0,
|
||||
HOEDOWN_HTML_TAG_OPEN,
|
||||
HOEDOWN_HTML_TAG_CLOSE,
|
||||
} hoedown_html_tag;
|
||||
|
||||
int
|
||||
hoedown_html_is_tag(const uint8_t *tag_data, size_t tag_size, const char *tagname);
|
||||
|
|
|
@ -312,7 +312,7 @@ smartypants_cb__ltag(struct hoedown_buffer *ob, struct smartypants_data *smrt, u
|
|||
i++;
|
||||
|
||||
for (tag = 0; tag < skip_tags_count; ++tag) {
|
||||
if (hoedown_html_is_tag(text, size, skip_tags[tag]) == HTML_TAG_OPEN)
|
||||
if (hoedown_html_is_tag(text, size, skip_tags[tag]) == HOEDOWN_HTML_TAG_OPEN)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ smartypants_cb__ltag(struct hoedown_buffer *ob, struct smartypants_data *smrt, u
|
|||
if (i == size)
|
||||
break;
|
||||
|
||||
if (hoedown_html_is_tag(text + i, size - i, skip_tags[tag]) == HTML_TAG_CLOSE)
|
||||
if (hoedown_html_is_tag(text + i, size - i, skip_tags[tag]) == HOEDOWN_HTML_TAG_CLOSE)
|
||||
break;
|
||||
|
||||
i++;
|
||||
|
|
Loading…
Reference in a new issue