Download the PHP package candysax/telegraph-node-converter without Composer
On this page you can find all versions of the php package candysax/telegraph-node-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download candysax/telegraph-node-converter
More information about candysax/telegraph-node-converter
Files in candysax/telegraph-node-converter
Package telegraph-node-converter
Short Description Convert HTML to the content of the Telegraph page and back.
License MIT
Homepage https://github.com/candysax/telegraph-node-converter
Informations about the package telegraph-node-converter
Telegraph Node Converter
This library helps with the content field of the Page Telegraph API object. It converts an HTML string or a DOMDocument into the format required by the Telegraph API, and also converts it back to an HTML string or a DOMDocument.
- Telegraph API Docs: https://telegra.ph/api
Installation
To install this library run the command:
Usage
Converting from HTML to an array of Node
As the source data for conversion, the convertToNode
method accepts a string containing html tags or a DOMDocument object. The result can be obtained as an array of Node or its representation as a JSON string.
Get as array:
Get as JSON:
Passing the DOMDocument object as a data source for conversion:
Converting from an array of Node to HTML
As the source data for the conversion, the convertToHtml
method accepts an array of Node or a JSON string. The result can be obtained in the form of a string with HTML tags or a DOM object.
Get as string:
Get as DOMDocument:
Multiple conversions
Examples
Creating a Telegraph page:
Getting the content of the Telegraph page:
Testing
Tests can be launched by running the following:
License
The MIT License (MIT). Please see License File for more information.
All versions of telegraph-node-converter with dependencies
ext-dom Version *
ext-mbstring Version *
ext-json Version *
ext-libxml Version *