Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
huideyeren committed Dec 4, 2023
1 parent 7963a0a commit 658f505
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 64 deletions.
132 changes: 81 additions & 51 deletions .github/workflows/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,91 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
reviewdog-github-check:
name: reviewdog (github-check)
runs-on: ubuntu-latest
# reviewdog-github-check:
# name: reviewdog (github-check)
# runs-on: ubuntu-latest

steps:
#reviewdogのアクション
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
# steps:
# #reviewdogのアクション
# - uses: reviewdog/action-setup@v1
# with:
# reviewdog_version: latest

#textlintを動かすためのnodeアクション
- uses: actions/setup-node@v2
# #textlintを動かすためのnodeアクション
# - uses: actions/setup-node@v3

- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# submodules: recursive

- name: cache-node-modules
#stepsが失敗(文章の乱れ)した場合でもcacheを取得するようにする
uses: pat-s/[email protected]
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-
# - name: cache-node-modules
# #stepsが失敗(文章の乱れ)した場合でもcacheを取得するようにする
# uses: pat-s/[email protected]
# env:
# cache-name: cache-node-modules
# with:
# path: ~/.npm
# key: node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# node-

- name: Install textlint
run: 'npm install --save-dev textlint textlint-rule-preset-smarthr textlint-rule-prh textlint-plugin-review'
# - name: Install textlint
# run: 'npm install --save-dev textlint textlint-rule-preset-smarthr textlint-rule-prh textlint-plugin-review'

- name: Install dependent module
run: npm install
# - name: Install dependent module
# run: npm install

