Using the CLI
Markdom provides a simple CLI for converting Markdown files to HTML. This is useful for quick, one-off conversions without writing any code.
Basic Usage
Section titled “Basic Usage”To convert a Markdown file to HTML using the CLI, run the following command:
npx @tenedev/markdom file.md -o file.html
file.md
: The input Markdown file you want to convert.-o file.html
: The output HTML file where the converted content will be saved (make sure it ends in.html
).
CLI Flags
Section titled “CLI Flags”The Markdom CLI supports the following flags:
-o <file.html>
: Specifies the output HTML file name. The file extension must be.html
.
For example:
npx @tenedev/markdom README.md -o output.html
This command will take the README.md
file and convert it into an HTML file named output.html
.
Best Practices
Section titled “Best Practices”- Use a clear output filename: Always specify a clear, meaningful output filename (e.g.,
index.html
ordocumentation.html
). - Ensure correct file extensions: The output file must always end with
.html
for proper rendering and recognition by browsers. - Check file paths: Ensure that both the input Markdown file and the output HTML file are located in the correct directories relative to where you run the command.
Example
Section titled “Example”Input Markdown (example.md
):
Section titled “Input Markdown (example.md):”# Hello World
This is an example of a Markdown file converted to HTML.
Command:
Section titled “Command:”npx @tenedev/markdom example.md -o example.html
Output HTML (example.html
):
Section titled “Output HTML (example.html):”<h1>Hello World</h1><p>This is an example of a Markdown file converted to HTML.</p>