CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-showdown

A Markdown to HTML converter written in Javascript

Pending
Overview
Eval results
Files

cli.mddocs/

Command Line Interface

CLI tool for converting Markdown files to HTML with full option support and extension loading.

Capabilities

showdown makehtml

Main command for converting Markdown to HTML via command line.

showdown makehtml [options]

Options

Input/Output Options

-i, --input [file]              # Input source (file path or stdin)
-o, --output [file]             # Output target (file path or stdout)
-u, --encoding <encoding>       # Input encoding (default: utf8)
-y, --output-encoding <encoding> # Output encoding (default: utf8)
-a, --append                    # Append to output file instead of overwriting

Conversion Options

-p, --flavor <flavor>           # Use predefined flavor (vanilla, github, ghost, original)
-c, --config <config...>        # Enable parser options
-e, --extensions <extensions...> # Load extensions (file paths)

Utility Options

--config-help                   # Show available configuration options
-q, --quiet                     # Quiet mode (only print errors)
-m, --mute                      # Mute mode (print nothing)
-h, --help                      # Show help information
-V, --version                   # Show version number

Usage Examples

Basic Conversion

# Convert file to HTML
showdown makehtml -i input.md -o output.html

# Convert from stdin to stdout
echo "# Hello World" | showdown makehtml

# Read from stdin, write to file
showdown makehtml -i -o output.html < input.md

Using Flavors

# Use GitHub Flavored Markdown
showdown makehtml -i input.md -o output.html --flavor github

# Use Ghost flavor
showdown makehtml -i input.md --flavor ghost

# Use original Markdown behavior
showdown makehtml -i input.md --flavor original

Configuration Options

# Enable specific options
showdown makehtml -i input.md -c tables strikethrough ghCodeBlocks

# Enable options with values
showdown makehtml -i input.md -c prefixHeaderId="section-"

# Combine flavor with custom options
showdown makehtml -i input.md --flavor github -c emoji=false

Extension Loading

# Load single extension
showdown makehtml -i input.md -e ./my-extension.js

# Load multiple extensions
showdown makehtml -i input.md -e ./ext1.js ./ext2.js ./ext3.js

# Combine with other options
showdown makehtml -i input.md --flavor github -e ./highlight.js -c tables

Encoding Options

# Specify input encoding
showdown makehtml -i input.md -u utf16le

# Specify both input and output encoding
showdown makehtml -i input.md -u utf8 -y ascii

# For Windows users with special characters
showdown makehtml -i input.md -u utf8

Output Control

# Append to existing file
showdown makehtml -i input.md -o output.html --append

# Quiet mode (only errors)
showdown makehtml -i input.md -o output.html --quiet

# Mute mode (no output)
showdown makehtml -i input.md -o output.html --mute

Configuration Help

View all available configuration options:

showdown makehtml --config-help

This displays detailed information about all parser options including:

  • Option names
  • Default values
  • Descriptions
  • Data types

Configuration Examples

GitHub-style Conversion

showdown makehtml -i README.md -o README.html \
  --flavor github \
  -c ghMentionsLink="https://github.com"

Custom Blog Conversion

showdown makehtml -i post.md -o post.html \
  -c tables \
  -c strikethrough \
  -c headerLevelStart=2 \
  -c prefixHeaderId="post-"

Extension with Options

showdown makehtml -i doc.md -o doc.html \
  -e ./syntax-highlight.js \
  -c ghCodeBlocks \
  -c tables

Error Handling

The CLI provides informative error messages:

# File not found
showdown makehtml -i nonexistent.md
# ERROR: Could not read from file nonexistent.md, reason: ENOENT: no such file or directory

# Invalid extension
showdown makehtml -i input.md -e ./bad-extension.js
# ERROR: Could not load extension ./bad-extension.js. Reason: [error details]

# Invalid flavor
showdown makehtml -i input.md --flavor invalid
# ERROR: invalid flavor was not found

Exit Codes

  • 0: Success
  • 1: Error (file not found, invalid options, conversion failure, etc.)

Windows Considerations

For Windows users dealing with encoding issues:

# Set command line to UTF-8 before running
chcp 65001

# Then run showdown
showdown makehtml -i input.md -o output.html

Or specify encoding explicitly:

showdown makehtml -i input.md -o output.html -u utf8

Stdin/Stdout Patterns

Pipe from other commands

# From curl
curl -s https://raw.githubusercontent.com/user/repo/main/README.md | showdown makehtml

# From echo
echo "**Bold text**" | showdown makehtml

# From cat
cat *.md | showdown makehtml --flavor github

Pipe to other commands

# Pipe to less for viewing
showdown makehtml -i large-doc.md | less

# Pipe to file with additional processing
showdown makehtml -i input.md | sed 's/old/new/g' > output.html

# Count output lines
showdown makehtml -i input.md | wc -l

Batch Processing

Process multiple files:

# Using shell loop
for file in *.md; do
  showdown makehtml -i "$file" -o "${file%.md}.html" --flavor github
done

# Using find and xargs
find . -name "*.md" -exec showdown makehtml -i {} -o {}.html \;

Performance Tips

  • Use --quiet or --mute for batch processing to reduce output
  • Load extensions once per batch rather than per file when possible
  • Consider using the JavaScript API for high-volume processing
  • Specify encoding explicitly to avoid detection overhead

Install with Tessl CLI

npx tessl i tessl/npm-showdown

docs

cli.md

core-conversion.md

event-system.md

extension-system.md

flavor-management.md

global-configuration.md

index.md

instance-configuration.md

tile.json