summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c20
-rw-r--r--src/cmark.h14
-rw-r--r--src/commonmark.c2
-rw-r--r--src/html.c12
-rw-r--r--src/latex.c2
-rw-r--r--src/man.c2
-rw-r--r--src/node.c12
-rw-r--r--src/node.h4
-rw-r--r--src/scanners.c60
-rw-r--r--src/scanners.h8
-rw-r--r--src/scanners.re8
-rw-r--r--src/xml.c2
12 files changed, 79 insertions, 67 deletions
diff --git a/src/blocks.c b/src/blocks.c
index 45831a6..a943303 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -208,7 +208,7 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
b->end_column = parser->last_line_length;
} else if (b->type == CMARK_NODE_DOCUMENT ||
(b->type == CMARK_NODE_CODE_BLOCK && b->as.code.fenced) ||
- (b->type == CMARK_NODE_HEADER && b->as.header.setext)) {
+ (b->type == CMARK_NODE_HEADER && b->as.heading.setext)) {
b->end_line = parser->line_number;
b->end_column = parser->curline->size;
if (b->end_column && parser->curline->ptr[b->end_column - 1] == '\n')
@@ -687,7 +687,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
}
} else if (container->type == CMARK_NODE_HEADER) {
- // a header can never contain more than one line
+ // a heading can never contain more than one line
all_matched = false;
} else if (container->type == CMARK_NODE_HTML) {
@@ -750,7 +750,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
container = add_child(parser, container, CMARK_NODE_BLOCK_QUOTE,
parser->offset + 1);
- } else if (!indented && (matched = scan_atx_header_start(
+ } else if (!indented && (matched = scan_atx_heading_start(
&input, parser->first_nonspace))) {
S_advance_offset(parser, &input,
@@ -767,8 +767,8 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
level++;
hashpos++;
}
- container->as.header.level = level;
- container->as.header.setext = false;
+ container->as.heading.level = level;
+ container->as.heading.setext = false;
} else if (!indented && (matched = scan_open_code_fence(
&input, parser->first_nonspace))) {
@@ -799,22 +799,22 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
} else if (!indented && container->type == CMARK_NODE_PARAGRAPH &&
(lev =
- scan_setext_header_line(&input, parser->first_nonspace)) &&
+ scan_setext_heading_line(&input, parser->first_nonspace)) &&
// check that there is only one line in the paragraph:
(cmark_strbuf_strrchr(
&container->string_content, '\n',
cmark_strbuf_len(&container->string_content) - 2) < 0)) {
container->type = CMARK_NODE_HEADER;
- container->as.header.level = lev;
- container->as.header.setext = true;
+ container->as.heading.level = lev;
+ container->as.heading.setext = true;
S_advance_offset(parser, &input, input.len - 1 - parser->offset, false);
} else if (!indented &&
!(container->type == CMARK_NODE_PARAGRAPH && !all_matched) &&
(matched = scan_hrule(&input, parser->first_nonspace))) {
- // it's only now that we know the line is not part of a setext header:
+ // it's only now that we know the line is not part of a setext heading:
container = add_child(parser, container, CMARK_NODE_HRULE,
parser->first_nonspace + 1);
S_advance_offset(parser, &input, input.len - 1 - parser->offset, false);
@@ -981,7 +981,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
} else if (accepts_lines(container->type)) {
if (container->type == CMARK_NODE_HEADER &&
- container->as.header.setext == false) {
+ container->as.heading.setext == false) {
chop_trailing_hashtags(&input);
}
add_line(container, &input, parser->first_nonspace);
diff --git a/src/cmark.h b/src/cmark.h
index ae00e86..ec36e02 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -141,7 +141,7 @@ CMARK_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
* One natural application is an HTML renderer, where an `ENTER` event
* outputs an open tag and an `EXIT` event outputs a close tag.
* An iterator might also be used to transform an AST in some systematic
- * way, for example, turning all level-3 headers into regular paragraphs.
+ * way, for example, turning all level-3 headings into regular paragraphs.
*
* void
* usage_example(cmark_node *root) {
@@ -245,13 +245,17 @@ CMARK_EXPORT const char *cmark_node_get_literal(cmark_node *node);
*/
CMARK_EXPORT int cmark_node_set_literal(cmark_node *node, const char *content);
-/** Returns the header level of 'node', or 0 if 'node' is not a header.
+/** Returns the heading level of 'node', or 0 if 'node' is not a heading.
*/
-CMARK_EXPORT int cmark_node_get_header_level(cmark_node *node);
+CMARK_EXPORT int cmark_node_get_heading_level(cmark_node *node);
-/** Sets the header level of 'node', returning 1 on success and 0 on error.
+/* For backwards compatibility */
+#define cmark_node_get_header_level cmark_node_get_heading_level
+#define cmark_node_set_header_level cmark_node_set_heading_level
+
+/** Sets the heading level of 'node', returning 1 on success and 0 on error.
*/
-CMARK_EXPORT int cmark_node_set_header_level(cmark_node *node, int level);
+CMARK_EXPORT int cmark_node_set_heading_level(cmark_node *node, int level);
/** Returns the list type of 'node', or `CMARK_NO_LIST` if 'node'
* is not a list.
diff --git a/src/commonmark.c b/src/commonmark.c
index 7dabbc3..57a8747 100644
--- a/src/commonmark.c
+++ b/src/commonmark.c
@@ -230,7 +230,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
case CMARK_NODE_HEADER:
if (entering) {
- for (i = cmark_node_get_header_level(node); i > 0; i--) {
+ for (i = cmark_node_get_heading_level(node); i > 0; i--) {
LIT("#");
}
LIT(" ");
diff --git a/src/html.c b/src/html.c
index 8daf574..beda214 100644
--- a/src/html.c
+++ b/src/html.c
@@ -43,8 +43,8 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
cmark_node *parent;
cmark_node *grandparent;
cmark_strbuf *html = state->html;
- char start_header[] = "<h0";
- char end_header[] = "</h0";
+ char start_heading[] = "<h0";
+ char end_heading[] = "</h0";
bool tight;
char buffer[100];
@@ -130,13 +130,13 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
case CMARK_NODE_HEADER:
if (entering) {
cr(html);
- start_header[2] = (char)('0' + node->as.header.level);
- cmark_strbuf_puts(html, start_header);
+ start_heading[2] = (char)('0' + node->as.heading.level);
+ cmark_strbuf_puts(html, start_heading);
S_render_sourcepos(node, html, options);
cmark_strbuf_putc(html, '>');
} else {
- end_header[3] = (char)('0' + node->as.header.level);
- cmark_strbuf_puts(html, end_header);
+ end_heading[3] = (char)('0' + node->as.heading.level);
+ cmark_strbuf_puts(html, end_heading);
cmark_strbuf_puts(html, ">\n");
}
break;
diff --git a/src/latex.c b/src/latex.c
index d0c5a9c..6d3c4af 100644
--- a/src/latex.c
+++ b/src/latex.c
@@ -266,7 +266,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
case CMARK_NODE_HEADER:
if (entering) {
- switch (cmark_node_get_header_level(node)) {
+ switch (cmark_node_get_heading_level(node)) {
case 1:
LIT("\\section");
break;
diff --git a/src/man.c b/src/man.c
index 941a06c..42f6e4a 100644
--- a/src/man.c
+++ b/src/man.c
@@ -123,7 +123,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
case CMARK_NODE_HEADER:
if (entering) {
CR();
- LIT(cmark_node_get_header_level(node) == 1 ? ".SH" : ".SS");
+ LIT(cmark_node_get_heading_level(node) == 1 ? ".SH" : ".SS");
CR();
} else {
CR();
diff --git a/src/node.c b/src/node.c
index 8b358ce..ea0913b 100644
--- a/src/node.c
+++ b/src/node.c
@@ -74,7 +74,7 @@ cmark_node *cmark_node_new(cmark_node_type type) {
switch (node->type) {
case CMARK_NODE_HEADER:
- node->as.header.level = 1;
+ node->as.heading.level = 1;
break;
case CMARK_NODE_LIST: {
@@ -173,7 +173,7 @@ const char *cmark_node_get_type_string(cmark_node *node) {
case CMARK_NODE_PARAGRAPH:
return "paragraph";
case CMARK_NODE_HEADER:
- return "header";
+ return "heading";
case CMARK_NODE_HRULE:
return "hrule";
case CMARK_NODE_TEXT:
@@ -303,14 +303,14 @@ int cmark_node_set_literal(cmark_node *node, const char *content) {
return 0;
}
-int cmark_node_get_header_level(cmark_node *node) {
+int cmark_node_get_heading_level(cmark_node *node) {
if (node == NULL) {
return 0;
}
switch (node->type) {
case CMARK_NODE_HEADER:
- return node->as.header.level;
+ return node->as.heading.level;
default:
break;
@@ -319,14 +319,14 @@ int cmark_node_get_header_level(cmark_node *node) {
return 0;
}
-int cmark_node_set_header_level(cmark_node *node, int level) {
+int cmark_node_set_heading_level(cmark_node *node, int level) {
if (node == NULL || level < 1 || level > 6) {
return 0;
}
switch (node->type) {
case CMARK_NODE_HEADER:
- node->as.header.level = level;
+ node->as.heading.level = level;
return 1;
default:
diff --git a/src/node.h b/src/node.h
index cc93d23..397d8e3 100644
--- a/src/node.h
+++ b/src/node.h
@@ -35,7 +35,7 @@ typedef struct {
typedef struct {
int level;
bool setext;
-} cmark_header;
+} cmark_heading;
typedef struct {
cmark_chunk url;
@@ -72,7 +72,7 @@ struct cmark_node {
cmark_chunk literal;
cmark_list list;
cmark_code code;
- cmark_header header;
+ cmark_heading heading;
cmark_link link;
cmark_custom custom;
int html_block_type;
diff --git a/src/scanners.c b/src/scanners.c
index d9f998f..2d5796f 100644
--- a/src/scanners.c
+++ b/src/scanners.c
@@ -15128,37 +15128,45 @@ bufsize_t _scan_html_tag(const unsigned char *p) {
unsigned char yych;
static const unsigned char yybm[] = {
/* table 1 .. 8: 0 */
- 0, 230, 230, 230, 230, 230, 230, 230, 230, 199, 199, 199, 199, 199, 230,
+ 0, 230, 230, 230, 230, 230, 230, 230, 230, 199, 199, 199, 199, 199,
230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
- 230, 230, 230, 199, 230, 70, 230, 230, 230, 230, 134, 230, 230, 230,
- 230, 230, 254, 246, 230, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 246, 230, 198, 198, 196, 230, 230, 254, 254, 254, 254, 254, 254,
+ 230, 230, 230, 230, 199, 230, 70, 230, 230, 230, 230, 134, 230, 230,
+ 230, 230, 230, 254, 246, 230, 254, 254, 254, 254, 254, 254, 254, 254,
+ 254, 254, 246, 230, 198, 198, 196, 230, 230, 254, 254, 254, 254, 254,
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 230, 230, 226, 230, 246, 198, 254, 254,
+ 254, 254, 254, 254, 254, 254, 254, 230, 230, 226, 230, 246, 198, 254,
254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 230, 230, 230, 230,
- 230, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 230, 230, 230,
+ 230, 230, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0,
/* table 9 .. 11: 256 */
- 0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
+ 0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
- 160, 160, 32, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
- 160, 160, 160, 160, 160, 160, 128, 160, 224, 224, 224, 224, 224, 224,
+ 160, 160, 160, 32, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
+ 160, 160, 160, 160, 160, 160, 160, 128, 160, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224,
- 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 160, 160, 160, 160,
+ 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
- 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 160, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0,
};
yych = *(marker = p);
if (yych <= '`') {
@@ -25077,8 +25085,8 @@ bufsize_t _scan_spacechars(const unsigned char *p) {
}
}
-// Match ATX header start.
-bufsize_t _scan_atx_header_start(const unsigned char *p) {
+// Match ATX heading start.
+bufsize_t _scan_atx_heading_start(const unsigned char *p) {
const unsigned char *marker = NULL;
const unsigned char *start = p;
@@ -25277,9 +25285,9 @@ bufsize_t _scan_atx_header_start(const unsigned char *p) {
}
}
-// Match setext header line. Return 1 for level-1 header,
+// Match setext heading line. Return 1 for level-1 heading,
// 2 for level-2, 0 for no match.
-bufsize_t _scan_setext_header_line(const unsigned char *p) {
+bufsize_t _scan_setext_heading_line(const unsigned char *p) {
const unsigned char *marker = NULL;
{
diff --git a/src/scanners.h b/src/scanners.h
index 4616f9f..735aa5d 100644
--- a/src/scanners.h
+++ b/src/scanners.h
@@ -21,8 +21,8 @@ bufsize_t _scan_html_block_end_5(const unsigned char *p);
bufsize_t _scan_link_url(const unsigned char *p);
bufsize_t _scan_link_title(const unsigned char *p);
bufsize_t _scan_spacechars(const unsigned char *p);
-bufsize_t _scan_atx_header_start(const unsigned char *p);
-bufsize_t _scan_setext_header_line(const unsigned char *p);
+bufsize_t _scan_atx_heading_start(const unsigned char *p);
+bufsize_t _scan_setext_heading_line(const unsigned char *p);
bufsize_t _scan_hrule(const unsigned char *p);
bufsize_t _scan_open_code_fence(const unsigned char *p);
bufsize_t _scan_close_code_fence(const unsigned char *p);
@@ -43,8 +43,8 @@ bufsize_t _scan_dangerous_url(const unsigned char *p);
#define scan_link_url(c, n) _scan_at(&_scan_link_url, c, n)
#define scan_link_title(c, n) _scan_at(&_scan_link_title, c, n)
#define scan_spacechars(c, n) _scan_at(&_scan_spacechars, c, n)
-#define scan_atx_header_start(c, n) _scan_at(&_scan_atx_header_start, c, n)
-#define scan_setext_header_line(c, n) _scan_at(&_scan_setext_header_line, c, n)
+#define scan_atx_heading_start(c, n) _scan_at(&_scan_atx_heading_start, c, n)
+#define scan_setext_heading_line(c, n) _scan_at(&_scan_setext_heading_line, c, n)
#define scan_hrule(c, n) _scan_at(&_scan_hrule, c, n)
#define scan_open_code_fence(c, n) _scan_at(&_scan_open_code_fence, c, n)
#define scan_close_code_fence(c, n) _scan_at(&_scan_close_code_fence, c, n)
diff --git a/src/scanners.re b/src/scanners.re
index 75417a1..ef2016b 100644
--- a/src/scanners.re
+++ b/src/scanners.re
@@ -247,8 +247,8 @@ bufsize_t _scan_spacechars(const unsigned char *p)
*/
}
-// Match ATX header start.
-bufsize_t _scan_atx_header_start(const unsigned char *p)
+// Match ATX heading start.
+bufsize_t _scan_atx_heading_start(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
@@ -258,9 +258,9 @@ bufsize_t _scan_atx_header_start(const unsigned char *p)
*/
}
-// Match setext header line. Return 1 for level-1 header,
+// Match setext heading line. Return 1 for level-1 heading,
// 2 for level-2, 0 for no match.
-bufsize_t _scan_setext_header_line(const unsigned char *p)
+bufsize_t _scan_setext_heading_line(const unsigned char *p)
{
const unsigned char *marker = NULL;
/*!re2c
diff --git a/src/xml.c b/src/xml.c
index 7392c6e..65f8527 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -87,7 +87,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
cmark_strbuf_puts(xml, buffer);
break;
case CMARK_NODE_HEADER:
- sprintf(buffer, " level=\"%d\"", node->as.header.level);
+ sprintf(buffer, " level=\"%d\"", node->as.heading.level);
cmark_strbuf_puts(xml, buffer);
break;
case CMARK_NODE_CODE_BLOCK: