%% options copyright owner = Dirk Krause copyright year = 2013-xxxx SPDX-License-Identifier: BSD-3-Clause %% header #ifdef __cplusplus extern "C" { #endif /** Write one HTML file. @param job Job structure. @param nodeptr Node for file to write. @param p Previous node. @param n Next node. */ void hbhtml_write_file(hb_job_t *job,hb_node_t *nodeptr,hb_node_t *p,hb_node_t *n); /** Write one 32-bit character to HTML output. @param job Job structure. @param c32 Character to write. */ void hbhtml_c32(hb_job_t *job, dk3_c32_t c32); /** Write some text as HTML. @param job Job structure. @param text Text to write. @return 1 on success, 0 on error. */ int hbhtml_output_for_text(hb_job_t *job, dkChar const *text); /** Write some URL text as HTML. @param job Job structure. @param text Text to write. @return 1 on success, 0 on error. */ int hbhtml_url_output_for_text(hb_job_t *job, dkChar const *text); /** Handle one input line, either from template or from text file. @param obj Line processor structure. @param il Input line to process. @return 1 on success, 0 on error (continue), -1 on error (exit). */ int hbhtml_line_handler(void *obj, dkChar *il); /** Construct output file name. @param dptr Destination buffer pointer. @param sz Destination buffer size. @param job Job structure. @param nptr Node to process. @return 1 on success, 0 on error. */ int hbhtml_create_output_filename( dkChar *dptr, size_t sz, hb_job_t *job, hb_node_t *nptr ); /** Check whether a link is an external link (http:// or ftp:// at start). @param link Link to check. @return 1 for external links, 0 for internal links. */ int hbhtml_check_link_for_external(dkChar const *link); /** Find HTML doctype for a node. @param job Htmlbook job. @param nodeptr Node to start search. @return Doctype for node or job. */ int hbhtml_get_doctype( hb_job_t *job, hb_node_t *nodeptr ); #ifdef __cplusplus } #endif %% state machine [options] name = hbhtml_stm1 write header = no [states] STM1_ST_START # Start state STM1_ST_ERROR # Error occured STM1_ST_BS # Backslash found STM1_ST_PERCENT # One percent sign found STM1_ST_SPECIAL # Recording a special STM1_ST_SPEC_BS # Backslash found in special STM1_ST_SPEC_PC # Percent found in special [inputs] STM1_I_ANY # Any character STM1_I_BS # Backslash STM1_I_PERCENT # Percent sign [outputs] STM1_O_ERROR # Error, do nothing STM1_O_NOTHING # Do nothing STM1_O_SHIPOUT # Add character to shipout buffer STM1_O_BS_SHIPOUT # Shipout character after backslash STM1_O_PERCENT_SHIPOUT # Shipout percent sign and current character STM1_O_PERCENT # Shipout just percent sign STM1_O_SWITCH # Flush shipout and switch to saving special STM1_O_SPECIAL # Add current character to special STM1_O_SPEC_BS # Add char after backslash to special STM1_O_SPEC_PC_ADD # Add percent and current char to special STM1_O_SPEC_PC # Add percent sign to special STM1_O_EXECUTE # Execute special [rules] * * STM1_ST_ERROR STM1_O_ERROR STM1_ST_START * STM1_ST_START STM1_O_SHIPOUT STM1_ST_START STM1_I_BS STM1_ST_BS STM1_O_NOTHING STM1_ST_START STM1_I_PERCENT STM1_ST_PERCENT STM1_O_NOTHING STM1_ST_BS * STM1_ST_START STM1_O_BS_SHIPOUT STM1_ST_PERCENT * STM1_ST_START STM1_O_PERCENT_SHIPOUT STM1_ST_PERCENT STM1_I_BS STM1_ST_BS STM1_O_PERCENT STM1_ST_PERCENT STM1_I_PERCENT STM1_ST_SPECIAL STM1_O_SWITCH STM1_ST_SPECIAL * STM1_ST_SPECIAL STM1_O_SPECIAL STM1_ST_SPECIAL STM1_I_BS STM1_ST_SPEC_BS STM1_O_NOTHING STM1_ST_SPECIAL STM1_I_PERCENT STM1_ST_SPEC_PC STM1_O_NOTHING STM1_ST_SPEC_BS * STM1_ST_SPECIAL STM1_O_SPEC_BS STM1_ST_SPEC_PC * STM1_ST_SPECIAL STM1_O_SPEC_PC_ADD STM1_ST_SPEC_PC STM1_I_BS STM1_ST_SPEC_BS STM1_O_SPEC_PC STM1_ST_SPEC_PC STM1_I_PERCENT STM1_ST_START STM1_O_EXECUTE %% state machine [options] name = hbhtml_stm3 write header = no [states] STM3_ST_START # No character processed yet STM3_ST_NAME # ASCII characters (for protocol name) found STM3_ST_COLON # Colon found STM3_ST_COLSL # Colon and slash STM3_ST_SUCCESS # Colon and two slashes found STM3_ST_ERROR # Not a protocol at start of text [inputs] STM3_I_ANY # Anything not listed below STM3_I_ASCII # a-zA-Z01-9_ STM3_I_COLON # Colon STM3_I_SLASH # Slash [outputs] STM3_O_OK # OK so far STM3_O_ERROR # ERROR found [rules] * * STM3_ST_ERROR STM3_O_ERROR STM3_ST_START STM3_I_ASCII STM3_ST_NAME STM3_O_OK STM3_ST_NAME STM3_I_ASCII STM3_ST_NAME STM3_O_OK STM3_ST_NAME STM3_I_COLON STM3_ST_COLON STM3_O_OK STM3_ST_COLON STM3_I_SLASH STM3_ST_COLSL STM3_O_OK STM3_ST_COLSL STM3_I_SLASH STM3_ST_SUCCESS STM3_O_OK STM3_ST_SUCCESS * STM3_ST_SUCCESS STM3_O_OK %% module #include "dk3all.h" #include "dk3strkv.h" #include "htmlbook.h" #include "dk3enc.h" $!trace-include /** Object for line reader (special comments). */ typedef struct { hb_job_t *job; /**< Job structure. */ hb_node_t *nodeptr; /**< Current node to process. */ unsigned long lineno; /**< Current line number to process. */ } hb_spc_reader_t; /** Translation table for ASCII characters. */ static char const * const hbhtml_translation_table[] = { /* 0 00 */ NULL, /* 1 01 */ NULL, /* 2 02 */ NULL, /* 3 03 */ NULL, /* 4 04 */ NULL, /* 5 05 */ NULL, /* 6 06 */ NULL, /* 7 07 */ NULL, /* 8 08 */ NULL, /* 9 09 */ "\t", /* 10 0a */ NULL, /* 11 0b */ NULL, /* 12 0c */ NULL, /* 13 0d */ NULL, /* 14 0e */ NULL, /* 15 0f */ NULL, /* 16 10 */ NULL, /* 17 11 */ NULL, /* 18 12 */ NULL, /* 19 13 */ NULL, /* 20 14 */ NULL, /* 21 15 */ NULL, /* 22 16 */ NULL, /* 23 17 */ NULL, /* 24 18 */ NULL, /* 25 19 */ NULL, /* 26 1a */ NULL, /* 27 1b */ NULL, /* 28 1c */ NULL, /* 29 1d */ NULL, /* 30 1e */ NULL, /* 31 1f */ NULL, /* 32 20 */ " ", /* 33 21 */ "!", /* 34 22 */ """, /* 35 23 */ "#", /* 36 24 */ "$", /* 37 25 */ "%", /* 38 26 */ "&", /* 39 27 */ "'", /* 40 28 */ "(", /* 41 29 */ ")", /* 42 2a */ "*", /* 43 2b */ "+", /* 44 2c */ ",", /* 45 2d */ "-", /* 46 2e */ ".", /* 47 2f */ "/", /* 48 30 */ "0", /* 49 31 */ "1", /* 50 32 */ "2", /* 51 33 */ "3", /* 52 34 */ "4", /* 53 35 */ "5", /* 54 36 */ "6", /* 55 37 */ "7", /* 56 38 */ "8", /* 57 39 */ "9", /* 58 3a */ ":", /* 59 3b */ ";", /* 60 3c */ "<", /* 61 3d */ "=", /* 62 3e */ ">", /* 63 3f */ "?", /* 64 40 */ "@", /* 65 41 */ "A", /* 66 42 */ "B", /* 67 43 */ "C", /* 68 44 */ "D", /* 69 45 */ "E", /* 70 46 */ "F", /* 71 47 */ "G", /* 72 48 */ "H", /* 73 49 */ "I", /* 74 4a */ "J", /* 75 4b */ "K", /* 76 4c */ "L", /* 77 4d */ "M", /* 78 4e */ "N", /* 79 4f */ "O", /* 80 50 */ "P", /* 81 51 */ "Q", /* 82 52 */ "R", /* 83 53 */ "S", /* 84 54 */ "T", /* 85 55 */ "U", /* 86 56 */ "V", /* 87 57 */ "W", /* 88 58 */ "X", /* 89 59 */ "Y", /* 90 5a */ "Z", /* 91 5b */ "[", /* 92 5c */ "\\", /* 93 5d */ "]", /* 94 5e */ "^", /* 95 5f */ "_", /* 96 60 */ "`", /* 97 61 */ "a", /* 98 62 */ "b", /* 99 63 */ "c", /* 100 64 */ "d", /* 101 65 */ "e", /* 102 66 */ "f", /* 103 67 */ "g", /* 104 68 */ "h", /* 105 69 */ "i", /* 106 6a */ "j", /* 107 6b */ "k", /* 108 6c */ "l", /* 109 6d */ "m", /* 110 6e */ "n", /* 111 6f */ "o", /* 112 70 */ "p", /* 113 71 */ "q", /* 114 72 */ "r", /* 115 73 */ "s", /* 116 74 */ "t", /* 117 75 */ "u", /* 118 76 */ "v", /* 119 77 */ "w", /* 120 78 */ "x", /* 121 79 */ "y", /* 122 7a */ "z", /* 123 7b */ "{", /* 124 7c */ "|", /* 125 7d */ "}", /* 126 7e */ "~", /* 127 7f */ NULL, /* 128 80 */ NULL, /* 129 81 */ NULL, /* 130 82 */ NULL, /* 131 83 */ NULL, /* 132 84 */ NULL, /* 133 85 */ NULL, /* 134 86 */ NULL, /* 135 87 */ NULL, /* 136 88 */ NULL, /* 137 89 */ NULL, /* 138 8a */ NULL, /* 139 8b */ NULL, /* 140 8c */ NULL, /* 141 8d */ NULL, /* 142 8e */ NULL, /* 143 8f */ NULL, /* 144 90 */ NULL, /* 145 91 */ NULL, /* 146 92 */ NULL, /* 147 93 */ NULL, /* 148 94 */ NULL, /* 149 95 */ NULL, /* 150 96 */ NULL, /* 151 97 */ NULL, /* 152 98 */ NULL, /* 153 99 */ NULL, /* 154 9a */ NULL, /* 155 9b */ NULL, /* 156 9c */ NULL, /* 157 9d */ NULL, /* 158 9e */ NULL, /* 159 9f */ NULL, /* 160 a0 */ " ", /* 161 a1 */ "¡", /* 162 a2 */ "¢", /* 163 a3 */ "£", /* 164 a4 */ "¤", /* 165 a5 */ "¥", /* 166 a6 */ "¦", /* 167 a7 */ "§", /* 168 a8 */ "¨", /* 169 a9 */ "©", /* 170 aa */ "ª", /* 171 ab */ "«", /* 172 ac */ "¬", /* 173 ad */ "­", /* 174 ae */ "®", /* 175 af */ "¯", /* 176 b0 */ "°", /* 177 b1 */ "±", /* 178 b2 */ "²", /* 179 b3 */ "³", /* 180 b4 */ "´", /* 181 b5 */ "µ", /* 182 b6 */ "¶", /* 183 b7 */ "·", /* 184 b8 */ "¸", /* 185 b9 */ "¹", /* 186 ba */ "º", /* 187 bb */ "»", /* 188 bc */ "¼", /* 189 bd */ "½", /* 190 be */ "¾", /* 191 bf */ "¿", /* 192 c0 */ "À", /* 193 c1 */ "Á", /* 194 c2 */ "Â", /* 195 c3 */ "Ã", /* 196 c4 */ "Ä", /* 197 c5 */ "Å", /* 198 c6 */ "Æ", /* 199 c7 */ "Ç", /* 200 c8 */ "È", /* 201 c9 */ "É", /* 202 ca */ "Ê", /* 203 cb */ "Ë", /* 204 cc */ "/Igrave;", /* 205 cd */ "Í", /* 206 ce */ "Î", /* 207 cf */ "Ï", /* 208 d0 */ "Ð", /* 209 d1 */ "Ñ", /* 210 d2 */ "Ò", /* 211 d3 */ "Ó", /* 212 d4 */ "Ô", /* 213 d5 */ "Õ", /* 214 d6 */ "Ö", /* 215 d7 */ "×", /* 216 d8 */ "Ø", /* 217 d9 */ "Ù", /* 218 da */ "Ú", /* 219 db */ "Û", /* 220 dc */ "Ü", /* 221 dd */ "Ý", /* 222 de */ "Þ", /* 223 df */ "ß", /* 224 e0 */ "à", /* 225 e1 */ "á", /* 226 e2 */ "â", /* 227 e3 */ "ã", /* 228 e4 */ "ä", /* 229 e5 */ "å", /* 230 e6 */ "æ", /* 231 e7 */ "ç", /* 232 e8 */ "è", /* 233 e9 */ "é", /* 234 ea */ "ê", /* 235 eb */ "ë", /* 236 ec */ "ì", /* 237 ed */ "í", /* 238 ee */ "î", /* 239 ef */ "ï", /* 240 f0 */ "ð", /* 241 f1 */ "ñ", /* 242 f2 */ "ò", /* 243 f3 */ "ó", /* 244 f4 */ "ô", /* 245 f5 */ "õ", /* 246 f6 */ "ö", /* 247 f7 */ "÷", /* 248 f8 */ "ø", /* 249 f9 */ "ù", /* 250 fa */ "ú", /* 251 fb */ "û", /* 252 fc */ "ü", /* 253 fd */ "ý", /* 254 fe */ "þ", /* 255 ff */ "ÿ" }; /** Constant 8-bit character keywords. */ static char const * const hbhtml_c8_kw[] = { $!string-table # # 0 Newline # \n # # 1 Space # # # 2 Start of an image # # # 4 Image source # src=" # # 5 End of attribute # " # # 6 alt attribute # alt=" # # 7 title attribute # title=" # # 8 border attribute # border=" # # 9 width attribute # width=" # # 10 height attribute # height=" # # 11 12 HTML tag # \n \n # # 13 14 BODY tag # \n \n # # 15 16 HEAD tag # \n \n # # 17 18 Generated by # \n \n # # 19 20 TITLE tag # \n # # 21 22 Style sheet # \n # # 23 24 Charset specifications # \n \n # # 25 26 Author # \n # # 27 28 Shortcut icon # \n # # 29 30 Navi menu div #
\n
\n # # 31 32 Navi menu ul # \n # # 33 Navi menu separator #
  •  
  • \n # # 34 35 Navi menu current node entry #
  • \n # # 36 37 Navi menu current entry #
  • \n # # 38 Class name for navigation link # hb_nm_a # # 39 40 41 42 43 44 45 Link # \n # # 48 Space between navigation images #   # # 49 50 51 52 Navigation link # # # 53 54 55 56 Image in navigation link # 
 〈%lu〉 # # 92 93 94 95 96 97 98 99 Menu entry table. # \n \n \n \n \n # # 100 101 Link classes # hb_a_i hb_a_e # # 102 103 104 105 #
    \n \n
    \n
    \n

    \n
    \n

    \n # # 114 115 # # # 118 119 # type="image/svg+xml" type="application/pdf" # # 120 #


    \n # # 121 122 # \n # # 123 124 125 126 # \n # # 127 ... 135 # author contents index top up first prev next last # # 136 137 # \#hb_toc \#hb_index # # 138 139 140 141 142 143 #
     → 
    \n \n
    \n  \n ">\n # # 144 # hb_nm_a_parent # # 145 #
    \n # # 146 147 148 149 150 # # # 151 152 153 # # # 154 # \n # # 159 # \n # # 160 # \n # # 161, 162 # \n # # 163, 164 # \n \n # # 165 # \n " async>\n " type="text/javascript" async>\n # # 169, 170 #