class ExtensionPointMarkdownExtension implements ExtensionInterface, ConfigurationAwareInterface (View source)

CommonMark extension which moves content from extension docs to places in the original doc.

The original doc declares an extension point with <!-- userdocs-extension-point: name -->. Content in an extension doc after an "insert" marker goes in a place in the original doc, until the next "insert" marker or the end of the extension doc:

  • <!-- userdocs-insert-at: name --> puts content in place of the extension point with that name.
  • <!-- userdocs-insert-before: #id --> puts content before the heading with that ID.
  • <!-- userdocs-insert-after: #id --> puts content directly after the heading with that ID.
  • <!-- userdocs-insert-end: #id --> puts content at the end of the section that starts with the heading with that ID. Content in an extension doc before the first "insert" marker is just appended to the end of the doc. Content for a place that the original doc doesn't have is removed. Content from an extension doc in a different language than the original doc is put in an ExtensionContentBlock.

The content of each extension doc must start with a marker from ExtensionDocMarker::getMarker().

Traits

A class that can be instantiated or replaced via DI

Constants

NOT_DOC_CONTENT_DATA_KEY

A key in the data of a top-level node that isn't content from the original doc or an extension doc.

Nodes with this key are never moved, removed or wrapped.

private MARKER_PATTERN

Matches an HTML comment that is an extension point or "insert" marker

private NAME_PATTERN

Matches a valid extension point name

private HEADING_ID_PATTERN

Matches a valid heading ID in an "insert" marker

private TYPE_EXTENSION_POINT

private TYPE_INSERT_AT

private TYPE_INSERT_BEFORE

private TYPE_INSERT_AFTER

private TYPE_INSERT_END

private TYPE_APPEND

Type for content in an extension doc before the first "insert" marker, which stays at the end of the doc

Methods

public static 
create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

public static 
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

public
__construct(array $docData, array $extensionData = [], bool $logWarnings = true)

No description

public
void
setConfiguration(ConfigurationInterface $configuration)

No description

public
void
register(EnvironmentBuilderInterface $environment)

No description

public
void
onDocumentParsed(DocumentParsedEvent $event)

No description

public
void
wrapContent(DocumentParsedEvent $event)

Put content from extension docs in a different language than the original doc in an ExtensionContentBlock, and give links to its headings in the table of contents the same language.

Details

static Injectable create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.

This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();

Parameters

mixed ...$args

Return Value

Injectable

static Injectable singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Parameters

string $class

Optional classname to create, if the called class should not be used

Return Value

Injectable

The singleton instance

__construct(array $docData, array $extensionData = [], bool $logWarnings = true)

No description

Parameters

array $docData

Metadata for the doc from UserDocsManifest

array $extensionData

Metadata for docs whose content is appended to this doc

bool $logWarnings

Whether to log warnings about invalid markers

void setConfiguration(ConfigurationInterface $configuration)

No description

Parameters

ConfigurationInterface $configuration

Return Value

void

void register(EnvironmentBuilderInterface $environment)

No description

Parameters

EnvironmentBuilderInterface $environment

Return Value

void

void onDocumentParsed(DocumentParsedEvent $event)

No description

Parameters

DocumentParsedEvent $event

Return Value

void

void wrapContent(DocumentParsedEvent $event)

Put content from extension docs in a different language than the original doc in an ExtensionContentBlock, and give links to its headings in the table of contents the same language.

Parameters

DocumentParsedEvent $event

Return Value

void