lib/fcb.rb in markdown_exec-2.7.1 vs lib/fcb.rb in markdown_exec-2.7.2
- old
+ new
@@ -33,10 +33,18 @@
title: '',
type: ''
}.merge(options)
end
+ def code_name_included?(*names)
+ names.include?(@attrs[:oname])
+ end
+
+ def code_name_exp?(regexp)
+ Regexp.new(regexp) =~ @attrs[:oname]
+ end
+
# Derives a title from the body of an FCB object.
# @param fcb [Object] The FCB object whose title is to be derived.
# @return [String] The derived title.
def derive_title_from_body
unless (body_content = @attrs[:body])
@@ -150,26 +158,30 @@
def to_yaml
@attrs.to_yaml
end
- # Expand variables in `dname` and `body` attributes
+ # Expand variables in attributes
+ ####
def expand_variables_in_attributes!(pattern, replacements)
- ### update name, nickname, title, label ???
-
- # Replace variables in `dname` using the replacements dictionary
+ @attrs[:raw_dname] ||= @attrs[:dname]
@attrs[:dname] = @attrs[:dname]&.gsub(pattern) do |match|
replacements[match]
end
+
+ @attrs[:raw_s0printable] ||= @attrs[:s0printable]
@attrs[:s0printable] = @attrs[:s0printable]&.gsub(pattern) do |match|
replacements[match]
end
+
+ @attrs[:raw_s1decorated] ||= @attrs[:s1decorated]
@attrs[:s1decorated] = @attrs[:s1decorated]&.gsub(pattern) do |match|
replacements[match]
end
# Replace variables in each line of `body` if `body` is present
if @attrs[:body]
+ @attrs[:raw_body] ||= @attrs[:body]
@attrs[:body] = @attrs[:body]&.map do |line|
if line.empty?
line
else
line.gsub(pattern) { |match| replacements[match] }