### Install development tools Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/theme-default/font-awesome/README.md Run these commands from the root of the repository to install the tools used for development. ```bash $ bundle install $ npm install ``` -------------------------------- ### Install HonKit with npm Source: https://github.com/honkit/honkit/blob/master/README.md Initializes a new npm project and installs HonKit as a local dev dependency. Requires Node.js LTS. Installing locally is recommended; plugins must be installed in the same scope (global or local) as HonKit. ```bash $ npm init --yes $ npm install honkit --save-dev ``` -------------------------------- ### Preview and serve the book Source: https://github.com/honkit/honkit/blob/master/README.md Starts a local server to preview the book while writing. ```bash $ npx honkit serve ``` -------------------------------- ### Install @honkit/markup-it Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/README.md Install the library via npm with the --save flag. ```bash $ npm i @honkit/markup-it --save ``` -------------------------------- ### Example .gitignore-style ignore file Source: https://github.com/honkit/honkit/blob/master/docs/structure.md Shows the format for ignoring files and folders in HonKit using .gitignore, .bookignore, or .ignore files. Comments start with #, and patterns follow gitignore conventions. ```text # This is a comment # Ignore the file test.md test.md # Ignore everything in the directory "bin" bin/* ``` -------------------------------- ### Example book.json for custom theme Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/honkit-plugin-fontsettings/README.md Example book.json configuration for a custom theme that uses the fontsettings plugin. ```json // book.json { plugins: ["my-theme"], pluginsConfig: { "my-theme": { "font-family": "sans" } } } ``` -------------------------------- ### Install dependencies with pnpm Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Installs all dependencies and builds the codebase. This is required before running the build command. ```sh $ pnpm install ``` -------------------------------- ### Ignore file format example Source: https://github.com/honkit/honkit/blob/master/packages/honkit/src/__tests__/__fixtures__/honkit/docs/structure.md Example of the format used in .gitignore, .bookignore, and .ignore files to skip files and folders. ```text # This is a comment # Ignore the file test.md test.md # Ignore everything in the directory "bin" bin/* ``` -------------------------------- ### Install @honkit/internal-test-utils with npm Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/internal-test-utils/README.md Install the package using npm. This is the standard installation command for adding the internal test utility as a dependency. ```bash npm install @honkit/internal-test-utils ``` -------------------------------- ### Install HonKit with NPM or Yarn Source: https://github.com/honkit/honkit/blob/master/docs/setup.md Install HonKit as a dev dependency. Use either npm or yarn. If installed globally, plugins must also be installed globally; if locally, plugins must be local. Local installation is recommended. ```bash $ npm install honkit --save-dev # or $ yarn add honkit --dev ``` -------------------------------- ### Example my-theme.js for custom theme Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/honkit-plugin-fontsettings/README.md Example JavaScript for a custom theme that initializes font families using the plugin API. ```js // my-theme.js require('gitbook', function(gitbook) { var FONT_FAMILIES = [ { config: 'sans', text: 'Sans', id: 0 }, { config: 'serif', text: 'Serif', id: 1 } ]; gitbook.events.on('start', function(e, config) { // Read configuration var themeConfig = config['my-theme'], defaultFont = themeConfig['font-family']; // Initialize new font families gitbook.fontsettings.setFamilies(FONT_FAMILIES); // Set to configured font-family gitbook.fontsettings.setFamily(defaultFont); }); }); ``` -------------------------------- ### Install Font Awesome as a component Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/theme-default/font-awesome/README.md Run this command to install Font Awesome as a component using the component package manager. ```bash $ component install FortAwesome/Font-Awesome ``` -------------------------------- ### Run build and serve via npm Source: https://github.com/honkit/honkit/blob/master/docs/setup.md Commands to build and start the server using the configured npm scripts. ```bash # Build npm run build # Start to server npm run serve ``` -------------------------------- ### Set font families example Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/honkit-plugin-fontsettings/README.md Example of setting font families using the plugin API. ```js var FONT_FAMILIES = [ { config: 'sans', text: 'Sans', id: 0 }, { config: 'serif', text: 'Serif', id: 1 } ]; gitbook.fontsettings.setFamilies(FONT_FAMILIES); ``` -------------------------------- ### book.json with root option Source: https://github.com/honkit/honkit/blob/master/docs/structure.md Configuration example setting the root option to "./docs" to indicate the folder where HonKit can find the book's files. ```json { "root": "./docs" } ``` -------------------------------- ### Change directory to your clone Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Navigate into your cloned repository directory before installing dependencies and building. ```sh $ cd YOUR_FORKED_REPOSITORY ``` -------------------------------- ### Install HonKit and Remove gitbook-cli Source: https://github.com/honkit/honkit/blob/master/README.md Use these commands to replace gitbook-cli with honkit as a dev dependency during migration. ```bash npm uninstall gitbook-cli npm install honkit --save-dev ``` -------------------------------- ### Install plugins in book.json Source: https://github.com/honkit/honkit/blob/master/docs/plugins/README.md Add plugins to the 'plugins' array in book.json. Use 'myPlugin@0.3.1' to specify a version; otherwise HonKit resolves the latest compatible version. ```json { "plugins": ["myPlugin", "anotherPlugin"] } ``` -------------------------------- ### Footnote syntax example Source: https://github.com/honkit/honkit/blob/master/docs/syntax/markdown.md Demonstrates HonKit's footnote syntax. Footnotes are relative to each page. ```markdown Text prior to footnote reference.[^2] [^2]: Comment to include in footnote. ``` -------------------------------- ### Raw HTML block example Source: https://github.com/honkit/honkit/blob/master/docs/syntax/markdown.md Shows that raw HTML is supported, but Markdown syntax inside HTML is not processed. The example includes a div with Markdown that will not be parsed. ```markdown
Markdown here will not be **parsed**
``` -------------------------------- ### HTML output for reference-style links Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by the reference-style links example. ```html

