Releases: thephpleague/commonmark
Releases · thephpleague/commonmark
1.6.5
2.0.0-beta1
See https://commonmark.thephpleague.com/2.0/upgrading/ for detailed information on upgrading to version 2.0.
Added
- Added three new extensions:
FrontMatterExtension
(see documentation)DescriptionListExtension
(see documentation)DefaultAttributesExtension
(see documentation)
- Added new
XmlRenderer
to simplify AST debugging (see documentation) (#431) - Added the ability to configure disallowed raw HTML tags (#507)
- Added the ability for Mentions to use multiple characters for their symbol (#514, #550)
- Added the ability to delegate event dispatching to PSR-14 compliant event dispatcher libraries
- Added new configuration options:
- Added
heading_permalink/min_heading_level
andheading_permalink/max_heading_level
options to control which headings get permalinks (#519) - Added
heading_permalink/fragment_prefix
to allow customizing the URL fragment prefix (#602) - Added
footnote/backref_symbol
option for customizing backreference link appearance (#522) - Added
slug_normalizer/max_length
option to control the maximum length of generated URL slugs - Added
slug_normalizer/unique
option to control whether unique slugs should be generated per-document or per-environment
- Added
- Added purity markers throughout the codebase (verified with Psalm)
- Added
Query
class to simplify Node traversal when looking to take action on certain Nodes - Added new
HtmlFilter
andStringContainerHelper
utility classes - Added new
AbstractBlockContinueParser
class to simplify the creation of custom block parsers - Added several new classes and interfaces:
BlockContinue
BlockContinueParserInterface
BlockContinueParserWithInlinesInterface
BlockStart
BlockStartParserInterface
ChildNodeRendererInterface
ConfigurableExtensionInterface
CursorState
DashParser
(extracted fromPunctuationParser
)DelimiterParser
DocumentBlockParser
DocumentPreRenderEvent
DocumentRenderedEvent
EllipsesParser
(extracted fromPunctuationParser
)ExpressionInterface
FallbackNodeXmlRenderer
InlineParserEngineInterface
InlineParserMatch
MarkdownParserState
MarkdownParserStateInterface
MarkdownRendererInterface
Query
RawMarkupContainerInterface
ReferenceableInterface
RenderedContent
RenderedContentInterface
ReplaceUnpairedQuotesListener
SpecReader
TableOfContentsRenderer
UniqueSlugNormalizer
UniqueSlugNormalizerInterface
XmlRenderer
XmlNodeRendererInterface
- Added several new methods:
Cursor::getCurrentCharacter()
Environment::createDefaultConfiguration()
Environment::setEventDispatcher()
EnvironmentInterface::getExtensions()
EnvironmentInterface::getInlineParsers()
EnvironmentInterface::getSlugNormalizer()
FencedCode::setInfo()
Heading::setLevel()
HtmlRenderer::renderDocument()
InlineParserContext::getFullMatch()
InlineParserContext::getFullMatchLength()
InlineParserContext::getMatches()
InlineParserContext::getSubMatches()
LinkParserHelper::parsePartialLinkLabel()
LinkParserHelper::parsePartialLinkTitle()
Node::assertInstanceOf()
RegexHelper::isLetter()
StringContainerInterface::setLiteral()
TableCell::getType()
TableCell::setType()
TableCell::getAlign()
TableCell::setAlign()
Changed
- Changed the converter return type
CommonMarkConverter::convertToHtml()
now returns an instance ofRenderedContentInterface
. This can be cast to a string for backward compatibility with 1.x.
- Table of Contents items are no longer wrapped with
<p>
tags (#613) - Heading Permalinks now link to element IDs instead of using
name
attributes (#602) - Heading Permalink IDs and URL fragments now have a
content
prefix by default (#602) - Changes to configuration options:
enable_em
has been renamed tocommonmark/enable_em
enable_strong
has been renamed tocommonmark/enable_strong
use_asterisk
has been renamed tocommonmark/use_asterisk
use_underscore
has been renamed tocommonmark/use_underscore
unordered_list_markers
has been renamed tocommonmark/unordered_list_markers
mentions/*/symbol
has been renamed tomentions/*/prefix
mentions/*/regex
has been renamed tomentions/*/pattern
and requires partial regular expressions (without delimiters or flags)max_nesting_level
now defaults toPHP_INT_MAX
and no longer supports floatsheading_permalink/slug_normalizer
has been renamed toslug_normalizer/instance
- Event dispatching is now fully PSR-14 compliant
- Moved and renamed several classes - see the full list here
- The
HeadingPermalinkExtension
andFootnoteExtension
were modified to ensure they never produce a slug which conflicts with slugs created by the other extension SlugNormalizer::normalizer()
now supports optional prefixes and max length options passed in via the$context
argument- The
AbstractBlock::$data
andAbstractInline::$data
arrays were replaced with aData
array-like object on the baseNode
class - Implemented a new approach to block parsing. This was a massive change, so here are the highlights:
- Functionality previously found in block parsers and node elements has moved to block parser factories and block parsers, respectively (more details)
ConfigurableEnvironmentInterface::addBlockParser()
is nowEnvironmentBuilderInterface::addBlockParserFactory()
ReferenceParser
was re-implemented and works completely different than before- The paragraph parser no longer needs to be added manually to the environment
- Implemented a new approach to inline parsing where parsers can now specify longer strings or regular expressions they want to parse (instead of just single characters):
InlineParserInterface::getCharacters()
is nowgetMatchDefinition()
and returns an instance ofInlineParserMatch
InlineParserContext::__construct()
now requires the contents to be provided as aCursor
instead of astring
- Implemented delimiter parsing as a special type of inline parser (via the new
DelimiterParser
class) - Changed block and inline rendering to use common methods and interfaces
BlockRendererInterface
andInlineRendererInterface
were replaced byNodeRendererInterface
with slightly different parameters. All core renderers now implement this interface.ConfigurableEnvironmentInterface::addBlockRenderer()
andaddInlineRenderer()
were combined intoEnvironmentBuilderInterface::addRenderer()
EnvironmentInterface::getBlockRenderersForClass()
andgetInlineRenderersForClass()
are now justgetRenderersForClass()
- Completely refactored the Configuration implementation
- All configuration-specific classes have been moved into a new
league/config
package with a new namespace Configuration
objects must now be configured with a schema and all options must match that schema - arbitrary keys are no longer permittedConfiguration::__construct()
no longer accepts the default configuration values - useConfiguration::merge()
insteadConfigurationInterface
now only contains aget(string $key)
; this method no longer allows arbitrary default values to be returned if the option is missingConfigurableEnvironmentInterface
was renamed toEnvironmentBuilderInterface
ExtensionInterface::register()
now requires anEnvironmentBuilderInterface
param instead ofConfigurableEnvironmentInterface
- All configuration-specific classes have been moved into a new
- Added missing return types to virtually every class and interface method
- Re-implemented the GFM Autolink extension using the new inline parser approach instead of document processors
EmailAutolinkProcessor
is nowEmailAutolinkParser
UrlAutolinkProcessor
is nowUrlAutolinkParser
HtmlElement
can now properly handle array (i.e.class
) and boolean (i.e.checked
) attribute valuesHtmlElement
automatically flattens any attributes with array values into space-separated strings, removing duplicate entries- Combined separate classes/interfaces into one:
DisallowedRawHtmlRenderer
replacesDisallowedRawHtmlBlockRenderer
andDisallowedRawHtmlInlineRenderer
NodeRendererInterface
replacesBlockRendererInterface
andInlineRendererInterface
- Renamed the following methods:
Environment
andConfigurableEnvironmentInterface
:addBlockParser()
is nowaddBlockStartParser()
ReferenceMap
andReferenceMapInterface
:addReference()
is nowadd()
getReference()
is nowget()
listReferences()
is nowgetIterator()
- Various node (block/inline) classes:
getContent()
is nowgetLiteral()
setContent()
is nowsetLiteral()
- Moved and renamed the following constants:
EnvironmentInterface::HTML_INPUT_ALLOW
is nowHtmlFilter::ALLOW
EnvironmentInterface::HTML_INPUT_ESCAPE
is nowHtmlFilter::ESCAPE
EnvironmentInterface::HTML_INPUT_STRIP
is nowHtmlFilter::STRIP
TableCell::TYPE_HEAD
is nowTableCell::TYPE_HEADER
TableCell::TYPE_BODY
i...
1.6.4
Changed
- Optimized attribute parsing to avoid inspecting every space character (30% performance boost)
1.6.3
1.6.2
Fixed
- Fixed incorrect error level for deprecation notices
1.6.1
1.6.0
Please see https://commonmark.thephpleague.com/1.6/upgrading/ for important information about this release and the upcoming 2.0.0 version.
Added
- Added forward-compatibility for configuration options which will be changing in 2.0:
commonmark/enable_em
(currentlyenable_em
in 1.x)commonmark/enable_strong
(currentlyenable_strong
in 1.x)commonmark/use_asterisk
(currentlyuse_asterisk
in 1.x)commonmark/use_underscore
(currentlyuse_underscore
in 1.x)commonmark/unordered_list_markers
(currentlyunordered_list_markers
in 1.x)mentions/*/prefix
(currentlymentions/*/symbol
in 1.x)mentions/*/pattern
(currentlymentions/*/regex
in 1.x)max_nesting_level
(currently supportsint
andfloat
values in 1.x; will only supportint
in 2.0)
- Added new
MarkdownConverter
class for creating converters with custom environments; this replaces the previously-deprecatedConverter
class - Added new
RegexHelper::matchFirst()
method - Added new
Configuration::exists()
method
Changed
- The
max_nesting_level
option now defaults toPHP_INT_MAX
instead ofINF
Deprecated
- Deprecated the configuration options shown above
- Deprecated the ability to pass a custom
Environment
into the constructors ofCommonMarkConverter
andGithubFlavoredMarkdownConverter
; useMarkdownConverter
instead - Deprecated
ConfigurableEnvironmentInterface::setConfig()
; usemergeConfig()
instead - Deprecated calling
ConfigurableEnvironmentInterface::mergeConfig()
without any parameters - Deprecated calling
Configuration::get()
andEnvironmentInterface::getConfig()
without any parameters - Deprecated calling
Configuration::set()
without the second$value
parameter - Deprecated
RegexHelper::matchAll()
; useRegexHelper::matchFirst()
instead - Deprecated extending the
ArrayCollection
class; will be markedfinal
in 2.0
Fixed
- Fixed missing check for empty arrays being passed into the
unordered_list_markers
configuration option
1.5.8
1.5.7
1.5.6
Changed
- Blocks added outside of the parsing context now have their start/end line numbers defaulted to 0 to avoid type errors (#579)