чување fdc3e455a0b78a8343b84f3964f1458226e7d0da
родитељ e7ac7d4690294ec7628a185a405750f92ae93e64
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Wed, 17 Mar 2021 12:27:59 +0100
Added additional ways to activate lists (*, o); added correct handling of parentheses inside URLs
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 4, додавања: 87(+), брисања: 7(-)
diff --git a/TODO b/TODO
@@ -6,8 +6,8 @@
[ ] keep-macros variable: when present in an included file, macros from
child process get added to the parent
- [ ] Add additional ways to activate lists (*, o)
- - Two spaces min instead of four for indent?
+ [~] Add additional ways to activate lists (*, o)
+ [ ] Two spaces min instead of four for indent?
[x] Add numbered lists?
diff --git a/index.html b/index.html
@@ -152,7 +152,7 @@ this program. If not, see <<a href="https://www.gnu.org/licenses">https://www
<div id="git-log">
Previous commit:
-index.slw db3c782 2021-03-11 17:02:16 +0100 (Страхиња Радић) (HEAD -> master, tag: v0.3.9, origin/master, origin/HEAD)
+index.slw e7ac7d4 2021-03-12 14:22:43 +0100 (Страхиња Радић) (HEAD -> master)
</div><!--git-log-->
diff --git a/slweb.1.in b/slweb.1.in
@@ -346,8 +346,9 @@ This can help reduce the amount of code in the text of the page.
.
.IP \[bu] 4
.BR Lists .
-Lines starting with a dash (\fC\-\fP) will start an unordered list (if used for
-the first time) and start a list item. Input:
+Lines starting with a dash (\fC\-\fP), an asterisk (\fC*\fP) or lowercase
+\[lq]o\[rq], followed by a space, will start an unordered list (if used for the
+first time) and start a list item. Input:
.
.CDS 8
Colors are:
diff --git a/slweb.c b/slweb.c
@@ -2402,6 +2402,53 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
}
break;
+ case 'o':
+ if (ANY(state, ST_CODE | ST_DISPLAY_FORMULA | ST_FORMULA
+ | ST_HTML_TAG | ST_IMAGE | ST_MACRO_BODY | ST_PRE
+ | ST_YAML))
+ {
+ CHECKCOPY(token, ptoken, token_size, pline)
+ colno++;
+ break;
+ }
+
+ if (colno == 1
+ && u8_strlen(pline) > 1
+ && *(pline+1) == ' ')
+ {
+ if (state & ST_NUMLIST)
+ {
+ state &= ~ST_NUMLIST;
+ if (!read_yaml_macros_and_links)
+ {
+ process_list_item_end(output);
+ process_numlist_end(output);
+ }
+ }
+ if (!read_yaml_macros_and_links)
+ {
+ if (!(state & ST_LIST))
+ process_list_start(output);
+ else
+ process_list_item_end(output);
+ process_list_item_start(output);
+ }
+
+ processed_start_of_line = TRUE;
+ skip_eol = FALSE;
+
+ state |= ST_LIST;
+
+ pline += 2;
+ colno += 2;
+ }
+ else
+ {
+ CHECKCOPY(token, ptoken, token_size, pline);
+ colno++;
+ }
+ break;
+
case '*':
if (ANY(state, ST_CODE | ST_DISPLAY_FORMULA | ST_FORMULA
| ST_HTML_TAG | ST_IMAGE | ST_MACRO_BODY | ST_PRE
@@ -2431,6 +2478,36 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
process_horizontal_rule(output);
pline = NULL;
}
+ else if (colno == 1
+ && u8_strlen(pline) > 1
+ && *(pline+1) == ' ')
+ {
+ if (state & ST_NUMLIST)
+ {
+ state &= ~ST_NUMLIST;
+ if (!read_yaml_macros_and_links)
+ {
+ process_list_item_end(output);
+ process_numlist_end(output);
+ }
+ }
+ if (!read_yaml_macros_and_links)
+ {
+ if (!(state & ST_LIST))
+ process_list_start(output);
+ else
+ process_list_item_end(output);
+ process_list_item_start(output);
+ }
+
+ processed_start_of_line = TRUE;
+ skip_eol = FALSE;
+
+ state |= ST_LIST;
+
+ pline += 2;
+ colno += 2;
+ }
else if (pline_len > 1 && *(pline+1) == '*')
{
/* Handle ** within footnotes, headings and link text specially */
@@ -3032,7 +3109,8 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
case '(':
if (ANY(state, ST_CODE | ST_DISPLAY_FORMULA | ST_FORMULA
| ST_FOOTNOTE_TEXT | ST_HEADING
- | ST_INLINE_FOOTNOTE | ST_MACRO_BODY | ST_PRE))
+ | ST_INLINE_FOOTNOTE | ST_LINK_SECOND_ARG
+ | ST_MACRO_BODY | ST_PRE))
CHECKCOPY(token, ptoken, token_size, pline)
else if (state & ST_LINK)
{
@@ -3058,7 +3136,8 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
break;
case ')':
- if (ANY(state, ST_DISPLAY_FORMULA | ST_FORMULA))
+ if (ANY(state, ST_DISPLAY_FORMULA | ST_FORMULA
+ | ST_LINK_SECOND_ARG))
{
CHECKCOPY(token, ptoken, token_size, pline)
colno++;