本文整理汇总了C++中bufputc函数的典型用法代码示例。如果您正苦于以下问题:C++ bufputc函数的具体用法?C++ bufputc怎么用?C++ bufputc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bufputc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rndr_raw_block
static void
rndr_raw_block(struct buf *ob, const struct buf *text, void *opaque)
{
size_t org, size;
struct html_renderopt *options = opaque;
if (!text)
return;
size = text->size;
while (size > 0 && text->data[size - 1] == '\n')
size--;
for (org = 0; org < size && text->data[org] == '\n'; ++org)
if (org >= size)
return;
/* Remove style tags if the `:no_styles` option is enabled */
if ((options->flags & HTML_SKIP_STYLE) != 0 &&
sdhtml_is_tag(text->data, size, "style"))
return;
if (ob->size)
bufputc(ob, '\n');
bufput(ob, text->data + org, size - org);
bufputc(ob, '\n');
}
示例2: rndr_link
static int
rndr_link(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *content, void *opaque)
{
struct html_renderopt *options = opaque;
if (link != NULL && (options->flags & HTML_SAFELINK) != 0 && !sd_autolink_issafe(link->data, link->size))
return 0;
BUFPUTSL(ob, "<a href=\"");
if (link && link->size)
escape_href(ob, link->data, link->size);
if (title && title->size) {
BUFPUTSL(ob, "\" title=\"");
escape_html(ob, title->data, title->size);
}
if (options->link_attributes) {
bufputc(ob, '\"');
options->link_attributes(ob, link, opaque);
bufputc(ob, '>');
} else {
BUFPUTSL(ob, "\">");
}
if (content && content->size) bufput(ob, content->data, content->size);
BUFPUTSL(ob, "</a>");
return 1;
}
示例3: parse_blockcode
/* parse_blockquote • hanldes parsing of a block-level code fragment */
static size_t
parse_blockcode(struct buf *ob, struct render *rndr,
char *data, size_t size) {
size_t beg, end, pre;
struct buf *work = new_work_buffer(rndr);
beg = 0;
while (beg < size) {
for (end = beg + 1; end < size && data[end - 1] != '\n';
end += 1);
pre = prefix_code(data + beg, end - beg);
if (pre) beg += pre; /* skipping prefix */
else if (!is_empty(data + beg, end - beg))
/* non-empty non-prefixed line breaks the pre */
break;
if (beg < end) {
/* verbatim copy to the working buffer,
escaping entities */
if (is_empty(data + beg, end - beg))
bufputc(work, '\n');
else bufput(work, data + beg, end - beg); }
beg = end; }
while (work->size && work->data[work->size - 1] == '\n')
work->size -= 1;
bufputc(work, '\n');
if (rndr->make.blockcode)
rndr->make.blockcode(ob, work, rndr->make.opaque);
release_work_buffer(rndr, work);
return beg; }
示例4: rndr_blockcode
static void
rndr_blockcode(struct buf *ob, const struct buf *text, const struct buf *lang, void *opaque)
{
if (ob->size) bufputc(ob, '\n');
if (lang && lang->size) {
size_t i, cls;
BUFPUTSL(ob, "<pre><code class=\"");
for (i = 0, cls = 0; i < lang->size; ++i, ++cls) {
while (i < lang->size && isspace(lang->data[i]))
i++;
if (i < lang->size) {
size_t org = i;
while (i < lang->size && !isspace(lang->data[i]))
i++;
if (lang->data[org] == '.')
org++;
if (cls) bufputc(ob, ' ');
escape_html(ob, lang->data + org, i - org);
}
}
BUFPUTSL(ob, "\">");
} else
BUFPUTSL(ob, "<pre><code>");
if (text)
escape_html(ob, text->data, text->size);
BUFPUTSL(ob, "</code></pre>\n");
}
示例5: houdini_escape_js
void
houdini_escape_js(struct buf *ob, const uint8_t *src, size_t size)
{
size_t i = 0, org, ch;
bufgrow(ob, ESCAPE_GROW_FACTOR(size));
while (i < size) {
org = i;
while (i < size && JS_ESCAPE[src[i]] == 0)
i++;
if (i > org)
bufput(ob, src + org, i - org);
/* escaping */
if (i >= size)
break;
ch = src[i];
switch (ch) {
case '/':
/*
* Escape only if preceded by a lt
*/
if (i && src[i - 1] == '<')
bufputc(ob, '\\');
bufputc(ob, ch);
break;
case '\r':
/*
* Escape as \n, and skip the next \n if it's there
*/
if (i + 1 < size && src[i + 1] == '\n') i++;
case '\n':
/*
* Escape actually as '\','n', not as '\', '\n'
*/
ch = 'n';
default:
/*
* Normal escaping
*/
bufputc(ob, '\\');
bufputc(ob, ch);
break;
}
i++;
}
}
示例6: rndr_raw_block
static void
rndr_raw_block(struct buf *ob, struct buf *text, void *opaque) {
size_t org, sz;
if (!text) return;
sz = text->size;
while (sz > 0 && text->data[sz - 1] == '\n') sz -= 1;
org = 0;
while (org < sz && text->data[org] == '\n') org += 1;
if (org >= sz) return;
if (ob->size) bufputc(ob, '\n');
bufput(ob, text->data + org, sz - org);
bufputc(ob, '\n'); }
示例7: rndr_list
static void
rndr_list(struct buf *ob, struct buf *text, int flags, void *opaque) {
if (ob->size) bufputc(ob, '\n');
bufput(ob, flags & MKD_LIST_ORDERED ? "<ol>\n" : "<ul>\n", 5);
if (text) bufput(ob, text->data, text->size);
bufput(ob, flags & MKD_LIST_ORDERED ? "</ol>\n" : "</ul>\n", 6);
}
示例8: rndr_header
static void
rndr_header(struct buf *ob, struct buf *text, int level, void *opaque) {
if (ob->size) bufputc(ob, '\n');
bufprintf(ob, "<h%d>", level);
if (text) bufput(ob, text->data, text->size);
bufprintf(ob, "</h%d>\n", level);
}
示例9: rndr_blockcode
static void
rndr_blockcode(struct buf *ob, struct buf *text, void *opaque) {
if (ob->size) bufputc(ob, '\n');
BUFPUTSL(ob, "<pre><code>");
if (text) lus_attr_escape(ob, text->data, text->size);
BUFPUTSL(ob, "</code></pre>\n");
}
示例10: rndr_hrule
static void
rndr_hrule(struct buf *ob, void *opaque)
{
struct html_renderopt *options = opaque;
if (ob->size) bufputc(ob, '\n');
bufputs(ob, USE_XHTML(options) ? "<hr/>\n" : "<hr>\n");
}
示例11: build_ref_id
/* build_ref_id • collapse whitespace from input text to make it a ref id */
static int
build_ref_id(struct buf *id, const char *data, size_t size) {
size_t beg, i;
/* skip leading whitespace */
while (size > 0
&& (data[0] == ' ' || data[0] == '\t' || data[0] == '\n')) {
data += 1;
size -= 1; }
/* skip trailing whitespace */
while (size > 0
&& (data[size - 1] == ' ' || data[size - 1] == '\t'
|| data[size - 1] == '\n'))
size -= 1;
if (size == 0) return -1;
/* making the ref id */
i = 0;
id->size = 0;
while (i < size) {
/* copy non-whitespace into the output buffer */
beg = i;
while (i < size
&& !(data[i] == ' ' || data[i] == '\t' || data[i] == '\n'))
i += 1;
bufput(id, data + beg, i - beg);
/* add a single space and skip all consecutive whitespace */
if (i < size) bufputc(id, ' ');
while (i < size
&& (data[i] == ' ' || data[i] == '\t' || data[i] == '\n'))
i += 1; }
return 0; }
示例12: smartypants_cb__number
static size_t
smartypants_cb__number(struct buf *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size)
{
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, "½");
return 2;
}
}
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, "¼");
return 2;
}
}
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, "¾");
return 2;
}
}
}
bufputc(ob, text[0]);
return 0;
}
示例13: houdini_escape_html0
void
houdini_escape_html0(struct buf *ob, const uint8_t *src, size_t size, int secure)
{
size_t i = 0, org, esc = 0;
bufgrow(ob, ESCAPE_GROW_FACTOR(size));
while (i < size) {
org = i;
while (i < size && (esc = HTML_ESCAPE_TABLE[src[i]]) == 0)
i++;
if (i > org)
bufput(ob, src + org, i - org);
/* escaping */
if (i >= size)
break;
/* The forward slash is only escaped in secure mode */
if (src[i] == '/' && !secure) {
bufputc(ob, '/');
} else if (HTML_ESCAPE_TABLE[src[i]] == 7) {
/* skip control characters */
} else {
bufputs(ob, HTML_ESCAPES[esc]);
}
i++;
}
}
示例14: rndr_blockcode_github
/*
* GitHub style code block:
*
* <pre lang="LANG"><code>
* ...
* </pre></code>
*
* Unlike other parsers, we store the language identifier in the <pre>,
* and don't let the user generate custom classes.
*
* The language identifier in the <pre> block gets postprocessed and all
* the code inside gets syntax highlighted with Pygments. This is much safer
* than letting the user specify a CSS class for highlighting.
*
* Note that we only generate HTML for the first specifier.
* E.g.
* ~~~~ {.python .numbered} => <pre lang="python"><code>
*/
static void
rndr_blockcode_github(struct buf *ob, struct buf *text, struct buf *lang, void *opaque)
{
if (ob->size) bufputc(ob, '\n');
if (lang && lang->size) {
size_t i = 0;
BUFPUTSL(ob, "<pre lang=\"");
while (i < lang->size && !isspace(lang->data[i]))
i++;
if (lang->data[0] == '.')
sdhtml_escape(ob, lang->data + 1, i - 1);
else
sdhtml_escape(ob, lang->data, i);
BUFPUTSL(ob, "\"><code>");
} else
BUFPUTSL(ob, "<pre><code>");
if (text)
sdhtml_escape(ob, text->data, text->size);
BUFPUTSL(ob, "</code></pre>\n");
}
示例15: rndr_blockcode_github
/*
* GitHub style code block:
*
* <pre lang="LANG"><code>
* ...
* </pre></code>
*
* Unlike other parsers, we store the language identifier in the <pre>,
* and don't let the user generate custom classes.
*
* The language identifier in the <pre> block gets postprocessed and all
* the code inside gets syntax highlighted with Pygments. This is much safer
* than letting the user specify a CSS class for highlighting.
*
* Note that we only generate HTML for the first specifier.
* E.g.
* ~~~~ {.python .numbered} => <pre lang="python"><code>
*/
static void
rndr_blockcode_github(struct buf *ob, struct buf *text, struct buf *lang, void *opaque)
{
if (ob->size) bufputc(ob, '\n');
if (lang && lang->size) {
size_t i = 0;
BUFPUTSL(ob, "<pre lang=\"");
for (; i < lang->size; ++i)
if (isspace(lang->data[i]))
break;
if (lang->data[0] == '.')
bufput(ob, lang->data + 1, i - 1);
else
bufput(ob, lang->data, i);
BUFPUTSL(ob, "\"><code>");
} else
BUFPUTSL(ob, "<pre><code>");
if (text)
attr_escape(ob, text->data, text->size);
BUFPUTSL(ob, "</code></pre>\n");
}