### Quick Start with markmap-cli
Source: https://markmap.js.org/docs/markmap/packages--markmap-cli
A quick example demonstrating how to generate a markmap from a Markdown file using `npx markmap-cli`. This command takes a Markdown file as input and produces an HTML markmap, providing a fast way to visualize your Markdown content.
```Shell
$ npx markmap-cli markmap.md
```
--------------------------------
### Quick Start HTML Integration for markmap-autoloader
Source: https://markmap.js.org/docs/markmap/packages--markmap-autoloader
This snippet demonstrates the basic setup for `markmap-autoloader` in an HTML page. It includes defining global styles for markmaps, embedding Markdown source within a `.markmap` div using a script template, and loading the `markmap-autoloader` script from a CDN.
```html
```
--------------------------------
### Install markmap-cli Globally
Source: https://markmap.js.org/docs/markmap/packages--markmap-cli
Instructions for installing the markmap-cli tool globally on your system. This allows you to run the `markmap` command directly from any terminal location. You can choose between `yarn` or `npm` package managers for the installation.
```Shell
$ yarn global add markmap-cli
# or
$ npm install -g markmap-cli
```
--------------------------------
### Install markmap-toolbar via npm
Source: https://markmap.js.org/docs/markmap/packages--markmap-toolbar
This snippet provides the command to install the `markmap-toolbar` package using npm, the standard package manager for Node.js. This is the first step to include the library in your project.
```bash
$ npm install markmap-toolbar
```
--------------------------------
### Install markmap-view via npm
Source: https://markmap.js.org/docs/markmap/packages--markmap-view
Instructions to install the markmap-view package using the npm package manager.
```shell
npm install markmap-view
```
--------------------------------
### Install markmap-render via npm
Source: https://markmap.js.org/docs/markmap/packages--markmap-render
Command to install the markmap-render package using the Node Package Manager (npm). This makes the library available for use in your project.
```Shell
$ npm install markmap-render
```
--------------------------------
### Use markmap-cli with npx
Source: https://markmap.js.org/docs/markmap/packages--markmap-cli
Demonstrates how to execute markmap-cli without a global installation using `npx`. This method is convenient for one-off uses or when you prefer not to install packages globally, as `npx` will download and run the package temporarily.
```Shell
$ npx markmap-cli
```
--------------------------------
### Install markmap-lib via npm
Source: https://markmap.js.org/docs/markmap/packages--markmap-lib
Instructions to install the markmap-lib package using npm, the Node.js package manager. This command adds the library to your project's dependencies.
```Shell
$ npm install markmap-lib
```
--------------------------------
### Configure markmap-autoloader with Global Options
Source: https://markmap.js.org/docs/markmap/packages--markmap-autoloader
This example shows how to customize `markmap-autoloader` behavior by setting `window.markmap.autoLoader` before the main script loads. It demonstrates enabling the toolbar feature using `AutoLoaderOptions`.
```javascript
```
--------------------------------
### Install coc-markmap Plugin
Source: https://markmap.js.org/docs/markmap/packages--coc-markmap
Installs the coc-markmap plugin using coc.nvim's built-in CocInstall command. This command should be executed within a Vim or Neovim session where coc.nvim is active.
```Vim
:CocInstall coc-markmap
```
--------------------------------
### Import Transformer without built-in plugins
Source: https://markmap.js.org/docs/markmap/packages--markmap-lib
Illustrates importing the Transformer class from 'markmap-lib/no-plugins' for scenarios where built-in plugins are not desired. This allows for a more lightweight setup or explicit inclusion of specific plugins like 'pluginFrontmatter'.
```JavaScript
import { Transformer } from 'markmap-lib/no-plugins';
import { pluginFrontmatter } from 'markmap-lib/plugins';
// No plugin at all
const transformer = new Transformer();
// With specified plugins
const transformer = new Transformer([pluginFrontmatter]);
```
--------------------------------
### Create SVG container for markmap
Source: https://markmap.js.org/docs/markmap/packages--markmap-view
Example HTML snippet to define an SVG element with specific width and height, which will serve as the rendering target for the markmap visualization.
```html
```
--------------------------------
### Derive low-level options from JSON options
Source: https://markmap.js.org/docs/markmap/packages--markmap-view
Example of converting portable JSON options into the low-level Markmap options object using the `deriveOptions` utility function from `markmap-view`.
```javascript
import { deriveOptions } from 'markmap-view';
const options = deriveOptions(jsonOptions);
```
--------------------------------
### Applying Magic Comments for Node Folding in Markmap
Source: https://markmap.js.org/docs/markmap/magic-comments
This Markdown example demonstrates how to embed `markmap:` magic comments within headings and list items to control their initial folded state. The `foldAll` action collapses a node and all its descendants, while `fold` collapses only the current node.
```markdown
## heading 1
- item 1
- item 1.1
- item 1.1.1
- item 1.2
- item 1.2.1
- item 2
## heading 2
- item 3
- item 3.1
- item 4
- item 4.1
```
--------------------------------
### Render a markmap instance
Source: https://markmap.js.org/docs/markmap/packages--markmap-view
Steps to initialize and render a markmap. This involves loading necessary CSS and JavaScript assets dynamically, and then creating a Markmap instance using `Markmap.create` with an SVG selector, optional configuration, and transformed data.
```javascript
// 1. load assets
if (styles) loadCSS(styles);
if (scripts) {
loadJS(scripts, {
// For plugins to access the `markmap` module
getMarkmap: () => markmap,
});
}
// 2. create markmap
// `options` is optional, i.e. `undefined` can be passed here
Markmap.create('#markmap', options, root); // -> returns a Markmap instance
```
--------------------------------
### Markmap.create API Reference
Source: https://markmap.js.org/docs/markmap/packages--markmap-view
Documentation for the `Markmap.create` method, including its parameters and return type, and details about the `options` parameter's type (`IMarkmapOptions`) and portability considerations.
```APIDOC
Markmap.create(container: string | SVGElement, options?: IMarkmapOptions, root?: any): MarkmapInstance
container: A CSS selector string or an SVG DOM element where the markmap will be rendered.
options: Optional configuration object of type IMarkmapOptions. It is a low-level object with functions and is not portable. Consider using JSON options with deriveOptions for portability.
root: The transformed data root node from markmap-lib.
Returns: A Markmap instance.
```
--------------------------------
### Create and Attach Toolbar to Markmap Instance
Source: https://markmap.js.org/docs/markmap/packages--markmap-toolbar
This snippet demonstrates the process of instantiating a new toolbar using `Toolbar.create(mm)`, where `mm` is an existing markmap instance. It then shows how to apply basic CSS styling to position the toolbar absolutely and append its DOM element (`el`) to a specified container, integrating it visually with the markmap.
```javascript
const { el } = Toolbar.create(mm);
el.style.position = 'absolute';
el.style.bottom = '0.5rem';
el.style.right = '0.5rem';
// `container` could be the element that contains both the markmap and the toolbar
container.append(el);
```
--------------------------------
### markmap-cli Command-Line Interface Reference
Source: https://markmap.js.org/docs/markmap/packages--markmap-cli
Detailed documentation for the `markmap` command-line tool, outlining its general usage pattern and all available options. This section describes how to specify input files, control output behavior, and enable features like offline mode or watch mode.
```APIDOC
Usage: markmap [options]
Create a markmap from a Markdown input file
Options:
-V, --version output the version number
--no-open do not open the output file after generation
--no-toolbar do not show toolbar
-o, --output