This release contains several major internal changes. It will likely break compatibility with custom elements, parsers, and renderers. Simple Markdown parsing is unaffected.
Added
- Added new
Nodeclass, which bothAbstractBlockandAbstractInlineextend from (#169) - Added a
NodeWalkerandNodeWalkerEventto traverse the AST without using recursion - Added new
InlineContainerinterface for blocks - Added new
getContainer()andgetReferenceMap()methods toInlineParserContext - Added
iframeto whitelist of HTML block tags (as per spec) - Added
./bin/commonmarkfor converting Markdown at the command line
Changed
- Bumped spec target version to 0.22
- Revised AST to use a double-linked list (#169)
AbstractBlockandAbstractInlineboth extend fromNode- Sub-classes must implement new
isContainer()method
- Sub-classes must implement new
- Other major changes to
AbstractBlock:getParent()is nowparent()setParent()now expects aNodeinstead of anAbstractBlockgetChildren()is nowchildren()getLastChild()is nowlastChild()addChild()is nowappendChild()
InlineParserContextis constructed using the containerAbstractBlockand the document'sRefereceMap- The constructor will automatically create the
Cursorusing the container's string contents
- The constructor will automatically create the
InlineParserEngine::parsenow requires theNodecontainer and the document'sReferenceMapinstead of aContextInterfaceandCursor- Changed
Delimiterto reference the actual inlineNodeinstead of the position- The
int $posprotected member and constructor arg is nowNode $node - Use
getInlineNode()andsetInlineNode()instead ofgetPos()andsetPos()
- The
- Changed
DocParser::processInlinesto use aNodeWalkerto iterate through inlines- Walker passed as second argument instead of
AbstractBlock - Uses a
whileloop instead of recursion to traverse the AST
- Walker passed as second argument instead of
ImageandLinknow only accept a string as their second argument- Refactored how
CloseBracketParser::parse()works internally CloseBracketParser::createInlineno longer accepts label inlines- Disallow list item starting with multiple blank lines (see commonmark/commonmark-spec#332)
- Modified
AbstractBlock::setLastLineBlank()- Functionality moved to
AbstractBlock::shouldLastLineBeBlank()and newDocParser::setAndPropagateLastLineBlank()method AbstractBlock::setLastLineBlank()is now a setter method forAbstractBlock::$lastLineBlank
- Functionality moved to
AbstractBlock::handleRemainingContents()is no longer abstract- A default implementation is provided
- Removed duplicate code from sub-classes which used the default implementation - they'll just use the parent method from now on
Fixed
- Fixed logic error in calculation of offset (see commonmark/commonmark.js@94053a8)
- Fixed bug where
DocParserchecked the wrong method to determine remainder handling behavior - Fixed bug where
HorizontalRuleParserfailed to advance the cursor beyond the parsed horizontal rule characters - Fixed
DocParsernot ignoring the final newline of the input (like the reference parser does)
Removed
- Removed
Block\Element\AbstractInlineContainer- Extend
AbstractBlockand implementInlineContainerinstead - Use child methods instead of
getInlinesandsetInlines
- Extend
- Removed
AbstractBlock::replaceChild()- Call
Node::replaceWith()directly the child node instead
- Call
- Removed the
getInlines()method fromInlineParserContext- Add parsed inlines using
$inlineContext->getContainer()->appendChild()instead of$inlineContext->getInlines()->add()
- Add parsed inlines using
- Removed the
ContextInterfaceargument fromAbstractInlineParser::parse()andInlineParserEngine::parseCharacter - Removed the first
ArrayCollection $inlinesargument fromInlineProcessorInterface::processInlines() - Removed
CloseBracketParser::nullify() - Removed
prefrom rule 6 of HTML blocks (see commonmark/commonmark-spec#355)