markugen
Version:
Markdown to HTML/PDF static site generation tool
362 lines (346 loc) • 24.1 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>Command Line Interface</title>
<link rel="stylesheet" href="markugen.css">
</head>
<body>
<h1 id="command-line-interface-cli">Command Line Interface (CLI)</h1>
<p>Markugen comes with a command line interface (CLI) that can be used in lieu
of having to build a Markugen object in code. Markugen will still need to be
installed into your project by using one of the following commands:</p>
<div class="markugen-tabs-container markugen-not-printable">
<div class="markugen-tabs-labels">
<div name="tab-1" class="markugen-tab-label active">npm</div>
<div name="tab-2" class="markugen-tab-label">yarn</div>
<div name="tab-3" class="markugen-tab-label">pnpm</div>
</div>
<div class="markugen-tabs">
<div name="tab-1" class="markugen-tab">
<p><code>npm install markugen</code></p>
</div>
<div name="tab-2" class="markugen-tab markugen-hidden">
<p><code>yarn add markugen</code></p>
</div>
<div name="tab-3" class="markugen-tab markugen-hidden">
<p><code>pnpm add markugen</code></p>
</div>
</div>
</div>
<div name="tab-1" class="markugen-tabs-container markugen-printable">
<div name="tab-1" class="markugen-tab-label">npm</div>
<div name="tab-1" class="markugen-tab">
<p><code>npm install markugen</code></p>
</div>
</div>
<div name="tab-2" class="markugen-tabs-container markugen-printable">
<div name="tab-2" class="markugen-tab-label">yarn</div>
<div name="tab-2" class="markugen-tab">
<p><code>yarn add markugen</code></p>
</div>
</div>
<div name="tab-3" class="markugen-tabs-container markugen-printable">
<div name="tab-3" class="markugen-tab-label">pnpm</div>
<div name="tab-3" class="markugen-tab">
<p><code>pnpm add markugen</code></p>
</div>
</div>
<h2 id="execution">Execution</h2>
<p>Once Markugen has been installed, you should now be able to execute the CLI
via the following command:</p>
<div class="markugen-code">
<div class="markugen-code-toolbar">
<div class="markugen-code-title">.bash</div>
<div title="Copy to Clipboard" class="markugen-code-copy" onclick="markugen.copyToClipboard('copy-save-9', this)">
<svg height="24px" viewBox="0 -960 960 960" width="24px" fill="var(--markugen-color)">
<path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"/>
</svg>
</div>
</div>
<pre class="markugen-code-content"><code id="copy-save-9" class="hljs language-bash">npx markugen</code></pre>
</div><p>Additionally, you can add markugen to your <code>package.json</code> as a script and
use <code>npm run</code> to execute the script:</p>
<div class="markugen-code">
<div class="markugen-code-toolbar">
<div class="markugen-code-title">.json</div>
<div title="Copy to Clipboard" class="markugen-code-copy" onclick="markugen.copyToClipboard('copy-save-10', this)">
<svg height="24px" viewBox="0 -960 960 960" width="24px" fill="var(--markugen-color)">
<path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"/>
</svg>
</div>
</div>
<pre class="markugen-code-content"><code id="copy-save-10" class="hljs language-json"><span class="hljs-punctuation">{</span>
...
<span class="hljs-attr">"scripts"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
<span class="hljs-attr">"markugen"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"markugen"</span>
<span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span></code></pre>
</div><h2 id="options">Options</h2>
<p>Most of the <a class="markugen-md-link" href="./Features/Options.html">options</a> available to Markugen's
constructor are also available with the CLI. There are a few options that are
too complex for the command line and, therefore, are not available
(i.e. <a class="markugen-md-link" href="./Features/Options.html#themes">themes</a>).</p>
<p>All available options/arguments can be viewed by executing one of the following
commands:</p>
<div class="markugen-code">
<div class="markugen-code-toolbar">
<div class="markugen-code-title">.bash</div>
<div title="Copy to Clipboard" class="markugen-code-copy" onclick="markugen.copyToClipboard('copy-save-11', this)">
<svg height="24px" viewBox="0 -960 960 960" width="24px" fill="var(--markugen-color)">
<path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"/>
</svg>
</div>
</div>
<pre class="markugen-code-content"><code id="copy-save-11" class="hljs language-bash">markugen <span class="hljs-built_in">help</span>
<span class="hljs-comment"># or</span>
markugen -h
<span class="hljs-comment"># or</span>
markugen --<span class="hljs-built_in">help</span></code></pre>
</div><p>The help option will output the following help message:</p>
<div class="markugen-code">
<div class="markugen-code-toolbar">
<div class="markugen-code-title">.txt</div>
<div title="Copy to Clipboard" class="markugen-code-copy" onclick="markugen.copyToClipboard('copy-save-12', this)">
<svg height="24px" viewBox="0 -960 960 960" width="24px" fill="var(--markugen-color)">
<path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"/>
</svg>
</div>
</div>
<pre class="markugen-code-content"><code id="copy-save-12" class="hljs language-txt">> markugen@2.0.5 start
> node --import tsx src/bin/cli.ts help
markugen
Markdown to HTML and/or PDF file generation
Commands:
markugen html Markdown to HTML and/or PDF file generation
[default] [aliases: mdtohtml]
markugen pdf HTML to PDF file generation [aliases: htmltopdf]
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
--format, --input-format, --if format of the input, string of markdown or
path to file/directory
[choices: "file", "string"] [default: "file"]
--output-format, --of format of the output, html files or string
of html (string is only valid if format is
also string or input is a file)
[choices: "file", "string"] [default: "file"]
-i, --input the directory to locate the markdown
files, a single file, or a string of
markdown [string] [default: "."]
--extensions, --exts list of file extensions to search the
input directory for
[array] [default: ["md"]]
-o, --output directory to write the output
[default: "./output"]
-n, --outputName, --on base name of the file to output, only used
when --input is a file or string, defaults
to index for strings and the file name for
files
-p, --pdf generates PDF files instead of html files
[boolean] [default: false]
--pdf-only, --po implies --pdf and removes all html
generated files, leaving only the PDFs
[boolean] [default: false]
-x, --exclude list of files or folders to exclude from
generation, paths should be relative to
the input directory [array]
-t, --title the title to use for the site
[string] [default: "Markugen v2.0.5"]
--inherit-title, --it if true, all pages not custom configured
will inherit the site title [boolean]
-f, --footer overrides the default Markugen footer
[string]
--timestamp, --ts if true, a timestamp will be embedded in
the js output [boolean] [default: true]
--home, --index sets the home page for the site, default
uses the first root page [string]
--toc maximum header depth to output in the
Table of Contents, values less than or
equal to zero will hide the Table of
Contents. [number] [default: 3]
-e, --embed if true, css and javascript will be
embedded in each page [boolean]
--favicon relative path to an icon to use as the
favicon, must be relative to the input
directory [string]
-a, --assets list of files or folders to copy to the
output [array]
-k, --keep-assets, --ka if true and --pdf, will keep the assets
after generation[boolean] [default: false]
--script additional JavaScript to embed in the
script tag at the end of the body [string]
--js additional JavaScript files to include on
each page [array]
--style additional CSS to embed in the style tag
[string]
--css additional CSS files to include on each
page [array]
--include-hidden, --ih include folders and files that begin with
a dot (.) [boolean] [default: false]
--clear-output, --co clears the output folder before building
[boolean] [default: false]
-v, --vars path to a JSON file representing dynamic
variables used in template expansion
[string]
--config path to a JSON file with an object
containing CLI arguments [string]
-b, --browser the path to the Chrome or Firefox
executable. This is only required if
generating PDFs and Markugen is unable to
locate the executable. [string]
--sandbox turns off the use of a sandbox for Chrome,
this should only be necessary if running
in a container and generating PDFs
[boolean] [default: true]
-c, --color if true, console output will be colored
[boolean] [default: true]
-q, --quiet if given, no output will be displayed
[boolean] [default: false]
-d, --debug turns on debugging
[boolean] [default: false]</code></pre>
</div><h2 id="subcommands">Subcommands</h2>
<p>The CLI has two subcommands that can be used: <code>html</code> and <code>pdf</code>. The subcommands
have aliases as well: <code>mdtohtml</code> and <code>htmltopdf</code> respectively. The <code>html</code>
subcommand is the default command used by the CLI; therefore, if no command
is provided, it will use the <code>html</code> command. The options available for each
subcommand can be obtained by providing the name of the command right before
the help option. The following two outputs show the options available via
the default <code>html</code> subcommand and the <code>pdf</code> subcommand respectively:</p>
<h3 id="markdown-to-html">Markdown to HTML</h3>
<div class="markugen-code">
<div class="markugen-code-toolbar">
<div class="markugen-code-title">.txt</div>
<div title="Copy to Clipboard" class="markugen-code-copy" onclick="markugen.copyToClipboard('copy-save-13', this)">
<svg height="24px" viewBox="0 -960 960 960" width="24px" fill="var(--markugen-color)">
<path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"/>
</svg>
</div>
</div>
<pre class="markugen-code-content"><code id="copy-save-13" class="hljs language-txt">> markugen@2.0.5 start
> node --import tsx src/bin/cli.ts html help
markugen html
Markdown to HTML and/or PDF file generation
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
--format, --input-format, --if format of the input, string of markdown or
path to file/directory
[choices: "file", "string"] [default: "file"]
--output-format, --of format of the output, html files or string
of html (string is only valid if format is
also string or input is a file)
[choices: "file", "string"] [default: "file"]
-i, --input the directory to locate the markdown
files, a single file, or a string of
markdown [string] [default: "."]
--extensions, --exts list of file extensions to search the
input directory for
[array] [default: ["md"]]
-o, --output directory to write the output
[default: "./output"]
-n, --outputName, --on base name of the file to output, only used
when --input is a file or string, defaults
to index for strings and the file name for
files
-p, --pdf generates PDF files instead of html files
[boolean] [default: false]
--pdf-only, --po implies --pdf and removes all html
generated files, leaving only the PDFs
[boolean] [default: false]
-x, --exclude list of files or folders to exclude from
generation, paths should be relative to
the input directory [array]
-t, --title the title to use for the site
[string] [default: "Markugen v2.0.5"]
--inherit-title, --it if true, all pages not custom configured
will inherit the site title [boolean]
-f, --footer overrides the default Markugen footer
[string]
--timestamp, --ts if true, a timestamp will be embedded in
the js output [boolean] [default: true]
--home, --index sets the home page for the site, default
uses the first root page [string]
--toc maximum header depth to output in the
Table of Contents, values less than or
equal to zero will hide the Table of
Contents. [number] [default: 3]
-e, --embed if true, css and javascript will be
embedded in each page [boolean]
--favicon relative path to an icon to use as the
favicon, must be relative to the input
directory [string]
-a, --assets list of files or folders to copy to the
output [array]
-k, --keep-assets, --ka if true and --pdf, will keep the assets
after generation[boolean] [default: false]
--script additional JavaScript to embed in the
script tag at the end of the body [string]
--js additional JavaScript files to include on
each page [array]
--style additional CSS to embed in the style tag
[string]
--css additional CSS files to include on each
page [array]
--include-hidden, --ih include folders and files that begin with
a dot (.) [boolean] [default: false]
--clear-output, --co clears the output folder before building
[boolean] [default: false]
-v, --vars path to a JSON file representing dynamic
variables used in template expansion
[string]
--config path to a JSON file with an object
containing CLI arguments [string]
-b, --browser the path to the Chrome or Firefox
executable. This is only required if
generating PDFs and Markugen is unable to
locate the executable. [string]
--sandbox turns off the use of a sandbox for Chrome,
this should only be necessary if running
in a container and generating PDFs
[boolean] [default: true]
-c, --color if true, console output will be colored
[boolean] [default: true]
-q, --quiet if given, no output will be displayed
[boolean] [default: false]
-d, --debug turns on debugging
[boolean] [default: false]</code></pre>
</div><h3 id="html-to-pdf">HTML to PDF</h3>
<div class="markugen-code">
<div class="markugen-code-toolbar">
<div class="markugen-code-title">.txt</div>
<div title="Copy to Clipboard" class="markugen-code-copy" onclick="markugen.copyToClipboard('copy-save-14', this)">
<svg height="24px" viewBox="0 -960 960 960" width="24px" fill="var(--markugen-color)">
<path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"/>
</svg>
</div>
</div>
<pre class="markugen-code-content"><code id="copy-save-14" class="hljs language-txt">> markugen@2.0.5 start
> node --import tsx src/bin/cli.ts pdf help
markugen pdf
HTML to PDF file generation
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
-i, --input the directory to locate the markdown files, a single
file, or a string of markdown [string] [required]
--extensions, --exts list of file extensions to search the input
directory for [array] [default: ["html"]]
-l, --links if true, markdown links generated by Markugen will
be converted to PDF links [boolean] [default: true]
-b, --browser the path to the Chrome or Firefox executable. This
is only required if generating PDFs and Markugen is
unable to locate the executable. [string]
--sandbox turns off the use of a sandbox for Chrome, this
should only be necessary if running in a container
and generating PDFs [boolean] [default: true]
-c, --color if true, console output will be colored
[boolean] [default: true]
-q, --quiet if given, no output will be displayed
[boolean] [default: false]
-d, --debug turns on debugging [boolean] [default: false]</code></pre>
</div>
<script src="markugen.js"></script>
</body>
</html>