All Projects → GaelGirodon → markdown-to-document

GaelGirodon / markdown-to-document

Licence: GPL-3.0 License
A Markdown CLI to easily generate HTML documents from Markdown files

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
powershell
5483 projects
HTML
75241 projects

Projects that are alternatives of or similar to markdown-to-document

Phpstamp
The XSL-way templating library for MS Office Word DOCX documents.
Stars: ✭ 150 (+435.71%)
Mutual labels:  word, docx, document
Etherpad Lite
Etherpad: A modern really-real-time collaborative document editor.
Stars: ✭ 11,937 (+42532.14%)
Mutual labels:  word, docx, document
Docx
Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
Stars: ✭ 2,150 (+7578.57%)
Mutual labels:  word, docx, document
Pandiff
Prose diffs for any document format supported by Pandoc
Stars: ✭ 110 (+292.86%)
Mutual labels:  word, document
docxmustache
laravel 8.x docx template manipulation class, based on mustache templating language
Stars: ✭ 34 (+21.43%)
Mutual labels:  word, docx
Sharpdocx
C# based template engine for generating Word documents
Stars: ✭ 100 (+257.14%)
Mutual labels:  word, docx
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+3500%)
Mutual labels:  word, docx
Net Core Docx Html To Pdf Converter
.NET Core library to create custom reports based on Word docx or HTML documents and convert to PDF
Stars: ✭ 133 (+375%)
Mutual labels:  word, docx
Docxtemplater
Generate docx pptx and xlsx (Microsoft Word, Powerpoint, Excel documents) from templates, from Node.js, the Browser and the command line / Demo: https://www.docxtemplater.com/demo
Stars: ✭ 1,990 (+7007.14%)
Mutual labels:  word, docx
Documentserver
ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
Stars: ✭ 2,335 (+8239.29%)
Mutual labels:  word, docx
Docviewer
文档/文件查看器(支持本地或者其他app分享过来的word、excel、pdf、rtf等格式文件)
Stars: ✭ 155 (+453.57%)
Mutual labels:  word, document
officeexport-java
三行代码导出自定义样式word
Stars: ✭ 68 (+142.86%)
Mutual labels:  word, docx
Js Word
✒️ Word Processing Document Library
Stars: ✭ 1,203 (+4196.43%)
Mutual labels:  word, docx
Superfileview
基于腾讯浏览服务Tbs,使用X5Webkit内核,实现文件的展示功能,支持多种文件格式
Stars: ✭ 1,115 (+3882.14%)
Mutual labels:  word, docx
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (+117.86%)
Mutual labels:  word, docx
aspose-words-cloud-node
Node.Js library for communicating with the Aspose.Words Cloud API
Stars: ✭ 20 (-28.57%)
Mutual labels:  word, document
Fiduswriter
Fidus Writer is an online collaborative editor for academics.
Stars: ✭ 405 (+1346.43%)
Mutual labels:  word, docx
Docconv
Converts PDF, DOC, DOCX, XML, HTML, RTF, etc to plain text
Stars: ✭ 735 (+2525%)
Mutual labels:  word, docx
Poi Tl
Generate awesome word(docx) with template
Stars: ✭ 2,306 (+8135.71%)
Mutual labels:  word, docx
wordroller
Free Microsoft Word document (aka .docx) processing library for .Net
Stars: ✭ 17 (-39.29%)
Mutual labels:  word, docx

Markdown To Document

npm version npm license node build tests coverage

A Markdown CLI to easily generate HTML documents from Markdown files.

The original purpose of this tool was to provide an alternative to using Microsoft Word to write and send technical documents.

Use cases: replace docx and pdf files by Markdown (storage in Git, editing, ...) and HTML files (export, sending by email, ...), export a multi-files documentation into a single HTML file, etc.

Install

Install the CLI globally using NPM (Node.js >= 16):

npm install markdown-to-document -g

Linux users: EACCES permissions errors when installing packages globally?
→ Follow this guide to resolve them.

Usage

Compile Markdown files (path) into HTML documents.

mdtodoc [options] <path...>

Read usage examples to learn how to use the CLI.

Options

Option Description
-V, --version Output the version number
-d, --dest [value] Destination path (default: next to .md files)
-j, --join Concatenate all files before compilation
-l, --layout [value] HTML layout
-t, --theme [value] CSS theme
-s, --highlight-style [value] Syntax highlighting style
-n, --numbered-headings Enable numbered headings
-c, --code-copy Enable copy code button
-m, --mermaid Enable mermaid
-e, --embed-mode [value] Embed external resources (default: default)
-w, --watch Watch input files and compile on change
-h, --help Output usage information

Destination (--dest)

The destination path can be used to change where output HTML files are written.

Join (--join)

