Skip to main content

Crate streamdown_plugin

Crate streamdown_plugin 

Source
Expand description

Streamdown Plugin System

This crate provides the plugin architecture for extending streamdown with custom content processors. Plugins can intercept lines of input and transform them before normal markdown processing.

§Plugin Behavior

  • If a plugin returns None, it’s not interested in the line
  • If a plugin returns Some(ProcessResult::Lines(vec)), those lines are emitted
  • If a plugin returns Some(ProcessResult::Continue), it’s buffering input
  • A plugin that returns non-None gets priority until it returns None

§Example

use streamdown_plugin::{Plugin, ProcessResult, PluginManager};
use streamdown_core::state::ParseState;
use streamdown_config::ComputedStyle;

struct EchoPlugin;

impl Plugin for EchoPlugin {
    fn name(&self) -> &str { "echo" }

    fn process_line(
        &mut self,
        line: &str,
        _state: &ParseState,
        _style: &ComputedStyle,
    ) -> Option<ProcessResult> {
        if line.starts_with("!echo ") {
            Some(ProcessResult::Lines(vec![line[6..].to_string()]))
        } else {
            None
        }
    }

    fn flush(&mut self) -> Option<Vec<String>> { None }
    fn reset(&mut self) {}
}

Modules§

builtin
Built-in plugins and plugin discovery.
latex
LaTeX to Unicode conversion plugin.

Structs§

PluginManager
Plugin manager for registering and coordinating plugins.

Enums§

ProcessResult
Result of plugin processing.

Traits§

Plugin
Plugin trait for custom content processors.