Module: Coradoc::Markdown::Serializer::Strategies::Autolink::Registry
- Defined in:
- lib/coradoc/markdown/serializer/strategies/autolink/registry.rb
Overview
Resolves an autolink strategy from a Config + (url, text).
Mode lookup:
autolinks == true → Angle (default, CommonMark-safe)
autolinks == false → None (use standard link syntax)
The angle form is preferred over bare because angle brackets disambiguate the URL in flowing text and render identically across HTML-aware Markdown processors.
Use ‘Bare` explicitly for GFM-targeted output where minimal noise is preferred.
Constant Summary collapse
Class Method Summary collapse
- .lookup(mode) ⇒ Object
- .render_or_default(url:, text:, ctx:, default:) ⇒ Object
- .resolve(url:, text:, ctx:) ⇒ Object
Class Method Details
.lookup(mode) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/coradoc/markdown/serializer/strategies/autolink/registry.rb', line 33 def lookup(mode) MODES.fetch(mode.to_sym) do raise ArgumentError, "Unknown autolink mode: #{mode.inspect}. " \ "Known: #{MODES.keys.inspect}" end end |
.render_or_default(url:, text:, ctx:, default:) ⇒ Object
48 49 50 51 |
# File 'lib/coradoc/markdown/serializer/strategies/autolink/registry.rb', line 48 def render_or_default(url:, text:, ctx:, default:) strategy = resolve(url: url, text: text, ctx: ctx) strategy ? strategy.render(url, text, ctx) : default end |
.resolve(url:, text:, ctx:) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/coradoc/markdown/serializer/strategies/autolink/registry.rb', line 40 def resolve(url:, text:, ctx:) mode = ctx.config.autolinks ? :angle : :none strategy = lookup(mode) return nil unless strategy.applies?(url, text, ctx) strategy end |