chptr
Command Line tool to handle separate Markdown files with special markup notations and export as a complete document.
Last updated 6 months ago by spiky.ing .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install chptr 
SYNC missed versions from official npm registry.

chptr

Command Line tool to handle separate Markdown files with special markup notations and export as a complete document.

oclif Version Downloads/week License

It is aimed at helping writing fiction, but could be used for managing any complicated long document.

Table of Contents

Key features

  • Wrapping Git basic functions for versionning and remote repository backup
  • Wrapping Pandoc basic functions for building assembled files in Markdown (.md), Word (.docx), LaTex (.tex), PDF (.pdf), Html (.html) and ePub (.epub).
  • Every "chapter" has three files:
    • Main content, in Markdown (.chptr file)
    • Summary content, in Markdown (.md file)
    • Metadata, in either YAML or JSON5.
  • Commands to
    • Init a new project and create a few required files
    • Add new chapters
    • Delete chapters
    • Reorder chapters
    • Build output and recomputing some metadata
    • Help with Antidote language checker workflow
    • Save to repository, in sentence-by-line style
    • Put chapters back to Edit mode, by removing paragraph markup and bringing back file in paragraphs
    • Rename chapters
    • Split chapters when many first-level titles are found in them
    • Track other files in repository system, for notes-taking
  • An extension is available for Antidote spell-checker workflow in Github and npm

Philosophy

That project was (and is still) a personal take on the fiction (and non-fiction) writing softwares. I like to separate content from format1, track all references and notes as I write2, have precise history of the files with source control3, and use the editing software of my choice4. Many other tools exist and have other philosophies, and they fit better for most people. They just don't work so well for me. This is a geeky tool, that I wanted to be simple (even if it is growing to be more than I first expected). It is aimed at me alone, but if you're another geek that thinks like me, enjoy, I hope you like it.

  • Every file has LF (\n) line endings; CRLF (\r\n) are converted. You can still work on Windows but the original Notepad won't do.
  • Every file is a UTF8 file without BOM. When sending a file to Antidote, files are converted to UTF8-BOM (because of limitations in that software) and have a .antidote extension added. When the Antidote work is done, that file is processed back to its original extension and the .antidote one is deleted.
  • Sentences are marked by a sentence termination character and two spaces. In the output files, the parsers will take all those double-spaces and convert them to single-spaces. That helps Chptr to identify sentence endings and put them on separate lines before saving them to repository, helping track evolution of the text with Git tools on a sentence-by-sentence basis, instead of paragraph-by-paragraph basis.
  • Metadata written inline has this structure: {key: possibly long value}. In the output, this metadata is either kept (and visually reorganized) or removed completely (for eventual outside review and publishing), depending on a --removemarkup flag in the build command. It is parsed and indexed in some metadata files.
  • Characters, places, hints (and possibly any other important things to track) have a special notation too, called props: {Batman} is a superhero in Gotham City. In this case, the word(s) between the brackets are kept in the output, either with ou without some outlining, depending on the --removemarkup flag of the build command again. They are indexed also in some metadata files to help finding them back easily.
  • Config folder has a few files that can be customized to fit many preferences:
    • YAML vs JSON5
    • Project's title, language, file naming patterns, etc.
    • What to put in an empty (new) chapter
    • What manual fields to track on each chapter's metadata

[1]: Pandoc does that

[2]: The markup format that I use to extend Markdown does that

[3]: Git does that

[4]: VSCode is nice↩

Prerequisites

To make it work, you'll need to have Git and Pandoc globally installed first (refer to those sites to download and install if needed). Also, Node (with it's companion NPM) are necessary to use as explained down here. There are ways to build a standalone executable from there but I won't publish those online, as I expect that if you want to use this tool, you probably already have Node and NPM installed. Instructions on how to build those executables is described here.

Roadmap, todos and warnings

This app doesn't have tests at this point, is not documented and will be liberately refactored as intensely as needed. It is not mature at all but I decided I wouldn't wait until it was to open-source it. Any and all breaking changes may appear between now and version 1.0.0.

In some future, I wish to do these things:

  • Include all sorts of tests
  • Document properly
  • Improve the code structure, code reusability and general code cleanliness

Usage

$ npm install -g chptr
$ chptr COMMAND
running command...
$ chptr (-v|--version|version)
chptr/0.1.13 win32-x64 node-v10.15.1
$ chptr --help [COMMAND]
USAGE
  $ chptr COMMAND
...

Commands

chptr add [NAME] [NUMBER]

Adds a file or set of files as a new chapter, locally and in repository

USAGE
  $ chptr add [NAME] [NUMBER]

ARGUMENTS
  NAME    name of chapter to add

  NUMBER  force this number to be used, if available.  If this argument is given, the `atnumbered` flag is ignored.
          AtNumbering will be determined by the presence or absence of @ sign.

OPTIONS
  -N, --notify      show a notification box when command is completed.
  -a, --atnumbered  Add an @numbered chapter
  -c, --compact     Compact chapter numbers at the same time
  -h, --help        show CLI help
  -p, --path=path   [default: .] Path where root of project files are

See code: src\commands\add.ts

