本文整理匯總了C++中BUFPUTSL函數的典型用法代碼示例。如果您正苦於以下問題:C++ BUFPUTSL函數的具體用法?C++ BUFPUTSL怎麽用?C++ BUFPUTSL使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BUFPUTSL函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: rndr_paragraph
static void
rndr_paragraph(struct buf *ob, struct buf *text, void *opaque)
{
struct xhtml_renderopt *options = opaque;
size_t i = 0;
if (ob->size) bufputc(ob, '\n');
if (!text || !text->size)
return;
while (i < text->size && isspace(text->data[i])) i++;
if (i == text->size)
return;
BUFPUTSL(ob, "<p>");
if (options->flags & XHTML_HARD_WRAP) {
size_t org;
while (i < text->size) {
org = i;
while (i < text->size && text->data[i] != '\n')
i++;
if (i > org)
bufput(ob, text->data + org, i - org);
if (i >= text->size)
break;
BUFPUTSL(ob, "<br/>\n");
i++;
}
} else {
bufput(ob, &text->data[i], text->size - i);
}
BUFPUTSL(ob, "</p>\n");
/* Close any open quotes at the end of the paragraph */
options->quotes.in_squote = 0;
options->quotes.in_dquote = 0;
}
示例2: rndr_paragraph
static void
rndr_paragraph(struct buf *ob, const struct buf *text, void *opaque)
{
struct html_renderopt *options = opaque;
size_t i = 0;
if (ob->size) bufputc(ob, '\n');
if (!text || !text->size)
return;
while (i < text->size && isspace(text->data[i])) i++;
if (i == text->size)
return;
BUFPUTSL(ob, "<p>");
if (options->flags & HTML_HARD_WRAP) {
size_t org;
while (i < text->size) {
org = i;
while (i < text->size && text->data[i] != '\n')
i++;
if (i > org)
bufput(ob, text->data + org, i - org);
/*
* do not insert a line break if this newline
* is the last character on the paragraph
*/
if (i >= text->size - 1)
break;
rndr_linebreak(ob, opaque);
i++;
}
} else {
bufput(ob, &text->data[i], text->size - i);
}
BUFPUTSL(ob, "</p>\n");
}
示例3: latex_header
static void
latex_header(struct buf *ob, struct buf *text, int level, void *opaque) {
if (ob->size) bufputc(ob, '\n');
switch(level) {
case 1:
BUFPUTSL(ob,"\\section{");
break;
case 2:
BUFPUTSL(ob, "\\subsection{");
break;
case 3:
BUFPUTSL(ob, "\\subsubsection{");
break;
default:
fprintf(stderr, "Warning: ignoring header level %d\n",
level);
}
if (text) bufput(ob, text->data, text->size);
if (level >= 1 && level <= 3) BUFPUTSL(ob, "}\n");
}
示例4: rndr_image
static int
rndr_image(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *alt, void *opaque)
{
struct html_renderopt *options = opaque;
if (!link || !link->size) return 0;
BUFPUTSL(ob, "<img src=\"");
escape_href(ob, link->data, link->size);
BUFPUTSL(ob, "\" alt=\"");
if (alt && alt->size)
escape_html(ob, alt->data, alt->size);
if (title && title->size) {
BUFPUTSL(ob, "\" title=\"");
escape_html(ob, title->data, title->size); }
bufputs(ob, USE_XHTML(options) ? "\"/>" : "\">");
return 1;
}
示例5: rndr_autolink
/********************
* GENERIC RENDERER *
********************/
static int
rndr_autolink(struct buf *ob, const struct buf *link, enum mkd_autolink type, void *opaque)
{
struct html_renderopt *options = opaque;
if (!link || !link->size)
return 0;
if ((options->flags & HTML_SAFELINK) != 0 &&
!sd_autolink_issafe(link->data, link->size) &&
type != MKDA_EMAIL)
return 0;
BUFPUTSL(ob, "<a href=\"");
if (type == MKDA_EMAIL)
BUFPUTSL(ob, "mailto:");
escape_href(ob, link->data, link->size);
if (options->link_attributes) {
bufputc(ob, '\"');
options->link_attributes(ob, link, opaque);
bufputc(ob, '>');
} else {
BUFPUTSL(ob, "\">");
}
/*
* Pretty printing: if we get an email address as
* an actual URI, e.g. `mailto:[email protected]`, we don't
* want to print the `mailto:` prefix
*/
if (bufprefix(link, "mailto:") == 0) {
escape_html(ob, link->data + 7, link->size - 7);
} else {
escape_html(ob, link->data, link->size);
}
BUFPUTSL(ob, "</a>");
return 1;
}
示例6: snudown_link_attr
static void
snudown_link_attr(struct buf *ob, const struct buf *link, void *opaque)
{
struct snudown_renderopt *options = opaque;
if (options->nofollow)
BUFPUTSL(ob, " rel=\"nofollow\"");
/* If we have an option, if it is "_blank" which means to open a
new tab, then we should check to make sure the item is not
on the lightnet domain before outputting the target. We don't
want to open new windows for links within the lightnet.is domain. */
if (options->target != NULL &&
(strcmp(options->target, "_blank") != 0 ||
strstr((const char*) link->data, options->domain) == 0) ) {
BUFPUTSL(ob, " target=\"");
bufputs(ob, options->target);
bufputc(ob, '\"');
}
}
示例7: toc_header
static void
toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
{
struct html_renderopt *options = opaque;
/* set the level offset if this is the first header
* we're parsing for the document */
if (options->toc_data.current_level == 0) {
options->toc_data.level_offset = level - 1;
}
level -= options->toc_data.level_offset;
if (level > options->toc_data.current_level) {
while (level > options->toc_data.current_level) {
BUFPUTSL(ob, "<ul>\n<li>\n");
options->toc_data.current_level++;
}
} else if (level < options->toc_data.current_level) {
BUFPUTSL(ob, "</li>\n");
while (level < options->toc_data.current_level) {
BUFPUTSL(ob, "</ul>\n</li>\n");
options->toc_data.current_level--;
}
BUFPUTSL(ob,"<li>\n");
} else {
BUFPUTSL(ob,"</li>\n<li>\n");
}
bufprintf(ob, "<a href=\"#toc_%d\">", options->toc_data.header_count++);
if (text)
escape_html(ob, text->data, text->size);
BUFPUTSL(ob, "</a>\n");
}
示例8: toc_header
static void
toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
{
struct html_renderopt *options = opaque;
if (level > options->toc_data.current_level) {
while (level > options->toc_data.current_level) {
BUFPUTSL(ob, "<ul>\n<li>\n");
options->toc_data.current_level++;
}
} else if (level < options->toc_data.current_level) {
BUFPUTSL(ob, "</li>\n");
while (level < options->toc_data.current_level) {
BUFPUTSL(ob, "</ul>\n</li>\n");
options->toc_data.current_level--;
}
BUFPUTSL(ob,"<li>\n");
} else {
BUFPUTSL(ob,"</li>\n<li>\n");
}
bufprintf(ob, "<a href=\"#toc_%d\">", options->toc_data.header_count++);
if (text)
bufput(ob, text->data, text->size);
BUFPUTSL(ob, "</a>\n");
}
示例9: smartypants_cb__dash
static size_t
smartypants_cb__dash(struct buf *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, "—");
return 2;
}
if (size >= 2 && text[1] == '-') {
if(size >= 4 && (previous_char == '>' || previous_char == '\n') && text[2] == ' ' && text[3] == '<') {
// A hack to avoid '-- ' being converted to an ndash.
}
else
{
BUFPUTSL(ob, "–");
return 1;
}
}
bufputc(ob, text[0]);
return 0;
}
示例10: nat_paragraph
static void
nat_paragraph(struct buf *ob, struct buf *text, void *opaque) {
size_t i = 0;
if (ob->size) bufputc(ob, '\n');
BUFPUTSL(ob, "<p");
if (text && text->size && text->data[0] == '(') {
i = 1;
while (i < text->size && (text->data[i] == ' '
/* this seems to be a bit more restrictive than */
/* what is allowed for class names */
|| (text->data[i] >= 'a' && text->data[i] <= 'z')
|| (text->data[i] >= 'A' && text->data[i] <= 'Z')
|| (text->data[i] >= '0' && text->data[i] <= '0')))
i += 1;
if (i < text->size && text->data[i] == ')') {
bufprintf(ob, " class=\"%.*s\"",
(int)(i - 1), text->data + 1);
i += 1; }
else i = 0; }
bufputc(ob, '>');
if (text) bufput(ob, text->data + i, text->size - i);
BUFPUTSL(ob, "</p>\n"); }
示例11: rndr_image
static int
rndr_image(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *alt, 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, "<img src=\"");
escape_href(ob, link->data, link->size);
BUFPUTSL(ob, "\" alt=\"");
if (alt && alt->size)
escape_html(ob, alt->data, alt->size);
if (title && title->size) {
BUFPUTSL(ob, "\" title=\"");
escape_html(ob, title->data, title->size); }
bufputs(ob, USE_XHTML(options) ? "\"/>" : "\">");
return 1;
}
示例12: rndr_paragraph
static void
rndr_paragraph(struct buf *ob, struct buf *text, void *opaque)
{
struct html_renderopt *options = opaque;
size_t i = 0;
if (ob->size) bufputc(ob, '\n');
if (!text || !text->size)
return;
while (i < text->size && isspace(text->data[i])) i++;
if (i == text->size)
return;
BUFPUTSL(ob, "<p>");
if (options->flags & HTML_HARD_WRAP) {
size_t org;
while (i < text->size) {
org = i;
while (i < text->size && text->data[i] != '\n')
i++;
if (i > org)
bufput(ob, text->data + org, i - org);
if (i >= text->size)
break;
BUFPUTSL(ob, "<br");
bufputs(ob, options->close_tag);
i++;
}
} else {
bufput(ob, &text->data[i], text->size - i);
}
BUFPUTSL(ob, "</p>\n");
}
示例13: toc_header
static void
toc_header(struct buf *ob, struct buf *text, int level, void *opaque)
{
struct xhtml_renderopt *options = opaque;
if (level > options->toc_data.current_level) {
if (level > 1)
BUFPUTSL(ob, "<li>");
BUFPUTSL(ob, "<ul>\n");
}
if (level < options->toc_data.current_level) {
BUFPUTSL(ob, "</ul>");
if (options->toc_data.current_level > 1)
BUFPUTSL(ob, "</li>\n");
}
options->toc_data.current_level = level;
bufprintf(ob, "<li><a href=\"#toc_%d\">", options->toc_data.header_count++);
if (text)
bufput(ob, text->data, text->size);
BUFPUTSL(ob, "</a></li>\n");
}
示例14: smartypants_cb__squote
static size_t
smartypants_cb__squote(struct buf *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size)
{
if (size >= 2) {
uint8_t t1 = tolower(text[1]);
if (t1 == '\'') {
if (smartypants_quotes(ob, previous_char, size >= 3 ? text[2] : 0, 'd', &smrt->in_dquote))
return 1;
}
if ((t1 == 's' || t1 == 't' || t1 == 'm' || t1 == 'd') &&
(size == 3 || word_boundary(text[2]))) {
BUFPUTSL(ob, "’");
return 0;
}
if (size >= 3) {
uint8_t t2 = tolower(text[2]);
if (((t1 == 'r' && t2 == 'e') ||
(t1 == 'l' && t2 == 'l') ||
(t1 == 'v' && t2 == 'e')) &&
(size == 4 || word_boundary(text[3]))) {
BUFPUTSL(ob, "’");
return 0;
}
}
}
if (smartypants_quotes(ob, previous_char, size > 0 ? text[1] : 0, 's', &smrt->in_squote))
return 0;
bufputc(ob, text[0]);
return 0;
}
示例15: print_link_wxh
static int
print_link_wxh(struct buf *ob, struct buf *link) {
size_t eq, ex, end;
eq = link->size - 1;
while (eq > 0 && (link->data[eq - 1] != ' ' || link->data[eq] != '='))
eq -= 1;
if (eq <= 0) return 0;
ex = eq + 1;
while (ex < link->size
&& link->data[ex] >= '0' && link->data[ex] <= '9')
ex += 1;
if (ex >= link->size || ex == eq + 1 || link->data[ex] != 'x') return 0;
end = ex + 1;
while (end < link->size
&& link->data[end] >= '0' && link->data[end] <= '9')
end += 1;
if (end == ex + 1) return 0;
/* everything is fine, proceeding to actual printing */
lus_attr_escape(ob, link->data, eq - 1);
BUFPUTSL(ob, "\" width=");
bufput(ob, link->data + eq + 1, ex - eq - 1);
BUFPUTSL(ob, " height=");
bufput(ob, link->data + ex + 1, end - ex - 1);
return 1; }