-
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
allow recursive container prefixes for cross-references: https://gith… #548
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
40e55d3
allow recursive container prefixes for cross-references: https://gith…
opoudjis 31f1e4a
more robust sorting of headings for ToC: https://github.com/metanorma…
opoudjis ae237b6
autonumber back matter assets: https://github.com/metanorma/metanorma…
opoudjis 299ab8e
allow recursive container prefixes for cross-references: https://gith…
opoudjis 41721bd
more robust sorting of headings for ToC: https://github.com/metanorma…
opoudjis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,24 +24,25 @@ def subfigure_increment(idx, counter, elem) | |
.//figure[not(@class)] | .//figure[@class = 'pseudocode'] | .//sourcecode[not(ancestor::example)] | ||
XPATH | ||
|
||
def sequential_figure_names(clause) | ||
def sequential_figure_names(clause, container: false) | ||
c = Counter.new | ||
j = 0 | ||
clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t| | ||
j = subfigure_increment(j, c, t) | ||
sequential_figure_body(j, c, t, "figure") | ||
sequential_figure_body(j, c, t, "figure", container: container) | ||
end | ||
sequential_figure_class_names(clause) | ||
sequential_figure_class_names(clause, container: container) | ||
end | ||
|
||
def sequential_figure_class_names(clause) | ||
def sequential_figure_class_names(clause, container: false) | ||
c = {} | ||
j = 0 | ||
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]")) | ||
.each do |t| | ||
c[t["class"]] ||= Counter.new | ||
j = subfigure_increment(j, c[t["class"]], t) | ||
sequential_figure_body(j, c[t["class"]], t, t["class"]) | ||
sequential_figure_body(j, c[t["class"]], t, t["class"], | ||
container: container) | ||
end | ||
end | ||
|
||
|
@@ -50,27 +51,28 @@ def subfigure_label(subfignum) | |
"-#{subfignum}" | ||
end | ||
|
||
def sequential_figure_body(subfignum, counter, block, klass) | ||
def sequential_figure_body(subfig, counter, elem, klass, container: false) | ||
label = counter.print | ||
label &&= label + subfigure_label(subfignum) | ||
@anchors[block["id"]] = anchor_struct( | ||
label, nil, @labels[klass] || klass.capitalize, klass, | ||
block["unnumbered"] | ||
label &&= label + subfigure_label(subfig) | ||
@anchors[elem["id"]] = anchor_struct( | ||
label, container ? elem : nil, | ||
@labels[klass] || klass.capitalize, klass, | ||
elem["unnumbered"] | ||
) | ||
end | ||
|
||
def sequential_table_names(clause) | ||
def sequential_table_names(clause, container: false) | ||
c = Counter.new | ||
clause.xpath(ns(".//table")).noblank.each do |t| | ||
labelled_ancestor(t) and next | ||
@anchors[t["id"]] = anchor_struct( | ||
c.increment(t).print, nil, | ||
c.increment(t).print, container ? t : nil, | ||
@labels["table"], "table", t["unnumbered"] | ||
) | ||
end | ||
end | ||
|
||
def sequential_formula_names(clause) | ||
def sequential_formula_names(clause, container: false) | ||
c = Counter.new | ||
clause.xpath(ns(".//formula")).noblank.each do |t| | ||
@anchors[t["id"]] = anchor_struct( | ||
|
@@ -91,60 +93,63 @@ def sequential_formula_names(clause) | |
./permission | ./requirement | ./recommendation | ||
XPATH | ||
|
||
def sequential_permission_names(clause) | ||
def sequential_permission_names(clause, container: false) | ||
c = ReqCounter.new | ||
clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t| | ||
m = @reqt_models.model(t["model"]) | ||
klass, label = reqt2class_label(t, m) | ||
id = c.increment(label, t).print | ||
sequential_permission_body(id, t, label, klass, m) | ||
sequential_permission_children(t, id) | ||
sequential_permission_body(id, t, label, klass, m, | ||
container: container) | ||
sequential_permission_children(t, id, container: container) | ||
end | ||
end | ||
|
||
def sequential_permission_children(block, lbl) | ||
def sequential_permission_children(elem, lbl, container: false) | ||
c = ReqCounter.new | ||
block.xpath(ns(REQ_CHILDREN)).noblank.each do |t| | ||
elem.xpath(ns(REQ_CHILDREN)).noblank.each do |t| | ||
m = @reqt_models.model(t["model"]) | ||
klass, label = reqt2class_nested_label(t, m) | ||
id = "#{lbl}#{hierfigsep}#{c.increment(label, t).print}" | ||
sequential_permission_body(id, t, label, klass, m) | ||
sequential_permission_children(t, id) | ||
sequential_permission_body(id, t, label, klass, m, | ||
container: container) | ||
sequential_permission_children(t, id, container: container) | ||
end | ||
end | ||
|
||
def sequential_permission_body(id, block, label, klass, model) | ||
@anchors[block["id"]] = model.postprocess_anchor_struct( | ||
block, anchor_struct(id, block, | ||
label, klass, block["unnumbered"]) | ||
def sequential_permission_body(id, elem, label, klass, model, container: false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid parameter lists longer than 5 parameters. [6/5] |
||
@anchors[elem["id"]] = model.postprocess_anchor_struct( | ||
elem, anchor_struct(id, elem, | ||
label, klass, elem["unnumbered"]) | ||
) | ||
model.permission_parts(block, id, label, klass).each do |n| | ||
model.permission_parts(elem, id, label, klass).each do |n| | ||
@anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label], | ||
n[:klass], false) | ||
end | ||
end | ||
|
||
def reqt2class_label(block, model) | ||
def reqt2class_label(elem, model) | ||
model.req_class_paths.each do |n| | ||
v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "") | ||
block.at("./self::#{v1}") and return [n[:klass], n[:label]] | ||
elem.at("./self::#{v1}") and return [n[:klass], n[:label]] | ||
end | ||
[nil, nil] | ||
end | ||
|
||
def reqt2class_nested_label(block, model) | ||
def reqt2class_nested_label(elem, model) | ||
model.req_nested_class_paths.each do |n| | ||
v1 = ns("/#{n[:xpath]}").sub(%r{^/}, "") | ||
block.at("./self::#{v1}") and return [n[:klass], n[:label]] | ||
elem.at("./self::#{v1}") and return [n[:klass], n[:label]] | ||
end | ||
[nil, nil] | ||
end | ||
|
||
def sequential_asset_names(clause) | ||
sequential_table_names(clause) | ||
sequential_figure_names(clause) | ||
sequential_formula_names(clause) | ||
sequential_permission_names(clause) | ||
# container makes numbering be prefixed with the parent clause reference | ||
def sequential_asset_names(clause, container: false) | ||
sequential_table_names(clause, container: container) | ||
sequential_figure_names(clause, container: container) | ||
sequential_formula_names(clause, container: container) | ||
sequential_permission_names(clause, container: container) | ||
end | ||
|
||
def hierarchical_figure_names(clause, num) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unused method argument - container.