Class: LlmDocsBuilder::Transformers::LinkTransformer

Inherits:
Object
  • Object
show all
Includes:
BaseTransformer
Defined in:
lib/llm_docs_builder/transformers/link_transformer.rb

Overview

Transformer for link-related operations

Handles expansion of relative links to absolute URLs and conversion of HTML URLs to markdown format.

Instance Method Summary collapse

Methods included from BaseTransformer

#should_transform?

Instance Method Details

#transform(content, options = {}) ⇒ String

Transform links in content

Parameters:

  • content (String)

    markdown content

  • options (Hash) (defaults to: {})

    transformation options

Options Hash (options):

  • :base_url (String)

    base URL for expanding relative links

  • :convert_urls (Boolean)

    convert HTML URLs to markdown format

Returns:

  • (String)

    transformed content



21
22
23
24
25
26
27
28
29
# File 'lib/llm_docs_builder/transformers/link_transformer.rb', line 21

def transform(content, options = {})
  result = content.dup

  result = expand_relative_links(result, options[:base_url]) if options[:base_url]
  result = convert_html_urls(result) if options[:convert_urls]
  result = simplify_links(result) if options[:simplify_links]

  result
end