Download the PHP package catouse/turndown-php without Composer

On this page you can find all versions of the php package catouse/turndown-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package turndown-php

Turndown PHP

English | 繁體中文

🌐 Visit the Turndown PHP project website →

Turndown PHP is a configurable HTML-to-Markdown converter for PHP 8.1+. It is an independent PHP port compatible with Turndown 7.2.4 and includes PHP ports of the official GFM plugins.

Installation

The package requires PHP 8.1 or later with the DOM and Mbstring extensions:

Usage

turndown() accepts either an HTML string or one of the supported DOM node types: DOMDocument, DOMDocumentFragment, or DOMElement:

Options

Options are passed to the constructor. The defaults match Turndown 7.2.4:

Option Accepted values Default
headingStyle setext, atx setext
hr Markdown thematic break * * *
bulletListMarker -, +, * *
codeBlockStyle indented, fenced indented
fence
emDelimiter _, * _
strongDelimiter **, __ **
linkStyle inlined, referenced inlined
linkReferenceStyle full, collapsed, shortcut full
preformattedCode bool false
br Markdown inserted before the newline for <br> two spaces

The advanced options blankReplacement, keepReplacement, and defaultReplacement accept a callable with this shape:

Options are merged loosely: unknown keys are retained and made available to custom filters and replacements. Invalid values are not normalized, so callers should use the documented values for built-in options.

Rules

Add a custom rule with a lowercase tag name, a list of tag names, or a callable filter:

A rule has the following shape:

Callable filters receive DOMElement $node and the merged options array. Replacement callables receive string $content, DOMElement $node, and the merged options. An optional append callable receives the merged options and appends content after conversion.

Rule precedence follows Turndown: blank elements, added rules, built-in CommonMark rules, kept elements, removed elements, then the default rule.

keep() preserves matching elements as serialized HTML. remove() removes a matching element together with its contents. Both accept the same string, list, or callable filters as a rule.

GFM plugins

Gfm installs highlighted fenced code blocks, strikethrough, tables, and task-list items together:

Each plugin can also be installed independently or as an iterable:

Available invokable plugin classes are Gfm, HighlightedCodeBlock, Strikethrough, Tables, and TaskListItems in the Catouse\Turndown\Plugin namespace.

Public API

The main class is Catouse\Turndown\TurndownService. It is intentionally not final, so applications can subclass it to customize behavior such as escaping.

Configuration methods return the service instance for chaining. A plugin is an invokable callable that receives the service, or an iterable of such callables.

Parsing and security

String input is parsed with Masterminds HTML5-PHP, while JavaScript Turndown operates on a browser DOM or Domino. Malformed markup recovery, namespaces, entity decoding, generated wrapper elements, whitespace, and serialized HTML retained by keep() can therefore differ. In particular, Masterminds documents limited support for some insertion modes and the adoption-agency algorithm. Supplying a supported DOM node uses the tree produced by the caller's parser. The project targets equivalent behavior for valid HTML and verifies it against the pinned official fixtures, but does not promise byte-for-byte parser parity for malformed HTML.

This library is a converter, not a sanitizer. It does not validate URL schemes or guarantee that input HTML, retained raw HTML, or generated Markdown is safe to render. Sanitize untrusted input according to your application's threat model, and treat the generated Markdown as untrusted when rendering it back to HTML.

Development

Install development dependencies and run the complete validation suite:

composer check validates composer.json, checks code style, runs PHPStan at its maximum level, and executes the PHPUnit suite. CI runs the suite on PHP 8.1 through 8.5 with both lowest and latest dependency sets. This library intentionally does not commit composer.lock.

License and attribution

Turndown PHP is released under the THIRD_PARTY_NOTICES.md for upstream and dependency attributions.


All versions of turndown-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-dom Version *
ext-mbstring Version *
masterminds/html5 Version ^2.10.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package catouse/turndown-php contains the following files

Loading the files please wait ...