- Notifications
You must be signed in to change notification settings - Fork44
Textile markup language parser for PHP
License
textile/php-textile
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Textile reference |Live editor
PHP-Textile is a modern Textile markup language parser forPHP. Textile is a humane web text generator that takes lightweight, readable, plaintext-like markup language and converts it into well formedHTML.
UsingComposer:
$ composer require netcarver/textileThe Textile parser can be accessed through theNetcarver\Textile\Parser class. The class is highly configurable, and actual parsing happens with theparse method:
require './vendor/autoload.php';$parser = new \Netcarver\Textile\Parser();echo $parser->parse('h1. Hello World!');If you are usingPHP-Textile to format user-supplied input, blog comments for instance, remember to enable restricted parser mode:
$parser = new \Netcarver\Textile\Parser();echo $parser ->setRestricted(true) ->parse('!bad/image/not/allowed.svg!');In restricted modePHP-Textile doesn’t allow more powerful formatting options such as inline styles, and removes any rawHTML.
If you are usingPHP-Textile as a field-level formatter to parse just inline spans and glyphs, use thesetBlockTags method to disable block tags:
$parser = new \Netcarver\Textile\Parser();echo $parser ->setBlockTags(false) ->parse('Hello *strong* world!');The above outputs:
Hello <strong>strong</strong> world!Currently,PHP-Textile can target eitherXHTML or HTML5 output withXHTML being the default for backward compatibility. The targeted doctype can be changed via thesetDocumentType method:
$parser = new \Netcarver\Textile\Parser();echo $parser ->setDocumentType('html5') ->parse('HTML(HyperText Markup Language)');Textile’s typographic substitutions can be overridden with thesetSymbol method. If you need to setup Textile to do non-standard substitutions, callsetSymbol before you parse the input withparse.
$parser = new \Netcarver\Textile\Parser();$parser ->setSymbol('half', '1⁄2') ->parse('Hello [1/2] World!');The symbol names you can pass tosetSymbol can be foundhere.
Setting prefix might be useful if you want to point relative paths to certain consistent location:
$parser = new \Netcarver\Textile\Parser();$parser ->setImagePrefix('/user/uploads') ->setLinkPrefix('/') ->parse('!image.jpg! "link":page');ThePHP-Textile project welcomes constructive input and bug reports from users. Pleaseopen an issue on the repository for a comment, feature request or bug.
About
Textile markup language parser for PHP
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.