# Copyright (c) 2020 Jerome Arbez-Gindre # frozen_string_literal: true module DefMastership # set of regexp of added asciidoctor constructions module DMRegexp SINGLE_LINE_COMMENT = %r{^//[^/]}.freeze MULTI_LINE_COMMENT_DELIM = %r{^////\s*$}.freeze DEF_BEFORE_REF = <<~'BEF' ^\s* \[\s*define\s*, \s*(?[\w:_-]+)\s*, \s* BEF DEF_AFTER_REF = <<~'AFT' \s* (,\s*\[\s*(?.*?)\s*\])?\s*\] AFT DEFINITION = Regexp.new( "#{DEF_BEFORE_REF}(?[\\w:_-]+)#{DEF_AFTER_REF}", Regexp::EXTENDED ) VARIABLE_DEF = /^\s*:(?[\w:_-]+):\s* \s*(?\S.*\S)\s*$/x.freeze VARIABLE_USE = /{(?[\w:_-]+)}/x.freeze EREF_CONFIG = /^\s*:eref-(?[\w:_-]+)-(?prefix|url):\s* \s*(?\S.*\S)\s*/x.freeze EREF_DEF = /^\s* defs:eref\[ \s*(?[\w:_-]+)\s*, \s*\[(?[^\]]+)\]\s*\]/x.freeze BLOCK = /^--\s*$/.freeze LITERAL_BLOCK = /^\.\.\.\.\s*$/.freeze IREF_DEF_BEF = 'defs:iref\[\s*' IREF_DEF_AFT = '\s*\]' IREF_DEF = Regexp.new( "#{IREF_DEF_BEF}(?[\\w:_-]+)#{IREF_DEF_AFT}", Regexp::EXTENDED ) ATTR_CONFIG = /\s*:attr-(?[\w:_-]+)-prefix: \s+(?.+?)\s*$/x.freeze ATTR_SET = /\s* defs:attribute\[ \s*(?[\w:_-]+)\s*, \s*(?.+?)\s*\]/x.freeze EMPTY_LINE = /^\s*$/.freeze WHATEVER = //.freeze public_constant :SINGLE_LINE_COMMENT, :MULTI_LINE_COMMENT_DELIM, :DEF_BEFORE_REF, :DEF_AFTER_REF, :DEFINITION, :VARIABLE_DEF, :VARIABLE_USE, :EREF_CONFIG, :EREF_DEF, :BLOCK, :LITERAL_BLOCK, :IREF_DEF_BEF, :IREF_DEF_AFT, :IREF_DEF, :ATTR_CONFIG, :ATTR_SET, :EMPTY_LINE, :WHATEVER end end