Coder Social home page Coder Social logo

bbcodecontent's Introduction

BBCodeContent

This extension adds a new content model, "BBCode", that you can switch pages to.

Installation

Run the following commands (assuming you're at your wiki's root, e.g. /w):

cd extensions
git clone https://github.com/Kenny2github/BBCodeContent.git
cd ..
echo "wfLoadExtension('BBCodeContent');" >> LocalSettings.php

Configuration

The only configuration variable is $wgBBCCTags, which controls how each different BBCode tag is interpreted.

Use it as follows for a simple tag:

$wgBBCCTags['red'] = [
	'<span style="color: red">', // opening tag
	'</span>', // closing tag
	false // if true, this is closed by a newline rather than a [/red]
];

Or as follows for a tag with a parameter:

// this is already in there by default
$wgBBCCTags['url'] = [
	'<a rel="nofollow" href="{PARAM}">', // {PARAM} is replaced by FOO in [url=FOO]
	'</a>',
	false
];

Or as follows for a complex tag that needs special things:

$wgBBCCTags['randomcolor'] = function ($tag, $content, $param) {
	// $param is FOO in [randomcolor=FOO]
	// it is not used here
	// $content is BAR in [randomcolor]BAR[/randomcolor]
	// it is directly echoed (everything has already been put through htmlspecialchars)
	$out = '<span style="color: ';
	$out .= sprintf('#%06X', mt_rand(0, 0xFFFFFF));
	$out .= '">';
	$out .= $content;
	$out .= '</span>';
	return $out;
};

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.