77PN = "create_normative_rules.rb"
88
99# Global constants
10- LT_UNICODE_DECIMAL = 60 # "<" Unicode devimal value
10+ LT_UNICODE_DECIMAL = 60 # "<" Unicode decimal value
1111GT_UNICODE_DECIMAL = 62 # ">"" Unicode decimal value
1212
1313LT_UNICODE_STR = "&##{ LT_UNICODE_DECIMAL } ;" # "<" Unicode string
@@ -589,12 +589,12 @@ def convert_extra_amp(text)
589589 "&" + $1 + ";"
590590 end
591591
592- # Sometimes the tags backend converts "≠" to "&#8800;". Convert it to "≠".
592+ # Sometimes the tags backend converts "≠" to "&#8800;". Convert it to "≠ ".
593593 text = text . gsub ( /&#([0-9]+);/ ) do
594594 "&#" + $1 + ";"
595595 end
596596
597- # And now handle the the hexadecimal variant.
597+ # And now handle the hexadecimal variant.
598598 text . gsub ( /&#x([0-9a-fA-F]+);/ ) do
599599 "&#x" + $1 + ";"
600600 end
@@ -1069,16 +1069,16 @@ def html_chapter_table(f, table_num, chapter_name, nr_defs, tags, tag_fname2url)
10691069 # will return multiple <<link>> in the same text as one.
10701070 tag_text . gsub! ( /#{ LT_UNICODE_STR } #{ LT_UNICODE_STR } (.+?)#{ GT_UNICODE_STR } #{ GT_UNICODE_STR } / ) do
10711071 # Look to see if custom text has been provided.
1072- split_texts = $1. split ( "," )
1072+ split_texts = $1. split ( "," ) . map ( & :strip )
10731073
10741074 if split_texts . length == 0
1075- fail ( "Hyperlink '$1 ' is empty" )
1075+ fail ( "Hyperlink '#{ $1 } ' is empty" )
10761076 elsif split_texts . length == 1
10771077 tag2html_link ( split_texts [ 0 ] , split_texts [ 0 ] , html_fname )
10781078 elsif split_texts . length == 2
10791079 tag2html_link ( split_texts [ 0 ] , split_texts [ 1 ] , html_fname )
10801080 else
1081- fail ( "Hyperlink '$1 ' contains too many commas" )
1081+ fail ( "Hyperlink '#{ $1 } ' contains too many commas" )
10821082 end
10831083 end
10841084
@@ -1098,9 +1098,9 @@ def html_chapter_table(f, table_num, chapter_name, nr_defs, tags, tag_fname2url)
10981098end
10991099
11001100def tag2html_link ( tag_ref , link_text , html_fname )
1101- fatal ( "Expected String for tag_ref but was passed a #{ tag_ref } .class" ) unless tag_ref . is_a? ( String )
1102- fatal ( "Expected String for link_text but was passed a #{ link_text } .class" ) unless link_text . is_a? ( String )
1103- fatal ( "Expected String for html_fname but was passed a #{ html_fname } .class" ) unless html_fname . is_a? ( String )
1101+ fatal ( "Expected String for tag_ref but was passed a #{ tag_ref . class } " ) unless tag_ref . is_a? ( String )
1102+ fatal ( "Expected String for link_text but was passed a #{ link_text . class } " ) unless link_text . is_a? ( String )
1103+ fatal ( "Expected String for html_fname but was passed a #{ html_fname . class } " ) unless html_fname . is_a? ( String )
11041104
11051105 return %Q{<a href="#{ html_fname } ##{ tag_ref } ">#{ link_text } </a>}
11061106end
@@ -1147,25 +1147,23 @@ def html_script(f)
11471147# Without heading:
11481148#
11491149# ===
1150- # | ABC | DEF
1151- # | GHI |JKL
1150+ # ABC | DEF
1151+ # GHI |JKL
11521152# ===
11531153#
1154- # Actual string from tags: "===\n| ABC | DEF\n|GHI |JKL\n==="
1154+ # Actual string from tags: "===\nABC | DEF\nGHI |JKL\n==="
11551155#
11561156# With heading:
11571157#
1158- # | H1 | H2
1158+ # H1 | H2
11591159# ===
1160- # | GHI | JKL
1160+ # GHI | JKL
11611161# ===
11621162#
1163- # Actual string from tags: "| H1 | H2\n===\n| GHI | JKL\n==="
1163+ # Actual string from tags: "H1 | H2\n===\nGHI | JKL\n==="
11641164
11651165def convert_tags_tables_to_html ( text )
1166- raise ArgumentError , "Expected String for text but was passed a #{ text } .class" unless text . is_a? ( String )
1167-
1168- ret = text # Default to input
1166+ raise ArgumentError , "Expected String for text but was passed a #{ text . class } " unless text . is_a? ( String )
11691167
11701168 text . gsub ( /(.*?)===\n (.+)\n ===/m ) do
11711169 # Found a "tags" formatted table
@@ -1203,18 +1201,17 @@ def convert_tags_tables_to_html(text)
12031201 ret << "</tbody>"
12041202 ret << "</table>" # End html table
12051203 end
1206-
1207- return ret
12081204end
12091205
12101206# Return array of table columns from one row/header of a table.
12111207# Returns empty array if row is nil or the empty string.
12121208def extract_tags_table_cells ( row )
1213- raise ArgumentError , "Expected String for row but was passed a #{ row } .class" unless row . is_a? ( String )
1209+ raise ArgumentError , "Expected String for row but was passed a #{ row . class } " unless row . is_a? ( String )
12141210
12151211 return [ ] if row . nil? || row . empty?
12161212
1217- # Split row fields with pipe symbol.
1213+ # Split row fields with pipe symbol. The -1 passed to split ensures trailing null fields are not suppressed.
1214+ #
12181215 # Examples:
12191216 # "H1 | H2" => ["H1", "H2"]
12201217 # "|" => ["", ""]
@@ -1225,7 +1222,7 @@ def extract_tags_table_cells(row)
12251222
12261223# Cleanup the tag text to be suitably displayed.
12271224def limit_table_rows ( text )
1228- raise ArgumentError , "Expected String for text but was passed a #{ text } .class" unless text . is_a? ( String )
1225+ raise ArgumentError , "Expected String for text but was passed a #{ text . class } " unless text . is_a? ( String )
12291226
12301227 # This is the detection pattern for an entire table being tagged from the "tags.rb" AsciiDoctor backend.
12311228 if text . end_with? ( "\n ===" )
@@ -1266,7 +1263,7 @@ def count_parameters(defs)
12661263
12671264# Convert newlines to <br>.
12681265def convert_newlines_to_html ( text )
1269- raise ArgumentError , "Expected String for text but was passed a #{ text } .class" unless text . is_a? ( String )
1266+ raise ArgumentError , "Expected String for text but was passed a #{ text . class } " unless text . is_a? ( String )
12701267
12711268 text . gsub ( /\n / , '<br>' )
12721269end
0 commit comments