Module: Coradoc::Markdown::Serializer::Flavor

Defined in:
lib/coradoc/markdown/serializer/flavor.rb

Overview

Named Markdown flavor profiles.

Each flavor bundles sensible defaults for the 5 spec options. Callers can override any option via ‘Serializer.build`.

Adding a new flavor = adding one entry here. No serializer code needs to change — Open/Closed.

Constant Summary collapse

PROFILES =
{
  commonmark: {
    markdown_flavor: :commonmark,
    admonition_style: :html,
    definition_list_nested: :html,
    suppress_comments: true,
    autolinks: true
  },
  gfm: {
    markdown_flavor: :gfm,
    admonition_style: :github,
    definition_list_nested: :html,
    suppress_comments: true,
    autolinks: true
  },
  kramdown: {
    markdown_flavor: :kramdown,
    admonition_style: :html,
    definition_list_nested: :html,
    suppress_comments: true,
    autolinks: true
  },
  pandoc: {
    markdown_flavor: :pandoc,
    admonition_style: :html,
    definition_list_nested: :html,
    suppress_comments: true,
    autolinks: true
  },
  vitepress: {
    markdown_flavor: :vitepress,
    admonition_style: :container,
    definition_list_nested: :html,
    suppress_comments: true,
    autolinks: true
  },
  php_markdown_extra: {
    markdown_flavor: :php_markdown_extra,
    admonition_style: :html,
    definition_list_nested: :html,
    suppress_comments: true,
    autolinks: true
  }
}.freeze
DEFAULT_FLAVOR =
:gfm

Class Method Summary collapse

Class Method Details

.defaultObject



75
76
77
# File 'lib/coradoc/markdown/serializer/flavor.rb', line 75

def default
  PROFILES[DEFAULT_FLAVOR]
end

.known?(name) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/coradoc/markdown/serializer/flavor.rb', line 66

def known?(name)
  PROFILES.key?(name.to_sym)
end

.namesObject



62
63
64
# File 'lib/coradoc/markdown/serializer/flavor.rb', line 62

def names
  PROFILES.keys
end

.resolve(name) ⇒ Object



70
71
72
73
# File 'lib/coradoc/markdown/serializer/flavor.rb', line 70

def resolve(name)
  profile = PROFILES[name.to_sym] || PROFILES[DEFAULT_FLAVOR]
  profile.dup
end