I get 10 times more traffic from Google than from Yahoo or MSN.

``` -------------------------------- ### Example commit message Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md A concrete example of a commit message following the Angular Convention, with a subject, body, and closing reference. ```text test(formatter): check types while testing - Add strict type check option to `ts-node` to make sure future interface changes will be took into account while running test. - Update test case for interface changes made at #430. Closes #448. ``` -------------------------------- ### Commit Message Examples Source: https://github.com/honkit/honkit/blob/master/.copilot-instructions.md Examples of valid commit messages following the Angular Convention, covering feat, fix, and docs types. ```text feat(parser): add support for new markdown syntax ``` ```text fix(build): resolve TypeScript compilation errors ``` ```text docs(readme): update installation instructions ``` -------------------------------- ### Output instance API usage Source: https://github.com/honkit/honkit/blob/master/docs/plugins/api.md Shows how to use the Output instance to get the root folder, resolve files, convert filenames to URLs, write files, copy files, and check file existence. Note that this API is internal and may be removed in the future. ```javascript // Return root folder for the output var root = output.root(); // Resolve a file in the output folder var filepath = output.resolve('myimage.png'); // Convert a filename to an URL (returns a path to an html file) var fileurl = output.toURL('mychapter/README.md'); // Write a file in the output folder output.writeFile('hello.txt', 'Hello World') .then(function() { ... }); // Copy a file to the output folder output.copyFile('./myfile.jpg', 'cover.jpg') .then(function() { ... }); // Verify that a file exists output.hasFile('hello.txt') .then(function(exists) { ... }); ``` -------------------------------- ### HTML output for ordered list Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by the ordered list example. ```html
  1. Red
  2. Green
  3. Blue
``` -------------------------------- ### Example of a chapter file Source: https://github.com/honkit/honkit/blob/master/docs/pages.md Shows the Markdown structure of a chapter page, using headings to define sections. HonKit infers the page structure from this syntax. ```markdown # Title of the chapter This is a great introduction. ## Section 1 Markdown will dictates _most_ of your **book's structure** ## Section 2 ... ``` -------------------------------- ### JavaScript code block Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/gfm_code.html A simple JavaScript example that logs a greeting to the console. ```javascript var a = 'hello'; console.log(a + ' world'); ``` -------------------------------- ### HTML output for inline link Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by the inline link example. ```html

This is an example link.

``` -------------------------------- ### HTML output for multi-paragraph list Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by the multi-paragraph list example. ```html ``` -------------------------------- ### Emphasis input example Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html Markdown input demonstrating emphasis with single and double asterisks and underscores. ```markdown *single asterisks* _single underscores_ **double asterisks** __double underscores__ ``` -------------------------------- ### HTML output for case-insensitive reference link Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by the case-insensitive reference link example. ```html

I start my morning with a cup of coffee and The New York Times.

``` -------------------------------- ### Debug HonKit build with --log=debug and --debug Source: https://github.com/honkit/honkit/blob/master/docs/setup.md Use these options to get better error messages with stack traces. ```bash $ honkit build ./ --log=debug --debug ``` -------------------------------- ### HTML output for images Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by both inline and reference-style image examples. ```html alt text ``` -------------------------------- ### Create symbolic link to ebook-convert on OS X Source: https://github.com/honkit/honkit/blob/master/docs/ebook.md After installing Calibre, create a symbolic link to the ebook-convert tool so it can be used from the command line. Replace /usr/local/bin with any directory in your $PATH. ```bash $ sudo ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/bin ``` -------------------------------- ### package.json manifest with configuration schema Source: https://github.com/honkit/honkit/blob/master/docs/plugins/create.md Example package.json for a HonKit plugin. It includes the required name, version, description, engines, and a honkit field that defines the configuration schema using JSON-Schema properties. ```json { "name": "honkit-plugin-mytest", "version": "0.0.1", "description": "This is my first HonKit plugin", "engines": { "honkit": ">1.x.x" }, "honkit": { "properties": { "myConfigKey": { "type": "string", "default": "it's the default value", "description": "It defines my awesome config!" } } } } ``` -------------------------------- ### Build HonKit with pnpm Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Manually builds the project. Note that pnpm install also builds the codebase, but this command is used to run the build explicitly. ```sh $ pnpm run build ``` -------------------------------- ### Emphasis output HTML Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html HTML output produced by the emphasis input example. ```html single asterisks single underscores double asterisks double underscores ``` -------------------------------- ### Template inheritance example Source: https://github.com/honkit/honkit/blob/master/packages/honkit/src/__tests__/__fixtures__/honkit/docs/templating/conrefs.md Example of template inheritance: a child template extends a base template and overrides a block. The base template (mypage.md) defines the block with default content. ```markdown {% extends "./mypage.md" %} {% block pageContent %} # This is my page content {% endblock %} ``` ```markdown {% block pageContent %} This is the default content {% endblock %} # License {% include "./LICENSE" %} ``` -------------------------------- ### Code span input example Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html Markdown input using backticks to create a code span. ```markdown Use the `printf()` function. ``` -------------------------------- ### HTML output for inline link with title Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by the inline link with title example. ```html

