honkit
はじめに
そうだ Docker も使えるようになろうと唐突に思い立ち、honkit(始めはGitBook)環境を作りながらやったら、すごい大変だった。
参考にしたサイトは沢山。ありがとう皆々様。
honkitは、マークダウン文章をpdfにしたり、説明書をオシャっぽくHTMLで仕上げたいとか、便利だと思う。
でも、環境構築するための学習コスト高くて辛かった。
ディレクトリ構成
~/docker/honkit:
d _bin
d _book
d assets
d book
d images
d node_modules
d styles
- .bookignore
- Dockerfile
- GLOSSARY.md
- README.md
- SUMMARY.md
- book.json
- package.json
- puppeteer-config.json
~/docker/honkit/book:
d 01-docker
- Dockerfile.md
- README.md
- book.json.md
- image-alpine-homebrew.md
- image-alpine.md
- y-vectorfield.md
d 05-honkit
d 05-plugins
- 99-plugin.org
- 99-scrap.md
- README.md
- alerts.md
- anchor-navigation-ex.md
- auto-scroll-table.md
- auto-summary.md
- chapter-fold.md
- code.md
- collapsible-chapters.md
- copy-code-button.md
- custom-js-css.md
- expandable-chapters-small.md
- expandable-chapters.md
- flexible-alerts.md
- hide-published-with.md
- hints.md
- image-captions.md
- include-codeblock.md
- include-csv.md
- isummary.md
- japanese-support.md
- katex-pro.md
- lb2br.md
- mermaid-gb3.md
- mermaid-newface.md
- plantuml.md
- search-pro-fixed.md
- splitter.md
- summary.md
- tags.md
- theme-code.md
- todo.md
- uml.md
- url-embed.md
- README.md
- summary.md
d 80-test
d 99-formats
- 01-formats.md
- 10-formats-titles.md
- 11-formats-table.md
- 20-formats-code.md
- 30-formats-link.md
- 31-formats-image.md
- 60-formats-mermaid.md
- 61-formats-plantuml.md
- README.md
- README.md
インストール
~/docker/honkit/Dockerfile
- dockerで使う
FROM node:lts-bookworm
RUN apt-get update && apt-get upgrade -y
RUN apt-get install --no-install-recommends --allow-unauthenticated -y \
calibre \
sudo locales \
fdclone lv ng-cjk silversearcher-ag \
build-essential default-jre graphviz \
libatk-bridge2.0-0 \
fonts-ipafont fonts-ipaexfont fonts-noto-cjk
COPY ./_bin/.* /root/
COPY ./_bin/.*.sh /usr/local/bin
RUN mkdir -p /honkit && mkdir -p /work
RUN curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
ENV PATH=/honkit/node_modules/.bin:$PATH
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
WORKDIR /honkit
ENV BOOKDIR=/honkit
EXPOSE 4000 35729
VOLUME $BOOKDIR
COPY ./ ./
# PlantUMLの吐き出す画像で日本語が表示出来ない問題に対応
RUN echo "ja_JP.UTF-8 UTF-8" > /etc/locale.gen
RUN locale-gen ja_JP
RUN update-locale LANG=ja_JP.UTF-8
ENV LANG="ja_JP.UTF-8" \
LANGUAGE="ja_JP:ja" \
LC_ALL="ja_JP.UTF-8" \
TZ=Asia/Tokyo
~/docker/honkit/.bookignore
- _book ディレクトリにビルドしないファイル
!assets/images/
/.*
/*.sh
/.bookignore
/.gitignore
/_arc
/LICENSE
docker-compose.*
package.json
yarn.lock
~/docker/honkit/book.json
- honkit 設定ファイル
{
"language": "ja",
"root": ".",
"sortedBy": "-",
"structure": {
"readme": "README.md",
"summary": "SUMMARY.md",
"glossary":"GLOSSARY.md",
"languages":"LANGS.md"
},
"redirects": {
"previous/page": "new-folder/page.md"
},
"plugins": [
"-chapter-fold",
"-collapsible-chapters",
"-expandable-chapters",
"-lunr", "-search", "search-pro-fixed",
"-summary",
"mermaid-newface",
"puml",
"-highlight", "-highlight-pro",
"@ansanloms/uml",
"alerts",
"anchor-navigation-ex",
"auto-scroll-table",
"auto-summary",
"code",
"codeblock-filename",
"custom-js-css",
"expandable-chapters-small",
"hide-published-with",
"hints",
"image-captions",
"include-codeblock",
"japanese-support",
"katex-pro",
"lb2br",
"livereload",
"splitter",
"tags",
"theme-code",
"todo"
],
"pluginsConfig": {
"anchor-navigation-ex": {
"showLevel": false,
"float": {
"floatIcon": "fa fa-navicon",
"showLevelIcon": false,
"level1Icon": "fa fa-hand-o-right",
"level2Icon": "fa fa-hand-o-right",
"level3Icon": "fa fa-hand-o-right"
},
"pageTop": {
"showLevelIcon": false,
"level1Icon": "fa fa-hand-o-right",
"level2Icon": "fa fa-hand-o-right",
"level3Icon": "fa fa-hand-o-right"
},
"themeDefault": {
"showLevel": false
}
},
"custom-js-css": {
"js": [
"styles/my.js"
],
"css": [
"styles/github-css.css",
"styles/my.css"
]
},
"auto-summary": {
"parts": {
"README.md": "はじめに",
"book/01-docker/**/*.md": "docker",
"book/05-honkit/**/*.md": "honkit",
"book/80-test/**/*.md": "テスト",
"book/99-formats/**/*.md": "フォーマット"
}
},
"uml": {
"format": "svg",
"charset": "utf8",
"config": "classic"
},
"highlight-pro": {
"theme": "mono-blue",
"map": {
"shell": "bash",
"sh": "bash",
"mermaid": "bash",
"txt": "markdown"
}
}
},
"pdf":{
"pageNumbers":true,
"fontFamily":"Arial",
"fontSize":12,
"paperSize":"a4",
"margin":{
"right":62,
"left":62,
"top":56,
"bottom":56
}
},
"styles": {
"website": "styles/website.css",
"ebook": "styles/ebook.css",
"pdf": "styles/pdf.css",
"mobi": "styles/mobi.css",
"epub": "styles/epub.css"
}
}
~/docker/honkit/package.json
- yarn install で node_modules にインストールする
{
"name": "honkit",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@ansanloms/honkit-plugin-uml": "^0.0.8",
"auto-scroll-table": "git+https://github.com/ideamean/gitbook-plugin-auto-scroll-table.git",
"gitbook-plugin-ace": "^0.3.2",
"gitbook-plugin-alerts": "^0.2.0",
"gitbook-plugin-anchor-navigation-ex": "^1.0.14",
"gitbook-plugin-auto-scroll-table": "^0.0.5",
"gitbook-plugin-auto-summary": "^0.0.2",
"gitbook-plugin-chapter-fold": "^0.0.4",
"gitbook-plugin-code": "^0.1.0",
"gitbook-plugin-codeblock-filename": "^0.0.9",
"gitbook-plugin-collapsible-chapters": "^0.1.8",
"gitbook-plugin-custom-js-css": "^0.0.1",
"gitbook-plugin-expandable-chapters": "^0.2.0",
"gitbook-plugin-expandable-chapters-small": "^0.1.7",
"gitbook-plugin-hide-published-with": "^0.0.1",
"gitbook-plugin-highlight-pro": "https://github.com/tkggcelt/gitbook-plugin-highlight-pro.git",
"gitbook-plugin-hints": "^1.0.2",
"gitbook-plugin-include-codeblock": "^3.2.3",
"gitbook-plugin-japanese-support": "^0.0.1",
"gitbook-plugin-katex-pro": "^0.16.3",
"gitbook-plugin-lb2br": "^0.0.5",
"gitbook-plugin-mermaid-newface": "^4.1.0",
"gitbook-plugin-puml": "^1.0.1",
"gitbook-plugin-search-pro-fixed": "^1.0.1",
"gitbook-plugin-splitter": "^0.0.8",
"gitbook-plugin-tags": "^1.5.2",
"gitbook-plugin-theme-code": "^0.0.24",
"gitbook-plugin-todo": "^0.1.3",
"gitbook-summary": "^1.2.4",
"honkit": "^6.0.3",
"honkit-plugin-image-captions": "https://github.com/youyinnn/honkit-plugin-image-captions",
"node-sass": "^9.0.0"
}
}
~/docker/honkit/puppeteer-config.json
- 忘れた
{
"args": ["--no-sandbox"]
}
~/docker/honkit/_bin/.bashrc
※ 必要じゃない
- ログインシェルで使う
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
~/docker/honkit/_bin/.fd2rc
※ 必要じゃない
- FDCloneで使う
PAGER=lv
EDITOR=ng
SHELL=/bin/sh
MESSAGELANG=ja
SIZEUNIT=1
TMPDIR=/home/bone/tmp
SORTTYPE=201
DISPLAYMODE=3
ANSICOLOR=1
UNICODEBUFFER=1
#export LANG=C
LANG=ja_JP.UTF-8
LANGUAGE=$LANG
INPUTKCODE=$LANG
FNAMEKCODE=$LANG
~/docker/honkit/_bin/.ng
※ 必要じゃない
;; $Id: dot.ng,v 1.1.1.1 2000/06/27 01:47:57 amura Exp $
;;
;; Ng startup file by H.Ohkubo
;;
;;
;; (global-unset-key "\^[\[" 'backward-paragraph)
;; (global-set-key "\^[\[A" 'previous-line)
;; (global-set-key "\^[\[B" 'next-line)
;; (global-set-key "\^[\[C" 'forward-char)
;; (global-set-key "\^[\[D" 'backward-char)
;;
;; (global-set-key "\^[OA" 'previous-line)
;; (global-set-key "\^[OB" 'next-line)
;; (global-set-key "\^[OC" 'forward-char)
;; (global-set-key "\^[OD" 'backward-char)
;;
;; (global-set-key "\^[2A" 'beginning-of-buffer)
;; (global-set-key "\^[2B" 'end-of-buffer)
;; (global-set-key "\^[5A" 'beginning-of-line)
;; (global-set-key "\^[5B" 'end-of-line)
;
; 'next-line' doesn't insert newline at the end of buffer.
(next-line-add-newlines nil)
;
; backspace <-> ^H
; exchange C-h with DEL.
(bsmap-mode)
;
; for No Backup files
; don't make backup files.
(make-backup-files nil)
; regexp search by typing ESC C-s/C-r
(global-set-key "\^[\^s" 're-search-forward)
(global-set-key "\^[\^r" 're-search-backward)
; set-mark-command to ^\
;(global-set-key "\^\\" 'set-mark-command)
; set-fep-toggle to ^\
;(global-set-key "\^\\" 'fep-toggle)
;(global-set-key "\^\\" 'set-mark-command)
;(set-kanji-expected-code nil)
;(set-default-fileio-code 'euc)
;(set-kanji-fileio-code 'euc)
(set-kanji-expected-code nil)
(set-default-fileio-code 'utf)
(set-kanji-fileio-code 'utf)
; c-mode setting
; C モードの変数を一般的な C 言語のスタイルに合わせたい時は次のようにします。
;
(set-c-argdecl-indent 0)
(set-c-continued-statement-offset 4)
(set-c-continued-brace-offset -4)
(set-c-brace-offset -4)
(set-c-brace-imaginary-offset 0)
(set-c-indent-level 4)
(set-c-label-offset -2)
(set-c-tab-always-indent t)
; 行頭禁則文字に '>' を、行末禁則文字に '<' を追加したい場合、次のようにし
; ます。
;
;(add-kinsoku-bol-chars ">")
;(add-kinsoku-eol-chars "<")
;
; 行頭禁則文字から「/」と「\」を削除したい場合は次のようにします。
;
;(delete-bol-kinsoku-chars "/\")
;
; blink matching parens
; 括弧の対応を自動的に表示させたい場合は次のようにします。
;
(global-set-key ")" 'blink-matching-paren-hack)
(global-set-key "}" 'blink-matching-paren-hack)
(global-set-key "]" 'blink-matching-paren-hack)
; ESC C-s/C-r で正規表現検索をするようにしたい場合は次のようにします。
; set regular-exp. re-search
;
;(global-set-key "\^[\^s" 're-search-forward)
;(global-set-key "\^[\^r" 're-search-backward)
;
; FEP 自動制御機能を常に有効にしたい場合は次のようにします。
;
;(set-fep-control t)
; setting for SKG
;(set-skg-roman-dictionary "/home/anonymous/etc/SKG-ROMAN")
;(set-skg-kanji-dictionary "/home/anonymous/etc/SKG-JISYO")
;
: other setting
(set-fill-column 80)
;; ;C-\ to canna-toggle (jedε
;; (global-set-key "\^\\" 'canna-toggle)
;; ;C-t
;; (global-set-key "\^t" 'scroll-down)
;; ;C-j
(global-set-key "\^xj" 'goto-line)
;; (global-set-key "\^[g" 'goto-line)
;; ;ESC-h to help
(global-set-key "\^[h" 'help-help)
;; ;C-h Backspace to delete backward
(global-set-key "\^h" 'delete-backward-char)
;; ;Del to delete char(can't use on kon2)
;; (global-set-key "\^?" 'delete-char)
;; ;Cursor
(global-set-key "\^[[A" 'previous-line)
(global-set-key "\^[[B" 'next-line)
(global-set-key "\^[[D" 'backward-char)
(global-set-key "\^[[C" 'forward-char)
;Home and End(for console only)
(global-set-key "\E[H" 'beginning-of-line)
(global-set-key "\E[F" 'end-of-line)
(global-set-key ";5H" 'beginning-of-buffer)
(global-set-key ";5F" 'end-of-buffer)
;; ;PageUp and PageDown(for console)
(global-set-key "\E[I" 'scroll-down)
(global-set-key "\E[G" 'scroll-up)
;; ;PageUp and PageDown(for X)
(global-set-key "\E[5~" 'scroll-down)
(global-set-key "\E[6~" 'scroll-up)
;; ;Ins(for X)
;; ; (global-set-key "\E[2~" 'overwrite-mode)
;;
;;(global-set-key "5~" 'scroll-down)
;;(global-set-key "6~" 'scroll-up)
~/docker/honkit/_bin/.profile
※ 必要じゃない
- ログインシェルで使う
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n 2> /dev/null || true
~/docker/honkit/_bin/add-plugins.sh
※ 必要じゃない
- node_modules ディレクトリを作り直したい時に使う
- プラグインをメモっておくのに使う
- yarnの使い方を忘れた時に使う
#!/bin/bash
yarn global upgrade npm@latest
# yarn global upgrade
yarn
yarn init --yes
yarn add honkit
## npx honkit init
## npx honkit build
## npx honkit serve
## yarn add
# npm install -g @mermaid-js/mermaid-cli
disableds=(
gitbook-plugin-advanced-emoji
gitbook-plugin-anchors@https://github.com/chick-p/honkit-plugin-anchors.git
gitbook-plugin-auto-summary
gitbook-plugin-back-to-top-button
gitbook-plugin-copy-code-button
gitbook-plugin-changelog
gitbook-plugin-comments-footer
gitbook-plugin-custom-js-css
gitbook-plugin-edit-link
gitbook-plugin-git-author
gitbook-plugin-graph
gitbook-plugin-include
gitbook-plugin-include-codeblock
gitbook-plugin-insert-logo
gitbook-plugin-intopic-toc
gitbook-plugin-lb2br@https://github.com/uniquejava/gitbook-plugin-lb2br.git
gitbook-plugin-mathjax-pro@https://github.com/kevinkangkang/gitbook-plugin-mathjax-pro.git
gitbook-plugin-recently-updated
gitbook-plugin-simple-mind-map
gitbook-plugin-splitter
gitbook-summary
honkit-plugin-image-captions
honkit-plugin-katex
honkit-plugin-mermaid
gitbook-plugin-mermaid-gb3
mathjax@2
mkdirp
svgexport
mermaid
@mermaid-js/mermaid-cli
csv-parse
gitbook-plugin-summary
gitbook-plugin-isummary
gitbook-plugin-custom-js-css
gitbook-plugin-mermaid-2
gitbook-plugin-chapter-fold
gitbook-plugin-anchors@https://github.com/chick-p/honkit-plugin-anchors.git
)
items=(
@ansanloms/honkit-plugin-uml
gitbook-plugin-ace
gitbook-plugin-alerts
gitbook-plugin-anchor-navigation-ex
gitbook-plugin-auto-scroll-table@git+https://github.com/ideamean/gitbook-plugin-auto-scroll-table.git
gitbook-plugin-auto-summary
gitbook-plugin-code
gitbook-plugin-codeblock-filename
gitbook-plugin-collapsible-chapters
gitbook-plugin-custom-js-css
gitbook-plugin-expandable-chapters
gitbook-plugin-expandable-chapters-small
gitbook-plugin-hide-published-with
gitbook-plugin-hints
gitbook-plugin-include-codeblock
gitbook-plugin-japanese-support
gitbook-plugin-katex-pro
gitbook-plugin-lb2br
gitbook-plugin-mermaid-newface
gitbook-plugin-puml
gitbook-plugin-search-pro-fixed
gitbook-plugin-splitter
gitbook-plugin-tags
gitbook-plugin-theme-code
gitbook-plugin-todo
honkit-plugin-image-captions
)
for item in "${items[@]}" ; do
yarn add ${item}
done
~/docker/honkit/_bin/pdfmaker.sh
*** PDF書き出し用にクリーンなディレクトリを構築するシェルスクリプト
#!/bin/bash
## Honkit でつくられたドキュメント群を PDF で書き出すメモ Posted on 2021年11月24日 by seigo
## https://www.1ft-seabass.jp/memo/2021/11/24/honkit-all-docs-convert-pdf-knowledge/
function MyEcho()
{
echo "[`date '+%Y/%m/%d %T'`] $1"
}
### 全ドキュメントを1ページにまとめて Honkit で書き出して PDF 印刷してしまおう
## はい。できるだけシンプルに出来ないかなということで、こういう着地になりました。
##
## * 全ドキュメントを目次ページである SUMMARY.md から結合する Markdown ファイル群を取得
## * 全ドキュメントを1ページにまとめて Honkit で書き出し
## * その1ページを PDF 印刷
## でやってみます。
MyEcho "*** start ***"
rm -rf /pdfmaker
mkdir -p /pdfmaker
## *** 超重要 ***
## *** 以降、カレントディレクトリ前提なのでうっかり上書き超怖い!!
cd /pdfmaker
MyEcho "mess - yarn --初期化-- ベース作成"
yarn init -y
MyEcho "mess - honbook --初期化-- ベース作成"
echo y | npx honkit init
# ### SUMMARY.md
# MyEcho "mess - make SUMMARY.md"
# cat << 'EOT' >> /pdfmaker/SUMMARY.md
# # Summary
#
# - [README](README.md)
# EOT
MyEcho "mess - copy markown documents"
mkdir -p /pdfmaker/book
mkdir -p /pdfmaker/pdf
# copy directory all. recursive force update
cp -Rfu /honkit/book/* /pdfmaker/book
# cp /honkit/README.md /pdfmaker/book
# cp /honkit/SUMMARY.md /pdfmaker/book
# sed -i".stok" 's@(book/@(./@g' /pdfmaker/book/SUMMARY.md
cp /honkit/README.md /pdfmaker/
cp /honkit/SUMMARY.md /pdfmaker/
## ## ### 元ネタの SUMMARY.md から全ドキュメントを 1 ページにまとめる Node.js のコード
## ## cat << 'EOT' >> /pdfmaker/app.js
## ## const fs = require('fs').promises;
## ## const path = require('path');
## ##
## ## async function main (){
## ##
## ## // SUMMARY.md から結合する Markdown ファイル群を取得
## ## const filepath = path.resolve(__dirname , './book/SUMMARY.md');
## ## const message = await fs.readFile(filepath, {encoding: 'utf-8'});
## ## // Markdown のリンク記法の配列で入ってくる
## ## let resultMarkdownLinkList = message.match(/\[(.*)\]\((.*)\)/gm);
## ## console.log(resultMarkdownLinkList);
## ##
## ## // 大量に取得してしまうと確認がしにくいので、いったん取得後に数件に限定する処理
## ## // チューニング用
## ## /*
## ## resultMarkdownLinkList = [
## ## resultMarkdownLinkList[0],
## ## resultMarkdownLinkList[1],
## ## resultMarkdownLinkList[2]
## ## ]
## ## */
## ##
## ## // ファイルを結合して README.md 1ファイルに集約
## ## let targetContent = "";
## ## let targetContentAll = "";
## ## for(let i = 0; i < resultMarkdownLinkList.length; i++){
## ## const targetMatchResult = resultMarkdownLinkList[i];
## ##
## ## // Markdown のリンク記法からリンクタイトルとファイルパスを抽出
## ## const regexp = /\[(.*)\]\((.*)\)/gm;
## ## const match = regexp.exec(targetMatchResult);
## ## // console.log(match[1],match[2]);
## ## const targetSummaryTitle = match[1];
## ## const targetResolveFilepath = match[2];
## ##
## ## // 相対パス化
## ## const targetFilepath = path.resolve(__dirname , './book/' , targetResolveFilepath);
## ##
## ## // 非同期でコンテンツ読み込み
## ## targetContent = await fs.readFile(targetFilepath, {encoding: 'utf-8'});
## ## console.log('----');
## ## console.log(targetContent.substr(0,100));
## ##
## ## // コンテンツ連結
## ## targetContentAll += targetContent;
## ## }
## ##
## ## console.log('----');
## ## console.log('コンテンツ書き込み');
## ## console.log('----');
## ##
## ## // pdf というフォルダに格納する
## ## // この pdf フォルダを honkit で書き出し
## ## const filepathMainContent = path.resolve(__dirname , './pdf/' , 'README.md');
## ##
## ## // コンテンツ書き込み
## ## await fs.writeFile(filepathMainContent,targetContentAll);
## ## }
## ##
## ## main();
## ## EOT
### website.css の調整
MyEcho "mess - make styles/website.css"
mkdir -p /pdfmaker/styles
cat << 'EOT' >> /pdfmaker/styles/website.css
/* 印刷用 */
@media print {
@page {
size: 190mm 277mm;
margin: 0;
}
body{
/*A4縦 210mm x 297mm*/
width: 186mm;
height: 270mm;
}
.page-inner {
width: 100% !important;
}
}
EOT
### pdf.css の調整
MyEcho "mess - make styles/pdf.css"
mkdir -p /pdfmaker/styles
cat << 'EOT' >> /pdfmaker/styles/pdf.css
EOT
### book.json の調整
MyEcho "mess - make book.json"
cat << 'EOT' >> /pdfmaker/book.json
{
"title": "あああいいいううう",
"description": "2021 授業資料",
"language": "ja",
"plugins": [
"-lunr", "-search",
"-summary",
"@ansanloms/uml",
"alerts",
"anchors@https://github.com/chick-p/honkit-plugin-anchors.git",
"auto-scroll-table",
"code",
"codeblock-filename",
"hide-published-with",
"highlight",
"hints",
"image-captions",
"include-codeblock",
"intopic-toc",
"japanese-support",
"lb2br",
"mermaid-gb3",
"puml",
"tags",
"theme-code",
"todo"
],
"pluginsConfig": {
"custom-js-css": {
"js": [
"styles/my.js"
],
"css": [
"styles/github-css.css",
"styles/my.css"
]
},
"uml": {
"format": "svg",
"charset": "utf8",
"config": "classic"
}
},
"pdf":{
"pageNumbers":true,
"fontFamily":"Arial",
"fontSize":12,
"paperSize":"a4",
"margin":{
"right":62,
"left":62,
"top":56,
"bottom":56
}
},
"styles": {
"website": "styles/website.css",
"ebook": "styles/ebook.css",
"pdf": "styles/pdf.css",
"mobi": "styles/mobi.css",
"epub": "styles/epub.css"
}
}
EOT
### プラグイン導入
MyEcho "mess - honbook --プラグイン導入-- コマンド発呼"
plugins=(
honkit
@ansanloms/honkit-plugin-uml
gitbook-plugin-ace
gitbook-plugin-alerts
gitbook-plugin-anchors@https://github.com/chick-p/honkit-plugin-anchors.git
gitbook-plugin-auto-scroll-table@git+https://github.com/ideamean/gitbook-plugin-auto-scroll-table.git
gitbook-plugin-code
gitbook-plugin-codeblock-filename
gitbook-plugin-hide-published-with
gitbook-plugin-hints
honkit-plugin-image-captions
gitbook-plugin-include-codeblock
gitbook-plugin-intopic-toc
gitbook-plugin-japanese-support
gitbook-plugin-lb2br
gitbook-plugin-mermaid-gb3
gitbook-plugin-puml
gitbook-plugin-tags
gitbook-plugin-theme-code
gitbook-plugin-todo
)
for PLG in "${plugins[@]}" ; do
MyEcho "mess - honbook Plugins -- yarn add ${PLG}"
yarn add ${PLG}
done
## head --lines=-1 /pdfmaker/package.json > /pdfmaker/aaa.json
## cat << 'EOT' >> /pdfmaker/aaa.json
## ,
## "scripts": {
## "serve-pdf": "export QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox" && npx honkit pdf src-pdf",
## "serve": "honkit serve base src",
## "build": "honkit build base docs"
## }
## }
## EOT
##
## cat /pdfmaker/aaa.json > /pdfmaker/package.json
MyEcho "*** end ***"
MyEcho 'ディレクトリ移動(cd)してPDF作成を続行してください'
MyEcho 'cd /pdfmaker'
MyEcho 'npx honkit pdf'
exit 0
~/docker/honkit/_bin/plantuml.sh
#!/bin/sh
exec /usr/bin/java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -jar '/usr/share/java/plantuml.jar' "$@"
起動
ビルドコマンド → 起動コマンド
ビルドコマンド
export CNAME=ohonkit && docker buildx build ./ -t ${CNAME}
起動コマンド
$ docker run -it -p 4000:4000 -p 35729:35729 -v "$PWD:/honkit" -w "/honkit" ${CNAME} bash
# ここから起動したdockerイメージ内部でのコマンド
$ ./add-plugins.sh
$ yarn install
$ npx honkit serve
npxコマンドを付けないで honkit を使うと、結果が違うので注意する
使う
ホストPCでブラウザからアクセスする
- 再起動はhonkitを再起動する
npx honkit serve
- マークダウンファイル(xxxx.md)を追加・削除した時はhonkitを再起動する
- 目次の自動生成は2回の再起動が必要
- コード表示のシンタックスハイライトは無効にする。有効にするとエラーが手に負えない