chptr build

Takes all original Markdown files and outputs a single file without metadata and comments. Handles these output formats: md, pdf, docx, html, epub, tex. Gives some insight into writing rate.

USAGE
  $ chptr build

OPTIONS
  -N, --notify                              show a notification box when command is completed.
  -S, --withsummaries                       Add summaries in output, before actual content
  -c, --compact                             Compact chapter numbers at the same time
  -d, --datetimestamp                       adds datetime stamp before output filename
  -h, --help                                show CLI help
  -p, --path=path                           [default: .] Path where root of project files are
  -r, --removemarkup                        Remove paragraph numbers and clean markup in output

  -s, --showWritingRate=yes|no|overwrite    [default: yes] Show word count per day.  Overwrite option recalculates it
                                            all from scratch.

  -t, --type=md|pdf|docx|html|epub|tex|all  filetype to export to.  Can be set multiple times.

ALIASES
  $ chptr compile

See code: src\commands\build\index.ts

chptr build:compact

Only compacts numbers of files

USAGE
  $ chptr build:compact

OPTIONS
  -N, --notify     show a notification box when command is completed.
  -h, --help       show CLI help
  -p, --path=path  [default: .] Path where root of project files are

See code: src\commands\build\compact.ts

chptr build:metadata

Updates only metadata files

USAGE
  $ chptr build:metadata

OPTIONS
  -N, --notify                            show a notification box when command is completed.
  -c, --compact                           Compact chapter numbers at the same time
  -d, --datetimestamp                     adds datetime stamp before output filename
  -h, --help                              show CLI help
  -p, --path=path                         [default: .] Path where root of project files are

  -s, --showWritingRate=yes|no|overwrite  [default: yes] Show word count per day.  Overwrite option recalculates it all
                                          from scratch.

See code: src\commands\build\metadata.ts

chptr build:output

Takes all original Markdown files and outputs a single file without metadata and comments. Handles these output formats: md, pdf, docx, html, epub, tex. Gives some insight into writing rate.

USAGE
  $ chptr build:output

OPTIONS
  -N, --notify                              show a notification box when command is completed.
  -S, --withsummaries                       Add summaries in output, before actual content
  -c, --compact                             Compact chapter numbers at the same time
  -d, --datetimestamp                       adds datetime stamp before output filename
  -h, --help                                show CLI help
  -p, --path=path                           [default: .] Path where root of project files are
  -r, --removemarkup                        Remove paragraph numbers and clean markup in output

  -s, --showWritingRate=yes|no|overwrite    [default: yes] Show word count per day.  Overwrite option recalculates it
                                            all from scratch.

  -t, --type=md|pdf|docx|html|epub|tex|all  filetype to export to.  Can be set multiple times.

ALIASES
  $ chptr compile

See code: src\commands\build\output.ts

chptr delete [NAME]

Delete a chapter or tracked file locally and in the repository

USAGE
  $ chptr delete [NAME]

ARGUMENTS
  NAME  chapter number or filename to delete

OPTIONS
  -N, --notify     show a notification box when command is completed.
  -c, --compact    Compact chapter numbers at the same time
  -h, --help       show CLI help
  -p, --path=path  [default: .] Path where root of project files are

ALIASES
  $ chptr del

See code: src\commands\delete.ts

chptr edit [CHAPTERIDS]

Adjust sentence and paragraph endings to allow for easier editing. Commit changes with SAVE command.

USAGE
  $ chptr edit [CHAPTERIDS]

ARGUMENTS
  CHAPTERIDS  Chapter number(s) to modify, comma-separated.

OPTIONS
  -N, --notify                    show a notification box when command is completed.
  -h, --help                      show CLI help
  -p, --path=path                 [default: .] Path where root of project files are
  -t, --type=all|summary|chapter  [default: all] Edit either chapter file, summary file or all.

ALIASES
  $ chptr modify
  $ chptr mod

See code: src\commands\edit.ts

chptr help [COMMAND]

display help for chptr

USAGE
  $ chptr help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

chptr init [NAME]

Generates basic config files for a new novel project

USAGE
  $ chptr init [NAME]

ARGUMENTS
  NAME  Name of project

OPTIONS
  -N, --notify                                            show a notification box when command is completed.
  -a, --author=author                                     Name of author of project
  -d, --directorystructure=/|chapters/|chapters/number/|  Directory structure initially written in config file
  -e, --email=email                                       Email of author of project

  -f, --force=force                                       [default: false] Overwrite config files if they exist.
                                                          Specify a filename to overwrite only one; write `true` to
                                                          overwrite all.

  -h, --help                                              show CLI help

  -l, --language=language                                 Language of project

  -p, --path=path                                         [default: .] Path where root of project files are

  -r, --gitRemote=gitRemote                               Git address of remote repository.

  -s, --style=style                                       Config files in JSON5 or YAML?

ALIASES
  $ chptr setup

See code: src\commands\init.ts

chptr plugins

list installed plugins

USAGE
  $ chptr plugins

OPTIONS
  --core  show core plugins

EXAMPLE
  $ chptr plugins

See code: @oclif/plugin-plugins

