A set of command-line tools for working with Markdown files with YAML headers.
Find a file
Dylan R. E. Moonfire 092db2a170
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci: removing spurious release
2023-01-25 20:40:27 -06:00
bin fix: corrected the shebangs for the installed scripts 2023-01-25 20:30:48 -06:00
scripts build: switching environment to use NixOS flakes 2023-01-25 20:28:19 -06:00
src chore(deps): updating packages 2021-02-03 23:15:00 -06:00
.editorconfig fix: added package management 2018-08-11 17:32:06 -05:00
.envrc build: switching environment to use NixOS flakes 2023-01-25 20:28:19 -06:00
.eslintrc.yml build: fixing issues with linting 2021-02-03 23:30:00 -06:00
.gitignore build: switching environment to use NixOS flakes 2023-01-25 20:28:19 -06:00
.npmignore Fixing the .npmignore to include the new path. 2017-10-20 00:15:59 -05:00
.woodpecker.yml ci: removing spurious release 2023-01-25 20:40:27 -06:00
CHANGELOG.md chore(release): v0.2.1 2021-02-05 00:21:05 +00:00
commitlint.config.js build: switching environment to use NixOS flakes 2023-01-25 20:28:19 -06:00
flake.lock build: switching environment to use NixOS flakes 2023-01-25 20:28:19 -06:00
flake.nix build: switching environment to use NixOS flakes 2023-01-25 20:28:19 -06:00
LICENSE.md Initial commit. 2016-10-31 19:25:37 -05:00
package.json build: switching environment to use NixOS flakes 2023-01-25 20:28:19 -06:00
prettier.config.js chore(deps): updating packages 2021-02-03 23:15:00 -06:00
README.md fix: correcting some documentation 2021-02-03 23:45:25 -06:00
release.config.js build: switching environment to use NixOS flakes 2023-01-25 20:28:19 -06:00
tsconfig.json fix: added package management 2018-08-11 17:32:06 -05:00
yarn.lock build: fixing issues with linting 2021-02-03 23:30:00 -06:00

markdowny

A set of command-line utilities for working with Markdown + YAML files, specifically for novels and short stories.

Setup and usage

Install markdowny using npm as a utility:

npm install --global markdowny

Basic usage is:

markdown verb *.markdown
markdowny-wc *.markdown

Verbs

version

Retrieves the version of the command-line utility and prints it out to the console.

markdowny version

content

Extract the content from one or more files.

markdowny content *.markdown

count

Counts the number of words excluding the YAML header and displays it.

markdowny count *.markdown [options]

Options:

  • -t, --total: Add a total line to the bottom that combines.
  • -s, --separator: Comma-separates the numbers in the total.

extract

Extract the metadata (front matter) from one or more files.

markdowny extract *.markdown [options]

Options:

  • --no-list: Don't write out the extract data as a list/sequence of items (default).
  • -y, --yaml: Extract the data as YAML instead of JSON (default).
  • --content PROPERTY: Extract the content as a property of the given name instead of just removing it. Defaults to not extracting the content.

sections

Displays each file as a heading 1 section with the title and contents provided.

Assuming that a file has a title and summary (which can be multiple lines) inside it, display a section for each file with the title as heading 1 and the contents of the summary value as the text for that section.

markdowny sections *.markdown -t title -f summary

Options:

  • -t, --title: The name of the property to put in for the section. May be nested such as author.name.first. Defaults to title.
  • -f, --field: The name of the property used for the contents of the section. Defaults to summary.

table

Displays a table of one or more fields inside the summary.

To list every file, it's title, the number of words inside it, and the list of secondary characters inside a nested value. The :rs makes the "Words" column right-aligned (r) and comma-separated (s).

markdowny table *.markdown -f _basename title _words characters.secondary -t File Title Words:rs "Secondary Characters"

Options:

  • -f, --fields: A parameter-separated list of YAML fields to list in the table, in the order they should be shown. Defaults to _basename title. These may also have a format specifier, starting with : (see below). This may be a nested value, such as characters.secondary.
  • -t, --titles: A parameter-separated list of titles for the columns. If there are more fields than titles, the field names will be used for the headers. These may have format specifiers.
  • --table-start: The characters to insert at the beginning of the row. Defaults to | .
  • --table-end: The characters to insert at the end of each row. Defaults to |.
  • --table-delimiter: The characters to insert between each field. Defaults to |.
  • --no-table-rule: Do not put a dashed line between the header and the various files.
  • --no-table-header: Do not display the header titles. The format of the headers is still parsed and used.
  • --list-delimiter: The characters to put between list items when inserted into a field. Defaults to , .
  • --prefix: The filename prefix that is trimmed from the _filename propery.

There are a number of special properties that are included in all files.

  • _filename: The full path of the filename, with the --prefix removed.
  • _basename: The name of the file without a directory.
  • _words: The number of words in the file, excluding the YAML header.