- name: Execute textlint
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx textlint -f checkstyle chapter/*.re wiki/*.md README.md \
| reviewdog -f=checkstyle -name="textlint" -diff="git diff ${{ github.event.pull_request.base.ref }}" -reporter=github-pr-review -level="error"
# - name: Execute textlint
# env:
# REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# npx textlint -f checkstyle chapter/*.re wiki/*.md README.md \
# | reviewdog -f=checkstyle -name="textlint" -diff="git diff ${{ github.event.pull_request.base.ref }}" -reporter=github-pr-review -level="error"

pdf:
needs: reviewdog-github-check
name: Make PDF
paper:
# needs: reviewdog-github-check
name: Make PDF for Paper
runs-on: ubuntu-latest
container:
image: ghcr.io/huideyeren/review-docker:main
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Install gems.
run: bundle install
- name: Copy plantuml.
run: cp /java/plantuml.jar .
- name: Check tools
run: dot -V && blockdiag --version && java -jar plantuml.jar -version
- name: convert PlantUML
run: pwd | bash ./plantuml.sh >> .plantuml.log
- name: Show .plantuml.log
run: cat .plantuml.log
- name: Convert SVG to PDF
run: pwd | python3 svg.py >> .svg.log
- name: Show .svg.log
run: cat .svg.log
- name: Grayscaling images.
run: pwd | python3 grayscaling.py >> .grayscaling.log
- name: Show .grayscaling.log
run: cat .grayscaling.log
- name: Build PDF.
run: REVIEW_CONFIG_FILE=config-print-pdf.yml bundle exec rake pdf
- name: Upload artifact.
uses: actions/upload-artifact@v3
with:
name: book.pdf
path: book.pdf
pdf-ebook:
# needs: reviewdog-github-check
name: Make PDF for Ebook
runs-on: ubuntu-latest
container:
image: huideyeren/review
image: ghcr.io/huideyeren/review-docker:main
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install gems.
run: bundle install
- name: Copy plantuml.
Expand All @@ -82,26 +116,22 @@ jobs:
run: pwd | python3 svg.py >> .svg.log
- name: Show .svg.log
run: cat .svg.log
# - name: Rotate images.
# run: pwd | python3 rotate.py >> .rotate.log
# - name: Show .rotate.log
# run: cat .rotate.log
- name: Build PDF.
run: bundle exec rake clean pdf
run: REVIEW_CONFIG_FILE=config-ebook-pdf.yml REVIEW_CATALOG_FILE=catalog-download.yml bundle exec rake pdf
- name: Upload artifact.
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: book.pdf
path: book.pdf
epub:
needs: reviewdog-github-check
# needs: reviewdog-github-check
name: Make EPUB
runs-on: ubuntu-latest
container:
image: huideyeren/review
image: ghcr.io/huideyeren/review-docker:main
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install gems.
run: bundle install
- name: Copy plantuml.
Expand All @@ -113,9 +143,9 @@ jobs:
- name: Show .plantuml.log
run: cat .plantuml.log
- name: Build EPUB.
run: bundle exec rake clean epub
run: REVIEW_CONFIG_FILE=config-epub.yml REVIEW_CATALOG_FILE=catalog-download.yml bundle exec rake epub
- name: Upload artifact.
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: book.epub
path: book.epub
path: book.epub
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"recommendations": [
"atsushieno.language-review",
"taichi.vscode-textlint",
"coenraads.bracket-pair-colorizer-2",
"8amjp.charactercount",
"mhutchie.git-graph",
"donjayamanne.githistory",
Expand Down
11 changes: 11 additions & 0 deletions catalog-download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PREDEF:
- preface.re

CHAPS:
- test.re

APPENDIX:

POSTDEF:
- postscript.re
- bib.re
8 changes: 8 additions & 0 deletions config-ebook-pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inherit: ["config.yml"]
page_metric: A5
catalogfile: catalog-download.yml
# backcover: backcover.tex
# bookname: louisa-works-2023-2-ebook
texdocumentclass: ["review-jlreq", "media=ebook,paper=a5,fontsize=10pt,serial_pagination=true,tate,twoside,onecolumn"]
# pdfmaker:
# coverimage: c103frontcover.pdf
5 changes: 5 additions & 0 deletions config-epub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
inherit: ["config.yml"]
catalogfile: catalog-download.yml
# bookname: louisa-works-2023-2-epub
# coverimage: c103frontcover.png
# backcover: C103backcover.png
4 changes: 4 additions & 0 deletions config-print-pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
inherit: ["config.yml"]
# bookname: louisa-works-2023-2-print
# prt: ねこのしっぽ
texdocumentclass: ["review-jlreq", "media=print,paper=b5,fontsize=9pt,serial_pagination=true,hiddenfolio=shippo,startpage=3,tate,twoside,onecolumn,openany"]
25 changes: 13 additions & 12 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ aut: ["ヨーシャ"]
# a-pbl, pbl: 出版社(発行所) ※ サークル名はここに設定するとよい
a-pbl: 恢徳堂
# a-prt, prt: 印刷所
prt: ねこのしっぽ
# prt: ねこのしっぽ
# a-red, red: 項目の枠組起草者
# a-rev, rev: 評論者
# a-spn, spn: 援助者
Expand Down Expand Up @@ -184,7 +184,8 @@ colophon: true
# catalogfile: catalog.yml

# reファイルを格納するディレクトリ。省略した場合は以下 (. はカレントディレクトリを示す)
contentdir: chapter
# contentdir: chapter
contentdir: _refiles

# @<w>命令で使用する単語ファイルのパス。["common.csv", "mybook.csv"]のように配列指定も可
# words_file: words.csv
Expand Down Expand Up @@ -219,7 +220,7 @@ page_metric: B5
# mathml: MathML変換。別途math_ml gemファイルが必要。EPUBMaker/WebMakerのみ効果
# imgmath: 画像化。オプションはimgmath_optionsで設定する
# mathjax: MathJax変換。EPUBMaker/WebMakerのみ効果。なお、MathJaxに必要なデータはインターネットから取得される。EPUBで利用できるかはEPUBリーダ依存
math_format: mathml
math_format: imgmath

# math_formatがimgmathの場合の設定
# 以下のパラメータを有効にするときには、
Expand All @@ -228,28 +229,28 @@ math_format: mathml
# パラメータ: 値
# ...
# という構成にする必要がある(インデントさせる)
# imgmath_options:
imgmath_options:
# 使用する画像拡張子。通常は「png」か「svg」(svgの場合は、pdfcrop_pixelize_cmdの-pngも-svgにする)
# format: png
format: svg
# 変換手法。pdfcrop または dvipng
# converter: pdfcrop
converter: pdfcrop
# プリアンブルの内容を上書きするファイルを指定する(デフォルトはupLaTeX+jsarticle.clsを前提とした、lib/review/makerhelper.rbのdefault_imgmath_preambleメソッドの内容)
# preamble_file: null
# 基準のフォントサイズ
# fontsize: 10
fontsize: 14
# 基準の行間
# lineheight: 12
lineheight: 12
# converterにpdfcropを指定したときのpdfcropコマンドのコマンドライン。プレースホルダは
# %i: 入力ファイル、%o: 出力ファイル
# pdfcrop_cmd: "pdfcrop --hires %i %o"
pdfcrop_cmd: "pdfcrop --hires %i %o"
# PDFから画像化するコマンドのコマンドライン。プレースホルダは
# %i: 入力ファイル、%o: 出力ファイル、%O: 出力ファイルから拡張子を除いたもの
# %p: 対象ページ番号、%t: フォーマット
# pdfcrop_pixelize_cmd: "pdftocairo -%t -r 90 -f %p -l %p -singlefile %i %O"
pdfcrop_pixelize_cmd: "pdftocairo -%t -r 90 -f %p -l %p -singlefile %i %O"
# pdfcrop_pixelize_cmdが複数ページの処理に対応していない場合に単ページ化するか
# extract_singlepage: null
extract_singlepage: true
# extract_singlepageがtrueの場合に単ページ化するコマンドのコマンドライン
# pdfextract_cmd: "pdfjam -q --outfile %o %i %p"
pdfextract_cmd: "pdfjam -q --outfile %o %i %p"
# converterにdvipngを指定したときのdvipngコマンドのコマンドライン
# dvipng_cmd: "dvipng -T tight -z 9 -p %p -l %p -o %o %i"
#
Expand Down
71 changes: 71 additions & 0 deletions lib/tasks/z01_pandoc2review.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) 2020 Kenshi Muto
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

require 'fileutils'
require 'yaml'

def make_mdre(ch, p2r, path)
basedir = 'chapter/'
source = basedir + ch
if File.exist?(source) # re file
FileUtils.cp(source, path)
elsif File.exist?(source.sub(/\.re\Z/, '.md')) # md file
system("#{p2r} #{source.sub(/\.re\Z/, '.md')} > #{path}/#{ch}")
end
end

desc 'run pandoc2review'
task :pandoc2review do
path = '_refiles'
p2r = 'pandoc2review'
if File.exist?('../../pandoc2review')
p2r = '../../pandoc2review'
end

unless File.exist?(path)
Dir.mkdir(path)
File.write("#{path}/THIS_FOLDER_IS_TEMPORARY", '')
end

catalog = YAML.load_file(ENV['REVIEW_CATALOG_FILE'] || 'catalog.yml')
%w(PREDEF CHAPS APPENDIX POSTDEF).each do |block|
if catalog[block].kind_of?(Array)
catalog[block].each do |ch|
if ch.kind_of?(Hash) # Parts
ch.each_pair do |k, v|
make_mdre(k, p2r, path)
# Chapters
v.each {|subch| make_mdre(subch, p2r, path) }
end
elsif ch.kind_of?(String) # Chapters
make_mdre(ch, p2r, path)
end
end
end
end
end

CLEAN.include('_refiles')
Rake::Task[BOOK_PDF].enhance([:pandoc2review])
Rake::Task[BOOK_EPUB].enhance([:pandoc2review])
Rake::Task[WEBROOT].enhance([:pandoc2review])
Rake::Task[TEXTROOT].enhance([:pandoc2review])
Rake::Task[TOPROOT].enhance([:pandoc2review])
Rake::Task[IDGXMLROOT].enhance([:pandoc2review])

0 comments on commit 658f505

Please sign in to comment.