Markdown Extension Manager
The markdownExtensions manager in PluginContext.manager allows customizing the Markdown React component to enable
executing commands and rendering custom content.
The main use case of this is enriching MolViewSpec support.
PluginContext.manager.markdownExtensions.register*functions can be used to register extensions and state/data resolvers to make the the manager work with plugin extensionPluginContext.manager.markdownExtensions.remove*can be used to dynamically remove the above
Commands
Section titled “Commands”Extends Markdown Hyperlink syntax to support expressions of the form [title](!c1=v1&c2=v2&...) into an executable
command. The command can be executed either on click, mouse enter, or mouse leave.
Generally, the command should be URL encoded, e.g., a b => a%20b (in JS, encodeURIComponent, in Python
urllib.parse.quote_plus/urlencode).
Built-in Commands
Section titled “Built-in Commands”center-camera- Centers the cameraapply-snapshot=key- Loads snapshots with the provided keynext-snapshot[=-1|1]- Loads next/previous snapshot, the direction is optional and default to1play-snapshots- Starts playback of state snapshotsplay-transition- Plays an animation associated with the given snapshotstop-animation- Stops currently playing animationfocus-refs=ref1,ref2,...- On click, focuses nodes with the provided refshighlight-refs=ref1,ref2,...- On mouse over, highlights the provided refsquery=...&lang=...&action=highlight,focus&focus-radius=...queryis an expression (e.g.,resn HEMwhen using PyMol syntax)- (optional)
langis one ofmol-script(default),pymol,vmd,jmol - (optional)
actionis an array ofhighlight(default),focus(multiple actions can be specified) - (optional)
focus-radiusis extra distance applied when focusing the selection (default is3) - Example:
[HEM](!query=resn%20HEM%26lang=pymol&action=highlight,focus)highlights or focuses the HEM residue (the query must be URL encoded because it contains spaces and possibly other special characters)
play-audio=src,toggle-audio[=src],stop-audio,pause-audio,dispose-audio- Audio playback support
Custom Content
Section titled “Custom Content”Extends Markdown Image syntax to support expressions of the form  to render custom elements
instead.
Built-in Custom Content
Section titled “Built-in Custom Content”color-swatch=color- Renders a box with the provided color- Color palettes:
color-palette-name=name- Renders a gradient with the provided named color palette (seemol-util/color/lists.tsfor supported color schemes)color-palette-colors=color1,color2- Renders a gradient with the provided colorscolor-palette-width=CCS-value- Specifies the width of the element, defaults to150pxcolor-palette-height=CCS-value- Specified the height of the element, defaults to0.5emcolor-palette-discrete- Renders discrete color list instead of interpolating
Example
Section titled “Example”### Highlight/Focus:-  [polymer](!highlight-refs=polymer&focus-refs=polymer)-  [ligand](!highlight-refs=ligand&focus-refs=ligand)- [both](!highlight-refs=polymer,ligand&focus-refs=polymer,ligand)
### Color Palettes|name|visual||---:|---||viridis|||rainbow (discrete)|||custom|)|
### Camera controls- [center](!center-camera)
### Image embedded in MVSX fileThis works with the MolViewSpec state built by:
import molviewspec as mvs
builder = mvs.create_builder()
assets = { "1cbs.cif": "https://files.wwpdb.org/download/1cbs.cif", "logo.png": "https://molstar.org/img/molstar-logo.png",}
model = ( builder.download(url="1cbs.cif") .parse(format="mmcif") .model_structure())( model.component(selector="polymer") .representation(ref="polymer") .color(color="blue"))( model.component(selector="ligand") .representation(ref="ligand") .color(color="red"))
mvsx = mvs.MVSX( data=builder.get_state( description="""...""" # inline the code above ), assets=assets)