Skip to content

Commit

Permalink
Deprecate MarkdownRendererInterface in favor of new DocumentRendererI…
Browse files Browse the repository at this point in the history
…nterface
  • Loading branch information
colinodell committed Feb 27, 2022
1 parent c695a4b commit 6f16994
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
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

0 comments on commit 6f16994

Please sign in to comment.