buildmd/README.md

50 lines
1.9 KiB
Markdown

# buildmd
Build markdown files to html
## Usage
```
buildmd - Build markdown files to html with templates and metadata
Usage:
buildmd file.md
buildmd file.md -o output.html
buildmd ./src/*.md --outdir public
echo "some markdown" | buildmd
Options:
--outfile, -o <file> Output path
--outdir, -d <dir> Output directory
--stdout Force output to stdout
--template, -t <file> Template path (default: _template.html)
--stylesheet, -s <file> Stylesheet path (default: _style.css)
--title, -T <string> Document title override
--help, -h Show this help message
```
## Templates
`buildmd` uses simple HTML files as templates, replacing instances of `%key%` with the value of `key` in the metadata of the document.
By default, `buildmd` will look for a `_template.html` file in the current working directory, unless an alternate template is specified with the `--template` or `-t` option.
The following metadata is available by default:
- `title`: The title of the document
- `content`: The rendered markdown content
- `stylesheet`: The document css styles
- `timestamp`: An ISO string representing when the build occurred
- `datetime` A localized string representing when the build occurred
Additionally, any data defined in YAML frontmatter in the markdown file
will be available for use in the template. Properties defined in frontmatter
take precedence over the default metadata.
If no template file is discovered, `buildmd` will inject a default template that includes the stylesheet, title, and content in well-structured HTML.
## Styles
`buildmd` will automatically look for a `_style.css` file in the current working directory, unless an alternate stylesheet is specified with the `--stylesheet` or `-s` option. The contents of the discovered stylesheet file will be available in the template as `%stylesheet%`.
In the event that no stylesheet is found, `buildmd` will inject a default stylesheet.