Skip to content

Commit

Permalink
Merge pull request #1562 from kmuto/deminicolumn
Browse files Browse the repository at this point in the history
add defminicolumn
  • Loading branch information
takahashim authored Aug 29, 2020
2 parents aefdcfa + 121c66e commit 3deb234
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/review/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module ReVIEW
class Builder
include TextUtils

CAPTION_TITLES = %w[note memo tip info warning important caution notice].freeze
CAPTION_TITLES = Compiler.minicolumn_names

def pre_paragraph
nil
Expand Down
39 changes: 29 additions & 10 deletions lib/review/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ def min_argc
end
end

def minicolumn?
@type == :minicolumn
end

def block_required?
@type == :block
@type == :block or @type == :minicolumn
end

def block_allowed?
@type == :block or @type == :optional
@type == :block or @type == :optional or @type == :minicolumn
end
end

Expand All @@ -88,6 +92,10 @@ def self.defblock(name, argc, optional = false, &block)
defsyntax(name, (optional ? :optional : :block), argc, &block)
end

def self.defminicolumn(name, argc, _optional = false, &block)
defsyntax(name, :minicolumn, argc, &block)
end

def self.defsingle(name, argc, &block)
defsyntax(name, :line, argc, &block)
end
Expand All @@ -100,6 +108,16 @@ def self.definline(name)
INLINE[name] = InlineSyntaxElement.new(name)
end

def self.minicolumn_names
buf = []
SYNTAX.each do |name, syntax|
if syntax.minicolumn?
buf << name.to_s
end
end
buf
end

def syntax_defined?(name)
SYNTAX.key?(name.to_sym)
end
Expand Down Expand Up @@ -148,18 +166,19 @@ def inline_defined?(name)
defblock :bpo, 0
defblock :flushright, 0
defblock :centering, 0
defblock :note, 0..1
defblock :memo, 0..1
defblock :info, 0..1
defblock :important, 0..1
defblock :caution, 0..1
defblock :notice, 0..1
defblock :warning, 0..1
defblock :tip, 0..1
defblock :box, 0..1
defblock :comment, 0..1, true
defblock :embed, 0..1

defminicolumn :note, 0..1
defminicolumn :memo, 0..1
defminicolumn :tip, 0..1
defminicolumn :info, 0..1
defminicolumn :warning, 0..1
defminicolumn :important, 0..1
defminicolumn :caution, 0..1
defminicolumn :notice, 0..1

defsingle :footnote, 2
defsingle :noindent, 0
defsingle :blankline, 0
Expand Down
10 changes: 0 additions & 10 deletions lib/review/index_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

module ReVIEW
class IndexBuilder < Builder
CAPTION_TITLES = %w[note memo tip info warning important caution notice box].freeze

attr_reader :list_index, :table_index, :equation_index, :footnote_index,
:numberless_image_index, :image_index, :icon_index, :indepimage_index,
:headline_index, :column_index, :bibpaper_index
Expand Down Expand Up @@ -597,14 +595,6 @@ def captionblock(_type, _lines, _caption, _specialstyle = nil)
''
end

CAPTION_TITLES.each do |name|
class_eval %Q(
def #{name}(lines, caption = nil)
captionblock("#{name}", lines, caption)
end
), __FILE__, __LINE__ - 4
end

def tsize(_str)
''
end
Expand Down

0 comments on commit 3deb234

Please sign in to comment.