Skip to content

Commit

Permalink
Merge branch 'childv2' of github.com:kmuto/review into childv2
Browse files Browse the repository at this point in the history
  • Loading branch information
takahashim committed Sep 27, 2020
2 parents 3a5afb4 + 0fce860 commit 02c9a74
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
14 changes: 8 additions & 6 deletions doc/format.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -932,23 +932,24 @@ Re:VIEW の箇条書きは `*` 型の箇条書きを除き、基本的に入れ

この対策として、Re:VIEW 4.2 では試験的に `//beginchild``//endchild` というブロック命令を追加しています。箇条書きの途中に何かを含めたいときには、それを `//beginchild``//endchild` で囲んで配置します。多重に入れ子にすることも可能です。

`//beginchild``//endchild` は任意の引数を1つ取ることができ、挙動には影響しませんが人間に向けたコメントを入れるのに利用できます。

```
* UL1
//beginchild[ここからUL1の子]
//beginchild
#@# ここからUL1の子
1. UL1-OL1
//beginchild[ここからUL1-OL1の子]
//beginchild
#@# ここからUL1-OL1の子
UL1-OL1-PARAGRAPH
* UL1-OL1-UL1
* UL1-OL1-UL2
//endchild[ここまでUL1-OL1の子]
//endchild
#@# ここまでUL1-OL1の子
2. UL1-OL2
Expand All @@ -957,7 +958,8 @@ UL1-OL1-PARAGRAPH
: UL1-DL2
UL1-DD2
//endchild[ここまでUL1の子]
//endchild
#@# ここまでUL1の子
* UL2
```
Expand Down
14 changes: 8 additions & 6 deletions doc/format.md
Original file line number Diff line number Diff line change
Expand Up @@ -972,23 +972,24 @@ Re:VIEW itemize blocks basically cannot express nested items. Also, none of item

As a workaround, Re:VIEW 4.2 provides an experimental `//beginchild` and `//endchild`. If you want to include something in an itemize block, enclose it with `//beginchild` and `//endchild`. It is also possible to create a multiple nest.

`//beginchild` and `//endchild` cant take one argument and can be used to write a comment.

```
* UL1
//beginchild[child of UL1 start]
//beginchild
#@# child of UL1 start
1. UL1-OL1
//beginchild[child of UL1-OL1 start]
//beginchild
#@# child of UL1-OL1 start
UL1-OL1-PARAGRAPH
* UL1-OL1-UL1
* UL1-OL1-UL2
//endchild[child of UL1-OL1 end]
//endchild
#@# child of UL1-OL1 end
2. UL1-OL2
Expand All @@ -997,7 +998,8 @@ UL1-OL1-PARAGRAPH
: UL1-DL2
UL1-DD2
//endchild[child of UL1 end]
//endchild
#@# child of UL1 end
* UL2
```
Expand Down
4 changes: 2 additions & 2 deletions lib/review/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ def escape(str)
str
end

def beginchild(_comment = nil)
def beginchild
@children ||= []
unless @previous_list_type
error "//beginchild is shown, but previous element isn't ul, ol, or dl"
Expand All @@ -734,7 +734,7 @@ def beginchild(_comment = nil)
@children.push(@previous_list_type)
end

def endchild(_comment = nil)
def endchild
if @children.nil? || @children.empty?
error "//endchild is shown, but any opened //beginchild doesn't exist"
else
Expand Down
7 changes: 3 additions & 4 deletions lib/review/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def initialize(builder)
@command_name_stack = []
end

attr_reader :previous_list_type
attr_reader :builder
attr_reader :builder, :previous_list_type

def strategy
error 'Compiler#strategy is obsoleted. Use Compiler#builder.'
Expand Down Expand Up @@ -192,8 +191,8 @@ def inline_defined?(name)
defsingle :include, 1
defsingle :olnum, 1
defsingle :firstlinenum, 1
defsingle :beginchild, 0..1
defsingle :endchild, 0..1
defsingle :beginchild, 0
defsingle :endchild, 0

definline :chapref
definline :chap
Expand Down

0 comments on commit 02c9a74

Please sign in to comment.