Skip to content

Commit

Permalink
Add inline op @<ins> and @<del>. Closes: #1630
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed Dec 31, 2020
1 parent 191d1b1 commit 7891aeb
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 38 deletions.
2 changes: 2 additions & 0 deletions doc/format.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,8 @@ UL1-OL1-PARAGRAPH
* `@<ttb>{〜}` : 等幅+太字にします。
* `@<code>{〜}` : 等幅にします(コードの引用という性質)。
* `@<tcy>{〜}` : 縦書きの文書において文字を縦中横にします。
* `@<ins>{〜}` : 挿入箇所を明示します(デフォルトでは下線が引かれます)。
* `@<del>{〜}` : 削除箇所を明示します(デフォルトでは打ち消し線が引かれます)。

### 参照
* `@<chap>{章ファイル名}` : 「第17章」のような、章番号を含むテキストに置換されます。
Expand Down
2 changes: 2 additions & 0 deletions doc/format.md
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,8 @@ Output:
@<ttb>{BarClass}:: teletype (monospaced font) and bold
@<code>{a.foo(bar)}:: teletype (monospaced font) for fragments of code
@<tcy>{}:: short horizontal text in vertical text
@<ins>{sentence}:: inserted part (underline)
@<del>{sentence}:: deleted part (strike through)
```

### References
Expand Down
8 changes: 8 additions & 0 deletions lib/review/idgxmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,14 @@ def inline_u(str)
%Q(<underline>#{escape(str)}</underline>)
end

def inline_ins(str)
%Q(<ins>#{escape(str)}</ins>)
end

def inline_del(str)
%Q(<del>#{escape(str)}</del>)
end

def inline_icon(id)
begin
%Q(<Image href="file://#{@chapter.image(id).path.sub(%r{\A\./}, '')}" type="inline" />)
Expand Down
4 changes: 4 additions & 0 deletions lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,10 @@ def inline_tt(str)
end
end

def inline_ins(str)
macro('reviewinsert', escape(str))
end

def inline_del(str)
macro('reviewstrike', escape(str))
end
Expand Down
10 changes: 9 additions & 1 deletion lib/review/markdownbuilder.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2013-2019 KADO Masanori, Masayoshi Takahashi, Kenshi Muto
# Copyright (c) 2013-2020 KADO Masanori, Masayoshi Takahashi, Kenshi Muto
#
# This program is free software.
# You can distribute or modify this program under the terms of
Expand Down Expand Up @@ -224,6 +224,14 @@ def inline_u(str)
"<u>#{str}</u>"
end

def inline_ins(str)
"<ins>#{str}</ins>"
end

def inline_del(str)
"~~#{str}~~"
end

def image_image(id, caption, _metric)
blank
puts "![#{compile_inline(caption)}](#{@chapter.image(id).path.sub(%r{\A\./}, '')})"
Expand Down
12 changes: 10 additions & 2 deletions lib/review/plaintextbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,16 @@ def inline_dtp(_str)
''
end

def inline_del(_str)
''
def inline_ins(str)
str
end

def inline_del(str)
str
end

def inline_tcy(str)
str
end

def inline_br(_str)
Expand Down
12 changes: 12 additions & 0 deletions lib/review/topbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ def inline_u(str)
"@#{str}@◆→@〜@部分に下線←◆"
end

def inline_ins(str)
"◆→開始:挿入表現←◆#{str}◆→終了:挿入表現←◆"
end

def inline_del(str)
"◆→開始:削除表現←◆#{str}◆→終了:削除表現←◆"
end

def inline_tcy(str)
"◆→開始:回転←◆#{str}◆→終了:縦回転←◆"
end

def inline_icon(id)
begin
"◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}←◆"
Expand Down
11 changes: 6 additions & 5 deletions samples/syntax-book/ch02.re
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ a_{m1} & \cdots & a_{mn}
#@# 場所ラベル定義

=== 書体
本文での……キーワード@<kw>{キーワード, keyword}@<fn>{kw}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
本文での……キーワード@<kw>{キーワード, keyword}@<fn>{kw}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、挿入@<ins>{ins挿入}、削除@<del>{del削除}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}

傍点@<embed>{@}<bou>{bou傍点}、ルビ@<embed>{@}<ruby>{愕然, がくぜん}、縦中横@<embed>{@}<tcy>{90}、はTeXでは現状、別パッケージが必要です。
#@# FIXME:TEXでの文字スタイル。外部パッケージが必要
Expand All @@ -299,24 +299,25 @@ a_{m1} & \cdots & a_{mn}

//footnote[kw][キーワードのカッコは太字にしないほうがいいのかなと思いつつあります(手元の案件では太字にしないよう挙動を変えてしまっているほうが多い)。]

* 箇条書き内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
* 箇条書き内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、挿入@<ins>{ins挿入}、削除@<del>{del削除}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}

//tsize[|latex|p{120mm}]
//table{
表内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
表内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、挿入@<ins>{ins挿入}、削除@<del>{del削除}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
//}

コードブロック内では対応装飾は減らしてよいと考えます。代わりにballoonが追加されます。

//emlist[キャプション内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}]{
//emlist[キャプション内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、挿入@<ins>{ins挿入}、削除@<del>{del削除}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}]{
コードブロック内での……
太字@<b>{b太字}
イタリック@<i>{iイタリック}
下線@<u>{u下線}
網カケ@<ami>{amiアミ} @<balloon>{ふきだし説明}
挿入@<ins>{ins挿入}、削除@<del>{del削除}
//}

=== 見出し内 @<b>{BOLD},@<i>{ITALIC},@<tt>{TT},@<strong>{STRONG},@<em>{EM},@<code>{CODE},@<ttb>{TTB},@<tti>{TTI},@<ami>{AMI},@<bou>{BOU},@<kw>{KW},@<u>{UNDERLINE}
=== 見出し内 @<b>{BOLD},@<i>{ITALIC},@<tt>{TT},@<strong>{STRONG},@<em>{EM},@<code>{CODE},@<ttb>{TTB},@<tti>{TTI},@<ami>{AMI},@<bou>{BOU},@<kw>{KW},@<u>{UNDERLINE},@<ins>{INS}、@<del>{DEL}

==={crossref} 参照
#@# FIXME:任意ラベルを使うと、EPUBチェックエラーになることがある?
Expand Down
8 changes: 3 additions & 5 deletions templates/latex/review-jlreq/review-base.sty
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\ProvidesClass{review-base}[2020/08/16]
\ProvidesClass{review-base}[2020/12/31]
% jlreq用基本設定
\def\recls@tmp{luatex}\ifx\recls@tmp\recls@driver
\hypersetup{
Expand Down Expand Up @@ -198,6 +198,7 @@
\def\reviewballoon#1{#1}
\def\reviewbou#1{#1}
\def\reviewkw#1{#1}
\def\reviewinsert#1{#1}
\def\reviewstrike#1{#1}
\def\reviewunderline#1{#1}
}
Expand Down Expand Up @@ -252,11 +253,8 @@

\DeclareRobustCommand{\reviewbou}[1]{\kenten{#1}}

%% @<del> is ignored in LaTeX with default style
%% \DeclareRobustCommand{\reviewstrike}[1]{#1}
%%%% for ulem.sty:
\DeclareRobustCommand{\reviewinsert}[1]{\uuline{#1}}
\DeclareRobustCommand{\reviewstrike}[1]{\sout{#1}}
%%
%%%% for jumoline.sty:
%%\DeclareRobustCommand{\reviewstrike}[1]{\Middleline{#1}}

Expand Down
11 changes: 4 additions & 7 deletions templates/latex/review-jsbook/review-base.sty
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\ProvidesClass{review-base}[2020/08/16]
\ProvidesClass{review-base}[2020/12/31]
\RequirePackage{ifthen}
\@ifundefined{Hy@Info}{% for jsbook.cls
\RequirePackage[dvipdfmx,bookmarks=true,bookmarksnumbered=true]{hyperref}
Expand Down Expand Up @@ -268,6 +268,7 @@
\def\reviewballoon#1{#1}
\def\reviewbou#1{#1}
\def\reviewkw#1{#1}
\def\reviewinsert#1{#1}
\def\reviewstrike#1{#1}
\def\reviewunderline#1{#1}
}
Expand Down Expand Up @@ -322,14 +323,10 @@

\DeclareRobustCommand{\reviewbou}[1]{\kenten{#1}}

%% @<del> is ignored in LaTeX with default style
\DeclareRobustCommand{\reviewstrike}[1]{#1}

\DeclareRobustCommand{\reviewinsert}[1]{\Underline{#1}}
\DeclareRobustCommand{\reviewstrike}[1]{\Midline{#1}}
%%%% for ulem.sty:
%%\renewcommand{\reviewstrike}[1]{\sout{#1}}
%%
%%%% for jumoline.sty:
%%\renewcommand{\reviewstrike}[1]{\Middleline{#1}}

\newcommand{\reviewth}[1]{\textgt{#1}}
\newcommand{\reviewtitlefont}[0]{\usefont{T1}{phv}{b}{n}\gtfamily}
Expand Down
10 changes: 10 additions & 0 deletions test/test_latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ def test_inline_u
assert_equal 'abc\\reviewunderline{def}ghi', actual
end

def test_inline_ins
actual = compile_inline('abc@<ins>{def}ghi')
assert_equal 'abc\\reviewinsert{def}ghi', actual
end

def test_inline_del
actual = compile_inline('abc@<del>{def}ghi')
assert_equal 'abc\\reviewstrike{def}ghi', actual
end

def test_inline_bou
actual = compile_inline('傍点の@<bou>{テスト}です。')
assert_equal '傍点の\\reviewbou{テスト}です。', actual
Expand Down
23 changes: 5 additions & 18 deletions test/test_plaintextbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,18 @@ def test_inline_br
assert_equal "\n", actual
end

def test_inline_i
actual = compile_inline('test @<i>{inline test} test2')
assert_equal 'test inline test test2', actual
def test_inline_asis
%w(i b tti ttb bou ami u strong em code ins del tcy).each do |tag|
actual = compile_inline("test @<#{tag}>{inline test} test2")
assert_equal 'test inline test test2', actual
end
end

def test_inline_i_and_escape
actual = compile_inline('test @<i>{inline<&;\\ test} test2')
assert_equal 'test inline<&;\\ test test2', actual
end

def test_inline_b
actual = compile_inline('test @<b>{inline test} test2')
assert_equal 'test inline test test2', actual
end

def test_inline_b_and_escape
actual = compile_inline('test @<b>{inline<&;\\ test} test2')
assert_equal 'test inline<&;\\ test test2', actual
Expand All @@ -115,16 +112,6 @@ def test_inline_tt
assert_equal 'test inline test test2}', actual
end

def test_inline_tti
actual = compile_inline('test @<tti>{inline test} test2')
assert_equal 'test inline test test2', actual
end

def test_inline_ttb
actual = compile_inline('test @<ttb>{inline test} test2')
assert_equal 'test inline test test2', actual
end

def test_inline_uchar
actual = compile_inline('test @<uchar>{2460} test2')
assert_equal 'test ① test2', actual
Expand Down
5 changes: 5 additions & 0 deletions test/test_topbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def test_inline_ttb
assert_equal 'test ★inline test☆◆→等幅フォント太字←◆ test2', actual
end

def test_inline_tcy
actual = compile_inline('test @<tcy>{A} test2')
assert_equal 'test ◆→開始:回転←◆A◆→終了:縦回転←◆ test2', actual
end

def test_inline_uchar
actual = compile_inline('test @<uchar>{2460} test2')
assert_equal 'test ① test2', actual
Expand Down

0 comments on commit 7891aeb

Please sign in to comment.