https://github.com/kcreate/ptf
PHP Tag Formatting (or short PTF)
https://github.com/kcreate/ptf
Last synced: 9 months ago
JSON representation
PHP Tag Formatting (or short PTF)
- Host: GitHub
- URL: https://github.com/kcreate/ptf
- Owner: KCreate
- License: mit
- Created: 2015-09-09T16:07:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-09-09T19:46:23.000Z (over 10 years ago)
- Last Synced: 2025-06-10T18:09:14.003Z (10 months ago)
- Language: PHP
- Size: 168 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## PTF
* Stands for PHP-Tag-Formatting
* Easily implementable
* Fast (i guess?)
* See an example here: http://leonardschuetz.ch/projects/PTF/source.php
## Installation
Installation is actually pretty easy. Just download the ls_ptf.php file and include it into your project.
## Usage and pre-supported tags
To format all the tags inside a string just write:
```
$a = "Click this #a#http://awesomesite.com - link#a#";
$b = parse($a);
// $b will be "Click this link"
```
### `#a#`
```
#a#url - title#a# // regular notation.
#a#url#a# // short notation, title will always be Link unless changed.
```
### `#img#`
```
#img#url#img# // regular notation.
```
### `#hl#`
```
#hl#some text#hl# // regular notation, puts wrapped text in a element with a class called "highlight".
```
### `#h#`
```
#h#title#h# // regular notation, puts wrapped text in a
element.
```
### `#qo#`
```
#qo#awesome cite ~ Leonard Schuetz#qo# // regular notation, puts wrapped text in a
element.
```
## Customization
Change the definitions in the parse() function to choose which, and how the tags are being outputted.
For example if you want #github#PTF#github# to result in this: `PTF`
You'd write:
```
if (str_contains('#github#', $value)) {
$value = parseTag('#github#', $value, "", '');
}
```
#### Parameters:
* Tag
* String
* What to replace the opening tag with
* What to replace the closing tag with