This is an example link.

``` -------------------------------- ### Simple SUMMARY.md example Source: https://github.com/honkit/honkit/blob/master/docs/pages.md Defines a basic table of contents with chapters and subchapters. The link title becomes the chapter title and the target is the file path. ```markdown # Summary * [Part I](part1/README.md) * [Writing is nice](part1/writing.md) * [HonKit is nice](part1/honkit.md) * [Part II](part2/README.md) * [We love feedback](part2/feedback_please.md) * [Better tools for authors](part2/better_tools.md) ``` -------------------------------- ### Front matter example Source: https://github.com/honkit/honkit/blob/master/docs/pages.md Defines a page description using YAML front matter. Must be the first thing in the file and be valid YAML between triple-dashed lines. Custom variables are added to the page variable for templating. ```yaml --- description: This is a short description of my page --- # The content of my page ... ``` -------------------------------- ### HTML output for pre-formatted code block Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by the pre-formatted code block example. ```html

If you want your page to validate under XHTML 1.0 Strict, you've got to put paragraph tags in your blockquotes:

<blockquote>
    <p>For example.</p>
</blockquote>
``` -------------------------------- ### Backtick delimiters output HTML Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html HTML output produced by the backtick delimiters with spaces example. ```html

A single backtick in a code span: `

A backtick-delimited string in a code span: `foo`

``` -------------------------------- ### Horizontal rule examples Source: https://github.com/honkit/honkit/blob/master/docs/syntax/markdown.md Shows how to insert horizontal rules using three or more asterisks, dashes, or underscores, optionally separated by spaces or tabs, on an otherwise blank line. ```markdown Three or more... --- Hyphens *** Asterisks ``` -------------------------------- ### HTML output for unordered list Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by any of the three unordered list examples above. ```html ``` -------------------------------- ### Dockerfile for custom font image Source: https://github.com/honkit/honkit/blob/master/docker/README.md Example Dockerfile that extends the honkit image to include custom fonts by copying them into the system font directory. ```dockerfile FROM ghcr.io/honkit/honkit:latest LABEL maintainer="your@example.com" # Install fonts COPY fonts/custom-font /usr/share/fonts ``` -------------------------------- ### Private plugin via git URL Source: https://github.com/honkit/honkit/blob/master/docs/plugins/create.md Example of including a private plugin hosted on GitHub using a git URL in the plugins list of a book's configuration. ```json { "plugins": [ "myplugin@git+https://github.com/MyCompany/myhonkitplugin.git#1.0.0" ] } ``` -------------------------------- ### Commit message format example Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Shows the recommended commit message structure: a subject line with type, component, and title, followed by a blank line, body text, and referenced issues. ```text component commit title commit type / / \ | | feat(rule-context): add template url parameter to events (a blank line) body -> The `src` (i.e. the url of the template to load) is now provided to the `$includeContentRequested`, `$includeContentLoaded` and `$includeContentError` events. referenced -> Closes #8453 issues Ref. #8454 ``` -------------------------------- ### Markdown blockquote Source: https://github.com/honkit/honkit/blob/master/docs/syntax/markdown.md Start a blockquote with the > marker followed by an optional space. All following lines with the marker belong to the blockquote. ```markdown As Kanye West said: > We're living the future so > the present is our past. ``` -------------------------------- ### Build the project and documentation Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/theme-default/font-awesome/README.md Run this command to build the project and documentation using Jekyll. ```bash $ bundle exec jekyll build ``` -------------------------------- ### Initialize Markdown and HTML syntaxes Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/README.md Require the library and syntax modules, then create instances for Markdown and HTML. ```javascript var MarkupIt = require('@honkit/markup-it'); var markdownSyntax = require('@honkit/markup-it/syntaxes/markdown'); var htmlSyntax = require('@honkit/markup-it/syntaxes/html'); var markdown = new MarkupIt(markdownSyntax); var html = new MarkupIt(htmlSyntax); ``` -------------------------------- ### Serve the project locally Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/theme-default/font-awesome/README.md Run this command to serve the project on a local server at http://localhost:7998/Font-Awesome/. ```bash $ bundle exec jekyll -w serve ``` -------------------------------- ### Asynchronous hook with promises Source: https://github.com/honkit/honkit/blob/master/docs/plugins/hooks.md Hooks callbacks can be asynchronous and return promises. This example shows an 'init' hook that writes two files sequentially using promise chaining. ```javascript { "init": function() { return writeSomeFile() .then(function() { return writeAnotherFile(); }); } } ``` -------------------------------- ### HTML tags in code span output Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html HTML output produced by the HTML tags in code span example. ```html

