Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

txt2tags/txt2tags.php

Repository files navigation

This project is archived.

This is the new location for the up-to-date code:
https://github.com/farvardin/lionwiki-t2t/blob/master/txt2tags.class.php

Snapshot from July 2024, just in case the previous link gets broken in the future:
https://github.com/farvardin/lionwiki-t2t/blob/b003c9a1e7bb35b2abda76e249100fa2333a7904/txt2tags.class.php

-----------------------------------------------------------------


                         ┌────────────────────┐
                         │ txt2tags.class.php │
                         └────────────────────┘

Written by (c) Petko Yotov 2012 www.pmwiki.org/Petko

Development sponsored by Eric Forgeot.

txt2tags is a lightweight markup language created by
Aurelio Jargas and written in Python (www.txt2tags.org).

This class here attempts to transpose some of the features
of the Python convertor to the PHP language.

Most of this script was written by Petko Yotov except:

 ⁃ functions PSS(), Keep(), Restore(), RegExp $UEX based on
   the PmWiki engine by Patrick R. Michaud www.pmichaud.com
 ⁃ the RegExp $imgrx based on txt2tags.py by Aurelio Jargas

This text is Free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
See http://www.gnu.org/copyleft/gpl.html for full details
and lack of warranty.


How to use this script
══════════════════════

This class should be included from other scripts, for example:

    # load the class
    require_once('txt2tags.class.php');
    
    ## initialize a new T2T object: two ways
    
    # either with an existing disk file:
    $x = new T2T("test.t2t", true);
    
    # or with a variable containing the entire T2T markup:
    $x = new T2T($page["text"]);
    
    # optional: some settings, after new/init, before go()
    $x->enabletoc = 1;
    $x->enableinclude = 1;
    $x->snippets['**'] = "<strong>%s</strong>"; # instead of <b>
    
    # run all processing
    $x->go();
    
    # get the complete HTML output including <head>
    $html = $x->fullhtml;
    
    # alternatively, get some other variables:
    $body = $x->bodyhtml;     # only the part inside the <body> tags
    $fullconfig = $x->config; # what was in the "config" area of the file?


Notes
═════

 ⁃ This is an early public release, ready to be tested.
 ⁃ Including disk files is disabled out of the box, because of
   potential vulnerabilities. Enabling it on systems where
   untrusted people could edit the t2t content is not recommended.
   A future version may allow the inclusion of files from the
   current directory or only with *.t2t extension.
   To enable inclusions, use $x->enableinclude = 1;

About

txt2tags implementation in PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published