diff options
author | Nicholas Johnson <nick@nicksphere.ch> | 2022-01-18 00:00:00 +0000 |
---|---|---|
committer | Nicholas Johnson <nick@nicksphere.ch> | 2022-01-18 00:00:00 +0000 |
commit | c6e80117776564c9cb1084572eb69520aa8056cfb6538d24d736be2e59dc8a80 (patch) | |
tree | 165b550ee0a03fe9dc1f6962f756926caa54849325c6775b67ff53a8ff50d331 | |
parent | 46a8a289a0a4142f658aba82171ea5abcecbc13bea852cc89104154b8c35f2ec (diff) |
Document escape_html_*()
-rw-r--r-- | src/gemini2html.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gemini2html.c b/src/gemini2html.c index ed2eaed..5e439db 100644 --- a/src/gemini2html.c +++ b/src/gemini2html.c @@ -20,8 +20,15 @@ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> + #include "gemini2html.h" +/* Escapes text so it can be safely inserted within HTML tags. + * Examples: + * "5 < 6" => "5 < 6" + * "6 > 5" => "6 > 5" + * "me & you" => "me & you" + */ char* escape_html_tag(const char* unescaped, const size_t size) { char* escaped = malloc(4 * size + 1); size_t escaped_pos = 0; @@ -46,6 +53,14 @@ char* escape_html_tag(const char* unescaped, const size_t size) { return escaped; } +/* Escapes text so it can be safely inserted within HTML tags. + * Examples: + * "5 < 6" => "5 < 6" + * "6 > 5" => "6 > 5" + * "me & you" => "me & you" + * "i'm so high" => "I'm so high" + * ""hello world" => ""hello world"" + */ char* escape_html_attribute(const char* unescaped, const size_t size) { char* escaped = malloc(4 * size + 1); size_t escaped_pos = 0; |