diff --git a/lib/bitclust/rdcompiler.rb b/lib/bitclust/rdcompiler.rb
index aecc1a0..eba7182 100644
--- a/lib/bitclust/rdcompiler.rb
+++ b/lib/bitclust/rdcompiler.rb
@@ -451,21 +451,31 @@ def method_signature(sig_line, first)
end
BracketLink = /\[\[[\w-]+?:[!-~]+?(?:\[\] )?\]\]/n
+ # BitClust には ISO/JIS へのリンク機能がないため、[[ISO:8601]]/[[JIS:X 0301]] は
+ # リンクにせず平文で表示する (rurema/bitclust#236)。引数に空白を含む JIS も拾う。
+ StandardRef = /\[\[(?:ISO|JIS):[!-~][!-~ ]*?\]\]/n
NeedESC = /[&"<>]/
def compile_text(str)
escape_table = HTMLUtils::ESC
- str.gsub(/(#{NeedESC})|(#{BracketLink})/o) {
+ str.gsub(/(#{NeedESC})|(#{StandardRef})|(#{BracketLink})/o) {
# @type var char: '&' | '"' | '<' | '>'
if char = _ = $1 then escape_table[char]
- elsif tok = $2 then bracket_link(tok[2..-3] || raise)
- elsif tok = $3 then seems_code(tok)
+ elsif tok = $2 then standard_ref(tok[2..-3] || raise)
+ elsif tok = $3 then bracket_link(tok[2..-3] || raise)
else
raise 'must not happen'
end
}
end
+ def standard_ref(link)
+ # 例: "ISO:8601" -> "ISO 8601", "JIS:X 0301" -> "JIS X 0301"
+ type, _arg = link.split(':', 2)
+ arg = _arg&.strip or raise
+ escape_html("#{type} #{arg}")
+ end
+
def bracket_link(link, label = nil, frag = nil)
type, _arg = link.split(':', 2)
arg = _arg&.rstrip or raise
diff --git a/sig/bitclust/rdcompiler.rbs b/sig/bitclust/rdcompiler.rbs
index 5b232a0..406f7c3 100644
--- a/sig/bitclust/rdcompiler.rbs
+++ b/sig/bitclust/rdcompiler.rbs
@@ -118,10 +118,14 @@ module BitClust
BracketLink: ::Regexp
+ StandardRef: ::Regexp
+
NeedESC: ::Regexp
def compile_text: (String str) -> String
+ def standard_ref: (String link) -> String
+
def bracket_link: (String link, ?String? label, ?String? frag) -> String
def protect: (String src) { () -> String } -> String
diff --git a/test/test_rdcompiler.rb b/test/test_rdcompiler.rb
index cc0013a..9a402e6 100644
--- a/test/test_rdcompiler.rb
+++ b/test/test_rdcompiler.rb
@@ -706,6 +706,8 @@ def test_invalid_case
"man header" => ['[[man:sys/socket.h(header)]]', 'sys/socket.h(header)'],
"man system call" => ['[[man:fopen(3linux)]]', 'fopen(3linux)'],
"RFC" => ['[[RFC:2822]]', '[RFC2822]'],
+ "ISO standard" => ['[[ISO:8601]]', 'ISO 8601'],
+ "JIS standard" => ['[[JIS:X 0301]]', 'JIS X 0301'],
"special var $~" => ['[[m:$~]]', '$~'],
"special var $," => ['[[m:$,]]', '$,'],
"extra close bracket" => ['[[c:String]]]', 'String]'],