PHP Class League\HTMLToMarkdown\HtmlConverter

A helper class to convert HTML to Markdown.
Author: Colin O'Dell ([email protected])
Author: Nick Cernis ([email protected])
Mostrar archivo Open project: nickcernis/html-to-markdown Class Usage Examples

Protected Properties

Property Type Description
$environment Environment

Public Methods

Method Description
__construct ( array $options = [] ) Constructor
__invoke ( string $html ) : string Convert
convert ( $html ) : string Convert
getConfig ( ) : League\HTMLToMarkdown\Configuration
getEnvironment ( ) : Environment

Protected Methods

Method Description
convertToMarkdown ( League\HTMLToMarkdown\ElementInterface $element ) : string Convert to Markdown
sanitize ( string $markdown ) : string

Private Methods

Method Description
convertChildren ( League\HTMLToMarkdown\ElementInterface $element ) Convert Children
createDOMDocument ( string $html ) : DOMDocument

Method Details

__construct() public method

Constructor
public __construct ( array $options = [] )
$options array Configuration options

__invoke() public method

Convert
See also: HtmlConverter::convert
public __invoke ( string $html ) : string
$html string
return string The Markdown version of the html

convert() public method

Loads HTML and passes to getMarkdown()
public convert ( $html ) : string
$html
return string The Markdown version of the html

convertToMarkdown() protected method

Converts an individual node into a #text node containing a string of its Markdown equivalent. Example: An

node with text content of 'Title' becomes a text node with content of '### Title'

protected convertToMarkdown ( League\HTMLToMarkdown\ElementInterface $element ) : string
$element League\HTMLToMarkdown\ElementInterface
return string The converted HTML as Markdown

getConfig() public method

public getConfig ( ) : League\HTMLToMarkdown\Configuration
return League\HTMLToMarkdown\Configuration

getEnvironment() public method

public getEnvironment ( ) : Environment
return Environment

sanitize() protected method

protected sanitize ( string $markdown ) : string
$markdown string
return string

Property Details

$environment protected_oe property

protected Environment,League\HTMLToMarkdown $environment
return Environment