Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue fixes #63

Merged
merged 47 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
03177d5
updated docs
knennigtri Feb 7, 2023
cd6f59c
depcheck added
knennigtri Feb 7, 2023
1e96e1c
updated pandoc requirement
knennigtri Jul 25, 2023
bfd33fc
creating clean CLI
knennigtri Mar 15, 2024
b4045c5
removing CLI
knennigtri Mar 15, 2024
62a4cbe
added debug options
knennigtri Mar 15, 2024
1d0400a
comments
knennigtri Mar 15, 2024
73c52e9
Update merge.js
knennigtri Mar 16, 2024
af8ee75
removed CLI from manifest logic
knennigtri Mar 16, 2024
bafd5bd
created stand alone cli
knennigtri Mar 16, 2024
285c53f
#61
knennigtri Mar 19, 2024
abc9c5b
Simplified extensions
knennigtri Mar 20, 2024
54dae4d
Simplified the writeSingleFile method
knennigtri Mar 20, 2024
ccdd8e8
#62
knennigtri Mar 21, 2024
d7a960e
cleanup and simplification
knennigtri Mar 21, 2024
4b2b88c
minor updates
knennigtri Mar 21, 2024
f24272c
name update
knennigtri Mar 21, 2024
9d4826f
messages update
knennigtri Mar 21, 2024
2aa64a4
presentation added
knennigtri Mar 21, 2024
3656398
simplified to make more efficient
knennigtri Mar 21, 2024
67f631e
Update manifest.yml
knennigtri Apr 10, 2024
da9b847
updated dependencies
knennigtri Apr 10, 2024
cf737a8
rewrote to make linkcheck and file write async
knennigtri Apr 10, 2024
3c1ecab
Update manifest.js
knennigtri Apr 10, 2024
e8c9aed
Update package-lock.json
knennigtri Apr 10, 2024
2f3839c
cleanup
knennigtri Apr 10, 2024
bc46feb
Update cli.js
knennigtri Apr 11, 2024
5f638ed
async update
knennigtri Apr 18, 2024
9adc460
Update merge.js
knennigtri Apr 18, 2024
05bb428
Update package.json
knennigtri Apr 18, 2024
5c6dc9d
simplified presentation
knennigtri Apr 18, 2024
a9f11fa
Update cli.js
knennigtri Apr 18, 2024
810b6d7
Prep docs
knennigtri Apr 18, 2024
3550aef
Force deletion of old files
knennigtri Apr 27, 2024
484ef47
Update presentation.js
knennigtri Apr 28, 2024
7109456
Update package-lock.json
knennigtri Apr 28, 2024
0628709
Update .gitignore
knennigtri Apr 28, 2024
6d68a8f
function to download docker files
knennigtri Apr 28, 2024
6fd0849
Update README.md
knennigtri May 1, 2024
ef95a91
lint fix
knennigtri May 1, 2024
b081bb8
Update README.md
knennigtri May 1, 2024
085b65b
Update .gitignore
knennigtri May 1, 2024
6a03407
Update package.json
knennigtri May 1, 2024
1db9b75
Update package.json
knennigtri May 1, 2024
b38e767
Update package.json
knennigtri May 2, 2024
747ee8c
Update package.json
knennigtri May 2, 2024
745898f
1.2.0
knennigtri May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ rules:
semi:
- error
- always
no-unused-vars:
- warn
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ output/
Output/
merged/
Merged/
Target/
target/
notes.txt
*.temp
*+*
TODO.md

# Logs
logs
Expand Down Expand Up @@ -86,3 +89,4 @@ typings/
# FuseBox cache
.fusebox/

