{"id":20229154,"url":"https://github.com/dacap/htmlex","last_synced_at":"2026-05-29T20:31:41.100Z","repository":{"id":2022952,"uuid":"2959059","full_name":"dacap/htmlex","owner":"dacap","description":"A small HTML preprocesor","archived":false,"fork":false,"pushed_at":"2016-04-01T02:38:40.000Z","size":202,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T16:19:10.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://davidcapello.com/programming/htmlex/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dacap.png","metadata":{"files":{"readme":"readme.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-11T17:07:24.000Z","updated_at":"2021-12-26T17:06:39.000Z","dependencies_parsed_at":"2022-09-04T14:41:38.323Z","dependency_job_id":null,"html_url":"https://github.com/dacap/htmlex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dacap%2Fhtmlex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dacap%2Fhtmlex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dacap%2Fhtmlex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dacap%2Fhtmlex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dacap","download_url":"https://codeload.github.com/dacap/htmlex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241670455,"owners_count":20000407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T07:34:30.669Z","updated_at":"2026-05-29T20:31:41.086Z","avatar_url":"https://github.com/dacap.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# htmlex\n**A powerful hypertext markup language preprocessor (HTML)**\n\u003e Copyright (C) 2001, 2002, 2003 by David Capello\n\n## Introduction\n\nhtmlex is a small but powerful HTML preprocesor, which has numerous\nadvantages compared to conventional HTML files. On top of that, htmlex\nis fully compatible with the standard HTML syntax. This means that you\ncan use any HTML file that you have previously made, rename it to\n`.htex`, and start using htmlex.\n\nThis software is distributed under the [MIT license](license.txt).\n\n## Options\n\nhtmlex interprets the following options from the command line:\n\n    -c   compiles all subsequent files (gets an output file name\n         from '-o' or generates a name with .html extension, see -E)\n    -o   adds output files\n    -a   adds arguments for the input files\n    -I   adds search include paths (you can use old '-i' parameter)\n    -E   changes the HTML extension generated by -c option (.html by default)\n    -k   kills comments (old htmlex behavior)\n    -d   calculates dependencies of the input files (output to STDOUT)\n    -v   activates the verbose mode (to see what htmlex does)\n    -V   activates very verbose mode (to debug .htex files)\n    -h   displays help screen and exit\n    --   breaks -coaI arguments\n\n## Execution\n\n### References\n\n* `STDIN` (standard input): from the keyboard or from file.\n* `STDOUT` (standard output): to the screen or to file.\n\n### Common behavior\n\n    ./htmlex\nProcess `STDIN` and leave the results in `STDOUT`.\n\n    ./htmlex file arguments...\nProcess `file` and leave the results in `STDOUT`.\n\n    ./htmlex -c files... -a arguments...\nProcess `files` and leave the results in `files.html`.\n\n    ./htmlex -c files... -o destinations...\n    ./htmlex -o destinations... -c files...\nProcess the `files` and leave the results in the `destinations`.\n\n### Some equivalent examples\n\n    ./htmlex file.htex arg1 arg2 \u003e file.html\n    ./htmlex -c file.htex -a arg1 arg2\n    ./htmlex -c file.htex -o file.html -a arg1 arg2\n    ./htmlex -a arg1 arg2 \u003c file.htex \u003e file.html\n    ./htmlex -a arg1 arg2 -o file.html \u003c file.htex\n\n### Common mistakes\n\n#### File to compile\n\n    ./htmlex -I examples file.htex \u003e file.html\n\nHere the program waits for input from `STDIN`, because `file.htex`\ncounts as another path for `-I`.\nPossible solutions:\n\n    ./htmlex -I examples -- file.htex \u003e file.html\n    ./htmlex -I examples -c file.htex\n    ./htmlex file.htex -I examples \u003e file.html\n\n#### Arguments for the input file\n\n    ./htmlex -c index.htex en English\n\nHere, htmlex will try to compile the files `index.htex`, `en` and\n`English`, instead of passing the arguments to `index.htex`.\nPossible solutions:\n\n    ./htmlex -c index.htex -a en English\n    ./htmlex index.htex en English \u003e index.html\n\n### Changes from previous versions\n\n* Now you can use `-I` instead of `-i` (like gcc).\n* The argument order isn't necessary anymore, so you can do:\n\n        ./htmlex -c src.htex -o dst.html -I dir\n\n## Features\n\n### Reference\n\nThis notation will be used along of the definitions:\n\n* `expression`: The `expression` is mandatory.\n* `[ expression ]`: The `expression` is optional.\n* `{ expression }`: The `expression` is optional and repeatable.\n* `source -\u003e result`: Indicates that `results` will be obtained when\n  the program will process the `source` text.\n\n### Tags\n\nLists of tags which you can use in the `.htex` files (by alphabetical\nsorting):\n\n#### args\n\n    \u003c!args\u003e\n\nReturns the number of arguments which was passed to the input file.\n\nExample:\n\n    You input \u003c!args\u003e argument(s).\n\n#### argN\n\n    \u003c!arg1\u003e ... \u003c!argN\u003e\nReturns the argument's value. The arguments are passed to the files\nvia the command line's `-a` option, or from the `\u003c!include file arg1 ... argN\u003e` tag.\n\nExample:\n\n    2nd argument = \u003c!arg2\u003e.\n\n#### basename\n\n    \u003c!basename file\u003e\n\nReturns the base name of the `file`. In other words, removes its\nextension.\n\nExamples:\n\n    \u003c!basename src/foo.c\u003e    -\u003e src/foo\n    \u003c!basename src-1.0/bar\u003e  -\u003e src-1.0/bar\n    \u003c!basename hacks\u003e        -\u003e hacks\n\n#### chop\n\n    \u003c!chop word\u003e\n\nRemoves the last character of `word`.\n\nExamples:\n\n    \u003c!chop hello\u003e       -\u003e hell\n    \u003c!chop directorio/\u003e -\u003e directorio\n\n#### clean\n\n    \u003c!clean word\u003e\n\nCleans `word` removing blank space (tabulators and line breaks)\naround it.\n\nExample:\n\n    *\u003c!clean \" hola \"\u003e* -\u003e *hola*\n\n#### dep\n\n    \u003c!dep file\u003e\nAdds 'file' as a dependency. This tag takes effect only in the dependency\ngeneration process.\n\nExample:\n\n    \u003c!exec ./script.sh\u003e\n    \u003c!dep script.sh\u003e\n\n#### dir\n\n    \u003c!dir file\u003e\n\nReturns the directory part of `file`. In other words, deletes the file name.\n\nExamples:\n\n    \u003c!dir src/foo.c\u003e -\u003e src/\n    \u003c!dir a/b/foo.h\u003e -\u003e a/b/\n    \u003c!dir hacks\u003e     -\u003e ./\n\n#### elif\n\n    \u003c!elif expression\u003e\n\nSee [if](#if).\n\n#### else\n\n    \u003c!else\u003e\n\nSee [if](#if).\n\n#### end\n\n    \u003c!end\u003e\n\nSee [function](#function).\n\n#### exec\n\n    \u003c!exec command { arguments }\u003e\n\nExecutes the indicated `command` passing the `arguments` to it. Whatever\nthe command prints to the standard output (`STDOUT`) will be inserted at\nthis position in the file.\n\nExamples:\n\n    \u003c!exec date\u003e\n    \u003c!exec gcc --version\u003e\n\n#### exec-proc\n\n    \u003c!exec-proc file { arguments }\u003e\n\nEqual to `\u003c!exec ...\u003e` except that it will process the results as other\nhtmlex file.\n\nExamples:\n\n    \u003c!exec-proc cat header.htex\u003e\n    \u003c!exec-proc cat \"a footer.htex\"\u003e\n    \u003c!exec-proc cat \u003c!find macros.htex\u003e\u003e\n\n#### fi\n\n    \u003c!fi\u003e\n\nSee [if](#if).\n\n#### file-size\n\n    \u003c!file-size file\u003e\n\nReturns the size of `file` in a format that's more human-readable\n(bytes, KB, MB or GB).\n\nExample:\n\n    image \u003c!file-size image.jpg\u003e\n\n#### find\n\n    \u003c!find file\u003e\n\nTries to find `file` in the search path (the active directory and\nall directories added with the `-I` option), and will return the name\nof the `file` with the matching path. In the case that the file isn't\nfound, nothing is returned.\n\nExamples:\n\n    \u003c!if \u003c!find index.en.html\u003e\u003e\n      english\n    \u003c!fi\u003e\n\n#### function\n\n    \u003c!function name { submacros }\u003e\n\nCreates a new functional macro like in C/C++. When the program see\nthis tag, it follows reading the file in \"raw\" mode until finds\n`\u003c!end\u003e` tag. Then, the macro could be called like any other tag:\n`\u003c!name {args}\u003e`\n\nExample:\n\n      \u003c!function my_macro a b c\u003ea is b c\u003c!end\u003e\n      \u003c!my_macro This my macro\u003e.\n\nOutput:\n\n      This is my macro.\n\n#### if\n\n    \u003c!if expression\u003e\n\nOne of the more powerful features of htmlex relative to\nconventional HTML is the conditional-blocks.\n\nThrough four tags you can do some of the conditional operations\nof \"normal\" programming languages. Although nowadays, htmlex has a\npoor handling of operations, improvements to this construct will\nmade.\n\nThe general syntax is the following:\n\n    \u003c!if [ expression ]\u003e block\n    { \u003c!elif [ expression ]\u003e block }\n    [ \u003c!else\u003e block ]\n    \u003c!fi\u003e\n\nThe `block` can be any text (or just nothing), can have other tags,\nand consequentialy, can have more nested `\u003c!if\u003e` tags.\n\nThe `expression` to be evaluated can have any of the formats below:\n\n    FORMAT               TRUE IF...\n    -------              ----------\n    number               number is not zero\n    ! number             number is zero\n    word                 word has one character as minimum\n    ! word               word is empty\n    number1 \u003c number2    number1 is less than number2\n    number1 \u003e number2    number1 is greater than number2\n    number1 \u003c= number2   number1 is less or equal than number2\n    number1 \u003e= number2   number1 is greater or equal than number2\n    number1 == number2   number1 is equal than number2\n    number1 != number2   number1 is different than number2\n    word1 == word2       word1 is identical than word2\n    word1 != word2       word1 differs in just one character than word2\n\nIf the expression format cannot be resolved to the table above, then\nfalse is returned.\n\n`numbers` are distinguished from `words` when they have some of these\nformats:\n\n    [1-9][0-9]*      decimals\n    0x[0-9a-fA-F]*   hexadecimals\n    0[0-7]           octals\n\nExamples:\n\n    \u003c!if \u003c!arg1\u003e == --help\u003e\n      Do you need help?\n    \u003c!else\u003e\n      Try with --help.\n    \u003c!fi\u003e\n    \u003c!if \u003c!tolower HELLO\u003e == \u003c!tolower Hello\u003e\u003e\n      works\n    \u003c!fi\u003e\n    \u003c!if\u003eFor here it won't never pass\u003c!fi\u003e\n\n#### include\n\n    \u003c!include file { arguments }\u003e\n\nIncludes the `file` to be processed like an normal `.htex` file. This file\nwill also be used for calculating dependencies. This is equivalent to\nC's `#include`.\n\nExamples:\n\n    \u003c!include header.htex\u003e\n    \u003c!include footer.htex en UK\u003e\n\n#### macro\n\n    \u003c!macro name [ value ]\u003e\n\nCreates or modifies a macro with the specified `name` and `value`.\nIf `value` is not specified, the macro will be eliminated from\nmemory. The main use of macros is to replace a certain keyword\n(its `name`) for some predetermined text (its `value`).\n\nExample:\n\n    \u003c!macro hi bye\u003e\n    hi -\u003e bye   \u003c!-- \"hi\" replaced by \"bye\" --\u003e\n    \u003c!macro hi\u003e\n    hi -\u003e hi    \u003c!-- \"hi\" macro is deleted --\u003e\n\n#### macro-reset\n\n    \u003c!macro-reset\u003e\n\nRemoves any macro which was created before this tag.\n\nExample:\n\n    \u003c!macro a b\u003ea\u003c!macro-reset\u003ea -\u003e ba\n\n#### notdir\n\n    \u003c!notdir file\u003e\n\nReturns the name of the `file` without the directory.\n\nExamples:\n\n    \u003c!notdir src/foo.c\u003e -\u003e foo.c\n    \u003c!notdir a/b/foo.h\u003e -\u003e foo.h\n    \u003c!notdir hacks\u003e     -\u003e hacks\n\n#### shift\n\n    \u003c!shift word\u003e\n\nRemoves the first character of `word`.\n\nExamples:\n\n    \u003c!shift your\u003e -\u003e our\n    \u003c!shift .txt\u003e -\u003e txt\n\n#### suffix\n\n    \u003c!suffix file\u003e\n\nReturns the extension of `file`.\n\nExamples:\n\n    \u003c!suffix \"src/foo.c\"\u003e   -\u003e .c\n    \u003c!suffix \"src-1.0/bar\"\u003e -\u003e\n    \u003c!suffix \"hacks\"\u003e       -\u003e\n\n#### tolower\n\n    \u003c!tolower word [ beginning [ final ] ]\u003e\n\nSee [toupper](#toupper).\n\n#### toupper\n\n    \u003c!toupper word [ beginning [ final ] ]\u003e\n\nConverts partially or completelly `word` to lower or upper case\ndepending on if you specify or not the `beginning` and/or the `final`\ncharacter index. Indecies start at 0.\n\nIf only `beginning` is specified, then the range starting from\n`beginning` to the last character is converted.\nIf you also indicate `final`, you are specifying an upper bound\nto the conversion range.\n\nNote: negative values for `final` indicates that values are to be taken\nfrom the end of the `word`.\n\nExamples:\n\n    \u003c!tolower HELLO\u003e      -\u003e hello\n    \u003c!tolower HELLO 0\u003e    -\u003e hELLO\n    \u003c!toupper hello 1 2\u003e  -\u003e hELlo\n    \u003c!toupper hello 0 -2\u003e -\u003e HELLo\n\n#### version\n\n    \u003c!version\u003e\n\nShows the program version which is processing the file.\n\nExample:\n\n    This page was created with htmlex \u003c!version\u003e.\n\n# Important Notes\n\n* `\u003c!macro X\u003e` deletes the X macro, so if you use `\u003c!if X\u003e`\n  that expression will give you true (because the string \"X\"\n  will be used, and not the value of X).\n\n* `\u003c!macro X \"\"\u003e` assigns a null value to the X macro, this is\n  necessary for a false result in `\u003c!if X\u003e` (because in this case,\n  the X is replaced by its value).\n\n## Author\n\nDavid Capello \u003cdavidcapello@gmail.com\u003e\n\nAny suggestion, thank-you letters, or (preferably) donations ;-),\nwill be most welcomed.\n\nYou can visit http://davidcapello.com/donate/ for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdacap%2Fhtmlex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdacap%2Fhtmlex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdacap%2Fhtmlex/lists"}