\ChapterThree\AppleNewsAPI\DocumentMarkdown

Handling of Apple News Document markdown.

Summary

Methods
Properties
Constants
escape()
__construct()
convert()
$dom
$white_list
ESCAPED_CHARACTERS
BLOCK_DELIMITER
getBlocks()
getBlock()
getBlockList()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

ESCAPED_CHARACTERS

ESCAPED_CHARACTERS

BLOCK_DELIMITER

BLOCK_DELIMITER

Properties

$dom

$dom : \DOMDocument

Type

\DOMDocument

$white_list

$white_list : array

Type

array

Methods

escape()

escape(string  $string) : mixed

Escape Markdown special characters.

Parameters

string $string

A string without any Markdown.

Returns

mixed —

$string with any special characters escaped.

__construct()

__construct(array  $white_list = array()) 

Implements __construct().

Parameters

array $white_list

An array of inline-type element names to preserve in situ.

convert()

convert(string  $html) : string|NULL

Convert HTML to Apple News Markdown.

Parameters

string $html

HTML to convert. Value is not validated, it is caller's responsibility to validate.

Returns

string|NULL —

Markdown representation of the HTML, or NULL if failed.

getBlocks()

getBlocks(\DOMNodeList|array  $nodes) : array

Converts a \DOMNodeList into a series of Markdown blocks.

Parameters

\DOMNodeList|array $nodes

DOM nodes.

Returns

array —

Array of string Markdown blocks.

getBlock()

getBlock(\DOMElement  $element) : string

Converts a DOM element into a single Markdown block.

Handles inline elements.

Parameters

\DOMElement $element

The Node to transform.

Returns

string —

A single Markdown block string.

getBlockList()

getBlockList(\DOMElement  $element) : string

Converts a list-type \DOMElement into a single Markdown block.

Note Apple markdown subset does not support nested lists.

Parameters

\DOMElement $element

One of ul, ol, dl.

Returns

string —

A single Markdown block string.