Skip to content

Commit

Permalink
Stylistic fixes
Browse files Browse the repository at this point in the history
This corrects metanorma#106
  • Loading branch information
hmdne committed Jul 1, 2024
1 parent d365dd0 commit 8c5a87b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
8 changes: 5 additions & 3 deletions lib/coradoc/element/comment_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ def initialize(text, options = {})
end

def to_adoc
"////\n" +
"#{@text}\n" +
"////#{@line_break}"
<<~ADOC.chomp
////
#{@text}
////#{@line_break}
ADOC
end
end
end
Expand Down
8 changes: 3 additions & 5 deletions lib/coradoc/element/document_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ def to_hash
end

def to_adoc
adoc = ""
to_hash.each do |key, value|
adoc << ":#{key}: #{value}\n"
end
adoc
to_hash.map do |key, value|
":#{key}: #{value}\n"
end.join("\n") + "\n"
end
end
end
Expand Down
43 changes: 31 additions & 12 deletions lib/coradoc/parser/asciidoc/attribute_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,39 @@ def positional_attribute
).as(:positional)
end

def named_many
(named_attribute.repeat(1,1) >>
(str(",") >> named_attribute).repeat(0))
end

def positional_one_named_many
(positional_attribute.repeat(1,1) >>
(str(",") >> named_attribute).repeat(1))
end

def positional_many_named_many
(positional_attribute.repeat(1,1) >>
(str(",") >> positional_attribute).repeat(1) >>
(str(",") >> named_attribute).repeat(1))
end

def positional_many
(positional_attribute.repeat(1,1) >>
(str(",") >> positional_attribute).repeat(0))
end

def positional_zero_or_one
positional_attribute.repeat(0,1)
end

def attribute_list
str("[") >>
(
(named_attribute.repeat(1,1) >>
(str(",") >> named_attribute).repeat(0)) |
(positional_attribute.repeat(1,1) >>
(str(",") >> named_attribute).repeat(1)) |
(positional_attribute.repeat(1,1) >>
(str(",") >> positional_attribute).repeat(1) >>
(str(",") >> named_attribute).repeat(1)) |
(positional_attribute.repeat(1,1) >>
(str(",") >> positional_attribute).repeat(0)) |
positional_attribute.repeat(0,1)
).as(:attribute_array).as(:attribute_list) >>
( named_many |
positional_one_named_many |
positional_many_named_many |
positional_many |
positional_zero_or_one
).as(:attribute_array).as(:attribute_list) >>
str("]")
end

Expand Down

0 comments on commit 8c5a87b

Please sign in to comment.