You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

341 lines
18 KiB

3 years ago
  1. # Change Log
  2. All notable changes to this project will be documented in this file.
  3. Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
  4. **Upgrading from 1.x?** See <https://commonmark.thephpleague.com/2.0/upgrading/> for additional information.
  5. ## [Unreleased][unreleased]
  6. ## [2.0.0] - 2021-07-24
  7. No changes were introduced since the previous RC2 release.
  8. See all entries below for a list of changes between 1.x and 2.0.
  9. ## [2.0.0-rc2] - 2021-07-17
  10. ### Fixed
  11. - Fixed Mentions inside of links creating nested links against the spec's rules (#688)
  12. ## [2.0.0-rc1] - 2021-07-10
  13. No changes were introduced since the previous release.
  14. ## [2.0.0-beta3] - 2021-07-03
  15. ### Changed
  16. - Any leading UTF-8 BOM will be stripped from the input
  17. - The `getEnvironment()` method of `CommonMarkConverter` and `GithubFlavoredMarkdownConverter` will always return the concrete, configurable `Environment` for upgrading convenience
  18. - Optimized AST iteration
  19. - Lots of small micro-optimizations
  20. ## [2.0.0-beta2] - 2021-06-27
  21. ### Added
  22. - Added new `Node::iterator()` method and `NodeIterator` class for faster AST iteration (#683, #684)
  23. ### Changed
  24. - Made compatible with CommonMark spec 0.30.0
  25. - Optimized link label parsing
  26. - Optimized AST iteration for a 50% performance boost in some event listeners (#683, #684)
  27. ### Fixed
  28. - Fixed processing instructions with EOLs
  29. - Fixed case-insensitive matching for HTML tag types
  30. - Fixed type 7 HTML blocks incorrectly interrupting lazy paragraphs
  31. - Fixed newlines in reference labels not collapsing into spaces
  32. - Fixed link label normalization with escaped newlines
  33. - Fixed unnecessary AST iteration when no default attributes are configured
  34. ## [2.0.0-beta1] - 2021-06-20
  35. ### Added
  36. - **Added three new extensions:**
  37. - `FrontMatterExtension` ([see documentation](https://commonmark.thephpleague.com/extensions/front-matter/))
  38. - `DescriptionListExtension` ([see documentation](https://commonmark.thephpleague.com/extensions/description-lists/))
  39. - `DefaultAttributesExtension` ([see documentation](https://commonmark.thephpleague.com/extensions/default-attributes/))
  40. - **Added new `XmlRenderer` to simplify AST debugging** ([see documentation](https://commonmark.thephpleague.com/xml/)) (#431)
  41. - **Added the ability to configure disallowed raw HTML tags** (#507)
  42. - **Added the ability for Mentions to use multiple characters for their symbol** (#514, #550)
  43. - **Added the ability to delegate event dispatching to PSR-14 compliant event dispatcher libraries**
  44. - **Added new configuration options:**
  45. - Added `heading_permalink/min_heading_level` and `heading_permalink/max_heading_level` options to control which headings get permalinks (#519)
  46. - Added `heading_permalink/fragment_prefix` to allow customizing the URL fragment prefix (#602)
  47. - Added `footnote/backref_symbol` option for customizing backreference link appearance (#522)
  48. - Added `slug_normalizer/max_length` option to control the maximum length of generated URL slugs
  49. - Added `slug_normalizer/unique` option to control whether unique slugs should be generated per-document or per-environment
  50. - **Added purity markers throughout the codebase** (verified with Psalm)
  51. - Added `Query` class to simplify Node traversal when looking to take action on certain Nodes
  52. - Added new `HtmlFilter` and `StringContainerHelper` utility classes
  53. - Added new `AbstractBlockContinueParser` class to simplify the creation of custom block parsers
  54. - Added several new classes and interfaces:
  55. - `BlockContinue`
  56. - `BlockContinueParserInterface`
  57. - `BlockContinueParserWithInlinesInterface`
  58. - `BlockStart`
  59. - `BlockStartParserInterface`
  60. - `ChildNodeRendererInterface`
  61. - `ConfigurableExtensionInterface`
  62. - `CursorState`
  63. - `DashParser` (extracted from `PunctuationParser`)
  64. - `DelimiterParser`
  65. - `DocumentBlockParser`
  66. - `DocumentPreRenderEvent`
  67. - `DocumentRenderedEvent`
  68. - `EllipsesParser` (extracted from `PunctuationParser`)
  69. - `ExpressionInterface`
  70. - `FallbackNodeXmlRenderer`
  71. - `InlineParserEngineInterface`
  72. - `InlineParserMatch`
  73. - `MarkdownParserState`
  74. - `MarkdownParserStateInterface`
  75. - `MarkdownRendererInterface`
  76. - `Query`
  77. - `RawMarkupContainerInterface`
  78. - `ReferenceableInterface`
  79. - `RenderedContent`
  80. - `RenderedContentInterface`
  81. - `ReplaceUnpairedQuotesListener`
  82. - `SpecReader`
  83. - `TableOfContentsRenderer`
  84. - `UniqueSlugNormalizer`
  85. - `UniqueSlugNormalizerInterface`
  86. - `XmlRenderer`
  87. - `XmlNodeRendererInterface`
  88. - Added several new methods:
  89. - `Cursor::getCurrentCharacter()`
  90. - `Environment::createDefaultConfiguration()`
  91. - `Environment::setEventDispatcher()`
  92. - `EnvironmentInterface::getExtensions()`
  93. - `EnvironmentInterface::getInlineParsers()`
  94. - `EnvironmentInterface::getSlugNormalizer()`
  95. - `FencedCode::setInfo()`
  96. - `Heading::setLevel()`
  97. - `HtmlRenderer::renderDocument()`
  98. - `InlineParserContext::getFullMatch()`
  99. - `InlineParserContext::getFullMatchLength()`
  100. - `InlineParserContext::getMatches()`
  101. - `InlineParserContext::getSubMatches()`
  102. - `LinkParserHelper::parsePartialLinkLabel()`
  103. - `LinkParserHelper::parsePartialLinkTitle()`
  104. - `Node::assertInstanceOf()`
  105. - `RegexHelper::isLetter()`
  106. - `StringContainerInterface::setLiteral()`
  107. - `TableCell::getType()`
  108. - `TableCell::setType()`
  109. - `TableCell::getAlign()`
  110. - `TableCell::setAlign()`
  111. ### Changed
  112. - **Changed the converter return type**
  113. - `CommonMarkConverter::convertToHtml()` now returns an instance of `RenderedContentInterface`. This can be cast to a string for backward compatibility with 1.x.
  114. - **Table of Contents items are no longer wrapped with `<p>` tags** (#613)
  115. - **Heading Permalinks now link to element IDs instead of using `name` attributes** (#602)
  116. - **Heading Permalink IDs and URL fragments now have a `content` prefix by default** (#602)
  117. - **Changes to configuration options:**
  118. - `enable_em` has been renamed to `commonmark/enable_em`
  119. - `enable_strong` has been renamed to `commonmark/enable_strong`
  120. - `use_asterisk` has been renamed to `commonmark/use_asterisk`
  121. - `use_underscore` has been renamed to `commonmark/use_underscore`
  122. - `unordered_list_markers` has been renamed to `commonmark/unordered_list_markers`
  123. - `mentions/*/symbol` has been renamed to `mentions/*/prefix`
  124. - `mentions/*/regex` has been renamed to `mentions/*/pattern` and requires partial regular expressions (without delimiters or flags)
  125. - `max_nesting_level` now defaults to `PHP_INT_MAX` and no longer supports floats
  126. - `heading_permalink/slug_normalizer` has been renamed to `slug_normalizer/instance`
  127. - **Event dispatching is now fully PSR-14 compliant**
  128. - **Moved and renamed several classes** - [see the full list here](https://commonmark.thephpleague.com/2.0/upgrading/#classesnamespaces-renamed)
  129. - The `HeadingPermalinkExtension` and `FootnoteExtension` were modified to ensure they never produce a slug which conflicts with slugs created by the other extension
  130. - `SlugNormalizer::normalizer()` now supports optional prefixes and max length options passed in via the `$context` argument
  131. - The `AbstractBlock::$data` and `AbstractInline::$data` arrays were replaced with a `Data` array-like object on the base `Node` class
  132. - **Implemented a new approach to block parsing.** This was a massive change, so here are the highlights:
  133. - Functionality previously found in block parsers and node elements has moved to block parser factories and block parsers, respectively ([more details](https://commonmark.thephpleague.com/2.0/upgrading/#new-block-parsing-approach))
  134. - `ConfigurableEnvironmentInterface::addBlockParser()` is now `EnvironmentBuilderInterface::addBlockParserFactory()`
  135. - `ReferenceParser` was re-implemented and works completely different than before
  136. - The paragraph parser no longer needs to be added manually to the environment
  137. - **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):
  138. - `InlineParserInterface::getCharacters()` is now `getMatchDefinition()` and returns an instance of `InlineParserMatch`
  139. - `InlineParserContext::__construct()` now requires the contents to be provided as a `Cursor` instead of a `string`
  140. - **Implemented delimiter parsing as a special type of inline parser** (via the new `DelimiterParser` class)
  141. - **Changed block and inline rendering to use common methods and interfaces**
  142. - `BlockRendererInterface` and `InlineRendererInterface` were replaced by `NodeRendererInterface` with slightly different parameters. All core renderers now implement this interface.
  143. - `ConfigurableEnvironmentInterface::addBlockRenderer()` and `addInlineRenderer()` were combined into `EnvironmentBuilderInterface::addRenderer()`
  144. - `EnvironmentInterface::getBlockRenderersForClass()` and `getInlineRenderersForClass()` are now just `getRenderersForClass()`
  145. - **Completely refactored the Configuration implementation**
  146. - All configuration-specific classes have been moved into a new `league/config` package with a new namespace
  147. - `Configuration` objects must now be configured with a schema and all options must match that schema - arbitrary keys are no longer permitted
  148. - `Configuration::__construct()` no longer accepts the default configuration values - use `Configuration::merge()` instead
  149. - `ConfigurationInterface` now only contains a `get(string $key)`; this method no longer allows arbitrary default values to be returned if the option is missing
  150. - `ConfigurableEnvironmentInterface` was renamed to `EnvironmentBuilderInterface`
  151. - `ExtensionInterface::register()` now requires an `EnvironmentBuilderInterface` param instead of `ConfigurableEnvironmentInterface`
  152. - **Added missing return types to virtually every class and interface method**
  153. - Re-implemented the GFM Autolink extension using the new inline parser approach instead of document processors
  154. - `EmailAutolinkProcessor` is now `EmailAutolinkParser`
  155. - `UrlAutolinkProcessor` is now `UrlAutolinkParser`
  156. - `HtmlElement` can now properly handle array (i.e. `class`) and boolean (i.e. `checked`) attribute values
  157. - `HtmlElement` automatically flattens any attributes with array values into space-separated strings, removing duplicate entries
  158. - Combined separate classes/interfaces into one:
  159. - `DisallowedRawHtmlRenderer` replaces `DisallowedRawHtmlBlockRenderer` and `DisallowedRawHtmlInlineRenderer`
  160. - `NodeRendererInterface` replaces `BlockRendererInterface` and `InlineRendererInterface`
  161. - Renamed the following methods:
  162. - `Environment` and `ConfigurableEnvironmentInterface`:
  163. - `addBlockParser()` is now `addBlockStartParser()`
  164. - `ReferenceMap` and `ReferenceMapInterface`:
  165. - `addReference()` is now `add()`
  166. - `getReference()` is now `get()`
  167. - `listReferences()` is now `getIterator()`
  168. - Various node (block/inline) classes:
  169. - `getContent()` is now `getLiteral()`
  170. - `setContent()` is now `setLiteral()`
  171. - Moved and renamed the following constants:
  172. - `EnvironmentInterface::HTML_INPUT_ALLOW` is now `HtmlFilter::ALLOW`
  173. - `EnvironmentInterface::HTML_INPUT_ESCAPE` is now `HtmlFilter::ESCAPE`
  174. - `EnvironmentInterface::HTML_INPUT_STRIP` is now `HtmlFilter::STRIP`
  175. - `TableCell::TYPE_HEAD` is now `TableCell::TYPE_HEADER`
  176. - `TableCell::TYPE_BODY` is now `TableCell::TYPE_DATA`
  177. - Changed the visibility of the following properties:
  178. - `AttributesInline::$attributes` is now `private`
  179. - `AttributesInline::$block` is now `private`
  180. - `TableCell::$align` is now `private`
  181. - `TableCell::$type` is now `private`
  182. - `TableSection::$type` is now `private`
  183. - Several methods which previously returned `$this` now return `void`
  184. - `Delimiter::setPrevious()`
  185. - `Node::replaceChildren()`
  186. - `Context::setTip()`
  187. - `Context::setContainer()`
  188. - `Context::setBlocksParsed()`
  189. - `AbstractStringContainer::setContent()`
  190. - `AbstractWebResource::setUrl()`
  191. - Several classes are now marked `final`:
  192. - `ArrayCollection`
  193. - `Emphasis`
  194. - `FencedCode`
  195. - `Heading`
  196. - `HtmlBlock`
  197. - `HtmlElement`
  198. - `HtmlInline`
  199. - `IndentedCode`
  200. - `Newline`
  201. - `Strikethrough`
  202. - `Strong`
  203. - `Text`
  204. - `Heading` nodes no longer directly contain a copy of their inner text
  205. - `StringContainerInterface` can now be used for inlines, not just blocks
  206. - `ArrayCollection` only supports integer keys
  207. - `HtmlElement` now implements `Stringable`
  208. - `Cursor::saveState()` and `Cursor::restoreState()` now use `CursorState` objects instead of arrays
  209. - `NodeWalker::next()` now enters, traverses any children, and leaves all elements which may have children (basically all blocks plus any inlines with children). Previously, it only did this for elements explicitly marked as "containers".
  210. - `InvalidOptionException` was removed
  211. - Anything with a `getReference(): ReferenceInterface` method now implements `ReferencableInterface`
  212. - The `SmartPunct` extension now replaces all unpaired `Quote` elements with `Text` elements towards the end of parsing, making the `QuoteRenderer` unnecessary
  213. - Several changes made to the Footnote extension:
  214. - Footnote identifiers can no longer contain spaces
  215. - Anonymous footnotes can now span subsequent lines
  216. - Footnotes can now contain multiple lines of content, including sub-blocks, by indenting them
  217. - Footnote event listeners now have numbered priorities (but still execute in the same order)
  218. - Footnotes must now be separated from previous content by a blank line
  219. - The line numbers (keys) returned via `MarkdownInput::getLines()` now start at 1 instead of 0
  220. - `DelimiterProcessorCollectionInterface` now extends `Countable`
  221. - `RegexHelper::PARTIAL_` constants must always be used in case-insensitive contexts
  222. - `HeadingPermalinkProcessor` no longer accepts text normalizers via the constructor - these must be provided via configuration instead
  223. - Blocks which can't contain inlines will no longer be asked to render inlines
  224. - `AnonymousFootnoteRefParser` and `HeadingPermalinkProcessor` now implement `EnvironmentAwareInterface` instead of `ConfigurationAwareInterface`
  225. - The second argument to `TextNormalizerInterface::normalize()` must now be an array
  226. - The `title` attribute for `Link` and `Image` nodes is now stored using a dedicated property instead of stashing it in `$data`
  227. - `ListData::$delimiter` now returns either `ListBlock::DELIM_PERIOD` or `ListBlock::DELIM_PAREN` instead of the literal delimiter
  228. ### Fixed
  229. - **Fixed parsing of footnotes without content**
  230. - **Fixed rendering of orphaned footnotes and footnote refs**
  231. - **Fixed some URL autolinks breaking too early** (#492)
  232. - Fixed `AbstractStringContainer` not actually being `abstract`
  233. ### Removed
  234. - **Removed support for PHP 7.1, 7.2, and 7.3** (#625, #671)
  235. - **Removed all previously-deprecated functionality:**
  236. - Removed the ability to pass custom `Environment` instances into the `CommonMarkConverter` and `GithubFlavoredMarkdownConverter` constructors
  237. - Removed the `Converter` class and `ConverterInterface`
  238. - Removed the `bin/commonmark` script
  239. - Removed the `Html5Entities` utility class
  240. - Removed the `InlineMentionParser` (use `MentionParser` instead)
  241. - Removed `DefaultSlugGenerator` and `SlugGeneratorInterface` from the `Extension/HeadingPermalink/Slug` sub-namespace (use the new ones under `./SlugGenerator` instead)
  242. - Removed the following `ArrayCollection` methods:
  243. - `add()`
  244. - `set()`
  245. - `get()`
  246. - `remove()`
  247. - `isEmpty()`
  248. - `contains()`
  249. - `indexOf()`
  250. - `containsKey()`
  251. - `replaceWith()`
  252. - `removeGaps()`
  253. - Removed the `ConfigurableEnvironmentInterface::setConfig()` method
  254. - Removed the `ListBlock::TYPE_UNORDERED` constant
  255. - Removed the `CommonMarkConverter::VERSION` constant
  256. - Removed the `HeadingPermalinkRenderer::DEFAULT_INNER_CONTENTS` constant
  257. - Removed the `heading_permalink/inner_contents` configuration option
  258. - **Removed now-unused classes:**
  259. - `AbstractStringContainerBlock`
  260. - `BlockRendererInterface`
  261. - `Context`
  262. - `ContextInterface`
  263. - `Converter`
  264. - `ConverterInterface`
  265. - `InlineRendererInterface`
  266. - `PunctuationParser` (was split into two classes: `DashParser` and `EllipsesParser`)
  267. - `QuoteRenderer`
  268. - `UnmatchedBlockCloser`
  269. - Removed the following methods, properties, and constants:
  270. - `AbstractBlock::$open`
  271. - `AbstractBlock::$lastLineBlank`
  272. - `AbstractBlock::isContainer()`
  273. - `AbstractBlock::canContain()`
  274. - `AbstractBlock::isCode()`
  275. - `AbstractBlock::matchesNextLine()`
  276. - `AbstractBlock::endsWithBlankLine()`
  277. - `AbstractBlock::setLastLineBlank()`
  278. - `AbstractBlock::shouldLastLineBeBlank()`
  279. - `AbstractBlock::isOpen()`
  280. - `AbstractBlock::finalize()`
  281. - `AbstractBlock::getData()`
  282. - `AbstractInline::getData()`
  283. - `ConfigurableEnvironmentInterface::addBlockParser()`
  284. - `ConfigurableEnvironmentInterface::mergeConfig()`
  285. - `Delimiter::setCanClose()`
  286. - `EnvironmentInterface::getConfig()`
  287. - `EnvironmentInterface::getInlineParsersForCharacter()`
  288. - `EnvironmentInterface::getInlineParserCharacterRegex()`
  289. - `HtmlRenderer::renderBlock()`
  290. - `HtmlRenderer::renderBlocks()`
  291. - `HtmlRenderer::renderInline()`
  292. - `HtmlRenderer::renderInlines()`
  293. - `Node::isContainer()`
  294. - `RegexHelper::matchAll()` (use the new `matchFirst()` method instead)
  295. - `RegexHelper::REGEX_WHITESPACE`
  296. - Removed the second `$contents` argument from the `Heading` constructor
  297. ### Deprecated
  298. **The following things have been deprecated and will not be supported in v3.0:**
  299. - `Environment::mergeConfig()` (set configuration before instantiation instead)
  300. - `Environment::createCommonMarkEnvironment()` and `Environment::createGFMEnvironment()`
  301. - Alternative 1: Use `CommonMarkConverter` or `GithubFlavoredMarkdownConverter` if you don't need to customize the environment
  302. - Alternative 2: Instantiate a new `Environment` and add the necessary extensions yourself
  303. [unreleased]: https://github.com/thephpleague/commonmark/compare/2.0.0...main
  304. [2.0.0]: https://github.com/thephpleague/commonmark/compare/2.0.0-rc2...2.0.0
  305. [2.0.0-rc2]: https://github.com/thephpleague/commonmark/compare/2.0.0-rc1...2.0.0-rc2
  306. [2.0.0-rc1]: https://github.com/thephpleague/commonmark/compare/2.0.0-beta3...2.0.0-rc1
  307. [2.0.0-beta3]: https://github.com/thephpleague/commonmark/compare/2.0.0-beta2...2.0.0-beta3
  308. [2.0.0-beta2]: https://github.com/thephpleague/commonmark/compare/2.0.0-beta1...2.0.0-beta2
  309. [2.0.0-beta1]: https://github.com/thephpleague/commonmark/compare/1.6...2.0.0-beta1