Skip to content

0.11.0

Compare
Choose a tag to compare
@colinodell colinodell released this 19 Sep 15:15

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 Node class, which both AbstractBlock and AbstractInline extend from (#169)
  • Added a NodeWalker and NodeWalkerEvent to traverse the AST without using recursion
  • Added new InlineContainer interface for blocks
  • Added new getContainer() and getReferenceMap() methods to InlineParserContext
  • Added iframe to whitelist of HTML block tags (as per spec)
  • Added ./bin/commonmark for converting Markdown at the command line

Changed

  • Bumped spec target version to 0.22
  • Revised AST to use a double-linked list (#169)
  • AbstractBlock and AbstractInline both extend from Node
    • Sub-classes must implement new isContainer() method
  • Other major changes to AbstractBlock:
    • getParent() is now parent()
    • setParent() now expects a Node instead of an AbstractBlock
    • getChildren() is now children()
    • getLastChild() is now lastChild()
    • addChild() is now appendChild()
  • InlineParserContext is constructed using the container AbstractBlock and the document's RefereceMap
    • The constructor will automatically create the Cursor using the container's string contents
  • InlineParserEngine::parse now requires the Node container and the document's ReferenceMap instead of a ContextInterface and Cursor
  • Changed Delimiter to reference the actual inline Node instead of the position
    • The int $pos protected member and constructor arg is now Node $node
    • Use getInlineNode() and setInlineNode() instead of getPos() and setPos()
  • Changed DocParser::processInlines to use a NodeWalker to iterate through inlines
    • Walker passed as second argument instead of AbstractBlock
    • Uses a while loop instead of recursion to traverse the AST
  • Image and Link now only accept a string as their second argument
  • Refactored how CloseBracketParser::parse() works internally
  • CloseBracketParser::createInline no 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 new DocParser::setAndPropagateLastLineBlank() method
    • AbstractBlock::setLastLineBlank() is now a setter method for AbstractBlock::$lastLineBlank
  • 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 DocParser checked the wrong method to determine remainder handling behavior
  • Fixed bug where HorizontalRuleParser failed to advance the cursor beyond the parsed horizontal rule characters
  • Fixed DocParser not ignoring the final newline of the input (like the reference parser does)

Removed

  • Removed Block\Element\AbstractInlineContainer
    • Extend AbstractBlock and implement InlineContainer instead
    • Use child methods instead of getInlines and setInlines
  • Removed AbstractBlock::replaceChild()
    • Call Node::replaceWith() directly the child node instead
  • Removed the getInlines() method from InlineParserContext
    • Add parsed inlines using $inlineContext->getContainer()->appendChild() instead of $inlineContext->getInlines()->add()
  • Removed the ContextInterface argument from AbstractInlineParser::parse() and InlineParserEngine::parseCharacter
  • Removed the first ArrayCollection $inlines argument from InlineProcessorInterface::processInlines()
  • Removed CloseBracketParser::nullify()
  • Removed pre from rule 6 of HTML blocks (see commonmark/commonmark-spec#355)