summaryrefslogtreecommitdiff
path: root/src/inlines.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/inlines.c')
-rw-r--r--src/inlines.c144
1 files changed, 72 insertions, 72 deletions
diff --git a/src/inlines.c b/src/inlines.c
index 6bed132..2487f63 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -47,7 +47,7 @@ S_insert_emph(subject *subj, delimiter *opener, delimiter *closer);
static int parse_inline(subject* subj, cmark_node * parent);
static void subject_from_buf(subject *e, cmark_strbuf *buffer,
- cmark_reference_map *refmap);
+ cmark_reference_map *refmap);
static int subject_find_special_char(subject *subj);
static unsigned char *cmark_clean_autolink(cmark_chunk *url, int is_email)
@@ -72,11 +72,11 @@ static inline cmark_node *make_link(cmark_node *label, unsigned char *url, unsig
if(e != NULL) {
e->type = CMARK_NODE_LINK;
e->first_child = label;
- e->last_child = label;
+ e->last_child = label;
e->as.link.url = url;
e->as.link.title = title;
e->next = NULL;
- label->parent = e;
+ label->parent = e;
}
return e;
}
@@ -94,14 +94,14 @@ static inline cmark_node* make_literal(cmark_node_type t, cmark_chunk s)
e->type = t;
e->as.literal = s;
e->next = NULL;
- e->prev = NULL;
- e->parent = NULL;
- e->first_child = NULL;
- e->last_child = NULL;
- // These fields aren't used for inlines:
- e->start_line = 0;
- e->start_column = 0;
- e->end_line = 0;
+ e->prev = NULL;
+ e->parent = NULL;
+ e->first_child = NULL;
+ e->last_child = NULL;
+ // These fields aren't used for inlines:
+ e->start_line = 0;
+ e->start_column = 0;
+ e->end_line = 0;
}
return e;
}
@@ -113,14 +113,14 @@ static inline cmark_node* make_simple(cmark_node_type t)
if(e != NULL) {
e->type = t;
e->next = NULL;
- e->prev = NULL;
- e->parent = NULL;
- e->first_child = NULL;
- e->last_child = NULL;
- // These fields aren't used for inlines:
- e->start_line = 0;
- e->start_column = 0;
- e->end_line = 0;
+ e->prev = NULL;
+ e->parent = NULL;
+ e->first_child = NULL;
+ e->last_child = NULL;
+ // These fields aren't used for inlines:
+ e->start_line = 0;
+ e->start_column = 0;
+ e->end_line = 0;
}
return e;
}
@@ -141,7 +141,7 @@ static unsigned char *bufdup(const unsigned char *buf)
}
static void subject_from_buf(subject *e, cmark_strbuf *buffer,
- cmark_reference_map *refmap)
+ cmark_reference_map *refmap)
{
e->input.data = buffer->ptr;
e->input.len = buffer->size;
@@ -212,7 +212,7 @@ static int scan_to_closing_backticks(subject* subj, int openticklength)
advance(subj);
numticks++;
}
- if (numticks != openticklength){
+ if (numticks != openticklength) {
return(scan_to_closing_backticks(subj, openticklength));
}
return (subj->pos);
@@ -261,7 +261,7 @@ scan_delims(subject* subj, unsigned char c, bool * can_open, bool * can_close)
before_char_pos -= 1;
}
len = utf8proc_iterate(subj->input.data + before_char_pos,
- subj->pos - before_char_pos, &before_char);
+ subj->pos - before_char_pos, &before_char);
if (len == -1) {
before_char = 10;
}
@@ -273,23 +273,23 @@ scan_delims(subject* subj, unsigned char c, bool * can_open, bool * can_close)
}
len = utf8proc_iterate(subj->input.data + subj->pos,
- subj->input.len - subj->pos, &after_char);
+ subj->input.len - subj->pos, &after_char);
if (len == -1) {
after_char = 10;
}
*can_open = numdelims > 0 && !utf8proc_is_space(after_char) &&
- !(utf8proc_is_punctuation(after_char) &&
- !utf8proc_is_space(before_char) &&
- !utf8proc_is_punctuation(before_char));
+ !(utf8proc_is_punctuation(after_char) &&
+ !utf8proc_is_space(before_char) &&
+ !utf8proc_is_punctuation(before_char));
*can_close = numdelims > 0 && !utf8proc_is_space(before_char) &&
- !(utf8proc_is_punctuation(before_char) &&
- !utf8proc_is_space(after_char) &&
- !utf8proc_is_punctuation(after_char));
+ !(utf8proc_is_punctuation(before_char) &&
+ !utf8proc_is_space(after_char) &&
+ !utf8proc_is_punctuation(after_char));
if (c == '_') {
*can_open = *can_open && !(before_char < 128 &&
- cmark_isalnum((char)before_char));
+ cmark_isalnum((char)before_char));
*can_close = *can_close && !(before_char < 128 &&
- cmark_isalnum((char)after_char));
+ cmark_isalnum((char)after_char));
}
return numdelims;
}
@@ -326,10 +326,10 @@ static void remove_delimiter(subject *subj, delimiter *delim)
}
static void push_delimiter(subject *subj, unsigned char c, bool can_open,
- bool can_close, cmark_node *inl_text)
+ bool can_close, cmark_node *inl_text)
{
delimiter *delim =
- (delimiter*)malloc(sizeof(delimiter));
+ (delimiter*)malloc(sizeof(delimiter));
if (delim == NULL) {
return;
}
@@ -418,7 +418,7 @@ S_insert_emph(subject *subj, delimiter *opener, delimiter *closer)
// calculate the actual number of characters used from this closer
if (closer_num_chars < 3 || opener_num_chars < 3) {
use_delims = closer_num_chars <= opener_num_chars ?
- closer_num_chars : opener_num_chars;
+ closer_num_chars : opener_num_chars;
} else { // closer and opener both have >= 3 characters
use_delims = closer_num_chars % 2 == 0 ? 2 : 1;
}
@@ -448,8 +448,7 @@ S_insert_emph(subject *subj, delimiter *opener, delimiter *closer)
emph->type = use_delims == 1 ? NODE_EMPH : NODE_STRONG;
// remove opener from list
remove_delimiter(subj, opener);
- }
- else {
+ } else {
// create new emph or strong, and splice it in to our inlines
// between the opener and closer
emph = use_delims == 1 ? make_emph() : make_strong();
@@ -510,9 +509,9 @@ static cmark_node* handle_entity(subject* subj)
advance(subj);
len = houdini_unescape_ent(&ent,
- subj->input.data + subj->pos,
- subj->input.len - subj->pos
- );
+ subj->input.data + subj->pos,
+ subj->input.len - subj->pos
+ );
if (len == 0)
return make_str(cmark_chunk_literal("&"));
@@ -557,26 +556,26 @@ unsigned char *cmark_clean_url(cmark_chunk *url)
unsigned char *cmark_clean_title(cmark_chunk *title)
{
- cmark_strbuf buf = GH_BUF_INIT;
- unsigned char first, last;
-
- if (title->len == 0)
- return NULL;
-
- first = title->data[0];
- last = title->data[title->len - 1];
-
- // remove surrounding quotes if any:
- if ((first == '\'' && last == '\'') ||
- (first == '(' && last == ')') ||
- (first == '"' && last == '"')) {
- houdini_unescape_html_f(&buf, title->data + 1, title->len - 2);
- } else {
- houdini_unescape_html_f(&buf, title->data, title->len);
- }
-
- cmark_strbuf_unescape(&buf);
- return cmark_strbuf_detach(&buf);
+ cmark_strbuf buf = GH_BUF_INIT;
+ unsigned char first, last;
+
+ if (title->len == 0)
+ return NULL;
+
+ first = title->data[0];
+ last = title->data[title->len - 1];
+
+ // remove surrounding quotes if any:
+ if ((first == '\'' && last == '\'') ||
+ (first == '(' && last == ')') ||
+ (first == '"' && last == '"')) {
+ houdini_unescape_html_f(&buf, title->data + 1, title->len - 2);
+ } else {
+ houdini_unescape_html_f(&buf, title->data, title->len);
+ }
+
+ cmark_strbuf_unescape(&buf);
+ return cmark_strbuf_detach(&buf);
}
// Parse an autolink or HTML tag.
@@ -595,9 +594,9 @@ static cmark_node* handle_pointy_brace(subject* subj)
subj->pos += matchlen;
return make_autolink(
- make_str_with_entities(&contents),
- contents, 0
- );
+ make_str_with_entities(&contents),
+ contents, 0
+ );
}
// next try to match an email autolink
@@ -607,9 +606,9 @@ static cmark_node* handle_pointy_brace(subject* subj)
subj->pos += matchlen;
return make_autolink(
- make_str_with_entities(&contents),
- contents, 1
- );
+ make_str_with_entities(&contents),
+ contents, 1
+ );
}
// finally, try to match an html tag
@@ -664,7 +663,7 @@ static int link_label(subject* subj, cmark_chunk *raw_label)
return 1;
}
- noMatch:
+noMatch:
subj->pos = startpos; // rewind
return 0;
@@ -727,7 +726,7 @@ static cmark_node* handle_close_bracket(subject* subj, cmark_node *parent)
// ensure there are spaces btw url and title
endtitle = (starttitle == endurl) ? starttitle :
- starttitle + scan_link_title(&subj->input, starttitle);
+ starttitle + scan_link_title(&subj->input, starttitle);
endall = endtitle + scan_spacechars(&subj->input, endtitle);
@@ -755,7 +754,7 @@ static cmark_node* handle_close_bracket(subject* subj, cmark_node *parent)
if (!found_label || raw_label.len == 0) {
cmark_chunk_free(&raw_label);
raw_label = cmark_chunk_dup(&subj->input, opener->position,
- initial_pos - opener->position - 1);
+ initial_pos - opener->position - 1);
}
if (!found_label) {
@@ -803,7 +802,7 @@ match:
// process_emphasis will remove this delimiter and all later ones.
// Now, if we have a link, we also want to deactivate earlier link
- // delimiters. (This code can be removed if we decide to allow links
+ // delimiters. (This code can be removed if we decide to allow links
// inside links.)
if (!is_image) {
opener = subj->last_delim;
@@ -861,7 +860,8 @@ static int subject_find_special_char(subject *subj)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
int n = subj->pos + 1;
@@ -886,7 +886,7 @@ static int parse_inline(subject* subj, cmark_node * parent)
if (c == 0) {
return 0;
}
- switch(c){
+ switch(c) {
case '\n':
new_inl = handle_newline(subj);
break;
@@ -960,7 +960,7 @@ static void spnl(subject* subj)
bool seen_newline = false;
while (peek_char(subj) == ' ' ||
(!seen_newline &&
- (seen_newline = peek_char(subj) == '\n'))) {
+ (seen_newline = peek_char(subj) == '\n'))) {
advance(subj);
}
}