Skip to content

CodeBlockRenderer

This class is responsible for rendering custom code blocks within Obsidian markdown files. It registers a markdown code block processor for the ‘enzyme’ code block type and defines the rendering logic for these blocks. The class interacts with various components of the Enzyme plugin, such as EnzymeAgent, and the markdown code block processor registration function, to facilitate the rendering of ‘enzyme’ blocks with interactive elements and integration with the enzymeing engine.

Methods

createSynthesisContainerAction()

createSynthesisContainerAction(
el,
context,
executionLock,
callback): Promise<void>

Creates a synthesis container and performs the provided action on it. This function is designed to be called when a user interaction requires a synthesis container to be created and an action to be executed with it. The action is an asynchronous callback that receives the created synthesis container as an argument. The execution of the action is guarded by an execution lock to prevent concurrent executions.

Parameters

ParameterTypeDescription
elHTMLElementThe HTML element where the synthesis container will be attached.
contextanyThe context in which the synthesis container is being created.
executionLockobjectAn object with an ‘isExecuting’ property that indicates
if an action is currently being executed.
executionLock.isExecutingboolean-
callback(synthesisContainerEl) => Promise<void>The asynchronous function to be executed with the created
synthesis container. It must return a Promise.

Source

render/CodeBlockRenderer.ts:187


parseEnzymeBlockContents()

parseEnzymeBlockContents(contents): AggregatorEnzymeBlockContents | SourceEnzymeBlockContents

Parses the contents of a Enzyme code block as YAML, producing an Aggregator (with guidance + sources, or by ID)

Parameters

ParameterTypeDescription
contentsstringthe raw contents, which we’ll try to parse as valid YAML syntax.

Returns

metadata, i.e. Aggregator metadata

Source

render/CodeBlockRenderer.ts:238


renderEnzyme()

renderEnzyme(
blockContents,
el,
context): Promise<void>

Renders the ‘enzyme’ code block in the markdown preview.

This function is responsible for parsing the contents of a ‘enzyme’ code block, creating the necessary HTML elements to display the block within the markdown preview, and setting up the interaction logic for the ‘Send’ button which triggers the enzymeing process.

Parameters

ParameterTypeDescription
blockContentsstringThe raw text content of the ‘enzyme’ code block.
elHTMLElementThe parent HTML element where the ‘enzyme’ block will be rendered.
contextMarkdownPostProcessorContextThe context provided by Obsidian for post-processing the markdown.

Source

render/CodeBlockRenderer.ts:67


Generated using typedoc-plugin-markdown and TypeDoc