|
1 | 1 | DOC-TITLE CMFC
|
2 | 2 | DOC-AUTHOR tirimid
|
3 | 3 | DOC-CREATED 2024-10-12
|
| 4 | +DOC-REVISED 2024-10-20 |
4 | 5 |
|
5 |
| - stuff will eventually be added here... |
| 6 | +=What is CMFC? |
| 7 | + |
| 8 | + CMFC is a compiler for a markup language I designed, CMF. This page will |
| 9 | +serve as both documentation and a tutorial surrounding both of them, should |
| 10 | +anybody want to use them. CMFC was created specifically for my personal website |
| 11 | +(the one you are on right now) and does not have any particularly advanced |
| 12 | +features. Still, I think it is good enough for simple articles and sharing my |
| 13 | +basic thoughts on the internet. |
| 14 | + Of course, this leads to the question of "why not just use Markdown and |
| 15 | +Jekyll build with GitHub pages?". The answer to this question is twofold - first |
| 16 | +of all, it's cool to make things yourself. Second of all, it irritates me how, |
| 17 | +in Markdown, paragraphs always have to begin on a double-newline separation. I |
| 18 | +would much rather write my plaintext document files in a style more similar to |
| 19 | +academic books, where the preferred style is generally no linebreaks but use of |
| 20 | +indentation to mark paragraph starts. Similarly, I'd prefer for blockquotes to |
| 21 | +be indented sections rather than just double-newline separated blocks with a `>` |
| 22 | +in front of them. Those are the main reasons I created CMF. And CMFC was created |
| 23 | +so that I could write documents in CMF and have them manifest as HTML files on |
| 24 | +my website. |
| 25 | + CMF stands for Custom Markup Format, and CMFC stands for Custom Markup |
| 26 | +Format Compiler. I suggest using the `.cmf` file extension for CMF files. |
| 27 | + |
| 28 | +=Installation |
| 29 | + |
| 30 | + CMFC is free software, licensed under the permissive MIT license. The source |
| 31 | +code for it is hosted on GitHub, and it is designed to work on Linux machines. |
| 32 | +Windows machines would probably work, but I make no guarantees. To prepare CMFC, |
| 33 | +clone @[https://github.com/tirimid/cmfc|the repository], Make it, then install |
| 34 | +it to your system as follows: |
| 35 | + |
| 36 | +``` |
| 37 | +$ git clone https://github.com/tirimid/cmfc |
| 38 | +$ cd cmfc |
| 39 | +$ make |
| 40 | +# make install |
| 41 | +``` |
| 42 | + |
| 43 | + The `cmfc` binary will be installed to `/usr/bin`, and can be uninstalled at |
| 44 | +any moment by going back to the cloned repository's directory and running this |
| 45 | +command: |
| 46 | + |
| 47 | +``` |
| 48 | +# make uninstall |
| 49 | +``` |
| 50 | + |
| 51 | +=The basic functioning of CMFC |
| 52 | + |
| 53 | + From an end-user's perspective, you only need to know the following sequence |
| 54 | +of events, executed by the `cmfc` binary when invoked: |
| 55 | + |
| 56 | +#Read command line arguments |
| 57 | +#Read in the contents of the input file and (if provided) style file |
| 58 | +#Parse the input file and construct a document AST |
| 59 | +#Write out the HTML generated from the AST into the output file (or if it isn't |
| 60 | + specified, standard output), along with the contents of the style file as the |
| 61 | + document's `<style>` |
| 62 | + |
| 63 | + Based on this simple process, we can understand the meaning of the command |
| 64 | +line flags which the program will accept: |
| 65 | + |
| 66 | +*`-A` will dump the AST directly instead of generating HTML |
| 67 | +*`-h` will display help text |
| 68 | +*`-o` will specify the output file (standard output if omitted) |
| 69 | +*`-s` will specify the style file to put in the HTML's `<style>` section |
| 70 | + |
| 71 | + Apart from the command line options, CMFC will also take one mandatory |
| 72 | +argument, the input file from which to read the CMF. |
| 73 | + |
| 74 | +=Example usage of CMFC |
| 75 | + |
| 76 | + Say you have an input file, `input.cmf`, and you want an output file, |
| 77 | +`output.html`, with a stylesheet, `style.css`, applied to it. In order to create |
| 78 | +it, you would invoke the following command: |
| 79 | + |
| 80 | +``` |
| 81 | +$ cmfc -o output.html -s style.css input.cmf |
| 82 | +``` |
| 83 | + |
| 84 | + Pretty simple. |
| 85 | + |
| 86 | +=CMF tutorial |
| 87 | + |
| 88 | +==Paragraphs |
| 89 | + |
| 90 | + Paragraphs can either be initiated through a double-linebreak or by placing |
| 91 | +four consecutive space characters at the beginning of a line. I prefer to use |
| 92 | +the four consecutive spaces, since that's pretty much the reason CMF/CMFC were |
| 93 | +created to begin with. |
| 94 | + Example paragraph: |
| 95 | + |
| 96 | +``` |
| 97 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod |
| 98 | +tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, |
| 99 | +quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo |
| 100 | +consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum |
| 101 | +dolore eu fugiat nulla pariatur. |
| 102 | +``` |
| 103 | + |
| 104 | +==Titles |
| 105 | + |
| 106 | + Titles of various sizes can be created by using `=` immediately after a |
| 107 | +double-linebreak. Similar to Markdown, the number of `=`s corresponds to the |
| 108 | +HTML header size. That is, more `=`s means a smaller header (unless the style |
| 109 | +file specifies otherwise). |
| 110 | + Example titles: |
| 111 | + |
| 112 | +``` |
| 113 | +=Size 1 title |
| 114 | + |
| 115 | +==Size 2 title |
| 116 | + |
| 117 | +===Size 3 title |
| 118 | +``` |
| 119 | + |
| 120 | +==Ordered and unordered lists |
| 121 | + |
| 122 | + Ordered and unordered lists can be created by using a `#` or a `\*` |
| 123 | +immediately after a double-linebreak, respectively. This was inspired by Wiki |
| 124 | +syntax, which will often do something similar. The level of nesting is specified |
| 125 | +by the number of consecutive `#`s or `\*`s. Each following element in the list |
| 126 | +is specified by placing a `#`/`\*` at the beginning of the line. |
| 127 | + Example ordered list: |
| 128 | + |
| 129 | +``` |
| 130 | +#Ordered list item 1 |
| 131 | +#Ordered list item 2 |
| 132 | +##Nested ordered list item 1 |
| 133 | +##Nested ordered list item 2 |
| 134 | +###Double-nested ordered list item 1 |
| 135 | +###Double-nested ordered list item 2 |
| 136 | +#Ordered list item 3 |
| 137 | +``` |
| 138 | + |
| 139 | + Example unordered list: |
| 140 | + |
| 141 | +``` |
| 142 | +\*Ordered list item 1 |
| 143 | +\*Ordered list item 2 |
| 144 | +\*\*Nested ordered list item 1 |
| 145 | +\*\*Nested ordered list item 2 |
| 146 | +\*\*\*Double-nested ordered list item 1 |
| 147 | +\*\*\*Double-nested ordered list item 2 |
| 148 | +\*Ordered list item 3 |
| 149 | +``` |
| 150 | + |
| 151 | +==Images |
| 152 | + |
| 153 | + Images are a standalone thing in CMF, unlike in Markdown, where they are |
| 154 | +merely another text element like a link. As such, they must be declared separate |
| 155 | +from other text. To add an image to the document, you must add a `!()` |
| 156 | +immediately after a double-linebreak. After the `!()`, add the link to the image |
| 157 | +you want to show up in the document. |
| 158 | + Example image: |
| 159 | + |
| 160 | +``` |
| 161 | +!()../res/gamingfumo.png |
| 162 | +``` |
| 163 | + |
| 164 | +==Blockquotes |
| 165 | + |
| 166 | + Blockquotes are meant to look how they do in academic books. To acheive such |
| 167 | +an effect, every line of a blockquote is indented by six spaces. I also suggest |
| 168 | +placing linebreaks between paragraphs and blockquote text. To initiate a |
| 169 | +blockquote, simply start a line with six spaces. Consecutive blockquote lines do |
| 170 | +not need to be similarly indented, but you should still do so for readability |
| 171 | +and visual clarity. |
| 172 | + Example blockquote: |
| 173 | + |
| 174 | +``` |
| 175 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod |
| 176 | + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim |
| 177 | + veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea |
| 178 | + commodo consequat. Duis aute irure dolor in reprehenderit in voluptate |
| 179 | + velit esse cillum dolore eu fugiat nulla pariatur. |
| 180 | +``` |
| 181 | + |
| 182 | +==Long code |
| 183 | + |
| 184 | + Long code snippets, like in Markdown, are enclosed in triple backticks. |
| 185 | +Unlike Markdown, however, you cannot use more than three backticks in a row to |
| 186 | +require more than three consecutive backticks in the long code snippet |
| 187 | +termination line. The long code snippet should be placed immediately after a |
| 188 | +double-linebreak. |
| 189 | + Example long code snippet: |
| 190 | + |
| 191 | +``` |
| 192 | +\`\`\` |
| 193 | +this is a long code snippet |
| 194 | +\`\`\` |
| 195 | +``` |
| 196 | + |
| 197 | +==Tables |
| 198 | + |
| 199 | + Tables are composed in plaintext form of cells, horizontally separated using |
| 200 | +dashes (`-`), and vertically separated using pipes (`|`). The horizontal |
| 201 | +separators are drawn overtop the vertical separators. To begin a table, place |
| 202 | +three consecutive `-`s immediately after a double-linebreak. Note that a single |
| 203 | +cell can take up more than one line, unlike in Markdown (another problem I have |
| 204 | +with it). |
| 205 | + Example table: |
| 206 | + |
| 207 | +``` |
| 208 | +--------------------------------------------------- |
| 209 | +|Lorem ipsum dolor sit|consectetur adipiscing elit| |
| 210 | +|amet | | |
| 211 | +--------------------------------------------------- |
| 212 | +|sed do eiusmod tempor|Ut enim ad minim veniam | |
| 213 | +|incididunt ut labore | | |
| 214 | +|et dolore magna | | |
| 215 | +|aliqua | | |
| 216 | +--------------------------------------------------- |
| 217 | +|quis nostrud |Duis aute irure dolor in | |
| 218 | +|exercitation ullamco |reprehenderit in voluptate | |
| 219 | +|laboris nisi ut |velit esse cillum dolore eu| |
| 220 | +|aliquip ex ea commodo|fugiat nulla pariatur | |
| 221 | +|consequat | | |
| 222 | +--------------------------------------------------- |
| 223 | +``` |
| 224 | + |
| 225 | +==Text formatting |
| 226 | + |
| 227 | + stuff will be added here eventually... |
| 228 | + |
| 229 | +=Collected CMF example |
| 230 | + |
| 231 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod |
| 232 | +tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, |
| 233 | +quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo |
| 234 | +consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum |
| 235 | +dolore eu fugiat nulla pariatur. |
| 236 | + |
| 237 | +=Size 1 title |
| 238 | + |
| 239 | +==Size 2 title |
| 240 | + |
| 241 | +===Size 3 title |
| 242 | + |
| 243 | +#Ordered list item 1 |
| 244 | +#Ordered list item 2 |
| 245 | +##Nested ordered list item 1 |
| 246 | +##Nested ordered list item 2 |
| 247 | +###Double-nested ordered list item 1 |
| 248 | +###Double-nested ordered list item 2 |
| 249 | +#Ordered list item 3 |
| 250 | + |
| 251 | +*Ordered list item 1 |
| 252 | +*Ordered list item 2 |
| 253 | +**Nested ordered list item 1 |
| 254 | +**Nested ordered list item 2 |
| 255 | +***Double-nested ordered list item 1 |
| 256 | +***Double-nested ordered list item 2 |
| 257 | +*Ordered list item 3 |
| 258 | + |
| 259 | +!()../res/gamingfumo.png |
| 260 | + |
| 261 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod |
| 262 | + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim |
| 263 | + veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea |
| 264 | + commodo consequat. Duis aute irure dolor in reprehenderit in voluptate |
| 265 | + velit esse cillum dolore eu fugiat nulla pariatur. |
| 266 | + |
| 267 | +``` |
| 268 | +this is a long code snippet |
| 269 | +``` |
| 270 | + |
| 271 | +--------------------------------------------------- |
| 272 | +|Lorem ipsum dolor sit|consectetur adipiscing elit| |
| 273 | +|amet | | |
| 274 | +--------------------------------------------------- |
| 275 | +|sed do eiusmod tempor|Ut enim ad minim veniam | |
| 276 | +|incididunt ut labore | | |
| 277 | +|et dolore magna | | |
| 278 | +|aliqua | | |
| 279 | +--------------------------------------------------- |
| 280 | +|quis nostrud |Duis aute irure dolor in | |
| 281 | +|exercitation ullamco |reprehenderit in voluptate | |
| 282 | +|laboris nisi ut |velit esse cillum dolore eu| |
| 283 | +|aliquip ex ea commodo|fugiat nulla pariatur | |
| 284 | +|consequat | | |
| 285 | +--------------------------------------------------- |
| 286 | + |
| 287 | +=DOC directives |
| 288 | + |
| 289 | + stuff will be added here eventually... |
0 commit comments