manifest.yml
169 changes: 114 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,44 @@ Takes in a list of markdown files and merges them into a single output file with
* Find/replace with regex (ex: names, titles, chapter #s, timestamps, etc)
* Create TOC with doctoc
* Remove yaml from top of md file
* NEW: Autocreate a starter manifest
* NEW: Download docker image for installation convienance with dependencies (pandoc/wkhtmltopdf)

> WARNING: [wkhtmltopdf](https://wkhtmltopdf.org/downloads.html) and [pandoc](https://pandoc.org/installing.html) must be installed prior to using this tool! Download and use the docker image if you want avoid this.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Contents

- [Installation](#installation)
- [Command Line Tool](#command-line-tool)
- [Usage](#usage)
- [Manifest file format](#manifest-file-format)
- [Supported Options](#supported-options)
- [noYAML](#noyaml)
- [replace](#replace)
- [doctoc](#doctoc)
- [Supported Output Options](#supported-output-options)
- [Merged file TOC](#merged-file-toc)
- [HTML Output](#html-output)
- [PDF Output](#pdf-output)
- [Special Modes](#special-modes)
- [QA Mode](#qa-mode)
- [nolinkcheck Mode](#nolinkcheck-mode)
- [Debug Mode](#debug-mode)
- [Manifest Examples](#manifest-examples)
- [YAML used as input](#yaml-used-as-input)
- [JSON used as input](#json-used-as-input)
- [Replace keys within a single file](#replace-keys-within-a-single-file)
- [Options applied to all files](#options-applied-to-all-files)
- [Apply output options](#apply-output-options)
- [Dockerfile](#dockerfile)
- [How to use this image](#how-to-use-this-image)
- [Basic execution commands](#basic-execution-commands)
- [merge-markdown](#merge-markdown)
- [Overview](#overview)
- [Contents](#contents)
- [Installation](#installation)
- [Command Line Tool](#command-line-tool)
- [Usage](#usage)
- [Manifest file format](#manifest-file-format)
- [Supported Options](#supported-options)
- [noYAML](#noyaml)
- [replace](#replace)
- [doctoc](#doctoc)
- [Supported Output Options](#supported-output-options)
- [Merged file TOC](#merged-file-toc)
- [HTML Output](#html-output)
- [PDF Output](#pdf-output)
- [Special Modes](#special-modes)
- [Download Docker Files](#download-docker-files)
- [QA Mode](#qa-mode)
- [nolinkcheck Mode](#nolinkcheck-mode)
- [Debug Mode](#debug-mode)
- [Manifest Examples](#manifest-examples)
- [YAML used as input](#yaml-used-as-input)
- [JSON used as input](#json-used-as-input)
- [Replace keys within a single file](#replace-keys-within-a-single-file)
- [Options applied to all files](#options-applied-to-all-files)
- [Apply output options](#apply-output-options)
- [Dockerfile](#dockerfile)
- [How to use this image](#how-to-use-this-image)
- [Basic execution commands](#basic-execution-commands)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand All @@ -63,60 +71,71 @@ npm install -g @knennigtri/merge-markdown

## Command Line Tool

Use default `./manifest.[md|yaml|yml|json]` for input
Use default `./manifest[.yml|.yaml|.json]` for input

```shell
> merge-markdown
```

Merge based on manifest file
Create an inital manifest with markdown files in a directory

```shell
> merge-markdown -m myManifest.md
> merge-markdown -c my/path/src
```

Merge based on `path/to/files` default manifest or merges all files in a default order
Merge based on existing manifest file

```shell
> merge-markdown -m path/to/files
> merge-markdown -m myManifest.yml
```

Output to PDF

```shell
> merge-markdown -m myManifest.md --pdf
> merge-markdown -m myManifest.yml --pdf
```

## Usage

```shell
```
Usage: merge-markdown [ARGS]
Arguments:
-m <manifestFile> Path to input folder, yaml, or json manifest
-m, --manifest <manifestFile> Path to input folder, yaml, or json manifest
-v, --version Displays version of this package
--qa QA mode.
--nolinkcheck Skips linkchecking
--pdf Output to PDF. wkhtmltopdf must be installed http://wkhtmltopdf.org/downloads.html
--html Output to HTML
-c, --create <path> auto-creates ./manifest.yml with input files from <path>
--getDockerFiles Downloads the Docker files to your local project
--qa QA mode.
--skipLinkcheck Skips linkchecking
--maintainAssetPaths Retains original asset paths
--pdf Output to PDF. Must have Pandoc and wkhtmltopdf installed!
--html Output to HTML. Must have Pandoc installed!
-h, --help Displays this screen
-h [manifest|options|outputOptions|qa] See examples
Default manifest: manifest.[md|yaml|yml|json] unless specified in -m.
-h manifest | options |
outputOptions | qa | docker See examples
-d, --debug See debug Options
Default manifest: manifest[.yml|.yaml|.json] unless specified in -m.

Download Pandoc: https://pandoc.org/installing.html
Download wkhtmltopdf: https://wkhtmltopdf.org/downloads.html
Download Docker: https://docs.docker.com/get-docker/
```

## Manifest file format

`manifest.[md|yaml|yml|json]`:
`manifest[.yml|.yaml|.json]`:
This file can be in YAML or JSON format.

* `input`: No `input` will merge all .md files in the same directory as the manifest.
* `input`:
* `myFile1.md: {options}` *Local options*
* `myFile2.md: {options}`
* `output`: No `output` will be save the merged doc in in `merged/<curDir>.out.md`.
* `output`:
* `name: path/name.md`: of the resultant file
* `{outputOptions}` See [Supported Output Options](#supported-output-options)
* `{options}`: global options. See [Supported Options](#supported-options)
* `{options}`: *global options*

See [Supported Options](#supported-options)
Relative or absolute are accepted

> Relative or absolute paths can be used for all values

### Supported Options

Expand Down Expand Up @@ -201,6 +220,8 @@ Similar to adding a TOC to the input files, you can add a TOC for the entire mer

You can optionally add pandoc parameters to the manifest. The `key` doesn't matter, only the `value` is evalutated based on [pandoc args](https://pandoc.org/MANUAL.html).

> [pandoc](https://pandoc.org/installing.html) must be installed in order to create HTML!

```yaml
output:
pandoc:
Expand All @@ -214,7 +235,10 @@ You can optionally add pandoc parameters to the manifest. The `key` doesn't matt

#### PDF Output

You can optionally add wkhtmltopdf options to the manifest. [wkhtmltopdf](http://wkhtmltopdf.org/downloads.html) must be installed and added to your path to create PDFs!
You can optionally add wkhtmltopdf options to the manifest.

> [pandoc](https://pandoc.org/installing.html) must be installed in order to create PDFs!
> [wkhtmltopdf](http://wkhtmltopdf.org/downloads.html) must be installed and added to your path to create PDFs!

See [wkhtmltopdf options](https://www.npmjs.com/package/wkhtmltopdf#options) to learn more:

Expand All @@ -235,23 +259,31 @@ See [wkhtmltopdf options](https://www.npmjs.com/package/wkhtmltopdf#options) to
Generate HTML only:

```shell
merge-markdown -m manifest.md --html
merge-markdown -m manifest.yml --html
```

Generate a PDF:

```shell
merge-markdown -m manifest.md --pdf
merge-markdown -m manifest.yml --pdf
```

Example files can be found in [test/pdf/src](test/pdf/src). You can also checkout a [working project](https://github.com/knennigtri/example-webpack-project) for css development using webpack.

### Special Modes

#### Download Docker Files

```shell
> merge-markdown --getDockerFiles
```

Downloads the Docker files to your local project. See [Docker](#dockerfile).

#### QA Mode

```shell
> merge-markdown -m manifest.json --qa
> merge-markdown -m manifest.yml --qa
```

Output will omit all filenames with `frontmatter` by default
Expand All @@ -273,13 +305,40 @@ Sometimes the [markdown-link-check](https://www.npmjs.com/package/markdown-link-

#### Debug Mode

[Debug](https://www.npmjs.com/package/debug) is used in this tool. Available debug options:
[Debug](https://www.npmjs.com/package/debug) is used in this tool:

Mac or Linux:
```shell
> DEBUG:options merge-markdown -m file
```

* index:[ input | manifest ]
* index:manifest:[ json | generate ]
* merge:[ relinks | yaml | doctoc | replace | linkcheck ]
* presentation:[ html | pdf ]:options
* presentation:verbose
Windows:
```shell
> set DEBUG=options & merge-markdown -m file
```

```
Options: {
"*": "Output all debugging messages",
"args": "See CLI argument messages",
"cli": "Validate CLI logic",
"manifest": "",
"manifest:deprecation": "",
"manifest:json": "",
"merge": "messages for merge process",
"rellinks": "relative links",
"o:yaml": "yaml removal",
"o:doctoc": "doctoc messages",
"o:replace": "regex replace messages",
"linkcheck": "linkcheck validation",
"linkcheck:deep": "deep linkcheck validation",
"presentation": "",
"html": "pandoc messages for html",
"html:options": "pandoc options messages",
"pdf": "wkhtmltopdf messages for pdf",
"pdf:options": "wkhtmltopdf options messages"
}
```

## Manifest Examples

Expand Down Expand Up @@ -377,7 +436,7 @@ A `Dockerfile` based on a NodeJS image with all required dependencies is also [a

### How to use this image

All you need to do is copy the `Dockerfile` and `docker-compose.yml` files inside your project, and set
The `Dockerfile` and `docker-compose.yml` need to be in the same directory as your project and set
up Docker Compose with the following command:

```shell
Expand Down
4 changes: 2 additions & 2 deletions bin/global.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

var mergeMarkdown = require("../index.js");
var module = require("../cli.js");

mergeMarkdown.run();
module.run();
Loading
Loading