Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DocumentRendererInterface #813

Merged
merged 1 commit into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi

### Added

- Added new `EmbedExtension` (#805)
- Added new `EmbedExtension` (#805)
- Added `DocumentRendererInterface` as a replacement for the now-deprecated `MarkdownRendererInterface`

### Deprecated

- Deprecated `MarkdownRendererInterface`; use `DocumentRendererInterface` instead

## [2.2.3] - 2022-02-26

Expand Down
28 changes: 28 additions & 0 deletions src/Renderer/DocumentRendererInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

/*
* This file is part of the league/commonmark package.
*
* (c) Colin O'Dell <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace League\CommonMark\Renderer;

use League\CommonMark\Node\Block\Document;
use League\CommonMark\Output\RenderedContentInterface;

/**
* Renders a parsed Document AST
*/
interface DocumentRendererInterface extends MarkdownRendererInterface
{
/**
* Render the given Document node (and all of its children)
*/
public function renderDocument(Document $document): RenderedContentInterface;
}
2 changes: 1 addition & 1 deletion src/Renderer/HtmlRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use League\CommonMark\Output\RenderedContent;
use League\CommonMark\Output\RenderedContentInterface;

final class HtmlRenderer implements MarkdownRendererInterface, ChildNodeRendererInterface
final class HtmlRenderer implements DocumentRendererInterface, ChildNodeRendererInterface
{
/** @psalm-readonly */
private EnvironmentInterface $environment;
Expand Down
2 changes: 2 additions & 0 deletions src/Renderer/MarkdownRendererInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

/**
* Renders a parsed Document AST
*
* @deprecated since 2.3; use {@link DocumentRendererInterface} instead
*/
interface MarkdownRendererInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Xml/MarkdownToXmlConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
use League\CommonMark\Output\RenderedContentInterface;
use League\CommonMark\Parser\MarkdownParser;
use League\CommonMark\Parser\MarkdownParserInterface;
use League\CommonMark\Renderer\MarkdownRendererInterface;
use League\CommonMark\Renderer\DocumentRendererInterface;

final class MarkdownToXmlConverter implements ConverterInterface
{
/** @psalm-readonly */
private MarkdownParserInterface $parser;

/** @psalm-readonly */
private MarkdownRendererInterface $renderer;
private DocumentRendererInterface $renderer;

public function __construct(EnvironmentInterface $environment)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Xml/XmlRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use League\CommonMark\Node\StringContainerInterface;
use League\CommonMark\Output\RenderedContent;
use League\CommonMark\Output\RenderedContentInterface;
use League\CommonMark\Renderer\MarkdownRendererInterface;
use League\CommonMark\Renderer\DocumentRendererInterface;
use League\CommonMark\Util\Xml;

final class XmlRenderer implements MarkdownRendererInterface
final class XmlRenderer implements DocumentRendererInterface
{
private const INDENTATION = ' ';

Expand Down