Module: Metanorma::Plugin::Glossarist::Sanitize
- Defined in:
- lib/metanorma/plugin/glossarist/sanitize.rb
Constant Summary collapse
- REF_REGEX =
/{{([^,{}]+),([^}]+?)}}(.*)$/s- XREF_REGEX =
/<<((?>[^,>\n]+))(?:,[^>\n]*)?>>/
Class Method Summary collapse
Class Method Details
.extract_xrefs(text) ⇒ Object
18 19 20 21 22 |
# File 'lib/metanorma/plugin/glossarist/sanitize.rb', line 18 def self.extract_xrefs(text) return [] unless text text.scan(XREF_REGEX).map(&:first).uniq end |
.references(str) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/metanorma/plugin/glossarist/sanitize.rb', line 10 def self.references(str) return str unless str&.match?(REF_REGEX) match = str.match(REF_REGEX) urn = Metanorma::Utils.to_ncname(match[1]).gsub(":", "_") "{{#{urn},#{match[2]}}}#{match[3]}" end |