Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@<balloon>を標準サポートタグとする #829

Merged
merged 6 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/format.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ LaTeXビルダを使用している場合:
* `@<embed>{|ビルダ|〜}` : 生の文字列を埋め込みます。`\}`は`}`に、`\\`は`\`に置き換えられます(`\n`はそのままです)。
* `@<idx>{文字列}` : 文字列を出力するとともに、索引として登録します。索引の使い方については、makeindex.ja.md を参照してください。
* `@<hidx>{文字列}` : 索引として登録します (idx と異なり、紙面内に出力はしません)。`親索引文字列<<>>子索引文字列` のように親子関係にある索引も定義できます。
* `@<balloon>{〜}` : コードブロック (emlist など) 内などでのいわゆる吹き出しを作成します。たとえば「`@<balloon>{ABC}`」とすると、「`←ABC`」となります。デフォルトの挙動および表現は簡素なので、より装飾されたものにするにはスタイルシートを改変するか、`review-ext.rb` を使って挙動を書き換える必要があります。

## 著者用タグ(プリプロセッサ命令)

Expand Down
1 change: 1 addition & 0 deletions doc/format.md
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ this is a special line.
@<embed>{|html|<span>ABC</span>}:: inline raw data inline. `\}` is `}` and `\\` is `\`.
@<idx>{string}:: output a string and register it as an index. See makeindex.md.
@<hidx>{string}:: register a string as an index. A leveled index is expressed like `parent<<>>child`
@<balloon>{abc}:: inline balloon in code block. For example, `@<balloon>{ABC}` produces `←ABC`. This may seem too simple. To decorate it, modify the style sheet file or override a function by `review-ext.rb`
```

## Commands for Authors (pre-processor commands)
Expand Down
4 changes: 0 additions & 4 deletions doc/format_idg.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ Re:VIEW フォーマットから、Adobe 社の DTP ソフトウェア「InDesig

`@<keytop>{キー文字}` でキーボードマークを出力します(実際のフォントとの割り当て処理はフィルタや review-ext.rb で調整します)。

## 吹き出し

`@<balloon>{〜}` でコード内などでの吹き出しを作成します。通常、吹き出しは右に寄せられ、記入した箇所から吹き出しまで線が引かれます。

## DTP 命令指定

`@<dtp>{ 〜 }` で「`<? dtp 〜 ?>`」という XML インストラクションを埋め込みます。処理系に渡す任意の文字列を指定できますが、次のような文字列を特殊文字指定できます。
Expand Down
7 changes: 7 additions & 0 deletions doc/sample.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ span.kw {
font-weight: bold;
}

span.balloon {
font-size: 0.9em;
}
span.balloon:before {
content: "←";
}

div.column {
padding: 0.5em;
background: #ffd0d0;
Expand Down
4 changes: 4 additions & 0 deletions lib/review/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ def inline_tcy(arg)
"#{arg}[rotate 90 degree]"
end

def inline_balloon(arg)
"← #{arg}"
end

def inline_w(s)
translated = @dictionary[s]
if translated
Expand Down
2 changes: 1 addition & 1 deletion lib/review/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def inline_defined?(name)
definline :recipe
definline :column
definline :tcy
definline :balloon

definline :abbr
definline :acronym
Expand Down Expand Up @@ -228,7 +229,6 @@ def inline_defined?(name)
definline :hidx
definline :comment
definline :include
definline :tcy
definline :embed
definline :pageref
definline :w
Expand Down
4 changes: 4 additions & 0 deletions lib/review/htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,10 @@ def inline_tcy(str)
%Q(<span class="#{style}">#{escape(str)}</span>)
end

def inline_balloon(str)
%Q(<span class="balloon">#{escape_html(str)}</span>)
end

def inline_raw(str)
super(str)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/review/idgxmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class IDGXMLBuilder < Builder
include TextUtils
include HTMLUtils

%i[ttbold hint maru keytop labelref ref balloon].each { |e| Compiler.definline(e) }
%i[ttbold hint maru keytop labelref ref].each { |e| Compiler.definline(e) }
Compiler.defsingle(:dtp, 1)

Compiler.defblock(:insn, 0..1)
Expand Down
4 changes: 4 additions & 0 deletions lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,10 @@ def inline_tcy(str)
macro('rensuji', escape(str))
end

def inline_balloon(str)
macro('reviewballoon', escape(str))
end

def bibpaper_header(id, caption)
puts "[#{@chapter.bibpaper(id).number}] #{compile_inline(caption)}"
puts macro('label', bib_label(id))
Expand Down
1 change: 1 addition & 0 deletions templates/latex-compat2/layout.tex.erb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
\newcommand{\reviewami}[1]{\mask{#1}{A}}
\newcommand{\reviewem}[1]{\textbf{#1}}
\newcommand{\reviewstrong}[1]{\textbf{#1}}
\newcommand{\reviewballoon}[1]{←{#1}}
\newcommand{\reviewunderline}{\Underline}

%% @<del> is ignored in LaTeX with default style
Expand Down
1 change: 1 addition & 0 deletions templates/latex/review-jsbook/review-basemacros.sty
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
\newcommand{\reviewami}[1]{\mask{#1}{A}}
\newcommand{\reviewem}[1]{\textbf{#1}}
\newcommand{\reviewstrong}[1]{\textbf{#1}}
\newcommand{\reviewballoon}[1]{←{#1}}
\newcommand{\reviewunderline}[1]{\Underline{#1}}
\newcommand{\reviewit}[1]{\textit{#1}}
\newcommand{\reviewbold}[1]{\textbf{#1}}
Expand Down
6 changes: 6 additions & 0 deletions test/sample-book/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ strong{
em {
font-style: italic;
}
span.balloon {
font-size: 0.9em;
}
span.balloon:before {
content: "←";
}

/**
* from Rouge
Expand Down
5 changes: 5 additions & 0 deletions test/test_htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ def test_inline_uchar
assert_equal 'test &#x2460; test2', actual
end

def test_inline_balloon
actual = compile_inline('test @<balloon>{①}')
assert_equal %Q(test <span class="balloon">①</span>), actual
end

def test_inline_ruby
actual = compile_inline('@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。')
assert_equal '<ruby>粗雑<rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby>繊細<rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。', actual
Expand Down
5 changes: 5 additions & 0 deletions test/test_latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ def test_inline_uchar
assert_equal 'test \\UTF{2460} test2', actual
end

def test_inline_balloon
actual = compile_inline('test @<balloon>{①}')
assert_equal 'test \\reviewballoon{①}', actual
end

def test_inline_idx
actual = compile_inline('@<idx>{__TEST%$}, @<hidx>{__TEST%$}')
assert_equal '\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}, \\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}', actual
Expand Down