Module: NotionToMd::Helpers::YamlSanitizer

Included in:
Page, PageProperty
Defined in:
lib/notion_to_md/helpers/yaml_sanitizer.rb

Instance Method Summary collapse

Instance Method Details

#escape_frontmatter_value(value) ⇒ String

Escape the frontmatter value if it contains a colon or a dash followed by a space

Parameters:

  • value (String)

    the value to escape

Returns:

  • (String)

    the escaped value



7
8
9
10
11
12
13
14
# File 'lib/notion_to_md/helpers/yaml_sanitizer.rb', line 7

def escape_frontmatter_value(value)
  if value.match?(/: |-\s/)
    # Escape the double quotes inside the string
    "\"#{value.gsub('"', '\"')}\""
  else
    value
  end
end