rmmd
v2.3.0
Published
Lightweight command-line tool to convert Markdown into HTML. Built on unified.js.
Downloads
214
Readme
rmmd
rmmd
is a lightweight command-line tool to convert Markdown into HTML. It supports standard input, file processing, and advanced options for wrapping output in a full HTML document. Built on unified.js.
- Convert Markdown to HTML: Quickly process Markdown files or input streams into semantic HTML.
- Flexible Input Options: Provide input via a file, stdin, or direct piping from another command.
- File Output: Write the output to a file using the
--file
or-f
option. - Full HTML Document Wrapping: Use the
--enclose
or-e
option to wrap the HTML content in a complete, standards-compliant HTML document. - Command-line Options:
- Process a file or piped content by default.
--file
(-f
): Specify a file to write the output.--enclose
(-e
): Wrap output in a fully compliant HTML document.--version
(-v
): Output the version.--help
(-h
): Display help information.- Use
--custom
(-c
) to enable custom syntax processing. - Leave out
--custom
to process only basic Markdown.
- Modern Web Standards: Outputs valid HTML5 for browser compatibility.
- Custom Markup Syntax:
=
wraps text in<mark>
:
Produces:This is =marked text= in markdown.
<p>This is <mark>marked text</mark> in markdown.</p>
+
wraps text in<dfn>
:
Produces:This is +a definition text+ in markdown.
<p>This is <dfn>a definition text</dfn> in markdown.</p>
~
wraps text in<s>
:
Produces:This is ~a styled text passage~ in markdown.
<p>This is <s>a styled text passage</s> in markdown.</p>
Installation
Install rmmd globally using npm:
npm install -g rmmd
This makes the rmmd
command available globally on your system.
Usage
Basic Conversion
Convert a Markdown file to HTML:
rmmd example.md
Piping Markdown Content
Pipe Markdown content directly into rmmd
:
cat example.md | rmmd
Write to a File
Use the --file
or -f
option to specify an output file:
rmmd example.md -f output.html
Wrap Output in an HTML Document
Use the --enclose
or -e
option to wrap the output in a complete HTML document:
rmmd example.md -e
Combine it with file output:
rmmd example.md -e -f wrapped.html
Display Version and Help
Check the version:
rmmd -v
Display help:
rmmd -h
- Convert Markdown to HTML and print to
stdout
:rmmd example.md
- Convert Markdown and write output to a file:
rmmd example.md -f result.html
- Convert Markdown, wrap in an HTML document, and print:
rmmd example.md -e
- Convert, wrap, and save to a file:
rmmd example.md -e -f full-document.html
- Pipe Markdown content into
rmmd
and wrap in a document:cat example.md | rmmd -e
- Convert Markdown to HTML with basic syntax:
rmmd example.md
- Convert Markdown to HTML with custom syntax:
rmmd example.md --custom
- Wrap the output in an HTML document:
rmmd example.md --enclose
- Combine custom syntax, file output, and HTML wrapping:
rmmd example.md --custom --enclose --file output.html
Default HTML Output
By default, the tool converts Markdown to clean HTML:
<h1>Hello, World</h1>
<p>This is Markdown rendered as HTML.</p>
Enclosed HTML Output
Using the --enclose
option wraps the output in a valid HTML document:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Markdown Output</title>
</head>
<body>
<h1>Hello, World</h1>
<p>This is Markdown rendered as HTML.</p>
</body>
</html>
The tool provides helpful error messages:
- If no input is provided:
No input provided. Use a file path or pipe Markdown content.
- If the specified file does not exist:
Error: ENOENT: no such file or directory, open 'example.md'
- If invalid options are passed:
error: unknown option '--invalid'
The tool is modular, using separate libraries for Markdown processing and HTML wrapping. It follows modern ESM standards.
Project Structure
rmmd/
|-- bin/
| |-- rmmd.js # CLI logic
|-- lib/
| |-- customMarkup.js # Custom markup manager
| |-- markdownToHtml.js # Markdown to HTML conversion
| |-- remarkMark.js # <mark> syntax plugin
| |-- remarkDfn.js # <dfn> syntax plugin
| |-- remarkStrikethrough.js # <s> syntax plugin
| |-- wrapHtml.js # HTML wrapping logic
Internal Modules
markdownToHtml.js
: Handles Markdown-to-HTML conversion.wrapHtml.js
: Wraps HTML output in a complete HTML document.
Adding New Syntax
- Create a new plugin file in
lib/
. - Register it in
customMarkup.js
. - Enable it in the
customMarkup
function call inmarkdownToHtml.js
.
Contributions welcome! Follow these steps:
- Fork the repository.
- Create a new branch for your feature:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add feature"
- Push to your branch:
git push origin feature-name
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE
file for more details.
Enjoy! -SL