Please don't use any <blink> tags.

``` -------------------------------- ### Serve documentation on port 4000 with Docker Source: https://github.com/honkit/honkit/blob/master/docker/README.md Serves the documentation on port 4000 using the honkit serve command, with the --init flag for proper signal handling. ```bash $ docker run -it --init -p 4000:4000 -v `pwd`:`pwd` -w `pwd` --rm ghcr.io/honkit/honkit honkit serve ``` -------------------------------- ### Iterate over arrays with for tag Source: https://github.com/honkit/honkit/blob/master/docs/templating/README.md Iterates over an array of articles from the glossary. The example generates a markdown list of article links. ```twig # Chapters about HonKit {% for article in glossary.terms['gitbook'].articles %} * [{{ article.title }}]({{ article.path }}) {% endfor %} ``` -------------------------------- ### Build static website Source: https://github.com/honkit/honkit/blob/master/README.md Builds the static website for the book. ```bash $ npx honkit build ``` -------------------------------- ### Atx-style headers Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html Atx-style headers use 1-6 hash characters at the start of the line, corresponding to header levels 1-6. ```markdown # This is an H1 ## This is an H2 ###### This is an H6 ``` -------------------------------- ### Perl subroutine status that prints 'working' Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/blockquotes_with_code_blocks.md Defines a Perl subroutine 'status' that prints the string 'working'. This is the first example inside a blockquote. ```perl sub status { print "working"; } ``` -------------------------------- ### Initialize a new HonKit book Source: https://github.com/honkit/honkit/blob/master/README.md Creates a boilerplate book in the current directory. To create the book in a new directory, run `honkit init ./directory`. ```bash $ npx honkit init ``` -------------------------------- ### Syntax highlighting with Ruby language identifier Source: https://github.com/honkit/honkit/blob/master/docs/syntax/markdown.md Adds an optional language identifier to enable syntax highlighting. This example uses 'ruby' to highlight Ruby code. ```markdown ```ruby require 'redcarpet' markdown = Redcarpet.new("Hello World!") puts markdown.to_html ``` ``` -------------------------------- ### Indented code block example Source: https://github.com/honkit/honkit/blob/master/docs/syntax/markdown.md Shows the two supported code block styles: lines indented with four spaces or one tab, and lines delimited by tilde characters. The content does not need to be indented in the tilde style. ```markdown This is a sample code block. Continued here. ``` -------------------------------- ### Inline code with backticks Source: https://github.com/honkit/honkit/blob/master/docs/syntax/markdown.md Marks up text phrases as code by surrounding them with backticks. The example shows using 'honkit' and 'text' as inline code. ```markdown Use `honkit` to convert the `text` in markdown syntax to HTML. ``` -------------------------------- ### Link plugin locally with npm link Source: https://github.com/honkit/honkit/blob/master/packages/honkit/src/__tests__/__fixtures__/honkit/docs/plugins/testing.md Run `npm link` in the plugin's folder to make it globally available, then link it into your book's folder with `npm link honkit-plugin-`. This allows testing the plugin on your book before publishing. ```bash $ npm link ``` ```bash $ npm link honkit-plugin- ``` -------------------------------- ### Perl subroutine status that returns 'working' Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/blockquotes_with_code_blocks.md Defines a Perl subroutine 'status' that returns the string 'working'. This is the second example inside a blockquote, presented as an alternative to the first. ```perl sub status { return "working"; } ``` -------------------------------- ### Code block starting with horizontal rule: ---, foo, foo, ---, bar Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/gfm_code_hr_list.html A code block inside a nested list item that starts with a horizontal rule, followed by text and another horizontal rule. ```plaintext --- foo foo --- bar ``` -------------------------------- ### Book instance API usage Source: https://github.com/honkit/honkit/blob/master/docs/plugins/api.md Shows how to use the Book instance to read configuration, resolve file paths, and render inline or block markup. The render methods return promises. ```javascript // Read configuration from book.json var value = book.config.get('title', 'Default Value'); // Resolve a filename to an absolute path var filepath = book.resolve('README.md'); // Render an inline markup string book.renderInline('markdown', 'This is **Markdown**') .then(function(str) { ... }) // Render a markup string (block mode) book.renderBlock('markdown', '* This is **Markdown**') .then(function(str) { ... }) ``` -------------------------------- ### init Source: https://github.com/honkit/honkit/blob/master/docs/plugins/hooks.md Called after parsing the book, before generating output and pages. No arguments. ```APIDOC ## init ### Description Called after parsing the book, before generating output and pages. ### Arguments None ### Example ```js { "init": function() { return writeSomeFile() .then(function() { return writeAnotherFile(); }); } } ``` ``` -------------------------------- ### Build documentation with Honkit in Docker Source: https://github.com/honkit/honkit/blob/master/docker/README.md Builds the documentation using the honkit build command inside a Docker container. ```bash $ docker run -v `pwd`:`pwd` -w `pwd` --rm -it ghcr.io/honkit/honkit honkit build ``` -------------------------------- ### Show Honkit help in Docker Source: https://github.com/honkit/honkit/blob/master/docker/README.md Runs the honkit --help command inside a Docker container, mounting the current directory and setting it as the working directory. ```bash $ docker run -v `pwd`:`pwd` -w `pwd` --rm -it ghcr.io/honkit/honkit honkit --help ``` -------------------------------- ### Link plugin in book with npm link honkit-plugin- Source: https://github.com/honkit/honkit/blob/master/docs/plugins/testing.md Run in the book's folder to link the globally linked plugin into the book's node_modules. ```bash $ npm link honkit-plugin- ``` -------------------------------- ### Accidental ordered list trigger Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html A number-period-space sequence at the start of a line triggers an ordered list. ```markdown 1986. What a great season. ``` -------------------------------- ### Use HonKit Docker image for build and PDF Source: https://github.com/honkit/honkit/blob/master/README.md Pulls the official HonKit Docker image and runs `honkit build` and `honkit pdf` commands. The image includes built-in dependencies for PDF/epub. The `-v` flag mounts the current directory and `-w` sets the working directory. ```bash docker pull ghcr.io/honkit/honkit docker run -v `pwd`:`pwd` -w `pwd` --rm -it ghcr.io/honkit/honkit honkit build docker run -v `pwd`:`pwd` -w `pwd` --rm -it ghcr.io/honkit/honkit honkit pdf ``` -------------------------------- ### Literal backtick output HTML Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html HTML output produced by the literal backtick code span example. ```html

