-
Notifications
You must be signed in to change notification settings - Fork 23
Fix for having two or more links in normative text #137
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1063,12 +1063,22 @@ def html_chapter_table(f, table_num, chapter_name, nr_defs, tags, tag_fname2url) | |||||||||
| # | ||||||||||
| # Can assume that the link is to the same HTML standards document as the | ||||||||||
| # tag text that it is found in because these kind of links only link within their document. | ||||||||||
| tag_text.gsub!(/#{LT_UNICODE_STR}#{LT_UNICODE_STR}([^,]+)#{GT_UNICODE_STR}#{GT_UNICODE_STR}/) do | ||||||||||
| tag2html_link($1, $1, html_fname) | ||||||||||
| end | ||||||||||
|
|
||||||||||
| tag_text.gsub!(/#{LT_UNICODE_STR}#{LT_UNICODE_STR}([^,]+),(.+)#{GT_UNICODE_STR}#{GT_UNICODE_STR}/) do | ||||||||||
| tag2html_link($1, $2, html_fname) | ||||||||||
| # | ||||||||||
| # Note that I'm using the non-greedy regular expression (? after +) otherwise the regular expression | ||||||||||
| # will return multiple <<link>> in the same text as one. | ||||||||||
| tag_text.gsub!(/#{LT_UNICODE_STR}#{LT_UNICODE_STR}(.+?)#{GT_UNICODE_STR}#{GT_UNICODE_STR}/) do | ||||||||||
| # Look to see if custom text has been provided. | ||||||||||
| split_texts = $1.split(",") | ||||||||||
|
|
||||||||||
| if split_texts.length == 0 | ||||||||||
| fail("Hyperlink '$1' is empty") | ||||||||||
|
||||||||||
| fail("Hyperlink '$1' is empty") | |
| fail("Hyperlink '#{$1}' is empty") |
Copilot
AI
Nov 27, 2025
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.
The condition split_texts.length == 0 is impossible to reach. When splitting a non-empty string (captured by .+?), the result will always have at least one element. Consider removing this dead code or replacing it with a more meaningful check.
| if split_texts.length == 0 | |
| fail("Hyperlink '$1' is empty") | |
| elsif split_texts.length == 1 | |
| if split_texts.length == 1 |
Copilot
AI
Nov 27, 2025
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.
The error message uses single quotes, which prevents Ruby from interpolating $1. The message will literally display "$1" instead of the actual hyperlink content. Change to double quotes: "Hyperlink \"#{$1}\" contains too many commas" or use "Hyperlink '#{$1}' contains too many commas" for proper interpolation.
| fail("Hyperlink '$1' contains too many commas") | |
| fail("Hyperlink '#{$1}' contains too many commas") |
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.
Consider trimming whitespace from
split_textselements before passing them totag2html_link. Currently,<<link , custom text>>(with space before comma) would result in "link " being used as the tag reference, which could cause issues. Adding.map(&:strip)after the split would handle this:split_texts = $1.split(",").map(&:strip)