Coder Social home page Coder Social logo

wiky.php's Introduction

Wiky.php

Wiky.php is a tiny PHP "library" to convert Wiki Markup language to HTML. It's basically an attempt to recreate wiky.js with regular expressions, wrapped in a tiny PHP code.

Code usage under any of these licenses:

Supported Syntax

  • == Heading ==
  • === Subheading ===
  • ==== Subsubheading ====
  • ''''' Bold-italic '''''
  • ''' Bold '''
  • '' Italic ''
  • ---- Horizontal Line
  • : Indentation
  • :: Subindentation
    • Unordered list (up to four levels "**** text")
  • Ordered list (up to four levels "#### text")

  • [[file:http://example.com/image.jpg title]] an image ([[file|img:http|https|ftp://example.com/image.jpg optional]])
  • [http://example.com An Example Link] a link ([http|https|ftp://example.com optional])

Known issues / limitations

  • Unordered and ordered lists can not be mixed (any help and/or ideas would be great)
  • Parsing of new lines should be smarter. It should join paragraphs (detected by two consecutive newlines) and avoid listings, headers and indentations
  • It's not designed to handle user errors. If your user fails with syntax, the end result will reflect that.
  • Has only been tested to work with PHP 5.3.6 and later versions. Some older versions might have problems with some markup.

Howto use

// Include the library (obviously)
require_once("wiky.inc.php");

// Create a new wiky to any variable You'd like. Could be $mooming
// If you pass true to __construct (new wiky(true)), "S" PCRE modifier will be added to all regular expressions. This gives a performance boost when running parse thousands of times. Extreme usage only.
$wiky=new wiky;

// Call for the function parse() on the variable You created and pass some unparsed text to it, it will return parsed HTML or false if the content was empty. In this example we are loading the file input.wiki, escaping all html characters with htmlspecialchars, running parse and echoing the output
$input=file_get_contents("input.wiki");
$input=htmlspecialchars($input);
echo $wiky->parse($input);

Author

Toni Lähdekorpi [email protected]

wiky.php's People

Contributors

lahdekorpi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.