чување fc89c76c65331cc25f777f4fc6cad0beb557f82c
родитељ 23859caca071edd677caaca7901d5ca8a104c6d7
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Tue, 2 Feb 2021 20:13:15 +0100
Added numbered lists; changed inline footnotes so they don't need to be on a single line
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 5, додавања: 132(+), брисања: 10(-)
diff --git a/defs.h b/defs.h
@@ -113,11 +113,12 @@ typedef struct
#define ST_HTML_TAG (1 << 19)
#define ST_KBD (1 << 20)
#define ST_LIST (1 << 21)
-#define ST_FOOTNOTE (1 << 22)
-#define ST_FOOTNOTE_TEXT (1 << 23)
-#define ST_INLINE_FOOTNOTE (1 << 24)
-#define ST_FORMULA (1 << 25)
-#define ST_DISPLAY_FORMULA (1 << 26)
+#define ST_NUMLIST (1 << 22)
+#define ST_FOOTNOTE (1 << 23)
+#define ST_FOOTNOTE_TEXT (1 << 24)
+#define ST_INLINE_FOOTNOTE (1 << 25)
+#define ST_FORMULA (1 << 26)
+#define ST_DISPLAY_FORMULA (1 << 27)
#define ST_CS_NONE 0
#define ST_CS_HEADER 1
diff --git a/examples/footnotes/inline.slw b/examples/footnotes/inline.slw
@@ -5,7 +5,8 @@ site-name: Inline footnotes test
# Inline footnotes
Footnotes can also be inline
-^[Note that with inline footnotes, the _entire_ footnote needs to fit on a single line!].
+^[Like this one. An inline footnote can span multiple lines, it doesn't need to
+be on a single line.].
Here's another paragraph^[With a footnote.].
diff --git a/index.html b/index.html
@@ -136,7 +136,7 @@ this program. If not, see <<a href="https://www.gnu.org/licenses">https://www
<div id="git-log">
Previous commit:
-index.slw b30d2ad 2021-01-31 15:54:11 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD)
+index.slw 23859ca 2021-02-02 07:14:15 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD)
</div><!--git-log-->
diff --git a/slweb.1.in b/slweb.1.in
@@ -156,8 +156,7 @@ With a footnote!</p>
can be added by using the construct \fC^[footnotetext]\fP. For example, input
.
.CDS 8
-Inline footnote^[Footnote text needs to fit on a line!] in a
-paragraph.
+Inline footnote^[Footnote text] in a paragraph.
.CDE
.
.IP ""
@@ -169,7 +168,7 @@ id="inline-footnote-text-1"><sup>1</sup></a> in a
paragraph.
<hr />
<p id="inline-footnote-1"><a href="#inline-footnote-text-1">
-1.</a> Footnote text needs to fit on a line!</p>
+1.</a> Footnote text</p>
.CDE
.RE
.
diff --git a/slweb.c b/slweb.c
@@ -775,19 +775,26 @@ process_include(uint8_t* token, FILE* output, BOOL read_yaml_macros_and_links)
uint8_t* ptoken = u8_strchr(token, (ucs4_t)' ');
char* include_filename = NULL;
char* pinclude_filename = NULL;
+ int var_pipe_fds[2];
if (!ptoken)
exit(error(1, (uint8_t*)"Directive 'include' requires"
" an argument"));
+ pipe(var_pipe_fds);
fflush(output);
pid_t pid = fork();
int pstatus = 0;
if (pid > 0)
+ {
+ close(var_pipe_fds[PIPE_WRITE_INDEX]);
wait(&pstatus);
+ }
else if (pid == 0)
{
+ close(var_pipe_fds[PIPE_READ_INDEX]);
+
CALLOC(include_filename, char, BUFSIZE)
pinclude_filename = include_filename;
ptoken++;
@@ -903,6 +910,20 @@ process_list_end(FILE* output)
}
int
+process_numlist_start(FILE* output)
+{
+ fprintf(output, "<ol>");
+ return 0;
+}
+
+int
+process_numlist_end(FILE* output)
+{
+ fprintf(output, "</ol>\n");
+ return 0;
+}
+
+int
filter_subdirs(const struct dirent* node)
{
if (!node || !strcmp(node->d_name, ".") || !strcmp(node->d_name, ".."))
@@ -1506,7 +1527,20 @@ process_line_start(uint8_t* line, BOOL first_line_in_doc,
{
state &= ~ST_LIST;
if (!read_yaml_macros_and_links)
+ {
+ process_list_item_end(output);
process_list_end(output);
+ }
+ }
+
+ if (state & ST_NUMLIST)
+ {
+ state &= ~ST_NUMLIST;
+ if (!read_yaml_macros_and_links)
+ {
+ process_list_item_end(output);
+ process_numlist_end(output);
+ }
}
if (state & ST_FOOTNOTE_TEXT)
@@ -1944,6 +1978,15 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
&& 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))
@@ -1967,6 +2010,7 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
colno++;
}
break;
+
case ':':
if (state & ST_YAML
&& !(ANY(state, ST_CODE | ST_DISPLAY_FORMULA | ST_FORMULA
@@ -2085,6 +2129,26 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
&& !(ANY(state, ST_CODE | ST_DISPLAY_FORMULA | ST_FORMULA
| ST_MACRO_BODY | ST_PRE | ST_YAML)))
{
+ if (state & ST_LIST)
+ {
+ state &= ~ST_LIST;
+ if (!read_yaml_macros_and_links)
+ {
+ process_list_item_end(output);
+ process_list_end(output);
+ }
+ }
+
+ if (state & ST_NUMLIST)
+ {
+ state &= ~ST_NUMLIST;
+ if (!read_yaml_macros_and_links)
+ {
+ process_list_item_end(output);
+ process_numlist_end(output);
+ }
+ }
+
state |= ST_HEADING;
heading_level = 1;
pline++;
@@ -2803,6 +2867,7 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
process_inline_footnote(token, read_yaml_macros_and_links,
output);
+ keep_token = FALSE;
RESET_TOKEN(token, ptoken, token_size)
state &= ~ST_INLINE_FOOTNOTE;
pline++;
@@ -2944,6 +3009,7 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
RESET_TOKEN(token, ptoken, token_size)
state |= ST_INLINE_FOOTNOTE;
+ keep_token = TRUE;
pline += 2;
colno += 2;
break;
@@ -3064,6 +3130,51 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
}
break;
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9': case '0':
+ if (ANY(state, ST_CODE | ST_DISPLAY_FORMULA | ST_FORMULA
+ | ST_MACRO_BODY | ST_PRE | ST_YAML_VAL))
+ {
+ CHECKCOPY(token, ptoken, token_size, pline)
+ colno++;
+ }
+ else if (colno == 1
+ && u8_strlen(pline) > 1
+ && (*(pline+1) == '.' || *(pline+1) == ')'))
+ {
+ if (state & ST_LIST)
+ {
+ state &= ~ST_LIST;
+ if (!read_yaml_macros_and_links)
+ {
+ process_list_item_end(output);
+ process_list_end(output);
+ }
+ }
+ if (!read_yaml_macros_and_links)
+ {
+ if (!(state & ST_NUMLIST))
+ process_numlist_start(output);
+ else
+ process_list_item_end(output);
+ process_list_item_start(output);
+ }
+
+ processed_start_of_line = TRUE;
+ skip_eol = FALSE;
+
+ state |= ST_NUMLIST;
+
+ pline += 2;
+ colno += 2;
+ }
+ else
+ {
+ CHECKCOPY(token, ptoken, token_size, pline)
+ colno++;
+ }
+ break;
+
default:
CHECKCOPY(token, ptoken, token_size, pline)
colno++;
@@ -3211,6 +3322,16 @@ slweb_parse(uint8_t* buffer, FILE* output, BOOL body_only,
state &= ~ST_LIST;
}
+ if (!*pbuffer && (state & ST_NUMLIST))
+ {
+ if (!read_yaml_macros_and_links)
+ {
+ process_list_item_end(output);
+ process_numlist_end(output);
+ }
+ state &= ~ST_NUMLIST;
+ }
+
if (!*pbuffer && (state & ST_FOOTNOTE_TEXT))
{
state &= ~ST_FOOTNOTE_TEXT;