chptr plugins:install PLUGIN...

installs a plugin into the CLI

USAGE
  $ chptr plugins:install PLUGIN...

ARGUMENTS
  PLUGIN  plugin to install

OPTIONS
  -f, --force    yarn install with force flag
  -h, --help     show CLI help
  -v, --verbose

DESCRIPTION
  Can be installed from npm or a git url.

  Installation of a user-installed plugin will override a core plugin.

  e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command 
  will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in 
  the CLI without the need to patch and update the whole CLI.

ALIASES
  $ chptr plugins:add

EXAMPLES
  $ chptr plugins:install myplugin 
  $ chptr plugins:install https://github.com/someuser/someplugin
  $ chptr plugins:install someuser/someplugin

See code: @oclif/plugin-plugins

chptr plugins:link PLUGIN

links a plugin into the CLI for development

USAGE
  $ chptr plugins:link PLUGIN

ARGUMENTS
  PATH  [default: .] path to plugin

OPTIONS
  -h, --help     show CLI help
  -v, --verbose

DESCRIPTION
  Installation of a linked plugin will override a user-installed or core plugin.

  e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello' 
  command will override the user-installed or core plugin implementation. This is useful for development work.

EXAMPLE
  $ chptr plugins:link myplugin

See code: @oclif/plugin-plugins

chptr plugins:uninstall PLUGIN...

removes a plugin from the CLI

USAGE
  $ chptr plugins:uninstall PLUGIN...

ARGUMENTS
  PLUGIN  plugin to uninstall

OPTIONS
  -h, --help     show CLI help
  -v, --verbose

ALIASES
  $ chptr plugins:unlink
  $ chptr plugins:remove

See code: @oclif/plugin-plugins

chptr plugins:update

update installed plugins

USAGE
  $ chptr plugins:update

OPTIONS
  -h, --help     show CLI help
  -v, --verbose

See code: @oclif/plugin-plugins

chptr rename [CHAPTERIDORFILENAME] [NEWNAME]

Modify chapter title in text, metadata and filename or tracked filename

USAGE
  $ chptr rename [CHAPTERIDORFILENAME] [NEWNAME]

ARGUMENTS
  CHAPTERIDORFILENAME  Chapter number or tracked filename to modify
  NEWNAME              New chapter name

OPTIONS
  -N, --notify     show a notification box when command is completed.
  -h, --help       show CLI help
  -p, --path=path  [default: .] Path where root of project files are
  -t, --title      'Use chapter's title as new name.  Will supercede a `newName` argument.

See code: src\commands\rename.ts

chptr reorder [ORIGINID] [DESTINATIONID]

Takes a chapter and modifies its index number to fit another ordering place

USAGE
  $ chptr reorder [ORIGINID] [DESTINATIONID]

ARGUMENTS
  ORIGINID       Chapter number to move
  DESTINATIONID  Number it will become (write `end` or `@end`to put at the end of each stack).

OPTIONS
  -N, --notify     show a notification box when command is completed.
  -c, --compact    Compact chapter numbers at the same time
  -h, --help       show CLI help
  -p, --path=path  [default: .] Path where root of project files are

ALIASES
  $ chptr move

See code: src\commands\reorder.ts

chptr save [MESSAGE]

Parse modified text files, adjust sentence and paragraph endings, and commit files to repository.

USAGE
  $ chptr save [MESSAGE]

ARGUMENTS
  MESSAGE  Message to use in commit to repository

OPTIONS
  -N, --notify             show a notification box when command is completed.
  -e, --empty              No manual message in commit

  -f, --filename=filename  Tracked filename or filename pattern to filter which files to stage before saving to
                           repository

  -h, --help               show CLI help

  -n, --number=number      Chapter number to filter which files to stage before saving to repository

  -p, --path=path          [default: .] Path where root of project files are

  -t, --track              Force tracking of file if not already in repository

ALIASES
  $ chptr commit

See code: src\commands\save.ts

chptr track [FILENAME]

Add a file to be tracked in repository that is not a chapter, summary or metadata file.

USAGE
  $ chptr track [FILENAME]

ARGUMENTS
  FILENAME  Filename to track

OPTIONS
  -N, --notify     show a notification box when command is completed.
  -h, --help       show CLI help
  -p, --path=path  [default: .] Path where root of project files are

See code: src\commands\track.ts

Current Tags

  • 0.1.13                                ...           latest (6 months ago)

14 Versions

  • 0.1.13                                ...           6 months ago
  • 0.1.12                                ...           6 months ago
  • 0.1.11                                ...           7 months ago
  • 0.1.10                                ...           9 months ago
  • 0.1.9                                ...           10 months ago
  • 0.1.8                                ...           10 months ago
  • 0.1.7                                ...           10 months ago
  • 0.1.6                                ...           10 months ago
  • 0.1.5                                ...           10 months ago
  • 0.1.4                                ...           10 months ago
  • 0.1.3                                ...           10 months ago
  • 0.1.2                                ...           10 months ago
  • 0.1.1                                ...           10 months ago
  • 0.1.0                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 1
Last Week 1
Last Month 1
Dev Dependencies (13)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |