Class: LlmDocsBuilder::MarkdownTransformer
- Inherits:
-
Object
- Object
- LlmDocsBuilder::MarkdownTransformer
- Defined in:
- lib/llm_docs_builder/markdown_transformer.rb
Overview
Transforms markdown files to be AI-friendly
Orchestrates a pipeline of specialized transformers to process markdown content. Each transformer is responsible for a specific aspect of the transformation.
Instance Attribute Summary collapse
-
#file_path ⇒ String
readonly
Path to markdown file.
-
#options ⇒ Hash
readonly
Transformation options.
Instance Method Summary collapse
-
#initialize(file_path, options = {}) ⇒ MarkdownTransformer
constructor
Initialize a new markdown transformer.
-
#transform ⇒ String
Transform markdown content using a pipeline of transformers.
Constructor Details
#initialize(file_path, options = {}) ⇒ MarkdownTransformer
Initialize a new markdown transformer
41 42 43 44 |
# File 'lib/llm_docs_builder/markdown_transformer.rb', line 41 def initialize(file_path, = {}) @file_path = file_path @options = end |
Instance Attribute Details
#file_path ⇒ String (readonly)
Returns path to markdown file.
18 19 20 |
# File 'lib/llm_docs_builder/markdown_transformer.rb', line 18 def file_path @file_path end |
#options ⇒ Hash (readonly)
Returns transformation options.
21 22 23 |
# File 'lib/llm_docs_builder/markdown_transformer.rb', line 21 def @options end |
Instance Method Details
#transform ⇒ String
Transform markdown content using a pipeline of transformers
Processes content through specialized transformers in order:
-
ContentCleanupTransformer - Removes unwanted elements
-
LinkTransformer - Processes links
-
HeadingTransformer - Normalizes heading hierarchy (if enabled)
-
TextCompressor - Advanced compression (if enabled)
-
EnhancementTransformer - Adds TOC and instructions
-
WhitespaceTransformer - Normalizes whitespace
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/llm_docs_builder/markdown_transformer.rb', line 57 def transform content = load_content # Build and execute transformation pipeline content = cleanup_transformer.transform(content, ) content = link_transformer.transform(content, ) content = heading_transformer.transform(content, ) content = compress_content(content) if should_compress? content = enhancement_transformer.transform(content, ) whitespace_transformer.transform(content, ) end |