чување 3db74469c853a910755c0fd2e001420261e1f782
родитељ 616079e178a7d7e0901e9e5c4906b0d9593e1af0
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Thu, 17 Mar 2022 21:29:52 +0100
Handle HTML entities; BOOL -> int
Diffstat:
| M | TODO | | | 2 | +- |
| M | defs.h | | | 134 | +++++++++++++++++++++++++++++++++++++------------------------------------------ |
| M | slw2gmi.c | | | 567 | +++++++++++++++++++++++++++++++++++++++++++++++-------------------------------- |
измењених датотека: 3, додавања: 402(+), брисања: 301(-)
diff --git a/TODO b/TODO
@@ -4,7 +4,7 @@
[ ] Investigate newline at enf or paragraph before outputting collected
links (gemini://gemini.strahinja.org/blog/2022-02/20220215.gmi)
- [ ] Handle HTML entities
+ [x] Handle HTML entities
< > Convert tables to formatted text?
diff --git a/defs.h b/defs.h
@@ -21,110 +21,102 @@
#include "utf8.h"
#define PROGRAMNAME "slw2gmi"
-#define VERSION "0.1.4"
+#define VERSION "0.1.4"
#define COPYRIGHTYEAR "2021"
#define MADEBY_URL "https://strahinja.srht.site/slw2gmi/"
-#define BUFSIZE 1024
-#define KEYSIZE 256
+#define BUFSIZE 1024
+#define KEYSIZE 256
#define SMALL_ARGSIZE 256
#define DATEBUFSIZE 12
-static const char timestamp_format[] = "y-m-d";
+static const char timestamp_format[] = "y-m-d";
static const char timestamp_output_ext[] = ".html";
-static const char CMD_GIT_LOG[] = "xargs";
-static const char* CMD_GIT_LOG_ARGS[]
- = { "xargs", "-I{}", "git", "log", "-1",
- "--pretty=format:{} %h %ci (%cn) %d", NULL };
-
-typedef enum
-{
- FALSE = 0,
- TRUE = 1
-} BOOL;
+static const char CMD_GIT_LOG[] = "xargs";
+static const char* CMD_GIT_LOG_ARGS[] = {"xargs", "-I{}", "git", "log", "-1",
+ "--pretty=format:{} %h %ci (%cn) %d", NULL};
#define ALL(var, mask) (((var) & (mask)) == (mask))
#define ANY(var, mask) (((var) & (mask)) != 0)
-#define IN(var, mask) ALL(var, mask)
+#define IN(var, mask) ALL(var, mask)
-typedef unsigned char UBYTE;
-typedef unsigned long ULONG;
+typedef unsigned char UBYTE;
+typedef unsigned long ULONG;
typedef unsigned long long ULLONG;
-typedef enum
-{
- CMD_NONE,
- CMD_BODY_ONLY,
- CMD_BASEDIR,
- CMD_HELP,
- CMD_LINK_PREFIX,
- CMD_VERSION
+typedef enum {
+ CMD_NONE,
+ CMD_BODY_ONLY,
+ CMD_BASEDIR,
+ CMD_HELP,
+ CMD_LINK_PREFIX,
+ CMD_VERSION
} Command;
-typedef struct
-{
- uint8_t* key;
- uint8_t* value;
- size_t value_size;
- BOOL seen; /* for use with macros */
+typedef struct {
+ uint8_t* key;
+ uint8_t* value;
+ size_t value_size;
+ BOOL seen; /* for use with macros */
} KeyValue;
-typedef int (*csv_callback_t)(FILE* output, uint8_t** csv_header, uint8_t** csv_register);
+typedef int (*csv_callback_t)(FILE* output, uint8_t** csv_header,
+ uint8_t** csv_register);
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-const-variable"
#endif
-#define MAX_HEADING_LEVEL 4
-#define MAX_CSV_REGISTERS 9
-
-#define ST_NONE 0
-#define ST_YAML 1
-#define ST_YAML_VAL ((ULLONG)1 << 1)
-#define ST_PARA_OPEN ((ULLONG)1 << 2)
-#define ST_TAG ((ULLONG)1 << 3)
-#define ST_HEADING ((ULLONG)1 << 4)
-#define ST_HEADING_TEXT ((ULLONG)1 << 5)
-#define ST_BOLD ((ULLONG)1 << 6)
-#define ST_ITALIC ((ULLONG)1 << 7)
-#define ST_PRE ((ULLONG)1 << 8)
-#define ST_CODE ((ULLONG)1 << 9)
-#define ST_BLOCKQUOTE ((ULLONG)1 << 10)
-#define ST_LINK ((ULLONG)1 << 11)
+#define MAX_HEADING_LEVEL 4
+#define MAX_CSV_REGISTERS 9
+
+#define ST_NONE 0
+#define ST_YAML 1
+#define ST_YAML_VAL ((ULLONG)1 << 1)
+#define ST_PARA_OPEN ((ULLONG)1 << 2)
+#define ST_TAG ((ULLONG)1 << 3)
+#define ST_HEADING ((ULLONG)1 << 4)
+#define ST_HEADING_TEXT ((ULLONG)1 << 5)
+#define ST_BOLD ((ULLONG)1 << 6)
+#define ST_ITALIC ((ULLONG)1 << 7)
+#define ST_PRE ((ULLONG)1 << 8)
+#define ST_CODE ((ULLONG)1 << 9)
+#define ST_BLOCKQUOTE ((ULLONG)1 << 10)
+#define ST_LINK ((ULLONG)1 << 11)
#define ST_LINK_SECOND_ARG ((ULLONG)1 << 12)
#define ST_LINK_SECOND_ARG_END ((ULLONG)1 << 13)
-#define ST_LINK_SPAN ((ULLONG)1 << 14)
-#define ST_LINK_MACRO ((ULLONG)1 << 15)
-#define ST_IMAGE ((ULLONG)1 << 16)
+#define ST_LINK_SPAN ((ULLONG)1 << 14)
+#define ST_LINK_MACRO ((ULLONG)1 << 15)
+#define ST_IMAGE ((ULLONG)1 << 16)
#define ST_IMAGE_SECOND_ARG ((ULLONG)1 << 17)
-#define ST_MACRO_BODY ((ULLONG)1 << 18)
-#define ST_CSV_BODY ((ULLONG)1 << 19)
-#define ST_HTML_TAG ((ULLONG)1 << 20)
-#define ST_KBD ((ULLONG)1 << 21)
-#define ST_LIST ((ULLONG)1 << 22)
-#define ST_NUMLIST ((ULLONG)1 << 23)
-#define ST_FOOTNOTE ((ULLONG)1 << 24)
+#define ST_MACRO_BODY ((ULLONG)1 << 18)
+#define ST_CSV_BODY ((ULLONG)1 << 19)
+#define ST_HTML_TAG ((ULLONG)1 << 20)
+#define ST_KBD ((ULLONG)1 << 21)
+#define ST_LIST ((ULLONG)1 << 22)
+#define ST_NUMLIST ((ULLONG)1 << 23)
+#define ST_FOOTNOTE ((ULLONG)1 << 24)
#define ST_FOOTNOTE_TEXT ((ULLONG)1 << 25)
#define ST_INLINE_FOOTNOTE ((ULLONG)1 << 26)
-#define ST_FORMULA ((ULLONG)1 << 27)
+#define ST_FORMULA ((ULLONG)1 << 27)
#define ST_DISPLAY_FORMULA ((ULLONG)1 << 28)
-#define ST_TABLE_HEADER ((ULLONG)1 << 29)
-#define ST_TABLE_LINE ((ULLONG)1 << 30)
-#define ST_TABLE ((ULLONG)1 << 31)
-#define ST_STRIKE ((ULLONG)1 << 32)
-
-#define ST_CS_NONE 0
-#define ST_CS_HEADER 1
-#define ST_CS_REGISTER (1 << 2)
-#define ST_CS_QUOTE (1 << 3)
-#define ST_CS_COND (1 << 4)
+#define ST_TABLE_HEADER ((ULLONG)1 << 29)
+#define ST_TABLE_LINE ((ULLONG)1 << 30)
+#define ST_TABLE ((ULLONG)1 << 31)
+#define ST_STRIKE ((ULLONG)1 << 32)
+#define ST_ENT ((ULLONG)1 << 33)
+
+#define ST_CS_NONE 0
+#define ST_CS_HEADER 1
+#define ST_CS_REGISTER (1 << 2)
+#define ST_CS_QUOTE (1 << 3)
+#define ST_CS_COND (1 << 4)
#define ST_CS_COND_NONEMPTY (1 << 5)
#define ST_CS_COND_EMPTY (1 << 6)
-#define ST_CS_ESCAPE (1 << 7)
+#define ST_CS_ESCAPE (1 << 7)
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#endif /* __DEFS_H */
-
diff --git a/slw2gmi.c b/slw2gmi.c
@@ -4,8 +4,8 @@
static size_t lineno = 0;
static size_t colno = 1;
-static BOOL output_firstcol = TRUE;
-static BOOL skip_para_end = FALSE;
+static int output_firstcol = 1;
+static int skip_para_end = 0;
static const char* input_filename = NULL;
static char* input_dirname = NULL;
static char* basedir = NULL;
@@ -177,25 +177,51 @@ slweb_cleanup()
}
int slweb_parse(FILE* output, const char* source_filename, const u8* buffer,
- const BOOL read_yaml_macros_and_links);
+ const int read_yaml_macros_and_links);
-BOOL
+int
startswith(const char* s, const char* what)
{
if (!s || !what)
- return FALSE;
+ return 0;
do
{
if (*s++ != *what++)
- return FALSE;
+ return 0;
} while (*s && *what);
return !*what;
}
+int
+endswith(const char* s, const char* what)
+{
+ const char* ps = s;
+ const char* pwhat = what;
+
+ if (!s || !what)
+ return 0;
+
+ if (!*what)
+ return 1;
+
+ while (*ps)
+ ps++;
+ while (*pwhat)
+ pwhat++;
+
+ while (ps != s && pwhat != what)
+ {
+ if (*ps-- != *pwhat--)
+ return 0;
+ }
+
+ return pwhat == what;
+}
+
u8*
-get_value(KeyValue* list, const size_t list_count, const u8* key, BOOL* seen)
+get_value(KeyValue* list, const size_t list_count, const u8* key, int* seen)
{
if (!list)
return NULL;
@@ -207,7 +233,7 @@ get_value(KeyValue* list, const size_t list_count, const u8* key, BOOL* seen)
if (seen)
{
*seen = plist->seen;
- plist->seen = TRUE;
+ plist->seen = 1;
}
return plist->value;
}
@@ -328,7 +354,7 @@ print_output(FILE* output, const char* fmt, ...)
int
print_command(FILE* output, const char* command, const u8* pass_arguments[],
- const u8* pipe_arguments[], const BOOL strip_newlines)
+ const u8* pipe_arguments[], const int strip_newlines)
{
if (!command || !pass_arguments)
exit(error(EINVAL, (u8*)"print_command: Invalid argument"));
@@ -393,7 +419,7 @@ print_command(FILE* output, const char* command, const u8* pass_arguments[],
strip_newlines ? "" : "\n");
}
if (!strip_newlines)
- output_firstcol = TRUE;
+ output_firstcol = 1;
free(cmd_output_line);
fclose(cmd_output);
@@ -456,7 +482,7 @@ int read_csv(FILE* output, const char* filename, csv_callback_t callback);
int
process_heading_start(FILE* output, const UBYTE heading_level,
- BOOL first_line_in_doc, const BOOL previous_line_blank)
+ int first_line_in_doc, const int previous_line_blank)
{
if (!output_firstcol)
print_output(output, "\n");
@@ -465,7 +491,7 @@ process_heading_start(FILE* output, const UBYTE heading_level,
for (size_t i = 0; i < heading_level; i++)
print_output(output, "#");
print_output(output, " ");
- output_firstcol = FALSE;
+ output_firstcol = 0;
return 0;
}
@@ -476,7 +502,7 @@ process_heading(FILE* output, const u8* token)
warning(1, (u8*)"Empty heading");
print_output(output, "%s\n\n", token ? (char*)token : "");
- output_firstcol = TRUE;
+ output_firstcol = 1;
return 0;
}
@@ -502,9 +528,9 @@ process_git_log(FILE* output)
print_output(output, "Previous commit: ");
result = print_command(output, CMD_GIT_LOG,
- (const u8**)CMD_GIT_LOG_ARGS, (const u8**)pipe_args, FALSE);
+ (const u8**)CMD_GIT_LOG_ARGS, (const u8**)pipe_args, 0);
print_output(output, "\n");
- output_firstcol = TRUE;
+ output_firstcol = 1;
free(basename);
@@ -831,7 +857,7 @@ read_csv(FILE* output, const char* filename, csv_callback_t callback)
int
process_csv(FILE* output, const u8* arg_token,
- const BOOL read_yaml_macros_and_links, const BOOL end_tag)
+ const int read_yaml_macros_and_links, const int end_tag)
{
if (end_tag)
{
@@ -893,7 +919,7 @@ process_csv(FILE* output, const u8* arg_token,
int
process_include(FILE* output, const u8* token,
- const BOOL read_yaml_macros_and_links)
+ const int read_yaml_macros_and_links)
{
if (read_yaml_macros_and_links)
return 0;
@@ -938,14 +964,14 @@ process_include(FILE* output, const u8* token,
include_filename);
free(include_filename);
- FILE* input = NULL;
- FILE* output = stdout;
- u8* buffer = NULL;
- size_t buffer_size = 0;
- int result = 0;
- ULLONG saved_state = ST_NONE;
- BOOL saved_output_firstcol = TRUE;
- BOOL saved_skip_para_end = FALSE;
+ FILE* input = NULL;
+ FILE* output = stdout;
+ u8* buffer = NULL;
+ size_t buffer_size = 0;
+ int result = 0;
+ ULLONG saved_state = ST_NONE;
+ int saved_output_firstcol = 1;
+ int saved_skip_para_end = 0;
read_file_into_buffer(&input, &buffer, &buffer_size,
input_filename, &input_dirname);
@@ -978,11 +1004,11 @@ process_include(FILE* output, const u8* token,
saved_output_firstcol = output_firstcol;
saved_skip_para_end = skip_para_end;
state = ST_NONE;
- output_firstcol = TRUE;
- skip_para_end = FALSE;
+ output_firstcol = 1;
+ skip_para_end = 0;
/* First pass: read YAML, macros and links */
- result = slweb_parse(output, input_filename, buffer, TRUE);
+ result = slweb_parse(output, input_filename, buffer, 1);
if (result)
{
@@ -992,13 +1018,13 @@ process_include(FILE* output, const u8* token,
return result;
}
state = ST_NONE;
- output_firstcol = TRUE;
- skip_para_end = FALSE;
+ output_firstcol = 1;
+ skip_para_end = 0;
current_footnote = 0;
current_inline_footnote = 0;
/* Second pass: parse and output */
- result = slweb_parse(output, input_filename, buffer, FALSE);
+ result = slweb_parse(output, input_filename, buffer, 0);
state = saved_state;
output_firstcol = saved_output_firstcol;
@@ -1038,7 +1064,7 @@ process_list_item_end(FILE* output, const u8* link_prefix)
{
state &= ~ST_PARA_OPEN;
print_output(output, "\n\n");
- output_firstcol = TRUE;
+ output_firstcol = 1;
process_paralinks(output, link_prefix);
}
return 0;
@@ -1121,7 +1147,7 @@ int process_timestamp(FILE* output, const u8* link_prefix, const char* link,
int
process_incdir_subdir(FILE* output, const char* subdirname,
- const u8* link_prefix, BOOL details_open, u8* macro_body)
+ const u8* link_prefix, int details_open, u8* macro_body)
{
struct dirent** namelist;
struct dirent** pnamelist;
@@ -1165,14 +1191,14 @@ process_incdir_subdir(FILE* output, const char* subdirname,
snprintf(filename, BUFSIZE, "%s/%s", abs_subdirname,
(*pnamelist)->d_name);
- FILE* input = NULL;
- FILE* output = stdout;
- u8* buffer = NULL;
- size_t buffer_size = 0;
- int result = 0;
- ULONG saved_state = ST_NONE;
- BOOL saved_output_firstcol = TRUE;
- BOOL saved_skip_para_end = FALSE;
+ FILE* input = NULL;
+ FILE* output = stdout;
+ u8* buffer = NULL;
+ size_t buffer_size = 0;
+ int result = 0;
+ ULONG saved_state = ST_NONE;
+ int saved_output_firstcol = 1;
+ int saved_skip_para_end = 0;
read_file_into_buffer(&input, &buffer, &buffer_size,
filename, &input_dirname);
@@ -1205,11 +1231,11 @@ process_incdir_subdir(FILE* output, const char* subdirname,
saved_output_firstcol = output_firstcol;
saved_skip_para_end = skip_para_end;
state = ST_NONE;
- output_firstcol = TRUE;
- skip_para_end = FALSE;
+ output_firstcol = 1;
+ skip_para_end = 0;
/* Read YAML, macros and links */
- result = slweb_parse(output, filename, buffer, TRUE);
+ result = slweb_parse(output, filename, buffer, 1);
if (result)
{
@@ -1278,7 +1304,7 @@ process_incdir(FILE* output, const u8* token, const u8* link_prefix)
int names_total = 0;
int current_name = 0;
struct dirent** namelist;
- BOOL details_open = TRUE;
+ int details_open = 1;
arg = (u8*)strtok_r((char*)NULL, " ", (char**)&saveptr);
if (!arg)
@@ -1343,11 +1369,11 @@ process_incdir(FILE* output, const u8* token, const u8* link_prefix)
{
process_incdir_subdir(output, namelist[current_name]->d_name,
link_prefix, details_open, macro_body);
- details_open = FALSE;
+ details_open = 0;
current_name++;
}
/*print_output(output, "\n");*/
- output_firstcol = TRUE;
+ output_firstcol = 1;
while (names_total--)
free(namelist[names_total]);
@@ -1357,7 +1383,7 @@ process_incdir(FILE* output, const u8* token, const u8* link_prefix)
return 0;
}
-BOOL url_is_local(const char* url);
+int url_is_local(const char* url);
int
process_timestamp(FILE* output, const u8* link_prefix, const char* link,
@@ -1419,7 +1445,7 @@ process_timestamp(FILE* output, const u8* link_prefix, const char* link,
? (const char*)link_prefix
: "",
link, formatted_date);
- output_firstcol = TRUE;
+ output_firstcol = 1;
process_timestamp_cleanup:
free(formatted_date);
@@ -1431,14 +1457,14 @@ process_timestamp_cleanup:
int
process_macro(FILE* output, const u8* token,
- const BOOL read_yaml_macros_and_links, const BOOL end_tag)
+ const int read_yaml_macros_and_links, const int end_tag)
{
if (!end_tag)
{
if (IN(state, ST_MACRO_BODY))
exit(error(1, (u8*)"Macro undefined or nested"));
- BOOL seen = FALSE;
+ int seen = 0;
u8* macro_body = get_value(macros, macros_count, token + 1,
read_yaml_macros_and_links ? NULL : &seen);
@@ -1484,7 +1510,7 @@ process_macro(FILE* output, const u8* token,
pmacros = macros + macros_count - 1;
}
CALLOC(pmacros->key, u8, KEYSIZE);
- pmacros->seen = FALSE;
+ pmacros->seen = 0;
strncpy((char*)pmacros->key, (char*)token + 1,
KEYSIZE - 1);
pmacros->value = NULL;
@@ -1500,12 +1526,12 @@ process_macro(FILE* output, const u8* token,
}
int process_para_end(FILE* output, const u8* link_prefix,
- const BOOL previous_line_blank);
+ const int previous_line_blank);
int
process_tag(FILE* output, const u8* token, const u8* link_prefix,
- const BOOL previous_line_blank, const BOOL read_yaml_macros_and_links,
- BOOL* skip_eol, const BOOL end_tag)
+ const int previous_line_blank, const int read_yaml_macros_and_links,
+ int* skip_eol, const int end_tag)
{
if (!token || strlen((char*)token) < 1)
return warning(1, (u8*)"%s:%ld:%ld: Empty tag name",
@@ -1522,7 +1548,7 @@ process_tag(FILE* output, const u8* token, const u8* link_prefix,
print_output(output,
"Generated by slw2gmi © %s Strahinya Radich.\n",
COPYRIGHTYEAR);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
else if (startswith((char*)token, "csv")) /* {csv} */
{
@@ -1531,29 +1557,29 @@ process_tag(FILE* output, const u8* token, const u8* link_prefix,
else if (startswith((char*)token, "include")) /* {include} */
{
process_include(output, token, read_yaml_macros_and_links);
- *skip_eol = TRUE;
+ *skip_eol = 1;
}
else if (startswith((char*)token, "incdir")
&& !read_yaml_macros_and_links) /* {incdir} */
{
process_incdir(output, token, link_prefix);
- *skip_eol = TRUE;
+ *skip_eol = 1;
}
else if (*token == '=') /* {=macro} */
{
process_macro(output, token, read_yaml_macros_and_links,
end_tag);
- *skip_eol = TRUE;
+ *skip_eol = 1;
}
else if (startswith((char*)token, "p") && !read_yaml_macros_and_links)
{
- skip_para_end = TRUE;
- *skip_eol = TRUE;
+ skip_para_end = 1;
+ *skip_eol = 1;
if (end_tag)
{
process_para_end(output, link_prefix,
previous_line_blank);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
}
@@ -1561,25 +1587,25 @@ process_tag(FILE* output, const u8* token, const u8* link_prefix,
}
int
-process_bold(FILE* output, BOOL end_tag)
+process_bold(FILE* output, int end_tag)
{
return 0;
}
int
-process_italic(FILE* output, BOOL end_tag)
+process_italic(FILE* output, int end_tag)
{
return 0;
}
int
-process_code(FILE* output, BOOL end_tag)
+process_code(FILE* output, int end_tag)
{
return 0;
}
int
-process_blockquote(FILE* output, BOOL end_tag)
+process_blockquote(FILE* output, int end_tag)
{
if (end_tag)
print_output(output, "\n\n");
@@ -1589,13 +1615,13 @@ process_blockquote(FILE* output, BOOL end_tag)
}
int
-process_kbd(FILE* output, BOOL end_tag)
+process_kbd(FILE* output, int end_tag)
{
return 0;
}
int
-process_strike(FILE* output, BOOL end_tag)
+process_strike(FILE* output, int end_tag)
{
print_output(output, "~");
return 0;
@@ -1620,7 +1646,7 @@ process_table_header_end(FILE* output)
}
int
-process_table_body_start(FILE* output, BOOL start_row)
+process_table_body_start(FILE* output, int start_row)
{
return 0;
}
@@ -1649,7 +1675,7 @@ process_table_end(FILE* output)
return 0;
}
-BOOL
+int
url_is_local(const char* url)
{
return !(startswith(url, "http://") || startswith(url, "https://")
@@ -1710,7 +1736,7 @@ process_paralinks(FILE* output, const u8* link_prefix)
? (const char*)link_prefix
: "",
pparalink->key, pparalink->value);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
pparalink++;
}
@@ -1728,7 +1754,7 @@ process_paralinks(FILE* output, const u8* link_prefix)
int
process_para_end(FILE* output, const u8* link_prefix,
- const BOOL previous_line_blank)
+ const int previous_line_blank)
{
if (!skip_para_end)
print_output(output, "\n");
@@ -1739,8 +1765,8 @@ process_para_end(FILE* output, const u8* link_prefix,
int
process_line_start(FILE* output, const u8* line, const u8* link_prefix,
- const BOOL first_line_in_doc, const BOOL previous_line_blank,
- const BOOL read_yaml_macros_and_links, const BOOL list_para, u8** token,
+ const int first_line_in_doc, const int previous_line_blank,
+ const int read_yaml_macros_and_links, const int list_para, u8** token,
u8** ptoken)
{
if ((first_line_in_doc || previous_line_blank)
@@ -1777,7 +1803,7 @@ process_line_start(FILE* output, const u8* line, const u8* link_prefix,
{
process_para_end(output, link_prefix,
previous_line_blank);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
state &= ~(ST_FOOTNOTE_TEXT | ST_PARA_OPEN);
}
@@ -1789,8 +1815,8 @@ process_line_start(FILE* output, const u8* line, const u8* link_prefix,
output_firstcol && previous_line_blank
? ""
: "\n");
- output_firstcol = TRUE;
- skip_para_end = FALSE;
+ output_firstcol = 1;
+ skip_para_end = 0;
state |= ST_PARA_OPEN;
}
}
@@ -1799,10 +1825,10 @@ process_line_start(FILE* output, const u8* line, const u8* link_prefix,
int
process_text_token(FILE* output, const u8* line, const u8* link_prefix,
- const BOOL first_line_in_doc, const BOOL previous_line_blank,
- const BOOL processed_start_of_line,
- const BOOL read_yaml_macros_and_links, const BOOL list_para, u8** token,
- u8** ptoken, size_t* token_size, const BOOL add_enclosing_paragraph)
+ const int first_line_in_doc, const int previous_line_blank,
+ const int processed_start_of_line, const int read_yaml_macros_and_links,
+ const int list_para, u8** token, u8** ptoken, size_t* token_size,
+ const int add_enclosing_paragraph)
{
if (!IN(state, ST_YAML))
{
@@ -1822,7 +1848,7 @@ process_text_token(FILE* output, const u8* line, const u8* link_prefix,
= *token + strlen((char*)*token) - eol
> 0;
else
- output_firstcol = FALSE;
+ output_firstcol = 0;
}
}
RESET_TOKEN(*token, *ptoken, *token_size);
@@ -1831,7 +1857,7 @@ process_text_token(FILE* output, const u8* line, const u8* link_prefix,
int
process_inline_footnote(FILE* output, const u8* token,
- const BOOL read_yaml_macros_and_links)
+ const int read_yaml_macros_and_links)
{
current_inline_footnote++;
@@ -1860,15 +1886,15 @@ process_inline_footnote(FILE* output, const u8* token,
else
{
print_output(output, "(%d)", current_inline_footnote);
- output_firstcol = FALSE;
+ output_firstcol = 0;
}
return 0;
}
int
-process_footnote(FILE* output, const u8* token, const BOOL footnote_definition,
- const BOOL footnote_output)
+process_footnote(FILE* output, const u8* token, const int footnote_definition,
+ const int footnote_output)
{
current_footnote++;
@@ -1896,7 +1922,7 @@ process_footnote(FILE* output, const u8* token, const BOOL footnote_definition,
if (footnote_output)
{
print_output(output, "(%d)", current_footnote);
- output_firstcol = FALSE;
+ output_firstcol = 0;
}
return 0;
@@ -1904,7 +1930,7 @@ process_footnote(FILE* output, const u8* token, const BOOL footnote_definition,
int
process_horizontal_rule(FILE* output, const u8* link_prefix,
- BOOL previous_line_blank)
+ int previous_line_blank)
{
/* Temporarily break paragraph as hr is para-level */
if (IN(state, ST_PARA_OPEN))
@@ -1916,16 +1942,16 @@ process_horizontal_rule(FILE* output, const u8* link_prefix,
}
int
-process_formula(FILE* output, const u8* token, BOOL display_formula)
+process_formula(FILE* output, const u8* token, int display_formula)
{
return 0;
}
int
-begin_article(FILE* output, const BOOL add_article_header, const u8* author,
+begin_article(FILE* output, const int add_article_header, const u8* author,
const u8* title, const u8* header_text, const char* title_heading_level,
- u8* date, const BOOL ext_in_permalink, BOOL first_line_in_doc,
- BOOL* previous_line_blank, const char* permalink_url)
+ u8* date, const int ext_in_permalink, int first_line_in_doc,
+ int* previous_line_blank, const char* permalink_url)
{
if (title)
{
@@ -1961,27 +1987,27 @@ begin_article(FILE* output, const BOOL add_article_header, const u8* author,
}
int
-end_footnotes(FILE* output, const u8* link_prefix, const BOOL add_footnote_div,
- const BOOL previous_line_blank)
+end_footnotes(FILE* output, const u8* link_prefix, const int add_footnote_div,
+ const int previous_line_blank)
{
size_t footnote = 0;
if (IN(state, ST_PARA_OPEN))
{
- output_firstcol = TRUE;
+ output_firstcol = 1;
state &= ~ST_PARA_OPEN;
if (paralinks_count > 0)
process_paralinks(output, link_prefix);
}
process_horizontal_rule(output, link_prefix, previous_line_blank);
- output_firstcol = TRUE;
+ output_firstcol = 1;
for (footnote = 0; footnote < inline_footnote_count; footnote++)
{
print_output(output, "%d. %s\n\n", footnote + 1,
(char*)inline_footnotes[footnote]);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
KeyValue* pfootnote = footnotes;
@@ -1990,7 +2016,7 @@ end_footnotes(FILE* output, const u8* link_prefix, const BOOL add_footnote_div,
{
print_output(output, "%d. %s\n\n", footnote + 1,
(char*)pfootnote->value);
- output_firstcol = TRUE;
+ output_firstcol = 1;
pfootnote++;
footnote++;
}
@@ -2000,40 +2026,40 @@ end_footnotes(FILE* output, const u8* link_prefix, const BOOL add_footnote_div,
int
slweb_parse(FILE* output, const char* source_filename, const u8* buffer,
- const BOOL read_yaml_macros_and_links)
+ const int read_yaml_macros_and_links)
{
- u8* title = NULL;
- u8* title_heading_level = NULL;
- u8* header_text = NULL;
- u8* author = NULL;
- u8* date = NULL;
- u8* permalink_url = NULL;
- u8* ext_in_permalink = NULL;
- u8* var_add_article_header = NULL;
- u8* var_add_footnote_div = NULL;
- u8* link_prefix = NULL;
- const u8* pbuffer = NULL;
- u8* line = NULL;
- u8* pline = NULL;
- size_t line_len = 0;
- u8* token = NULL;
- u8* ptoken = NULL;
- size_t token_size = 0;
- u8* link_text = NULL;
- size_t link_size = 0;
- u8* link_macro = NULL;
- UBYTE heading_level = 0;
- BOOL end_tag = FALSE;
- BOOL first_line_in_doc = TRUE;
- BOOL skip_change_first_line_in_doc = FALSE;
- BOOL skip_eol = FALSE;
- BOOL keep_token = FALSE;
- BOOL previous_line_blank = FALSE;
- BOOL processed_start_of_line = FALSE;
- BOOL add_footnote_div = FALSE;
- BOOL list_para = FALSE;
- BOOL footnote_at_line_start = FALSE;
- size_t pline_len = 0;
+ u8* title = NULL;
+ u8* title_heading_level = NULL;
+ u8* header_text = NULL;
+ u8* author = NULL;
+ u8* date = NULL;
+ u8* permalink_url = NULL;
+ u8* ext_in_permalink = NULL;
+ u8* var_add_article_header = NULL;
+ u8* var_add_footnote_div = NULL;
+ u8* link_prefix = NULL;
+ const u8* pbuffer = NULL;
+ u8* line = NULL;
+ u8* pline = NULL;
+ size_t line_len = 0;
+ u8* token = NULL;
+ u8* ptoken = NULL;
+ size_t token_size = 0;
+ u8* link_text = NULL;
+ size_t link_size = 0;
+ u8* link_macro = NULL;
+ UBYTE heading_level = 0;
+ int end_tag = 0;
+ int first_line_in_doc = 1;
+ int skip_change_first_line_in_doc = 0;
+ int skip_eol = 0;
+ int keep_token = 0;
+ int previous_line_blank = 0;
+ int processed_start_of_line = 0;
+ int add_footnote_div = 0;
+ int list_para = 0;
+ int footnote_at_line_start = 0;
+ size_t pline_len = 0;
if (!buffer)
exit(error(1, (u8*)"Empty buffer"));
@@ -2092,10 +2118,10 @@ do_buffer:;
lineno++;
colno = 1;
- output_firstcol = TRUE;
- processed_start_of_line = FALSE;
- skip_eol = FALSE;
- list_para = FALSE;
+ output_firstcol = 1;
+ processed_start_of_line = 0;
+ skip_eol = 0;
+ list_para = 0;
do_line:
if (!pline || !*pline)
@@ -2119,14 +2145,14 @@ do_line:
else if (colno == 1 && strlen((char*)pline) > 2
&& startswith((char*)pline, "---"))
{
- skip_eol = TRUE;
+ skip_eol = 1;
if (!(IN(state, ST_YAML)) && (lineno > 1)
&& !read_yaml_macros_and_links)
{
process_horizontal_rule(output, link_prefix,
previous_line_blank);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
else
{
@@ -2135,7 +2161,7 @@ do_line:
else
state &= ~ST_YAML;
- skip_change_first_line_in_doc = TRUE;
+ skip_change_first_line_in_doc = 1;
}
pline = NULL;
}
@@ -2162,8 +2188,8 @@ do_line:
process_list_item_start(output);
}
- processed_start_of_line = TRUE;
- skip_eol = FALSE;
+ processed_start_of_line = 1;
+ skip_eol = 0;
state |= ST_LIST;
@@ -2270,8 +2296,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &token, &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
if (!read_yaml_macros_and_links
&& !(ANY(state,
@@ -2312,8 +2338,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &token, &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
if (!read_yaml_macros_and_links
&& !(ANY(state,
@@ -2370,8 +2396,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &token, &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
}
state ^= ST_CODE;
@@ -2386,6 +2412,89 @@ do_line:
}
break;
+ case '&':
+ if (ANY(state,
+ ST_CODE | ST_DISPLAY_FORMULA | ST_FORMULA
+ | ST_HTML_TAG | ST_IMAGE | ST_KBD
+ | ST_LINK_SECOND_ARG
+ | ST_LINK_SECOND_ARG_END | ST_MACRO_BODY
+ | ST_PRE | ST_TAG | ST_YAML))
+ {
+ CHECKCOPY(token, ptoken, token_size, pline);
+ colno++;
+ }
+ else if (!IN(state, ST_ENT))
+ {
+ /* Output existing text up to & */
+ /**ptoken = 0;
+ process_text_token(output, line, link_prefix,
+ first_line_in_doc, previous_line_blank,
+ processed_start_of_line,
+ read_yaml_macros_and_links, list_para, &token,
+ &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
+
+ RESET_TOKEN(token, ptoken, token_size);*/
+
+ state |= ST_ENT;
+ pline++;
+ colno++;
+ }
+ else
+ {
+ CHECKCOPY(token, ptoken, token_size, pline);
+ colno++;
+ }
+ break;
+
+ case ';':
+ if (IN(state, ST_ENT))
+ {
+ state &= ~ST_ENT;
+ *ptoken = 0;
+ if (!read_yaml_macros_and_links)
+ {
+ /* TODO: Use map */
+ if (endswith((char*)token, "amp"))
+ {
+ token[strlen((char*)token)
+ - strlen("amp")]
+ = 0;
+ strcat((char*)token, "&");
+ }
+ else if (endswith((char*)token, "quot"))
+ {
+ token[strlen((char*)token)
+ - strlen("quot")]
+ = 0;
+ strcat((char*)token, "\"");
+ }
+ else if (endswith((char*)token, "ldquo"))
+ {
+ token[strlen((char*)token)
+ - strlen("ldquo")]
+ = 0;
+ strcat((char*)token, "“");
+ }
+ else if (endswith((char*)token, "rdquo"))
+ {
+ token[strlen((char*)token)
+ - strlen("rdquo")]
+ = 0;
+ strcat((char*)token, "”");
+ }
+ }
+ ptoken = token + strlen((char*)token);
+ pline++;
+ colno++;
+ }
+ else
+ {
+ CHECKCOPY(token, ptoken, token_size, pline);
+ colno++;
+ }
+ break;
+
case '#':
if (IN(state, ST_HTML_TAG))
{
@@ -2470,8 +2579,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &token, &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
if (!read_yaml_macros_and_links
&& !(ANY(state,
@@ -2496,8 +2605,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &token, &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
if (!read_yaml_macros_and_links
&& !(ANY(state,
@@ -2552,8 +2661,8 @@ do_line:
process_list_item_start(output);
}
- processed_start_of_line = TRUE;
- skip_eol = FALSE;
+ processed_start_of_line = 1;
+ skip_eol = 0;
state |= ST_LIST;
@@ -2600,12 +2709,12 @@ do_line:
else if (colno == 1 && pline_len > 2
&& startswith((char*)pline, "***"))
{
- skip_eol = TRUE;
+ skip_eol = 1;
if (!read_yaml_macros_and_links)
{
process_horizontal_rule(output, link_prefix,
previous_line_blank);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
pline = NULL;
}
@@ -2632,8 +2741,8 @@ do_line:
process_list_item_start(output);
}
- processed_start_of_line = TRUE;
- skip_eol = FALSE;
+ processed_start_of_line = 1;
+ skip_eol = 0;
state |= ST_LIST;
@@ -2653,8 +2762,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &token, &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
if (!read_yaml_macros_and_links
&& !(ANY(state,
@@ -2680,8 +2789,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &token, &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
if (!read_yaml_macros_and_links
&& !(ANY(state,
@@ -2720,13 +2829,13 @@ do_line:
if (colno == 1 && strlen((char*)pline) > 1
&& startswith((char*)pline, " "))
{
- list_para = TRUE;
+ list_para = 1;
process_text_token(output, line, link_prefix,
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para, &token,
- &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
while (*pline == ' ' || *pline == '\t')
{
pline++;
@@ -2741,7 +2850,7 @@ do_line:
strncat((char*)ptoken, "\n",
BUFSIZE - strlen((char*)token) - 1);
ptoken += strlen("\n");
- output_firstcol = TRUE;
+ output_firstcol = 1;
pline++;
colno++;
}
@@ -2781,7 +2890,7 @@ do_line:
*ptoken = 0;
size_t token_len = strlen((char*)token);
- skip_eol = TRUE;
+ skip_eol = 1;
if (read_yaml_macros_and_links)
{
if (!macros)
@@ -2825,8 +2934,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para, &token,
- &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
}
state |= ST_TAG;
@@ -2854,7 +2963,7 @@ do_line:
if ((IN(state, ST_TAG)) && pline - 1 && *(pline - 1) == '{')
{
- end_tag = TRUE;
+ end_tag = 1;
pline++;
}
else
@@ -2883,7 +2992,7 @@ do_line:
&skip_eol, end_tag);
RESET_TOKEN(token, ptoken, token_size);
- end_tag = FALSE;
+ end_tag = 0;
}
pline++;
@@ -2919,8 +3028,8 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &token, &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
}
state ^= ST_KBD;
@@ -2932,7 +3041,7 @@ do_line:
else if (!(IN(state, ST_PRE)) && colno == 1
&& strlen((char*)pline) > 1 && *(pline + 1) == '@')
{
- skip_eol = TRUE;
+ skip_eol = 1;
pline += 2;
colno += 2;
@@ -2954,7 +3063,7 @@ do_line:
case '-':
state &= ~ST_TABLE_HEADER;
if (!read_yaml_macros_and_links)
- process_table_body_start(output, FALSE);
+ process_table_body_start(output, 0);
pline = NULL;
break;
@@ -2979,7 +3088,7 @@ do_line:
}
else if (!(IN(state, ST_PRE)) && colno == 1)
{
- skip_eol = TRUE;
+ skip_eol = 1;
if (IN(state, ST_TABLE_HEADER))
{
@@ -2994,7 +3103,7 @@ do_line:
state &= ~ST_TABLE_LINE;
state |= ST_TABLE;
if (!read_yaml_macros_and_links)
- process_table_body_start(output, TRUE);
+ process_table_body_start(output, 1);
}
else if (IN(state, ST_TABLE))
{
@@ -3018,7 +3127,7 @@ do_line:
{
print_output(output, "%s", token);
if (*token)
- output_firstcol = FALSE;
+ output_firstcol = 0;
if (strlen((char*)pline) > 1)
process_table_header_cell(output);
else
@@ -3035,7 +3144,7 @@ do_line:
{
print_output(output, "%s", token);
if (*token)
- output_firstcol = FALSE;
+ output_firstcol = 0;
if (strlen((char*)pline) > 1)
process_table_body_cell(output);
else
@@ -3093,8 +3202,8 @@ do_line:
if (!read_yaml_macros_and_links
&& !(IN(state, ST_BLOCKQUOTE)))
{
- process_blockquote(output, FALSE);
- output_firstcol = FALSE;
+ process_blockquote(output, 0);
+ output_firstcol = 0;
}
state |= ST_BLOCKQUOTE;
@@ -3135,13 +3244,13 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para, &token,
- &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
RESET_TOKEN(token, ptoken, token_size);
state |= ST_IMAGE;
- keep_token = TRUE;
+ keep_token = 1;
pline += 2;
colno += 2;
}
@@ -3208,7 +3317,7 @@ do_line:
{
process_para_end(output, link_prefix,
previous_line_blank);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
state &= ~(ST_FOOTNOTE_TEXT | ST_PARA_OPEN);
}
@@ -3224,9 +3333,9 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
+ &token, &ptoken, &token_size, 1);
}
- processed_start_of_line = TRUE;
+ processed_start_of_line = 1;
RESET_TOKEN(token, ptoken, token_size);
state |= ST_FOOTNOTE;
@@ -3243,13 +3352,13 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para, &token,
- &ptoken, &token_size, TRUE);
+ &ptoken, &token_size, 1);
}
- processed_start_of_line = TRUE;
+ processed_start_of_line = 1;
RESET_TOKEN(token, ptoken, token_size);
state |= ST_LINK;
- keep_token = TRUE;
+ keep_token = 1;
*link_macro = 0;
pline++;
colno++;
@@ -3352,8 +3461,8 @@ do_line:
|| *(line + line_len - 1)
== ')'))
{
- skip_eol = TRUE;
- skip_para_end = TRUE;
+ skip_eol = 1;
+ skip_para_end = 1;
pline = NULL;
}
else
@@ -3400,7 +3509,7 @@ do_line:
process_inline_footnote(output, token,
read_yaml_macros_and_links);
- keep_token = FALSE;
+ keep_token = 0;
RESET_TOKEN(token, ptoken, token_size);
state &= ~ST_INLINE_FOOTNOTE;
pline++;
@@ -3408,7 +3517,7 @@ do_line:
}
else if (IN(state, ST_FOOTNOTE))
{
- BOOL footnote_definition = (strlen((char*)pline) > 1)
+ int footnote_definition = (strlen((char*)pline) > 1)
&& (*(pline + 1) == ':')
&& footnote_at_line_start;
@@ -3420,7 +3529,7 @@ do_line:
RESET_TOKEN(token, ptoken, token_size);
state &= ~ST_FOOTNOTE;
- footnote_at_line_start = FALSE;
+ footnote_at_line_start = 0;
pline++;
colno++;
if (footnote_definition)
@@ -3473,7 +3582,7 @@ do_line:
|| *(line + line_len - 1)
== ')'))
{
- skip_eol = TRUE;
+ skip_eol = 1;
pline = NULL;
}
else
@@ -3528,7 +3637,7 @@ do_line:
|| *(line + line_len - 1)
== ')'))
{
- skip_eol = TRUE;
+ skip_eol = 1;
pline = NULL;
}
else
@@ -3578,7 +3687,7 @@ do_line:
colno++;
}
RESET_TOKEN(token, ptoken, token_size);
- keep_token = FALSE;
+ keep_token = 0;
state |= ST_LINK_SECOND_ARG_END;
break;
@@ -3601,7 +3710,7 @@ do_line:
pline += 2;
colno += 2;
RESET_TOKEN(token, ptoken, token_size);
- keep_token = FALSE;
+ keep_token = 0;
if (IN(state, ST_LINK))
state |= ST_LINK_SECOND_ARG;
else
@@ -3646,12 +3755,12 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para, &token,
- &ptoken, &token_size, TRUE);
- processed_start_of_line = TRUE;
+ &ptoken, &token_size, 1);
+ processed_start_of_line = 1;
RESET_TOKEN(token, ptoken, token_size);
state |= ST_INLINE_FOOTNOTE;
- keep_token = TRUE;
+ keep_token = 1;
pline += 2;
colno += 2;
break;
@@ -3725,22 +3834,22 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
+ &token, &ptoken, &token_size, 1);
}
- processed_start_of_line = TRUE;
+ processed_start_of_line = 1;
state ^= ST_DISPLAY_FORMULA;
if (IN(state, ST_DISPLAY_FORMULA))
- keep_token = TRUE;
+ keep_token = 1;
else
{
*ptoken = 0;
if (!read_yaml_macros_and_links)
- process_formula(output, token, TRUE);
+ process_formula(output, token, 1);
- keep_token = FALSE;
+ keep_token = 0;
RESET_TOKEN(token, ptoken, token_size);
}
@@ -3761,22 +3870,22 @@ do_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
+ &token, &ptoken, &token_size, 1);
}
- processed_start_of_line = TRUE;
+ processed_start_of_line = 1;
state ^= ST_FORMULA;
if (IN(state, ST_FORMULA))
- keep_token = TRUE;
+ keep_token = 1;
else
{
*ptoken = 0;
if (!read_yaml_macros_and_links)
- process_formula(output, token, FALSE);
+ process_formula(output, token, 0);
- keep_token = FALSE;
+ keep_token = 0;
RESET_TOKEN(token, ptoken, token_size);
}
@@ -3831,8 +3940,8 @@ do_line:
process_list_item_start(output);
}
- processed_start_of_line = TRUE;
- skip_eol = FALSE;
+ processed_start_of_line = 1;
+ skip_eol = 0;
state |= ST_NUMLIST;
@@ -3899,7 +4008,7 @@ done_line:
size_t token_len = strlen((char*)token);
if (IN(state, ST_MACRO_BODY))
{
- skip_eol = TRUE;
+ skip_eol = 1;
if (!read_yaml_macros_and_links)
goto skip_macro_read;
if (!macros)
@@ -3948,7 +4057,7 @@ done_line:
}
else if (IN(state, ST_FOOTNOTE_TEXT))
{
- skip_eol = TRUE;
+ skip_eol = 1;
if (!read_yaml_macros_and_links)
goto skip_footnote_read;
if (!footnotes)
@@ -4026,7 +4135,7 @@ done_line:
state &= ~(ST_HEADING | ST_HEADING_TEXT);
if (!read_yaml_macros_and_links)
process_heading(output, token);
- first_line_in_doc = FALSE;
+ first_line_in_doc = 0;
RESET_TOKEN(token, ptoken, token_size);
heading_level = 0;
}
@@ -4037,7 +4146,7 @@ done_line:
first_line_in_doc, previous_line_blank,
processed_start_of_line,
read_yaml_macros_and_links, list_para,
- &token, &ptoken, &token_size, TRUE);
+ &token, &ptoken, &token_size, 1);
}
if (!ANY(state,
@@ -4078,11 +4187,11 @@ done_line:
{
process_para_end(output, link_prefix,
previous_line_blank);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
if (IN(state, ST_LIST))
- skip_eol = TRUE;
+ skip_eol = 1;
state &= ~ST_PARA_OPEN;
}
@@ -4094,7 +4203,7 @@ done_line:
*ptoken = 0;
size_t token_len = strlen((char*)token);
- skip_eol = TRUE;
+ skip_eol = 1;
if (read_yaml_macros_and_links)
{
if (!footnotes)
@@ -4145,8 +4254,8 @@ done_line:
state &= ~ST_BLOCKQUOTE;
if (!read_yaml_macros_and_links)
{
- process_blockquote(output, TRUE);
- output_firstcol = TRUE;
+ process_blockquote(output, 1);
+ output_firstcol = 1;
}
}
@@ -4183,9 +4292,9 @@ done_line:
RESET_TOKEN(token, ptoken, token_size);
if (!skip_change_first_line_in_doc && !IN(state, ST_YAML))
- first_line_in_doc = FALSE;
+ first_line_in_doc = 0;
- skip_change_first_line_in_doc = FALSE;
+ skip_change_first_line_in_doc = 0;
if (line_len == 0)
{
if (!previous_line_blank)
@@ -4200,14 +4309,14 @@ done_line:
{
process_para_end(output, link_prefix,
previous_line_blank);
- output_firstcol = TRUE;
+ output_firstcol = 1;
}
}
- previous_line_blank = TRUE;
+ previous_line_blank = 1;
}
}
else
- previous_line_blank = FALSE;
+ previous_line_blank = 0;
/* Lasts until the end of line */
state &= ~(ST_YAML_VAL | ST_IMAGE_SECOND_ARG | ST_LINK_SECOND_ARG
@@ -4226,7 +4335,7 @@ done_buffer:
if (!read_yaml_macros_and_links)
print_output(output, "\n");
- output_firstcol = TRUE;
+ output_firstcol = 1;
if (link_text)
free(link_text);
@@ -4398,7 +4507,7 @@ main(int argc, char** argv)
inline_footnote_count = 0;
/* First pass: read YAML, macros and links */
- result = slweb_parse(output, input_filename, buffer, TRUE);
+ result = slweb_parse(output, input_filename, buffer, 1);
if (result)
{
@@ -4412,7 +4521,7 @@ main(int argc, char** argv)
current_inline_footnote = 0;
/* Second pass: parse and output */
- result = slweb_parse(output, input_filename, buffer, FALSE);
+ result = slweb_parse(output, input_filename, buffer, 0);
slweb_cleanup();
free(buffer);