summaryrefslogtreecommitdiff
path: root/src/creole.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/creole.c')
-rw-r--r--src/creole.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/creole.c b/src/creole.c
index c8847bb..dc37075 100644
--- a/src/creole.c
+++ b/src/creole.c
@@ -24,6 +24,7 @@ long do_bold(const char *begin, const char *end, bool new_block, FILE *out);
long do_nowiki_inline(const char *begin, const char *end, bool new_block, FILE *out);
long do_nowiki_block(const char *begin, const char *end, bool new_block, FILE *out);
long do_list(const char *begin, const char *end, bool new_block, FILE *out);
+long do_horizontal_rule(const char *begin, const char *end, bool new_block, FILE *out);
// Prints string with special HTML characters escaped.
//
@@ -89,6 +90,7 @@ static parser_t parsers[] = {
do_headers,
do_nowiki_block,
do_list,
+ do_horizontal_rule,
do_paragraph, // <p> should be last as it eats anything
// Inline-level elements
@@ -97,7 +99,8 @@ static parser_t parsers[] = {
do_link,
do_raw_url,
do_nowiki_inline,
- do_replacements
+ do_replacements,
+
};
long do_headers(const char *begin, const char *end, bool new_block, FILE *out) {
@@ -508,6 +511,26 @@ long do_list(const char *begin, const char *end, bool new_block, FILE *out) {
return -(item_end - begin);
}
+long do_horizontal_rule(const char *begin, const char *end, bool new_block, FILE *out) {
+ if (!new_block) {
+ return 0;
+ }
+
+ unsigned length = 0;
+ const char *q = begin;
+ while (q < end && *q == '-') {
+ q++;
+ }
+
+ // Anything at least 4 hyphens long is a horizontal rule.
+ // See: http://www.wikicreole.org/wiki/HorizontalRuleReasoning
+ if (length >= 4) {
+ fputs("<hr>", out);
+ }
+
+ return q - end;
+}
+
void process(const char *begin, const char *end, bool new_block, FILE *out) {
assert(begin <= end);