mdod v0.0.19
mdod - Markdown On Demand
README & DOCS TODO
Installation
TODO
Developing
yarn gen-readme // update README.md
yarn docs // update DOCUMENTATION.md
yarn test // lint & mocha
yarn update-deps // bump all deps
Release History
See CHANGELOG.md for more information.
License
Distributed under the MIT license. See LICENSE.md for more information.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
API Reference
The standalone JSDoc reference can be found in DOCUMENTATION.md
Classes
Constants
Functions
Typedefs
FSAccessError ⇐ Error
Filesystem access error, providing the inaccessible path in the error message.
Kind: global class
Extends: Error
- FSAccessError ⇐ Error
new FSAccessError(path, origError)
Creates a new error object.
Param | Type | Description |
---|---|---|
path | string | path that was deemed inaccessible |
origError | Error | original error, if any |
fsAccessError.getPath() ⇒ string
Returns the inaccessible path.
Kind: instance method of FSAccessError
Returns: string - path - path that was deemed inaccessible
HLJSHighlightAutoError ⇐ HLJSHighlightError
Represents an error encountered when automatically highlighting an input
string with highlight.js
.
Kind: global class
Extends: HLJSHighlightError
new HLJSHighlightAutoError(lang, str, origError)
Creates a new HLJSHighlightAutoError object.
Param | Type | Description |
---|---|---|
lang | string | source language |
str | string | source |
origError | Error | original error, if any |
hljsHighlightAutoError.getString() ⇒ string
Returns the string that triggered the error.
Kind: instance method of HLJSHighlightAutoError
Overrides: getString
Returns: string - str
HLJSHighlightError ⇐ Error
Represents an error encountered when highlighting an input string with an
explicit language via highlight.js
.
Kind: global class
Extends: Error
new HLJSHighlightError(lang, str, origError)
Creates a new HLJSHighlightAutoError object.
Param | Type | Description |
---|---|---|
lang | string | source language |
str | string | source |
origError | Error | original error, if any |
hljsHighlightError.getString() ⇒ string
Returns the string that triggered the error.
Kind: instance method of HLJSHighlightError
Returns: string - str
VALID_MARKDOWN_EXTENSIONS : Array.<string>
Valid markdown extensions. Currently .md and .markdown are considered.
Kind: global constant
renderCommandHandler(args)
Renders markdown files to HTML based on passed parameters.
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
args | object | {} | arguments |
args.overwrite | boolean | false | if true, existing files are overwritten |
args.hidden | boolean | true | if false, hidden files (names starting with a '.') will not be rendered |
args.dest | string | destination directory to write HTML output too | |
args.src | string | source path to read markdown files from | |
args.recursive | string | if directories are to be searched for further renderable files. |
renderFile(args) ⇒ Promise.<RenderableFile>
Renders a single markdown file to HTML.
Kind: global function
Returns: Promise.<RenderableFile> - p
Param | Type | Default | Description |
---|---|---|---|
args | Object | {} | args |
args.file | FSFile | file to render | |
args.srcPath | string | source path | |
args.destPath | string | destination path | |
args.overwrite | boolean | overwrite existing files |
ensurePath(dirPath) ⇒ Promise
Ensures the specified path is accessible.
Kind: global function
Returns: Promise - p - resolves on success
Throws:
- FSAccessError if the path is not accessible.
Param | Type | Default | Description |
---|---|---|---|
dirPath | string | "''" | path to check |
getFilesInDirectoryByExts(args) ⇒ Promise.<Array.<string>>
Returns all markdown files in the specified directory as fs nodes. By default considers files with '.md' or '.markdown' extensions.
Kind: global function
Returns: Promise.<Array.<string>> - p
Throws:
- Error if the directory is not accessible.
Param | Type | Default | Description |
---|---|---|---|
args | object | {} | args - args |
args.dirPath | string | "''" | path to search for markdown files in |
args.allowHidden | boolean | false | if true, includes hidden files (prefixed with a '.') in results. |
args.exts | Array.<string> | extensions to filter for | |
args.recursive | boolean | if true, recurses into subdirectories |
getMdFilesInDirectory(args) ⇒ Promise.<Array.<string>>
Returns markdown files in the requested directory. Optionally recurses.
Kind: global function
Returns: Promise.<Array.<string>> - p
See: getFilesInDirectoryByExts
Todo
- add a typedef for the shared arguments
Param | Type | Default | Description |
---|---|---|---|
args | object | {} | args, @see getFilesInDirectoryByExts |
getNodesInDirectory(args) ⇒ Promise.<DirectoryNodes>
Returns an array of filenames in the specified directory.
Kind: global function
Returns: Promise.<DirectoryNodes> - p
Throws:
- FSAccessError if the directory is not accessible.
Param | Type | Default | Description |
---|---|---|---|
args | object | {} | args |
args.dirPath | string | "''" | directory to read |
args.recursive | boolean | false | if true, recurses into subdirectories |
args.files | boolean | true | allows files in res |
args.directories | boolean | true | allows directories in res |
args.allowHidden | boolean | false | if true, includes hidden files (prefixed with a '.') in res. |
RenderableFile
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
filePath | string | path for the source file |
fileDestPath | string | path for the rendered file |
fileSourceMD | string | source file markdown content |
fileHTML | string | rendered file HTML content |
fileRenderDurationMTS | number | milliseconds to render |
fileRendered | boolean | true if the destination file was written |
DirectoryNodes
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
dirPath | string | base path for all file & directory names |
files | Array.<string> | array of filenames |
directories | Array.<string> | array of directory names |