The --join option concatenates all Markdown source files in one (MERGED.md) before running the compilation (→ MERGED.html) :

  • Sorting: README.md and index.md files first, other .md files and sub-directories next
  • Front matter: remove YAML (---), TOML (+++) or JSON (;;;) front matter from source files
  • Titles: refactor titles level (# syntax only) to reflect path depth
  • Paths: refactor relative paths ([<...>](./<...>)) to reflect the directory structure
  • Table of contents: remove table of contents tokens from child pages

This feature, experimental and not very configurable for the moment, can be very useful to export a multi-files documentation into a single HTML file.

Layout (--layout)

A layout is an HTML template used as a base for the output HTML file, e.g.:

<!DOCTYPE html>
<html lang="en">
<head>
  <!--        ⬐ Markdown document title included here -->
  <title>{{ title }}</title>
  {{ styles }} <!-- ← CSS styles (theme, highlight styles, etc.) included here -->
</head>
<body>
{{ body }}     <!-- ← Compiled Markdown included here -->
</body>
{{ scripts }}  <!-- ← JS scripts included here -->
</html>

The --layout option can receive the name of a preset (e.g. page for page.html) or the path to a custom layout file (path/to/my-layout.html or a HTTP URL).

Theme (--theme)

A theme is a CSS stylesheet included in the HTML layout.

The --theme option can receive the name of a preset (e.g. github) or the path to a custom theme file (path/to/my-theme.css or a HTTP URL).

Highlight style (--highlight-style)

A highlight style is a CSS stylesheet included in the HTML layout to add a style to code blocks.

The --highlight-style option can receive the name of a Hightlight.js style (file name without extension, e.g. solarized-dark) or the path to a custom style file (a local path or a HTTP URL).

Additional features

Markdown To Document includes additional features:

  • Numbered headings (--numbered-headings): enable automatic headings numbering (h2 to h6, e.g. 1.1.1.)
  • Code copy (--code-copy): add a button Copy in each code block to easily copy the block content
  • Mermaid (--mermaid): add support for mermaid diagrams using fenced code blocks (```mermaid), e.g.:
graph LR
    Markdown -- mdtodoc --> HTML

Embed mode (--embed-mode)

The --embed-mode option allows to inline externally referenced resources (JS, CSS and images) to output a single HTML file without external dependencies (it can lead to a large output file).

3 modes are available:

  • light: inline light scripts (< 16 KB), stylesheets and light images (< 16 KB)
  • default: inline light scripts (< 16 KB), stylesheets and all images (default)
  • full: inline everything

Examples

Compile a single Markdown file (doc.md) into HTML (doc.html)

mdtodoc doc.md

Watch and compile multiple Markdown files using glob syntax

mdtodoc *.md --watch

Compile multiple Markdown files into a single HTML file (MERGED.html)

mdtodoc *.md --join

Improve the HTML output with a layout, a theme and a highlight style

mdtodoc doc.md --layout "page" --theme "github" --highlight-style "atom-one-light"

The compiled Markdown is now included into the predefined layout page and some CSS styling is added directly into the HTML file.

Enable additional extensions

mdtodoc doc.md -l "page" -t "github" -s "atom-one-light" --numbered-headings --code-copy --mermaid

HTML headings are now automatically numbered, a button Copy is added in each code block <pre> to copy the content and diagrams are generated from mermaid code blocks (```mermaid).

Embed all externally referenced resources

mdtodoc doc.md -l "page" -t "github" -s "atom-one-light" -n -c --embed-mode "full"

All external resources (CSS, JS and images) referenced in the Markdown file are now embedded into the output HTML file.

Use a custom layout (local file) and a custom highlight style (URL)

mdtodoc doc.md -l "./assets/layouts/page.html" -t "github" -s "https://raw.githubusercontent.com/highlightjs/highlight.js/master/src/styles/monokai.css" -n -c

Read options documentation for more information on how to use --layout, --theme and --highlight-style options.

Export a Markdown documentation in a GitLab CI pipeline

In a GitLab repository with Markdown files inside the docs/ folder, the following job can be defined (in .gitlab-ci.yml) to export all the documentation as a single HTML file:

export-doc:
  stage: doc
  image: node:lts
  before_script:
    - npm i markdown-to-document -g --only=prod
  script:
    - mdtodoc "docs/**/*.md" --join -l "page" -t "github" -s "atom-one-light" -n -c
    - mv docs/MERGED.html ./docs.html
  artifacts:
    paths:
      - docs.html

Resources

Useful apps, packages & more

Code editors

Although Markdown documents are simple text files and can be written using basic text editors, most code editors provide features and extensions to make writing these documents easier, e.g.:

Formatting

Markdown files can be easily formatted with code editors using built-in features or additional extensions but code formatters like Prettier also do a good job:

npm install --global prettier
prettier --check "*.md"
prettier --write "*.md"

Markdown compiler

Markdown To Document uses the Markdown.it compiler and the following plugins to generate HTML code from Markdown:

  • markdown-it-abbr - Abbreviation (<abbr>) tag support
  • markdown-it-anchor - Header anchors (permalinks) support
  • markdown-it-container - Custom block containers (:::) support
  • markdown-it-deflist - Definition list (<dl>) tag support
  • markdown-it-emoji - Emoji syntax (:memo:📝) support
  • markdown-it-footnote - Footnotes ([^1]) support
  • markdown-it-ins - Inserted (<ins>) tag support
  • markdown-it-mark - Marked (<mark>) tag support
  • markdown-it-sub - Subscript (<sub>) tag support
  • markdown-it-sup - Superscript (<sup>) tag support
  • markdown-it-toc-done-right - Table of contents ([[toc]]) support

Additional features also use the following packages:

  • highlight.js - Javascript syntax highlighter
  • web-resource-inliner - Brings externally referenced resources, such as js, css and images, into a single file
  • html-minifier - Javascript-based HTML compressor/minifier
  • clipboard.js - A modern approach to copy text to clipboard
  • cheerio - Fast, flexible, and lean implementation of core jQuery designed specifically for the server
  • chokidar - A neat wrapper around node.js fs.watch / fs.watchFile / FSEvents
  • mermaid - Generation of diagram and flowchart from text in a similar manner as markdown

Open package.json to see the full list of dependencies.

Useful links

Development

  • Link the mdtodoc command for development: npm link
    • Unlink: npm unlink
  • Format code with Prettier: npm run format[:check]
  • Lint code with ESLint: npm run lint
  • Build assets: npm run build:assets
  • Run tests: npm run test[:coverage]
  • Upgrade dependencies: npx npm-check-updates -u

License

Markdown To Document is licensed under the GNU General Public License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].