# frozen_string_literal: true module Gitlab module FrontMatter DELIM_LANG = { '---' => 'yaml', '+++' => 'toml', ';;;' => 'json' }.freeze DELIM = Regexp.union(DELIM_LANG.keys) PATTERN = %r{ \A(?[^\r\n]*coding:[^\r\n]*\R)? # optional encoding line (?\s*) ^(?#{DELIM})[ \t]*(?\S*)\R # opening front matter marker (optional language specifier) (?.*?) # front matter block content (not greedy) ^(\k | \.{3}) # closing front matter marker [^\S\r\n]*(\R|\z) }mx.freeze end end