Docs · API reference · Verso.Abstractions

INotebookSerializer Interface#

Serializes and deserializes notebooks to and from a specific file format (e.g. .ipynb, .dib, .vnb). The host selects the appropriate serializer based on FileExtensions.

public interface INotebookSerializer : Verso.Abstractions.IExtension

Implements IExtension

Properties#

FileExtensions Property#

File extensions this serializer handles (e.g. ".ipynb", ".vnb"), including the leading dot.

System.Collections.Generic.IReadOnlyList<string> FileExtensions { get; }

Property Value#

System.Collections.Generic.IReadOnlyList<System.String>

FormatId Property#

Unique identifier for the serialization format (e.g. "jupyter", "verso-native").

string FormatId { get; }

Property Value#

System.String

PreservesFormatByDefault Property#

Whether this format is automatically selected when saving a notebook whose file path this serializer handles, without requiring an explicit opt-in such as a preserve-format setting or command-line flag. Defaults to false, which keeps the host's convert-to-native behavior for formats that opt out.

bool PreservesFormatByDefault { get; }

Property Value#

System.Boolean

Methods#

CanImport(string) Method#

Determines whether this serializer can import the file at the given path, typically by inspecting the file extension or probing the content.

bool CanImport(string filePath);

Parameters#

filePath System.String

Absolute or relative path to the file.

Returns#

System.Boolean
true if this serializer can import the file; otherwise false.

DeserializeAsync(string) Method#

Deserializes the string content of a notebook file into a notebook model.

System.Threading.Tasks.Task<Verso.Abstractions.NotebookModel> DeserializeAsync(string content);

Parameters#

content System.String

The raw file content to deserialize.

Returns#

System.Threading.Tasks.Task<NotebookModel>
The deserialized notebook model.

SerializeAsync(NotebookModel) Method#

Serializes a notebook model to its string representation in this format.

System.Threading.Tasks.Task<string> SerializeAsync(Verso.Abstractions.NotebookModel notebook);

Parameters#

notebook NotebookModel

The notebook model to serialize.

Returns#

System.Threading.Tasks.Task<System.String>
The serialized string content.