From 3ea6b63788152f061ee4d71d4fbfbd3c157dc56d Mon Sep 17 00:00:00 2001 From: ota-meshi Date: Tue, 24 Dec 2024 17:20:24 +0900 Subject: [PATCH] Use mermaid-filter --- .github/workflows/GHPages.yml | 6 +-- .../test-build-resources-with-pandoc.yml | 12 +++++- .puppeteer.json | 4 ++ build-resources-with-pandoc.sh | 42 ++++++++++++++++++- 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 .puppeteer.json diff --git a/.github/workflows/GHPages.yml b/.github/workflows/GHPages.yml index 0c8fbd3e..24df7ca0 100644 --- a/.github/workflows/GHPages.yml +++ b/.github/workflows/GHPages.yml @@ -10,10 +10,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - - uses: docker://pandoc/latex:2.9 + - uses: docker://pandoc/latex:2.19 with: - args: | - sh build-resources-with-pandoc.sh + entrypoint: "/bin/sh" + args: "./build-resources-with-pandoc.sh" - name: Install Packages run: | npm i -f diff --git a/.github/workflows/test-build-resources-with-pandoc.yml b/.github/workflows/test-build-resources-with-pandoc.yml index 3398838d..df6d8689 100644 --- a/.github/workflows/test-build-resources-with-pandoc.yml +++ b/.github/workflows/test-build-resources-with-pandoc.yml @@ -14,12 +14,20 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - - uses: docker://pandoc/latex:2.9 + - uses: docker://pandoc/latex:2.19 with: - args: sh build-resources-with-pandoc.sh + entrypoint: "/bin/sh" + args: "./build-resources-with-pandoc.sh" - name: Archive resources uses: actions/upload-artifact@v4 with: name: pandoc_resources path: ./public/resources/ retention-days: 1 + - name: Archive Error resources + if: failure() + uses: actions/upload-artifact@v4 + with: + name: error_resources + path: ./documents/ + retention-days: 1 diff --git a/.puppeteer.json b/.puppeteer.json new file mode 100644 index 00000000..8f657e62 --- /dev/null +++ b/.puppeteer.json @@ -0,0 +1,4 @@ +{ + "args": ["--no-sandbox", "--disable-setuid-sandbox"], + "executablePath": "/usr/bin/chromium-browser" +} diff --git a/build-resources-with-pandoc.sh b/build-resources-with-pandoc.sh index 0b3346f0..8c7271da 100644 --- a/build-resources-with-pandoc.sh +++ b/build-resources-with-pandoc.sh @@ -1,8 +1,46 @@ +#!/bin/sh +set -e + ROOT_DIR=`pwd` CSS_PATH="${ROOT_DIR}/documents/common/pandoc_styles/css/style.css" STYLE_DOCX_PATH="${ROOT_DIR}/documents/common/pandoc_styles/スタイル.docx" RESOURCES_DIR="${ROOT_DIR}/public/resources" +# バージョンチェック +cat /etc/alpine-release + +apk update + +# apkによるインストール +## chromium のインストール +apk add --update chromium + +## nodejs のインストール +apk add nodejs npm + +## 日本語用フォントのインストール +apk add --no-cache curl fontconfig +curl -O https://moji.or.jp/wp-content/ipafont/IPAexfont/IPAexfont00301.zip +mkdir -p /usr/share/fonts/ipa +mkdir -p /temp +unzip IPAexfont00301.zip -d /temp +cp /temp/IPAexfont00301/*.ttf /usr/share/fonts/ipa/ +rm IPAexfont00301.zip + +# バージョンチェック +node -v +npm -v +chromium-browser --version + +# mermaid-filterに必要な変数をセット +export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD='true' +export MERMAID_FILTER_PUPPETEER_CONFIG="${ROOT_DIR}/.puppeteer.json" +export PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium-browser" +# export MERMAID_FILTER_FORMAT="svg" # docxでの出力時にはsvgは使えません + +# mermaid-filterのインストール +npm i -g mermaid-filter@1.4.7 + # Java cd ${ROOT_DIR}/documents/forJava @@ -26,8 +64,8 @@ pandoc ./AWSインフラリソース命名規約.md --toc --reference-doc=${STYL # OpenAPISpecification cd ${ROOT_DIR}/documents/forOpenAPISpecification -pandoc ./OpenAPI_Specification_3.0.3.md -s --self-contained --number-sections --toc -t html5 -c ${CSS_PATH} -o ${RESOURCES_DIR}/OpenAPI_Specification_3.0.3.html -pandoc ./OpenAPI_Specification_3.0.3.md --toc --reference-doc=${STYLE_DOCX_PATH} -s -o ${RESOURCES_DIR}/OpenAPI_Specification_3.0.3.docx +pandoc ./OpenAPI_Specification_3.0.3.md -s --self-contained --number-sections --toc -t html5 -c ${CSS_PATH} --filter mermaid-filter -o ${RESOURCES_DIR}/OpenAPI_Specification_3.0.3.html +pandoc ./OpenAPI_Specification_3.0.3.md --toc --reference-doc=${STYLE_DOCX_PATH} -s --filter mermaid-filter -o ${RESOURCES_DIR}/OpenAPI_Specification_3.0.3.docx # Git cd ${ROOT_DIR}/documents/forGitBranch