There is a literal backtick (`) here.

``` -------------------------------- ### book.json with root option Source: https://github.com/honkit/honkit/blob/master/packages/honkit/src/__tests__/__fixtures__/honkit/docs/structure.md Configuration file that sets the root folder to './docs' for the book's files. ```json { "root": "./docs" } ``` -------------------------------- ### Run unit tests for all packages Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Runs the unit test suite for all packages in the repository. Should be run at the top directory of your fork before submitting a pull request. ```sh $ pnpm test ``` -------------------------------- ### Generate PDF, ePub, and Mobi files with HonKit Source: https://github.com/honkit/honkit/blob/master/docs/ebook.md Use these commands to generate eBook files from your book. Each command outputs a file in the current directory or specified path. ```bash # Generate a PDF file $ honkit pdf ./ ./mybook.pdf # Generate an ePub file $ honkit epub ./ ./mybook.epub # Generate a Mobi file $ honkit mobi ./ ./mybook.mobi ``` -------------------------------- ### HTML output for code span Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html The HTML output produced by the code span example, showing escaped entities. ```html

I strongly recommend against using any <blink> tags.

I wish SmartyPants used named entities like &mdash; instead of decimal-encoded entites like &#8212;.

``` -------------------------------- ### Define build and serve scripts in package.json Source: https://github.com/honkit/honkit/blob/master/docs/setup.md Adds npm-run-scripts for build and serve commands. After this configuration, you can use 'npm run build' and 'npm run serve'. ```diff "scripts": { "build": "honkit build", "serve": "honkit serve" }, ``` -------------------------------- ### index.js entry point with hooks, blocks, and filters Source: https://github.com/honkit/honkit/blob/master/docs/plugins/create.md The main entry point of a HonKit plugin. It exports an object with empty maps for hooks, blocks, and filters, which you can fill with your plugin's functionality. ```javascript module.exports = { // Map of hooks hooks: {}, // Map of new blocks blocks: {}, // Map of new filters filters: {} }; ``` -------------------------------- ### Using the 'hello' filter in a book Source: https://github.com/honkit/honkit/blob/master/docs/plugins/filters.md Shows how to use the custom 'hello' filter in a template. ```text {{ "Aaron"|hello }}, how are you? ``` -------------------------------- ### Link plugin locally with npm link Source: https://github.com/honkit/honkit/blob/master/docs/plugins/testing.md Run in the plugin's folder to create a global symlink for local testing. ```bash $ npm link ``` -------------------------------- ### Project subdirectory structure with docs/ Source: https://github.com/honkit/honkit/blob/master/docs/structure.md Shows a project layout where the book is stored in a docs/ subdirectory, used with the root option in book.json. ```text . ├── book.json └── docs/ ├── README.md └── SUMMARY.md ``` -------------------------------- ### Include local file with {% include %} Source: https://github.com/honkit/honkit/blob/master/docs/templating/conrefs.md Use the include tag to import content from a local file. The path is relative to the current file. ```markdown {% include "./test.md" %} ``` -------------------------------- ### Run benchmark with yarn Source: https://github.com/honkit/honkit/blob/master/examples/benchmark/README.md Executes the benchmark suite using yarn. The command is `yarn run benchmark`. ```bash yarn run benchmark ``` -------------------------------- ### Add a title in page:before hook Source: https://github.com/honkit/honkit/blob/master/docs/plugins/hooks.md In the 'page:before' hook, page.content is the markdown/asciidoc content. This example prepends a title to the content and returns the modified page object. ```javascript { "page:before": function(page) { page.content = "# Title\n" +page.content; return page; } } ``` -------------------------------- ### finish:before Source: https://github.com/honkit/honkit/blob/master/docs/plugins/hooks.md Called after generating the pages, before copying assets, cover, etc. No arguments. ```APIDOC ## finish:before ### Description Called after generating the pages, before copying assets, cover, ... ### Arguments None ``` -------------------------------- ### Generate PDF with Honkit in Docker Source: https://github.com/honkit/honkit/blob/master/docker/README.md Generates a PDF version of the documentation using the honkit pdf command inside a Docker container. ```bash $ docker run -v `pwd`:`pwd` -w `pwd` --rm -it ghcr.io/honkit/honkit honkit pdf ``` -------------------------------- ### Basic HonKit directory structure Source: https://github.com/honkit/honkit/blob/master/docs/structure.md Shows the typical layout of a HonKit book with book.json, README.md, SUMMARY.md, and chapter directories. ```text . ├── book.json ├── README.md ├── SUMMARY.md ├── chapter-1/ | ├── README.md | └── something.md └── chapter-2/ ├── README.md └── something.md ``` -------------------------------- ### Basic filter usage in templates Source: https://github.com/honkit/honkit/blob/master/docs/plugins/filters.md Shows how to apply filters to variables using the pipe operator. Filters can be chained and take arguments. ```text {{ foo | title }} {{ foo | join(",") }} {{ foo | replace("foo", "bar") | capitalize }} ``` -------------------------------- ### Publish plugin to NPM Source: https://github.com/honkit/honkit/blob/master/docs/plugins/create.md Command to publish the plugin to NPM. Requires an account on npmjs.com. ```bash $ npm publish ``` -------------------------------- ### gitbook.fontsettings.setTheme() Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/honkit-plugin-fontsettings/README.md Takes a color theme `config` key as an argument and updates the color theme used for this book. This applies the CSS class with the corresponding theme `id` (`.color-theme-`) or removes the applied CSS class if the selected theme `id` is `0`. ```APIDOC ## gitbook.fontsettings.setTheme() ### Description Takes a color theme `config` key as an argument and updates the color theme used for this book. This applies the CSS class with the corresponding theme `id` (`.color-theme-`) or removes the applied CSS class if the selected theme `id` is `0`. ### Method `setTheme(config)` ### Parameters - **config** (string) - Required - The `config` key of the color theme to apply. ### Example ```js gitbook.fontsettings.setTheme('night'); ``` ### Result For `night` theme (id: 2), the root element will have class `color-theme-2`: ```html
``` For `white` theme (id: 0), the CSS class is removed: ```html
``` ``` -------------------------------- ### Run tests with npm test Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/internal-test-utils/README.md Run the test suite for the package. This command executes the tests defined in the project's package.json. ```bash npm test ``` -------------------------------- ### Replace HTML in page hook Source: https://github.com/honkit/honkit/blob/master/docs/plugins/hooks.md In the 'page' hook, page.content is the HTML generated from the markdown/asciidoc conversion. This example replaces tags with tags and returns the modified page object. ```javascript { "page": function(page) { page.content = page.content.replace("", "") .replace("", ""); return page; } } ``` -------------------------------- ### Block usage with arguments Source: https://github.com/honkit/honkit/blob/master/docs/plugins/blocks.md Shows how to pass positional and keyword arguments to a block in a template. ```twig {% tag1 "argument 1", "argument 2", name="Test" %} This is the body of the block. {% endtag1 %} ``` -------------------------------- ### Output instance Source: https://github.com/honkit/honkit/blob/master/docs/plugins/api.md The Output class represents the output/write process. It provides methods to manage files in the output folder. ```APIDOC ## Output instance ### Description The `Output` class represents the output/write process. It provides methods to manage files in the output folder. Note: This API is too internal and should probably be avoided as much as possible. It may be removed in the future. ### Methods #### `output.root()` - **Returns**: The root folder for the output. #### `output.resolve(filename)` - **filename** (string) - Required - The filename to resolve in the output folder. - **Returns**: The absolute path. #### `output.toURL(filename)` - **filename** (string) - Required - The filename to convert to a URL (returns a path to an HTML file). - **Returns**: The URL path. #### `output.writeFile(filename, content)` - **filename** (string) - Required - The filename to write. - **content** (string) - Required - The content to write. - **Returns**: A Promise. #### `output.copyFile(source, dest)` - **source** (string) - Required - The source file path. - **dest** (string) - Required - The destination file path. - **Returns**: A Promise. #### `output.hasFile(filename)` - **filename** (string) - Required - The filename to check. - **Returns**: A Promise resolving to a boolean indicating existence. ### Example ```js // Return root folder for the output var root = output.root(); // Resolve a file in the output folder var filepath = output.resolve('myimage.png'); // Convert a filename to an URL (returns a path to an html file) var fileurl = output.toURL('mychapter/README.md'); // Write a file in the output folder output.writeFile('hello.txt', 'Hello World') .then(function() { ... }); // Copy a file to the output folder output.copyFile('./myfile.jpg', 'cover.jpg') .then(function() { ... }); // Verify that a file exists output.hasFile('hello.txt') .then(function(exists) { ... }); ``` ``` -------------------------------- ### Create a feature branch Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Creates and switches to a new branch for your work. Replace your-new-feature with a descriptive branch name. ```sh $ git checkout -b your-new-feature ``` -------------------------------- ### HTML output for list with blank lines Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html HTML output for the list with blank lines. ```html
  • Bird

  • Magic

``` -------------------------------- ### Clone the forked HonKit repository Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Use this command to clone your forked HonKit repository locally. Replace YOUR_ACCOUNT and YOUR_FORKED_REPOSITORY with your GitHub username and repository name. The --recursive flag ensures submodules are included. ```sh $ git clone --recursive https://github.com/YOUR_ACCOUNT/honkit YOUR_FORKED_REPOSITORY ``` -------------------------------- ### Render content to HTML/Markdown Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/README.md Render the content object back to Markdown or HTML using the respective instances. ```javascript // Render back to markdown: var textMd = markdown.toText(content); // Render to HTML var textHtml = html.toText(content); ``` -------------------------------- ### finish Source: https://github.com/honkit/honkit/blob/master/docs/plugins/hooks.md Called after everything else. No arguments. ```APIDOC ## finish ### Description Called after everything else. ### Arguments None ``` -------------------------------- ### Include file from another book via git URL Source: https://github.com/honkit/honkit/blob/master/docs/templating/conrefs.md Use the include tag with a git URL to import content from another book. The URL format is git+https://user@hostname/owner/project.git/file#commit-ish. The commit-ish can be a tag, sha, or branch; default is master. ```markdown {% include "git+https://github.com/GitbookIO/documentation.git/README.md#0.0.1" %} ``` -------------------------------- ### Run package-level unit tests Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Runs unit tests for a specific package, which is faster during development. Replace PACKAGE with the actual package name. ```sh $ cd packages/PACKAGE $ pnpm test ``` -------------------------------- ### Version up and update CHANGELOG via versionup script Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Bumps the version and updates the changelog using npm run versionup, with optional patch, minor, or major variants, then pushes the changes to the release branch. ```bash # bump version and update changelog npm run versionup ## Also, available npm run versionup:{patch,minor,major} # push the changes to release branch git push origin HEAD -u ``` -------------------------------- ### Set custom color themes Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/honkit-plugin-fontsettings/README.md Defines a custom color themes array and passes it to gitbook.fontsettings.setThemes(). This recreates the fontsettings menu to reflect the changes. ```javascript var COLOR_THEMES = [ { config: 'light', text: 'Light', id: 0 }, { config: 'dark', text: 'Dark', id: 1 } ]; gitbook.fontsettings.setThemes(COLOR_THEMES); ``` -------------------------------- ### HTML output for list without blank lines Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html HTML output for the list without blank lines. ```html
  • Bird
  • Magic
``` -------------------------------- ### SUMMARY.md with anchors Source: https://github.com/honkit/honkit/blob/master/docs/pages.md Shows how to link to specific sections within a chapter file using anchor syntax in the table of contents. ```markdown # Summary ### Part I * [Part I](part1/README.md) * [Writing is nice](part1/README.md#writing) * [HonKit is nice](part1/README.md#honkit) * [Part II](part2/README.md) * [We love feedback](part2/README.md#feedback) * [Better tools for authors](part2/README.md#tools) ``` -------------------------------- ### Page instance properties Source: https://github.com/honkit/honkit/blob/master/docs/plugins/api.md Lists the properties available on a Page instance, including title, content, path, rawPath, and type. The type can be 'markdown' or 'asciidoc'. ```javascript // Title of the page (from SUMMARY) page.title // Content of the page (Markdown/Asciidoc/HTML according to the stage) page.content // Relative path in the book page.path // Absolute path to the file page.rawPath // Type of parser used for this file page.type ('markdown' or 'asciidoc') ``` -------------------------------- ### gitbook.fontsettings.getFamilies() Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/honkit-plugin-fontsettings/README.md Returns the currently set color themes. The method returns an array of theme objects, each with `config`, `text`, and `id` properties. ```APIDOC ## gitbook.fontsettings.getFamilies() ### Description Returns the currently set color themes. The method returns an array of theme objects, each with `config`, `text`, and `id` properties. ### Method `getFamilies()` ### Returns - **Array of Theme Objects** - The current color themes, each with `config` (string), `text` (string), and `id` (number). ### Example ```js var themes = gitbook.fontsettings.getFamilies(); ``` ``` -------------------------------- ### Book instance Source: https://github.com/honkit/honkit/blob/master/docs/plugins/api.md The Book class is the central point of HonKit, providing methods to read configuration, resolve file paths, and render markup. ```APIDOC ## Book instance ### Description The `Book` class is the central point of HonKit, it centralizes all access read methods. It provides methods to read configuration, resolve file paths, and render markup. ### Methods #### `book.config.get(key, default)` - **key** (string) - Required - The configuration key to read. - **default** (any) - Optional - The default value if the key is not found. - **Returns**: The configuration value. #### `book.resolve(filename)` - **filename** (string) - Required - The filename to resolve to an absolute path. - **Returns**: The absolute path. #### `book.renderInline(parser, string)` - **parser** (string) - Required - The parser type (e.g., 'markdown'). - **string** (string) - Required - The inline markup string to render. - **Returns**: A Promise resolving to the rendered string. #### `book.renderBlock(parser, string)` - **parser** (string) - Required - The parser type (e.g., 'markdown'). - **string** (string) - Required - The markup string to render in block mode. - **Returns**: A Promise resolving to the rendered string. ### Example ```js // Read configuration from book.json var value = book.config.get('title', 'Default Value'); // Resolve a filename to an absolute path var filepath = book.resolve('README.md'); // Render an inline markup string book.renderInline('markdown', 'This is **Markdown**') .then(function(str) { ... }) // Render a markup string (block mode) book.renderBlock('markdown', '* This is **Markdown**') .then(function(str) { ... }) ``` ``` -------------------------------- ### Extend a theme using templating syntax Source: https://github.com/honkit/honkit/blob/master/docs/themes/README.md Use this template to extend a theme instead of forking it. It overrides the 'body' block and adds content after the super() call. This is useful for making theme changes available to multiple books. ```html {% extends template.self %} {% block body %} {{ super() }} ... This will be added to the "body" block {% endblock %} ``` -------------------------------- ### Reference-style image Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html Reference-style image syntax with optional title. ```markdown ![alt text][id] [id]: /path/to/img.jpg "Title" ``` -------------------------------- ### Update Snapshots Command Source: https://github.com/honkit/honkit/blob/master/packages/honkit/src/__tests__/__fixtures__/README.md Run this command to update the snapshots for the fixtures. It is executed with pnpm. ```sh pnpm run updateSnapshot ``` -------------------------------- ### Multi-paragraph list items Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/markup-it/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html Create multi-paragraph list items by indenting paragraphs by 4 spaces or 1 tab. Blank lines between items produce

tags. ```markdown * A list item. With multiple paragraphs. * Another item in the list. ``` -------------------------------- ### Filter with arguments in template Source: https://github.com/honkit/honkit/blob/master/docs/plugins/filters.md Demonstrates passing positional and named arguments to a filter. Note the syntax includes a closing brace. ```text Hello {{ "Samy"|fullName("Pesse", man=true}} }} ``` -------------------------------- ### Base template with block and include Source: https://github.com/honkit/honkit/blob/master/docs/templating/conrefs.md Base template that defines a block and includes a license file. This is the file that the child template extends. ```markdown {% block pageContent %} This is the default content {% endblock %} # License {% include "./LICENSE" %} ``` -------------------------------- ### Access object properties with dot and bracket syntax Source: https://github.com/honkit/honkit/blob/master/docs/templating/README.md Demonstrates two ways to access properties: dot notation and bracket notation. Both are equivalent to JavaScript property access. ```twig {{ foo.bar }} {{ foo["bar"] }} ``` -------------------------------- ### gitbook.fontsettings.setThemes() Source: https://github.com/honkit/honkit/blob/master/packages/@honkit/honkit-plugin-fontsettings/README.md Sets the new color themes configuration as an array of theme objects. This recreates the fontsettings menu to reflect the changes. ```APIDOC ## gitbook.fontsettings.setThemes() ### Description Sets the new color themes configuration as an array of theme objects. This recreates the fontsettings menu to reflect the changes. ### Method `setThemes(themes)` ### Parameters - **themes** (Array of Theme Objects) - Required - The new color themes configuration. Each theme object has `config` (string), `text` (string), and `id` (number). ### Example ```js var COLOR_THEMES = [ { config: 'light', text: 'Light', id: 0 }, { config: 'dark', text: 'Dark', id: 1 } ]; gitbook.fontsettings.setThemes(COLOR_THEMES); ``` ``` -------------------------------- ### Pull the Honkit Docker image Source: https://github.com/honkit/honkit/blob/master/docker/README.md Downloads the official Honkit Docker image from GitHub Container Registry. ```bash docker pull ghcr.io/honkit/honkit ``` -------------------------------- ### page:before Source: https://github.com/honkit/honkit/blob/master/docs/plugins/hooks.md Called before running the templating engine on the page. Receives a Page Object. The page.content is the markdown/asciidoc content. ```APIDOC ## page:before ### Description Called before running the templating engine on the page. ### Arguments - **page** (Page Object) - The page object. ### Page Object Structure ```js { // Parser named "type": "markdown", // File Path relative to book root "path": "page.md", // Absolute file path "rawpath": "/usr/...", // Title of the page in the SUMMARY "title": "", // Content of the page // Markdown/Asciidoc in "page:before" // HTML in "page" "content": "

Hello

", // Level of the page "level": "1.5.3.1", // Depth of the page "depth": "3", // Other attributes appear in the .md between two '---' at the beginning of the content // For example in the front of the markdown: // --- // description: This is a description // --- "description": "This is a description", // Previous article "previous": Article Object, // Next article "next": Article Object } ``` ### Example to add a title ```js { "page:before": function(page) { page.content = "# Title\n" + page.content; return page; } } ``` ``` -------------------------------- ### Run Prettier to reformat code Source: https://github.com/honkit/honkit/blob/master/CONTRIBUTING.md Use this command to manually format code with Prettier when local Git hooks prevent lint-staged from running automatically. ```sh $ pnpm format ``` -------------------------------- ### Run snapshot tests with yarn Source: https://github.com/honkit/honkit/blob/master/examples/benchmark/README.md Runs snapshot tests for manual checking. Note that snapshot results may differ by OS; the current snapshot is based on macOS/Linux. ```bash yarn test ```