### Build and Start Local Web Example Source: https://github.com/activescott/agentmarkdown/blob/master/README.md Navigate to the example directory, install dependencies, and start the local development server for the AgentMarkdown web example. ```bash cd example/ npm install npm run start ``` -------------------------------- ### BoldPlugin Implementation Example Source: https://github.com/activescott/agentmarkdown/blob/master/README.md An example plugin that implements the `LayoutPlugin` interface to render the `` HTML element with markdown bold syntax. ```typescript class BoldPlugin { elementName: "b" layout: LayoutGenerator = ( context: LayoutContext, manager: LayoutManager, element: HtmlNode ): CssBox | null => { // let the manager use other plugins to layout any child elements: const kids = manager.layout(context, element.children) // wrap the child elements in the markdown ** syntax for bold/strong: kids.unshift(manager.createBox(BoxType.inline, "**")) kids.push(manager.createBox(BoxType.inline, "**")) // return a new box containing everything: return manager.createBox(BoxType.inline, "", kids) } } ``` -------------------------------- ### Run AgentMarkdown CLI with npx Source: https://github.com/activescott/agentmarkdown/blob/master/README.md Execute the agentmarkdown CLI tool without global installation using `npx`. This is useful for quick conversions or testing. ```bash npx agentmarkdown ``` -------------------------------- ### Initializing AgentMarkdown with Custom Plugins Source: https://github.com/activescott/agentmarkdown/blob/master/README.md Demonstrates how to initialize AgentMarkdown with custom plugins by passing an array of plugin instances to the `layoutPlugins` option. ```typescript const result = await AgentMarkdown.render({ html: myHtmlString, layoutPlugins: [ new BoldPlugin() ] }) ``` -------------------------------- ### Build Agent Markdown Package Source: https://github.com/activescott/agentmarkdown/blob/master/README.md Run this command from the root of the repository to build the package. The output will be in the /dist directory. ```bash npm run build ``` -------------------------------- ### Convert HTML via Stdin to Markdown via CLI Source: https://github.com/activescott/agentmarkdown/blob/master/README.md Pipe HTML content to the agentmarkdown CLI tool to convert it to Markdown. The output can be redirected to a file. ```bash echo "bold" | agentmarkdown > myfile.md ``` -------------------------------- ### Convert HTML File to Markdown via CLI Source: https://github.com/activescott/agentmarkdown/blob/master/README.md Convert an HTML file to Markdown directly from the command line. The output is printed to standard output. ```bash agentmarkdown ``` -------------------------------- ### LayoutPlugin Interface Definition Source: https://github.com/activescott/agentmarkdown/blob/master/README.md Defines the structure for custom plugins. Implement this to handle specific HTML elements. ```typescript export interface LayoutPlugin { /** * Specifies the name of the HTML element that this plugin renders markdown for. * NOTE: Must be all lowercase */ elementName: string /** * This is the core of the implementation that will be called for each instance of the HTML element that this plugin is registered for. */ layout: LayoutGenerator } ``` -------------------------------- ### Produce Markdown from HTML String Source: https://github.com/activescott/agentmarkdown/blob/master/README.md Use the `produce` method from the AgentMarkdown class to convert an HTML string into a Markdown string. This is the primary method for programmatic conversion. ```javascript import { AgentMarkdown } from "agentmarkdown" const markdownString = await AgentMarkdown.produce(htmlString) ``` -------------------------------- ### LayoutGenerator Function Signature Source: https://github.com/activescott/agentmarkdown/blob/master/README.md The function signature for a layout generator. It takes context, a manager, and the HTML node, returning a `CssBox` or null. ```typescript export interface LayoutGenerator { ( context: LayoutContext, manager: LayoutManager, element: HtmlNode ): CssBox | null } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.