summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/snac.58
-rw-r--r--format.c16
2 files changed, 17 insertions, 7 deletions
diff --git a/doc/snac.5 b/doc/snac.5
index fec3af3..1b07155 100644
--- a/doc/snac.5
+++ b/doc/snac.5
@@ -25,6 +25,8 @@ A special subset of Markdown is allowed, including:
25**text between two pairs of asterisks** 25**text between two pairs of asterisks**
26.It italic 26.It italic
27*text between a pair of asterisks* 27*text between a pair of asterisks*
28.It strikethrough text
29~~text between a pair of tildes~~
28.It code 30.It code
29Text `between backticks` is formatted as code. 31Text `between backticks` is formatted as code.
30.Bd -literal 32.Bd -literal
@@ -41,16 +43,16 @@ int main(int argc, char *argv[])
41Standalone URLs are converted to links. Also, from version 2.54, 43Standalone URLs are converted to links. Also, from version 2.54,
42markdown-style links in the form of [link label](url) are also 44markdown-style links in the form of [link label](url) are also
43supported. 45supported.
44.It Line separators 46.It line separators
45Horizonal rules can be inserted by typing three minus symbols 47Horizonal rules can be inserted by typing three minus symbols
46alone in a line. 48alone in a line.
47.It quoted text 49.It quoted text
48Lines starting with >. 50Lines starting with >.
49.It User Mentions 51.It user mentions
50Strings in the format @user@host are requested using the Webfinger 52Strings in the format @user@host are requested using the Webfinger
51protocol and converted to links and mentions if something reasonable 53protocol and converted to links and mentions if something reasonable
52is found. 54is found.
53.It Emoticons / Smileys / Silly Symbols 55.It emoticons /emojis / smileys / silly symbols
54(Note: from version 2.51, these symbols are configurable by the 56(Note: from version 2.51, these symbols are configurable by the
55instance administrator, so the available ones may differ). 57instance administrator, so the available ones may differ).
56.Pp 58.Pp
diff --git a/format.c b/format.c
index 52edd05..170d28a 100644
--- a/format.c
+++ b/format.c
@@ -89,6 +89,7 @@ static xs_str *format_line(const char *line, xs_list **attach)
89 xs *sm = xs_regex_split(line, 89 xs *sm = xs_regex_split(line,
90 "(" 90 "("
91 "`[^`]+`" "|" 91 "`[^`]+`" "|"
92 "~~[^~]+~~" "|"
92 "\\*\\*?\\*?[^\\*]+\\*?\\*?\\*" "|" 93 "\\*\\*?\\*?[^\\*]+\\*?\\*?\\*" "|"
93 "\\[[^]]+\\]\\([^\\)]+\\)" "|" 94 "\\[[^]]+\\]\\([^\\)]+\\)" "|"
94 "https?:/" "/[^[:space:]]+" 95 "https?:/" "/[^[:space:]]+"
@@ -100,30 +101,37 @@ static xs_str *format_line(const char *line, xs_list **attach)
100 if ((n & 0x1)) { 101 if ((n & 0x1)) {
101 /* markup */ 102 /* markup */
102 if (xs_startswith(v, "`")) { 103 if (xs_startswith(v, "`")) {
103 xs *s1 = xs_crop_i(xs_dup(v), 1, -1); 104 xs *s1 = xs_strip_chars_i(xs_dup(v), "`");
104 xs *e1 = encode_html(s1); 105 xs *e1 = encode_html(s1);
105 xs *s2 = xs_fmt("<code>%s</code>", e1); 106 xs *s2 = xs_fmt("<code>%s</code>", e1);
106 s = xs_str_cat(s, s2); 107 s = xs_str_cat(s, s2);
107 } 108 }
108 else 109 else
109 if (xs_startswith(v, "***")) { 110 if (xs_startswith(v, "***")) {
110 xs *s1 = xs_crop_i(xs_dup(v), 3, -3); 111 xs *s1 = xs_strip_chars_i(xs_dup(v), "*");
111 xs *s2 = xs_fmt("<b><i>%s</i></b>", s1); 112 xs *s2 = xs_fmt("<b><i>%s</i></b>", s1);
112 s = xs_str_cat(s, s2); 113 s = xs_str_cat(s, s2);
113 } 114 }
114 else 115 else
115 if (xs_startswith(v, "**")) { 116 if (xs_startswith(v, "**")) {
116 xs *s1 = xs_crop_i(xs_dup(v), 2, -2); 117 xs *s1 = xs_strip_chars_i(xs_dup(v), "*");
117 xs *s2 = xs_fmt("<b>%s</b>", s1); 118 xs *s2 = xs_fmt("<b>%s</b>", s1);
118 s = xs_str_cat(s, s2); 119 s = xs_str_cat(s, s2);
119 } 120 }
120 else 121 else
121 if (xs_startswith(v, "*")) { 122 if (xs_startswith(v, "*")) {
122 xs *s1 = xs_crop_i(xs_dup(v), 1, -1); 123 xs *s1 = xs_strip_chars_i(xs_dup(v), "*");
123 xs *s2 = xs_fmt("<i>%s</i>", s1); 124 xs *s2 = xs_fmt("<i>%s</i>", s1);
124 s = xs_str_cat(s, s2); 125 s = xs_str_cat(s, s2);
125 } 126 }
126 else 127 else
128 if (xs_startswith(v, "~~")) {
129 xs *s1 = xs_strip_chars_i(xs_dup(v), "~");
130 xs *e1 = encode_html(s1);
131 xs *s2 = xs_fmt("<s>%s</s>", e1);
132 s = xs_str_cat(s, s2);
133 }
134 else
127 if (xs_startswith(v, "http")) { 135 if (xs_startswith(v, "http")) {
128 xs *u = xs_replace(v, "#", "&#35;"); 136 xs *u = xs_replace(v, "#", "&#35;");
129 xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)"); 137 xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)");