Sidebar LogoHomeInstallationUsageIndexIndexGitHub </> Back Next Reference

Reference


About this page

This page contains reference information like factual technical details and descriptions that are usually long and would unnecessarily overload the other pages if placed there.


Command line syntax

Here is the program's help (the Python example, the Java version will give a similar output):

>python %MD2HTML_HOME%/python/md2html.py -h
usage: md2html.py [-h] [--input-root INPUT_ROOT] [-i INPUT]
                  [--input-glob INPUT_GLOB] [--sort-by-file-path]
                  [--sort-by-variable SORT_BY_VARIABLE] [--sort-by-title]
                  [--output-root OUTPUT_ROOT] [-o OUTPUT]
                  [--argument-file ARGUMENT_FILE] [-t TITLE]
                  [--title-from-variable TITLE_FROM_VARIABLE]
                  [--template TEMPLATE] [--link-css LINK_CSS]
                  [--include-css INCLUDE_CSS] [--no-css] [-f] [-v] [-r]
                  [--legacy-mode]

Creates HTML documentation out of Markdown texts.

optional arguments:
  -h, --help            show this help message and exit
  --input-root INPUT_ROOT
                        root directory for input Markdown files. Defaults to
                        current directory
  -i INPUT, --input INPUT
                        input Markdown file name: absolute or relative to the '
                        --input-root' argument value
  --input-glob INPUT_GLOB
                        input Markdown file name pattern: absolute or relative
                        to the '--input-root' argument value
  --sort-by-file-path   If '--input-glob' is used, the documents will be sorted
                        by the input file path
  --sort-by-variable SORT_BY_VARIABLE
                        If '--input-glob' is used, the documents will be sorted
                        by the value of the specified page variable
  --sort-by-title       If '--input-glob' is used, the documents will be sorted
                        by their titles
  --output-root OUTPUT_ROOT
                        root directory for output HTML files. Defaults to
                        current directory
  -o OUTPUT, --output OUTPUT
                        output HTML file name: absolute or relative to '--
                        output-root' argument value. Defaults to input file name
                        with '.html' extension
  --argument-file ARGUMENT_FILE
                        argument file. Allows processing multiple documents with
                        a single run. Also provides different adjustment
                        possibilities and automations. If omitted, the single
                        file will be processed
  -t TITLE, --title TITLE
                        the HTML page title
  --title-from-variable TITLE_FROM_VARIABLE
                        If specified then the program will take the title from
                        the page metadata at the step of making up the input
                        file list
  --template TEMPLATE   template that will be used for HTML documents generation
  --link-css LINK_CSS   links CSS file, multiple entries allowed
  --include-css INCLUDE_CSS
                        includes content of the CSS file into HTML, multiple
                        entries allowed
  --no-css              creates HTML with no CSS. If no CSS-related arguments is
                        specified, the default CSS will be included
  -f, --force           rewrites HTML output file even if it was modified later
                        than the input file
  -v, --verbose         outputs human readable information messages
  -r, --report          turns on formalized output that may be further
                        automatically processed. Only if HTML file is generated,
                        the path of this file will be output. Incompatible with
                        -v
  --legacy-mode         Allows processing documentation projects prepared for
                        version of the program prior to 1.0.0. It's still
                        recommended to migrate the documentation projects to the
                        newer version

Here are some additional explanations:


Argument file structure

Here is a very simple example of an argument file content:

{
    "documents": [
        { "input": "index.txt", "title": "Home" },
        { "input": "about.txt", "output": "about.html", "title": "Home" }
    ]
}

Here is a quite complex example of an argument file content:

{
    "options": {
        # This only affects the whole run verbosity, for now only printing execution duration.
        "verbose": true,
        "legacy-mode": false
    },
    "default": {
        # These are the default options for all documents.
        "input-root": "doc_src",
        "output-root": "doc",
        "template": "doc_src/templates/multipage.html",
        "no-css": true,
        "page-flows": ["sections"]
    },
    "documents": [
        { "input-root": "", "output-root": "", "input": "index.txt", "title": "Home" },
        { "input": "about.txt", "title": "About" },
        { "input-root": "tech_src", "output-root": "tech", 
            "input": "debug.txt", "output": "debugging.html", 
            "title": "Debug", "page-flows": [] }
    ],
    "plugins": {
        "variables": {"logo": "<img src=\"logo.png\" />" },
        "page-variables": {},
        "relative-paths": { "resource_path": "doc/" },
        "page-flows": {
            "otherLinks": [
                { "link": "https://daringfireball.net/projects/markdown/", 
                    "title": "Markdown Home", "external": true },
                { "link": "https://en.wikipedia.org/wiki/Markdown", 
                    "title": "Markdown Wiki", "external": true }
            ]
        },
        "index": {"index": {"output": "index_page.html", "title": "Index", 
            "index-cache": "index_cache.json" }
    }
}

Argument file format is JSON [json].

Note

Comments are not allowed in JSON syntax, but in this program, whole-line comments may be added with # as the first non-blank symbol of the line; such lines will be ignored.

Also the program ignores unknown keys that may be used for temporarily removing parameters. For example, if "plugins" is replaced with "plugins1" then all plugins will be disabled. Still the argument file format defines necessary elements and other rules that will be checked before processing.

The following is the detailed argument file format description by sections:

Name Type Required Description
options object No Options for the whole program run
default object No Default options for the documents
documents array of objects Yes Documents that will be processed
plugins object No Plugins that will be used for the documents processing

options section

to section list

Properties:

Name Type Required Description
verbose boolean No The whole run verbosity, for now, only printing execution duration on finish
legacy-mode boolean No Activates legacy mode

default section

to section list

These parameters will be applied to the document definitions if they are not defined explicitly. See the documents section for the details.

Properties:

Name Type Required Description
input-root string No
input-glob string No
sort-by-file-path boolean No
sort-by-variable string No
sort-by-title boolean No
output string No
output-root string No
template string No
title string No
title-from-variable string No
code-from-variable string No
verbose boolean No
link-css array of strings No
include-css array of strings No
no-css boolean No
page-flows array of strings No

documents section

to section list

Array of objects with properties:

Name Type Required Description
input-root string No Root directory for input Markdown files
input string No Input Markdown file: absolute or relative to the input-root property value
input-glob string No Input Markdown file name pattern, absolute or relative to the input-root' property value
sort-by-file-path boolean No If input-glob is used, the documents will be sorted by the input file path
sort-by-variable string No If input-glob is used, the documents will be sorted by the value of the specified page variable
sort-by-title boolean No If input-glob is used, the documents will be sorted by their titles
output-root string No Root directory for output HTML files
output string No Output HTML file: absolute or relative to the output-root property value
title string No Page title
code string No Unique page code, may be used by plugins
title-from-variable string No Take the title from the page metadata
code-from-variable string No Take the code from the page metadata
template string No Template that will wrap the generated HTML content
link-css array of strings No List of CSS resources that will be linked to the page
include-css array of strings No List of CSS files that will be included into the page
no-css boolean No Defines no CSS to be linked or included
add-link-css array of strings No Adds linked CSS to the previously defined list
add-include-css array of strings No Adds included CSS to the previously defined list
page-flows array of strings No Names of the page flows the page belongs to
add-page-flows array of strings No Adds page flow names to the previously defined list
verbose boolean No Outputs human readable information about this document generation
report boolean No The same meaning as the corresponding command line argument

plugins section

to section list

May contain multiple properties:

Name Type Required Description
plugin name defined by plugin No Plugin data

The plugins data and the plugins themselves are described in the separate sections.

 


Back Next