aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Johnson <nick@nicksphere.ch>2022-01-18 00:00:00 +0000
committerNicholas Johnson <nick@nicksphere.ch>2022-01-18 00:00:00 +0000
commitc3473a6b0ce218ff986de23109a359c0f53c59023f99546878cc67016be7d88c (patch)
treee9dfc29ee5269f380fb43c85a26db98778698dd10c67003c6417aa917166413e
parent8986a5a10398f555cd8456b2d9acfdc2fb837f7f56679a5970ef4d300e7ce476 (diff)
Document convert_text_line(), convert_pre_line(), and convert_pre_toggle_line()
-rw-r--r--src/gemini2html.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gemini2html.c b/src/gemini2html.c
index 40621a0..9f0f3fb 100644
--- a/src/gemini2html.c
+++ b/src/gemini2html.c
@@ -156,15 +156,28 @@ enum linetype getlinetype(const char* line, const bool pre_is_toggled) {
else return Text;
}
+/* Converts text line to HTML.
+ *
+ * If the text line is empty except for a newline, "<br/>\n" is returned.
+ * Otherwise the escaped text line is returned.
+ */
char* convert_text_line(const char* line, const size_t size) {
if (line[0] == '\n') return escape_text_add_tags("", "", "<br/>", 0);
else return escape_text_add_tags("<p>", line, "</p>", size);
}
+/* Converts the preformatted text line to HTML.
+ *
+ * Returns the escaped preformatted text line.
+ */
char* convert_pre_line(const char* line, const size_t size) {
return escape_text_add_tags("", line, "", size);
}
+/* Converts the preformatting toggle line to HTML.
+ *
+ * Returns the empty string. Preformatting toggle lines aren't to be displayed.
+ */
char* convert_pre_toggle_line(const char* line, const size_t size) {
return strdup("");
}
@@ -174,7 +187,7 @@ char* convert_link_line(const char* line, const size_t size) {
size_t before_link = 2;
skip_whitespace(line, &before_link);
- if (line[before_link] == '\0' || line[before_link] == '\n') return strdup("<a></a>\n");
+ if (line[before_link] == '\0' || line[before_link] == '\n') return escape_text_add_tags("<a>", "", "</a>", 0);
/* find end of link */
size_t after_link = before_link;