diff options
| -rw-r--r-- | doc/snac.5 | 8 | ||||
| -rw-r--r-- | format.c | 16 |
2 files changed, 17 insertions, 7 deletions
| @@ -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 |
| 29 | Text `between backticks` is formatted as code. | 31 | Text `between backticks` is formatted as code. |
| 30 | .Bd -literal | 32 | .Bd -literal |
| @@ -41,16 +43,16 @@ int main(int argc, char *argv[]) | |||
| 41 | Standalone URLs are converted to links. Also, from version 2.54, | 43 | Standalone URLs are converted to links. Also, from version 2.54, |
| 42 | markdown-style links in the form of [link label](url) are also | 44 | markdown-style links in the form of [link label](url) are also |
| 43 | supported. | 45 | supported. |
| 44 | .It Line separators | 46 | .It line separators |
| 45 | Horizonal rules can be inserted by typing three minus symbols | 47 | Horizonal rules can be inserted by typing three minus symbols |
| 46 | alone in a line. | 48 | alone in a line. |
| 47 | .It quoted text | 49 | .It quoted text |
| 48 | Lines starting with >. | 50 | Lines starting with >. |
| 49 | .It User Mentions | 51 | .It user mentions |
| 50 | Strings in the format @user@host are requested using the Webfinger | 52 | Strings in the format @user@host are requested using the Webfinger |
| 51 | protocol and converted to links and mentions if something reasonable | 53 | protocol and converted to links and mentions if something reasonable |
| 52 | is found. | 54 | is 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 |
| 55 | instance administrator, so the available ones may differ). | 57 | instance administrator, so the available ones may differ). |
| 56 | .Pp | 58 | .Pp |
| @@ -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, "#", "#"); | 136 | xs *u = xs_replace(v, "#", "#"); |
| 129 | xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)"); | 137 | xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)"); |