-
Notifications
You must be signed in to change notification settings - Fork 3
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
parser development, added support for multiple elements #106
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #106 +/- ##
==========================================
+ Coverage 96.67% 98.34% +1.66%
==========================================
Files 42 46 +4
Lines 1054 1327 +273
==========================================
+ Hits 1019 1305 +286
+ Misses 35 22 -13 ☔ View full report in Codecov by Sentry. |
module Asciidoc | ||
module Admonition | ||
def admonition_type | ||
str('NOTE') | str('TIP') | str('EDITOR') | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we want to allow defining "profiles" or "dialects" because Metanorma uses a special set that is not supported by the base language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be cleanly overriden by subclassing and:
def admonition_type
super | str("SOMETHING") | str("SOMETHING2")
end
).as(:positional) | ||
end | ||
|
||
def attribute_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks arbitrarily limiting. Worse to worse please split those cases into separate methods with documentation.
(ulist_item >> newline.maybe).repeat(1) | ||
end | ||
|
||
def definition_list(delimiter = "::") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI the delimiter can be any number of colon signs.
@line_break = options.fetch(:line_break, "\n") | ||
end | ||
|
||
def to_adoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use multiline string.
adoc = "#{@first_name}" | ||
adoc << " #{@middle_name}" if @middle_name | ||
adoc << " #{@last_name.to_s}" | ||
adoc << " <#{@email}>\n" if @email |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use multiline string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would make the code much more unreadable; this code returns a single line.
to_hash.each do |key, value| | ||
adoc << ":#{key}: #{value}\n" | ||
end | ||
adoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just:
to_hash.map do |key, value|
":#{key}: #{value}"
end.join("\n")
metanorma#15 done metanorma#16 added cross_references parser + transformer metanorma#25 done metanorma#31 missing parser code for parsing inline ellements in text metanorma#36 created parser for attribute list for further use metanorma#37 done parser for definition lists - moved some code from lib/coradoc/parser/asciidoc/content.rb info appropriate files like block.rb, list.rb, paragraph.rb, table.rb - created parser rules for comments, include + Coradoc::Element classes - created parser rules for attribute list, comments, admonition - created rspec for attribute list - created parser rules for definition list, with the goal of it replacing glossaries rules - created parser rules for bold / highlight / italic, cross_reference - created transformer rules for attribute list, comments, include, text elements, inlines - fixed some things required for round-trip, for example to_adoc method in Coradoc::Element::TextElement now outputs all the information - created parslet rule called "text_formatted", it's purpose will be to handle parsing inline elements within the text, that's still WIP - fixed some minor bugs that popped out during development of other things, for example olist_item parsing collided with sidebar block delimiter (****) - changed maybe to repeat(0) in multiple methods in Parser::Asciidoc::Section, this way instead of sometimes returning an empty string they always return an array even if it has 0 elements, this should allow to decrease number of transformer rules Co-authored-by: hmdne <[email protected]>
fixed failed rake in ruby 3.4
This corrects metanorma#106
This corrects metanorma#106 Co-authored-by: xyz65535 <[email protected]>
This corrects #106 Co-authored-by: xyz65535 <[email protected]>
Details:
lib/coradoc/parser/asciidoc/content.rb
info appropriate files likeblock.rb
,list.rb
,paragraph.rb
,table.rb
Coradoc::Element
classesto_adoc
method inCoradoc::Element::TextElement
now outputs all the informationtext_formatted
, it's purpose will be to handle parsing inline elements within the text, that's still WIPolist_item
parsing collided with sidebar block delimiter (****
)repeat(0)
in multiple methods inParser::Asciidoc::Section
, this way instead of sometimes returning an empty string they always return an array even if it has 0 elements, this should allow to decrease number of transformer rulesMetanorma PR checklist