Skip to content

Instantly share code, notes, and snippets.

@kmuto
kmuto / lazy-epub-csscheck.rb
Created August 15, 2016 03:24
怠惰なCSSチェッカー
#!/usr/bin/env ruby
# coding: utf-8
# Lazy AutoLayout CSS Checker
# Copyright 2016 Kenshi Muto
# MIT License
lno = 0
ARGF.each do |l|
lno += 1
l.chomp!
if l =~ /-@-[^\s]+/
#!/usr/bin/env ruby
# coding: utf-8
require 'rexml/document'
include REXML
doc = Document.new(ARGF)
doc.context[:attribute_quote] = :quote
# 親spanを追加するには%w()内に空白区切りで指定
%w(bold).each do |style|
doc.each_element("//span[@class='#{style}']") do |e|
% jlreqクラスのテスト
% https://github.com/abenori/jlreq/blob/master/README-ja.md
% https://www.w3.org/TR/jlreq/ja/
\documentclass[book,% chapterを使用するbook環境
twoside,% 書籍のような見開きデザイン
paper=a5,% 紙サイズ(a0〜a10、b0〜b10(JIS寸法)、c2〜c8)。変型を示すためにpaper={幅mm,高さmm}で指定することも可能
fontsize=12Q,% 欧文基本書体Q数(pt指定も可能)
jafontsize=12Q,% 和文基本書体Q数(pt指定も可能)
baselineskip=21.6Q,% 行送り。普通は和文の1.5〜1.8倍くらい
line_length=36zw,% (横書きにおいて)版面の横方向全角文字数。市販書を参考にするとよい
\newcommand*\includefullpagegraphics[2][]{%
\clearpage
\thispagestyle{empty}%
\vbox to \textheight{%
% \vskip-\review@head
\vbox to \paperheight{\vss
\hbox to \textwidth{%
\ifodd\c@page
\hskip-\dimexpr\oddsidemargin + 1in\relax
\else
@kmuto
kmuto / config.yml
Created April 13, 2018 10:04
カバー用設定例
# …既存の設定…
pdfmaker:
cover: cover.tex
#!/usr/bin/env ruby
# InDesign、TeXのB5変/A5のトンボ版をSONY DPT-RP1向けに実寸調整する
# Copyright 2018 Kenshi Muto
#
# TeXのトンボ値はGreenCherry社由来のトンボ設定に依存しており、別のトンボ実装の場合は異なる値になる可能性がある
#
# pdflatex、pdfinfo(Poppler)が利用できるようにしておく
require 'yaml'
require 'tmpdir'
\renewcommand\frontmatter{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\@mainmatterfalse
\setcounter{page}{3}
% \pagenumbering{roman}}
}
@kmuto
kmuto / review-ext.rb
Created November 14, 2018 00:32
表の折り返しの別法
module ReVIEW
module LATEXBuilderOverride
def th(s)
macro('reviewth', s.gsub("\\\\\n", '\\newline{}'))
end
def td(s)
s.gsub("\\\\\n", '\\newline{}')
end
end
@kmuto
kmuto / review-ext.rb
Created March 4, 2019 14:32
tt, code内の'をtextquotesingleの形にする(textttを書き換えるのはいろいろ大変らしいので…)
module ReVIEW
module LATEXBuilderOverride
def inline_tt(s)
super(s).gsub("'", '\textquotesingle ').sub(/(textquotesingle) }$/, '\1}')
end
def inline_code(s)
super(s).gsub("'", '\textquotesingle ').sub(/(textquotesingle) }$/, '\1}')
end
end
# 空白を~に置き換えることでseqsplitで空白が消えないようにするハックを入れたreview-ext.rb
# Re:VIEW 3.0〜Re:VIEW 3.1向け (Re:VIEW 3.2では不要)
# プロジェクトにこのファイルを配置し、techbooster-doujin-base.styの「tt/codeでの折り返しの許容」のロジックの「\iffalse」を「\iftrue」に置き換える
module ReVIEW
module LATEXBuilderOverride
def inline_tt(s)
escape_space(super(s))
end