Add formatting libraries to composer.json

This commit is contained in:
Kijin Sung 2016-03-17 20:37:43 +09:00
parent 59ee4a7387
commit 2b008f7be6
202 changed files with 28022 additions and 133 deletions

View file

@ -1,39 +1,44 @@
{
"name": "rhymix/rhymix",
"description": "Rhymix",
"homepage": "https://www.rhymix.org",
"license": "GPL-2.0+",
"type": "project",
"authors": [
{ "name": "Rhymix Developers and Contributors", "email": "devops@rhymix.org" },
{ "name": "NAVER", "email": "developers@xpressengine.com" }
],
"require": {
"php": ">=5.3.3",
"ext-curl": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-mcrypt": "*",
"ext-openssl": "*",
"ext-pcre": "*",
"ext-xml": "*",
"defuse/php-encryption": "1.2.1",
"ezyang/htmlpurifier": "4.7.*",
"firephp/firephp-core": "0.4.0",
"hautelook/phpass": "0.3.*",
"matthiasmullie/minify": "1.3.*",
"michelf/php-markdown": "1.5.*",
"rmccue/requests": "1.6.*",
"sunra/php-simple-html-dom-parser": "1.5.*",
"name": "rhymix/rhymix",
"description": "Rhymix",
"homepage": "https://www.rhymix.org",
"license": "GPL-2.0+",
"type": "project",
"authors": [
{ "name": "Rhymix Developers and Contributors", "email": "devops@rhymix.org" },
{ "name": "NAVER", "email": "developers@xpressengine.com" }
],
"require": {
"php": ">=5.3.3",
"ext-curl": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-mcrypt": "*",
"ext-openssl": "*",
"ext-pcre": "*",
"ext-xml": "*",
"defuse/php-encryption": "1.2.1",
"ezyang/htmlpurifier": "4.7.*",
"firephp/firephp-core": "0.4.0",
"hautelook/phpass": "0.3.*",
"jbbcode/jbbcode": "1.3.*",
"leafo/lessphp": "0.5.*",
"leafo/scssphp": "0.4.*",
"league/html-to-markdown": "4.2.*",
"matthiasmullie/minify": "1.3.*",
"michelf/php-markdown": "1.6.*",
"michelf/php-smartypants": "1.6.0-beta1",
"rmccue/requests": "1.6.*",
"sunra/php-simple-html-dom-parser": "1.5.*",
"swiftmailer/swiftmailer": "5.4.*",
"true/punycode": "2.*"
},
"require-dev": {
"php": ">=5.4.0",
"codeception/codeception": "2.1.*",
"codeception/verify": "0.3.*",
"codeception/specify": "0.4.*"
}
},
"require-dev": {
"php": ">=5.4.0",
"codeception/codeception": "2.1.*",
"codeception/verify": "0.3.*",
"codeception/specify": "0.4.*"
}
}

288
composer.lock generated
View file

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "9b062f27815a9b2ef1e700b4664ee864",
"content-hash": "69345a9112733f99c09fa298ba72fa22",
"hash": "61ea4cb999dbb61cd01ba1a4ede5ead6",
"content-hash": "ec214228f19d828ce0ea5feeb0a72aba",
"packages": [
{
"name": "defuse/php-encryption",
@ -176,6 +176,213 @@
],
"time": "2012-08-31 00:00:00"
},
{
"name": "jbbcode/jbbcode",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/jbowens/jBBCode.git",
"reference": "645b6a1c0afa92b7d029d3417ebd8b60a5c578b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jbowens/jBBCode/zipball/645b6a1c0afa92b7d029d3417ebd8b60a5c578b3",
"reference": "645b6a1c0afa92b7d029d3417ebd8b60a5c578b3",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"type": "library",
"autoload": {
"psr-0": {
"JBBCode": "."
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jackson Owens",
"email": "jackson_owens@alumni.brown.edu",
"homepage": "http://jbowens.org/",
"role": "Developer"
}
],
"description": "A lightweight but extensible BBCode parser written in PHP 5.3.",
"homepage": "http://jbbcode.com/",
"keywords": [
"BB",
"bbcode"
],
"time": "2014-07-06 05:48:20"
},
{
"name": "leafo/lessphp",
"version": "v0.5.0",
"source": {
"type": "git",
"url": "https://github.com/leafo/lessphp.git",
"reference": "0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/lessphp/zipball/0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283",
"reference": "0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283",
"shasum": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
}
},
"autoload": {
"classmap": [
"lessc.inc.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT",
"GPL-3.0"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"description": "lessphp is a compiler for LESS written in PHP.",
"homepage": "http://leafo.net/lessphp/",
"time": "2014-11-24 18:39:20"
},
{
"name": "leafo/scssphp",
"version": "v0.4.0",
"source": {
"type": "git",
"url": "https://github.com/leafo/scssphp.git",
"reference": "78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/scssphp/zipball/78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a",
"reference": "78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"kherge/box": "~2.5",
"phpunit/phpunit": "~3.7",
"squizlabs/php_codesniffer": "~2.3"
},
"bin": [
"bin/pscss"
],
"type": "library",
"autoload": {
"classmap": [
"classmap.php"
],
"psr-4": {
"Leafo\\ScssPhp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"description": "scssphp is a compiler for SCSS written in PHP.",
"homepage": "http://leafo.github.io/scssphp/",
"keywords": [
"css",
"less",
"sass",
"scss",
"stylesheet"
],
"time": "2015-11-09 14:44:09"
},
{
"name": "league/html-to-markdown",
"version": "4.2.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "9a5becc8c6b520920fb846afefcfd7faf4c31712"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/9a5becc8c6b520920fb846afefcfd7faf4c31712",
"reference": "9a5becc8c6b520920fb846afefcfd7faf4c31712",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-xml": "*",
"php": ">=5.3.3"
},
"require-dev": {
"mikehaertl/php-shellcommand": "~1.1.0",
"phpunit/phpunit": "4.*",
"scrutinizer/ocular": "~1.1"
},
"bin": [
"bin/html-to-markdown"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
}
},
"autoload": {
"psr-4": {
"League\\HTMLToMarkdown\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "http://www.colinodell.com",
"role": "Lead Developer"
},
{
"name": "Nick Cernis",
"email": "nick@cern.is",
"homepage": "http://modernnerd.net",
"role": "Original Author"
}
],
"description": "An HTML-to-markdown conversion helper for PHP",
"homepage": "https://github.com/thephpleague/html-to-markdown",
"keywords": [
"html",
"markdown"
],
"time": "2016-02-01 16:49:02"
},
{
"name": "matthiasmullie/minify",
"version": "1.3.34",
@ -284,16 +491,16 @@
},
{
"name": "michelf/php-markdown",
"version": "1.5.0",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-markdown.git",
"reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9"
"reference": "156e56ee036505ec637d761ee62dc425d807183c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/e1aabe18173231ebcefc90e615565742fc1c7fd9",
"reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/156e56ee036505ec637d761ee62dc425d807183c",
"reference": "156e56ee036505ec637d761ee62dc425d807183c",
"shasum": ""
},
"require": {
@ -315,15 +522,15 @@
"BSD-3-Clause"
],
"authors": [
{
"name": "John Gruber",
"homepage": "http://daringfireball.net/"
},
{
"name": "Michel Fortin",
"email": "michel.fortin@michelf.ca",
"homepage": "https://michelf.ca/",
"role": "Developer"
},
{
"name": "John Gruber",
"homepage": "https://daringfireball.net/"
}
],
"description": "PHP Markdown",
@ -331,7 +538,62 @@
"keywords": [
"markdown"
],
"time": "2015-03-01 12:03:08"
"time": "2015-12-24 01:37:31"
},
{
"name": "michelf/php-smartypants",
"version": "1.6.0-beta1",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-smartypants.git",
"reference": "c0465c6d4c5ab853c2fa45df6c10bce7e35cc137"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-smartypants/zipball/c0465c6d4c5ab853c2fa45df6c10bce7e35cc137",
"reference": "c0465c6d4c5ab853c2fa45df6c10bce7e35cc137",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-lib": "1.6.x-dev"
}
},
"autoload": {
"psr-0": {
"Michelf": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Michel Fortin",
"email": "michel.fortin@michelf.ca",
"homepage": "http://michelf.ca/",
"role": "Developer"
},
{
"name": "John Gruber",
"homepage": "http://daringfireball.net/"
}
],
"description": "PHP SmartyPants",
"homepage": "http://michelf.ca/projects/php-smartypants/",
"keywords": [
"dashes",
"quotes",
"spaces",
"typographer",
"typography"
],
"time": "2013-07-31 18:13:10"
},
{
"name": "rmccue/requests",
@ -528,7 +790,9 @@
"packages-dev": null,
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"michelf/php-smartypants": 10
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {

1
vendor/bin/html-to-markdown vendored Symbolic link
View file

@ -0,0 +1 @@
../league/html-to-markdown/bin/html-to-markdown

1
vendor/bin/pscss vendored Symbolic link
View file

@ -0,0 +1 @@
../leafo/scssphp/bin/pscss

View file

@ -238,6 +238,67 @@ return array(
'HTMLPurifier_VarParser_Native' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php',
'HTMLPurifier_Zipper' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php',
'Hautelook\\Phpass\\PasswordHash' => $vendorDir . '/hautelook/phpass/src/Hautelook/Phpass/PasswordHash.php',
'JBBCode\\CodeDefinition' => $vendorDir . '/jbbcode/jbbcode/JBBCode/CodeDefinition.php',
'JBBCode\\CodeDefinitionBuilder' => $vendorDir . '/jbbcode/jbbcode/JBBCode/CodeDefinitionBuilder.php',
'JBBCode\\CodeDefinitionSet' => $vendorDir . '/jbbcode/jbbcode/JBBCode/CodeDefinitionSet.php',
'JBBCode\\DefaultCodeDefinitionSet' => $vendorDir . '/jbbcode/jbbcode/JBBCode/DefaultCodeDefinitionSet.php',
'JBBCode\\DocumentElement' => $vendorDir . '/jbbcode/jbbcode/JBBCode/DocumentElement.php',
'JBBCode\\ElementNode' => $vendorDir . '/jbbcode/jbbcode/JBBCode/ElementNode.php',
'JBBCode\\InputValidator' => $vendorDir . '/jbbcode/jbbcode/JBBCode/InputValidator.php',
'JBBCode\\Node' => $vendorDir . '/jbbcode/jbbcode/JBBCode/Node.php',
'JBBCode\\NodeVisitor' => $vendorDir . '/jbbcode/jbbcode/JBBCode/NodeVisitor.php',
'JBBCode\\Parser' => $vendorDir . '/jbbcode/jbbcode/JBBCode/Parser.php',
'JBBCode\\ParserException' => $vendorDir . '/jbbcode/jbbcode/JBBCode/ParserException.php',
'JBBCode\\TextNode' => $vendorDir . '/jbbcode/jbbcode/JBBCode/TextNode.php',
'JBBCode\\Tokenizer' => $vendorDir . '/jbbcode/jbbcode/JBBCode/Tokenizer.php',
'JBBCode\\validators\\CssColorValidator' => $vendorDir . '/jbbcode/jbbcode/JBBCode/validators/CssColorValidator.php',
'JBBCode\\validators\\UrlValidator' => $vendorDir . '/jbbcode/jbbcode/JBBCode/validators/UrlValidator.php',
'JBBCode\\visitors\\HTMLSafeVisitor' => $vendorDir . '/jbbcode/jbbcode/JBBCode/visitors/HTMLSafeVisitor.php',
'JBBCode\\visitors\\NestLimitVisitor' => $vendorDir . '/jbbcode/jbbcode/JBBCode/visitors/NestLimitVisitor.php',
'JBBCode\\visitors\\SmileyVisitor' => $vendorDir . '/jbbcode/jbbcode/JBBCode/visitors/SmileyVisitor.php',
'JBBCode\\visitors\\TagCountingVisitor' => $vendorDir . '/jbbcode/jbbcode/JBBCode/visitors/TagCountingVisitor.php',
'Leafo\\ScssPhp\\Base\\Range' => $vendorDir . '/leafo/scssphp/src/Base/Range.php',
'Leafo\\ScssPhp\\Block' => $vendorDir . '/leafo/scssphp/src/Block.php',
'Leafo\\ScssPhp\\Colors' => $vendorDir . '/leafo/scssphp/src/Colors.php',
'Leafo\\ScssPhp\\Compiler' => $vendorDir . '/leafo/scssphp/src/Compiler.php',
'Leafo\\ScssPhp\\Compiler\\Environment' => $vendorDir . '/leafo/scssphp/src/Compiler/Environment.php',
'Leafo\\ScssPhp\\Formatter' => $vendorDir . '/leafo/scssphp/src/Formatter.php',
'Leafo\\ScssPhp\\Formatter\\Compact' => $vendorDir . '/leafo/scssphp/src/Formatter/Compact.php',
'Leafo\\ScssPhp\\Formatter\\Compressed' => $vendorDir . '/leafo/scssphp/src/Formatter/Compressed.php',
'Leafo\\ScssPhp\\Formatter\\Crunched' => $vendorDir . '/leafo/scssphp/src/Formatter/Crunched.php',
'Leafo\\ScssPhp\\Formatter\\Debug' => $vendorDir . '/leafo/scssphp/src/Formatter/Debug.php',
'Leafo\\ScssPhp\\Formatter\\Expanded' => $vendorDir . '/leafo/scssphp/src/Formatter/Expanded.php',
'Leafo\\ScssPhp\\Formatter\\Nested' => $vendorDir . '/leafo/scssphp/src/Formatter/Nested.php',
'Leafo\\ScssPhp\\Formatter\\OutputBlock' => $vendorDir . '/leafo/scssphp/src/Formatter/OutputBlock.php',
'Leafo\\ScssPhp\\Node' => $vendorDir . '/leafo/scssphp/src/Node.php',
'Leafo\\ScssPhp\\Node\\Number' => $vendorDir . '/leafo/scssphp/src/Node/Number.php',
'Leafo\\ScssPhp\\Parser' => $vendorDir . '/leafo/scssphp/src/Parser.php',
'Leafo\\ScssPhp\\Server' => $vendorDir . '/leafo/scssphp/src/Server.php',
'Leafo\\ScssPhp\\Type' => $vendorDir . '/leafo/scssphp/src/Type.php',
'Leafo\\ScssPhp\\Util' => $vendorDir . '/leafo/scssphp/src/Util.php',
'Leafo\\ScssPhp\\Version' => $vendorDir . '/leafo/scssphp/src/Version.php',
'League\\HTMLToMarkdown\\Configuration' => $vendorDir . '/league/html-to-markdown/src/Configuration.php',
'League\\HTMLToMarkdown\\ConfigurationAwareInterface' => $vendorDir . '/league/html-to-markdown/src/ConfigurationAwareInterface.php',
'League\\HTMLToMarkdown\\Converter\\BlockquoteConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/BlockquoteConverter.php',
'League\\HTMLToMarkdown\\Converter\\CommentConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/CommentConverter.php',
'League\\HTMLToMarkdown\\Converter\\ConverterInterface' => $vendorDir . '/league/html-to-markdown/src/Converter/ConverterInterface.php',
'League\\HTMLToMarkdown\\Converter\\DefaultConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/DefaultConverter.php',
'League\\HTMLToMarkdown\\Converter\\DivConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/DivConverter.php',
'League\\HTMLToMarkdown\\Converter\\EmphasisConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/EmphasisConverter.php',
'League\\HTMLToMarkdown\\Converter\\HardBreakConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/HardBreakConverter.php',
'League\\HTMLToMarkdown\\Converter\\HeaderConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/HeaderConverter.php',
'League\\HTMLToMarkdown\\Converter\\HorizontalRuleConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/HorizontalRuleConverter.php',
'League\\HTMLToMarkdown\\Converter\\ImageConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/ImageConverter.php',
'League\\HTMLToMarkdown\\Converter\\LinkConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/LinkConverter.php',
'League\\HTMLToMarkdown\\Converter\\ListBlockConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/ListBlockConverter.php',
'League\\HTMLToMarkdown\\Converter\\ListItemConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/ListItemConverter.php',
'League\\HTMLToMarkdown\\Converter\\ParagraphConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/ParagraphConverter.php',
'League\\HTMLToMarkdown\\Converter\\PreformattedConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/PreformattedConverter.php',
'League\\HTMLToMarkdown\\Converter\\TextConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/TextConverter.php',
'League\\HTMLToMarkdown\\Element' => $vendorDir . '/league/html-to-markdown/src/Element.php',
'League\\HTMLToMarkdown\\ElementInterface' => $vendorDir . '/league/html-to-markdown/src/ElementInterface.php',
'League\\HTMLToMarkdown\\Environment' => $vendorDir . '/league/html-to-markdown/src/Environment.php',
'League\\HTMLToMarkdown\\HtmlConverter' => $vendorDir . '/league/html-to-markdown/src/HtmlConverter.php',
'MatthiasMullie\\Minify\\CSS' => $vendorDir . '/matthiasmullie/minify/src/CSS.php',
'MatthiasMullie\\Minify\\Exception' => $vendorDir . '/matthiasmullie/minify/src/Exception.php',
'MatthiasMullie\\Minify\\Exceptions\\BasicException' => $vendorDir . '/matthiasmullie/minify/src/Exceptions/BasicException.php',
@ -304,4 +365,16 @@ return array(
'Requests_Utility_FilteredIterator' => $vendorDir . '/rmccue/requests/library/Requests/Utility/FilteredIterator.php',
'Sunra\\PhpSimple\\HtmlDomParser' => $vendorDir . '/sunra/php-simple-html-dom-parser/Src/Sunra/PhpSimple/HtmlDomParser.php',
'TrueBV\\Punycode' => $vendorDir . '/true/punycode/src/Punycode.php',
'lessc' => $vendorDir . '/leafo/lessphp/lessc.inc.php',
'lessc_formatter_classic' => $vendorDir . '/leafo/lessphp/lessc.inc.php',
'lessc_formatter_compressed' => $vendorDir . '/leafo/lessphp/lessc.inc.php',
'lessc_formatter_lessjs' => $vendorDir . '/leafo/lessphp/lessc.inc.php',
'lessc_parser' => $vendorDir . '/leafo/lessphp/lessc.inc.php',
'scss_formatter' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_formatter_compressed' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_formatter_crunched' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_formatter_nested' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_parser' => $vendorDir . '/leafo/scssphp/classmap.php',
'scss_server' => $vendorDir . '/leafo/scssphp/classmap.php',
'scssc' => $vendorDir . '/leafo/scssphp/classmap.php',
);

View file

@ -8,7 +8,8 @@ $baseDir = dirname($vendorDir);
return array(
'Sunra\\PhpSimple\\HtmlDomParser' => array($vendorDir . '/sunra/php-simple-html-dom-parser/Src'),
'Requests' => array($vendorDir . '/rmccue/requests/library'),
'Michelf' => array($vendorDir . '/michelf/php-markdown'),
'Michelf' => array($vendorDir . '/michelf/php-markdown', $vendorDir . '/michelf/php-smartypants'),
'JBBCode' => array($vendorDir . '/jbbcode/jbbcode'),
'Hautelook' => array($vendorDir . '/hautelook/phpass/src'),
'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
);

View file

@ -9,4 +9,6 @@ return array(
'TrueBV\\' => array($vendorDir . '/true/punycode/src'),
'MatthiasMullie\\PathConverter\\' => array($vendorDir . '/matthiasmullie/path-converter/src'),
'MatthiasMullie\\Minify\\' => array($vendorDir . '/matthiasmullie/minify/src'),
'League\\HTMLToMarkdown\\' => array($vendorDir . '/league/html-to-markdown/src'),
'Leafo\\ScssPhp\\' => array($vendorDir . '/leafo/scssphp/src'),
);

View file

@ -92,59 +92,6 @@
"html"
]
},
{
"name": "michelf/php-markdown",
"version": "1.5.0",
"version_normalized": "1.5.0.0",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-markdown.git",
"reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/e1aabe18173231ebcefc90e615565742fc1c7fd9",
"reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2015-03-01 12:03:08",
"type": "library",
"extra": {
"branch-alias": {
"dev-lib": "1.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Michelf": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "John Gruber",
"homepage": "http://daringfireball.net/"
},
{
"name": "Michel Fortin",
"email": "michel.fortin@michelf.ca",
"homepage": "https://michelf.ca/",
"role": "Developer"
}
],
"description": "PHP Markdown",
"homepage": "https://michelf.ca/projects/php-markdown/",
"keywords": [
"markdown"
]
},
{
"name": "sunra/php-simple-html-dom-parser",
"version": "v1.5.0",
@ -537,5 +484,330 @@
"password",
"security"
]
},
{
"name": "michelf/php-markdown",
"version": "1.6.0",
"version_normalized": "1.6.0.0",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-markdown.git",
"reference": "156e56ee036505ec637d761ee62dc425d807183c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/156e56ee036505ec637d761ee62dc425d807183c",
"reference": "156e56ee036505ec637d761ee62dc425d807183c",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2015-12-24 01:37:31",
"type": "library",
"extra": {
"branch-alias": {
"dev-lib": "1.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Michelf": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Michel Fortin",
"email": "michel.fortin@michelf.ca",
"homepage": "https://michelf.ca/",
"role": "Developer"
},
{
"name": "John Gruber",
"homepage": "https://daringfireball.net/"
}
],
"description": "PHP Markdown",
"homepage": "https://michelf.ca/projects/php-markdown/",
"keywords": [
"markdown"
]
},
{
"name": "jbbcode/jbbcode",
"version": "v1.3.0",
"version_normalized": "1.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/jbowens/jBBCode.git",
"reference": "645b6a1c0afa92b7d029d3417ebd8b60a5c578b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jbowens/jBBCode/zipball/645b6a1c0afa92b7d029d3417ebd8b60a5c578b3",
"reference": "645b6a1c0afa92b7d029d3417ebd8b60a5c578b3",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"time": "2014-07-06 05:48:20",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"JBBCode": "."
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jackson Owens",
"email": "jackson_owens@alumni.brown.edu",
"homepage": "http://jbowens.org/",
"role": "Developer"
}
],
"description": "A lightweight but extensible BBCode parser written in PHP 5.3.",
"homepage": "http://jbbcode.com/",
"keywords": [
"BB",
"bbcode"
]
},
{
"name": "leafo/lessphp",
"version": "v0.5.0",
"version_normalized": "0.5.0.0",
"source": {
"type": "git",
"url": "https://github.com/leafo/lessphp.git",
"reference": "0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/lessphp/zipball/0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283",
"reference": "0f5a7f5545d2bcf4e9fad9a228c8ad89cc9aa283",
"shasum": ""
},
"time": "2014-11-24 18:39:20",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"classmap": [
"lessc.inc.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT",
"GPL-3.0"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"description": "lessphp is a compiler for LESS written in PHP.",
"homepage": "http://leafo.net/lessphp/"
},
{
"name": "leafo/scssphp",
"version": "v0.4.0",
"version_normalized": "0.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/leafo/scssphp.git",
"reference": "78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/leafo/scssphp/zipball/78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a",
"reference": "78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"kherge/box": "~2.5",
"phpunit/phpunit": "~3.7",
"squizlabs/php_codesniffer": "~2.3"
},
"time": "2015-11-09 14:44:09",
"bin": [
"bin/pscss"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"classmap": [
"classmap.php"
],
"psr-4": {
"Leafo\\ScssPhp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"description": "scssphp is a compiler for SCSS written in PHP.",
"homepage": "http://leafo.github.io/scssphp/",
"keywords": [
"css",
"less",
"sass",
"scss",
"stylesheet"
]
},
{
"name": "league/html-to-markdown",
"version": "4.2.0",
"version_normalized": "4.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "9a5becc8c6b520920fb846afefcfd7faf4c31712"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/9a5becc8c6b520920fb846afefcfd7faf4c31712",
"reference": "9a5becc8c6b520920fb846afefcfd7faf4c31712",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-xml": "*",
"php": ">=5.3.3"
},
"require-dev": {
"mikehaertl/php-shellcommand": "~1.1.0",
"phpunit/phpunit": "4.*",
"scrutinizer/ocular": "~1.1"
},
"time": "2016-02-01 16:49:02",
"bin": [
"bin/html-to-markdown"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"League\\HTMLToMarkdown\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "http://www.colinodell.com",
"role": "Lead Developer"
},
{
"name": "Nick Cernis",
"email": "nick@cern.is",
"homepage": "http://modernnerd.net",
"role": "Original Author"
}
],
"description": "An HTML-to-markdown conversion helper for PHP",
"homepage": "https://github.com/thephpleague/html-to-markdown",
"keywords": [
"html",
"markdown"
]
},
{
"name": "michelf/php-smartypants",
"version": "1.6.0-beta1",
"version_normalized": "1.6.0.0-beta1",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-smartypants.git",
"reference": "c0465c6d4c5ab853c2fa45df6c10bce7e35cc137"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-smartypants/zipball/c0465c6d4c5ab853c2fa45df6c10bce7e35cc137",
"reference": "c0465c6d4c5ab853c2fa45df6c10bce7e35cc137",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2013-07-31 18:13:10",
"type": "library",
"extra": {
"branch-alias": {
"dev-lib": "1.6.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Michelf": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Michel Fortin",
"email": "michel.fortin@michelf.ca",
"homepage": "http://michelf.ca/",
"role": "Developer"
},
{
"name": "John Gruber",
"homepage": "http://daringfireball.net/"
}
],
"description": "PHP SmartyPants",
"homepage": "http://michelf.ca/projects/php-smartypants/",
"keywords": [
"dashes",
"quotes",
"spaces",
"typographer",
"typography"
]
}
]

2
vendor/jbbcode/jbbcode/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
composer.lock
vendor

View file

@ -0,0 +1,328 @@
<?php
namespace JBBCode;
/**
* This class represents a BBCode Definition. You may construct instances of this class directly,
* usually through the CodeDefinitionBuilder class, to create text replacement bbcodes, or you
* may subclass it to create more complex bbcode definitions.
*
* @author jbowens
*/
class CodeDefinition
{
/* NOTE: THIS PROPERTY SHOULD ALWAYS BE LOWERCASE; USE setTagName() TO ENSURE THIS */
protected $tagName;
/* Whether or not this CodeDefinition uses an option parameter. */
protected $useOption;
/* The replacement text to be used for simple CodeDefinitions */
protected $replacementText;
/* Whether or not to parse elements of this definition's contents */
protected $parseContent;
/* How many of this element type may be nested within each other */
protected $nestLimit;
/* How many of this element type have been seen */
protected $elCounter;
/* The input validator to run options through */
protected $optionValidator;
/* The input validator to run the body ({param}) through */
protected $bodyValidator;
/**
* Constructs a new CodeDefinition.
*/
public static function construct($tagName, $replacementText, $useOption = false,
$parseContent = true, $nestLimit = -1, $optionValidator = array(),
$bodyValidator = null)
{
$def = new CodeDefinition();
$def->elCounter = 0;
$def->setTagName($tagName);
$def->setReplacementText($replacementText);
$def->useOption = $useOption;
$def->parseContent = $parseContent;
$def->nestLimit = $nestLimit;
$def->optionValidator = $optionValidator;
$def->bodyValidator = $bodyValidator;
return $def;
}
/**
* Constructs a new CodeDefinition.
*
* This constructor is deprecated. You should use the static construct() method or the
* CodeDefinitionBuilder class to construct a new CodeDefiniton.
*
* @deprecated
*/
public function __construct()
{
/* WARNING: This function is deprecated and will be made protected in a future
* version of jBBCode. */
$this->parseContent = true;
$this->useOption = false;
$this->nestLimit = -1;
$this->elCounter = 0;
$this->optionValidator = array();
$this->bodyValidator = null;
}
/**
* Determines if the arguments to the given element are valid based on
* any validators attached to this CodeDefinition.
*
* @param $el the ElementNode to validate
* @return true if the ElementNode's {option} and {param} are OK, false if they're not
*/
public function hasValidInputs(ElementNode $el)
{
if ($this->usesOption() && $this->optionValidator) {
$att = $el->getAttribute();
foreach($att as $name => $value){
if(isset($this->optionValidator[$name]) && !$this->optionValidator[$name]->validate($value)){
return false;
}
}
}
if (!$this->parseContent() && $this->bodyValidator) {
/* We only evaluate the content if we're not parsing the content. */
$content = "";
foreach ($el->getChildren() as $child) {
$content .= $child->getAsBBCode();
}
if (!$this->bodyValidator->validate($content)) {
/* The content of the element is not valid. */
return false;
}
}
return true;
}
/**
* Accepts an ElementNode that is defined by this CodeDefinition and returns the HTML
* markup of the element. This is a commonly overridden class for custom CodeDefinitions
* so that the content can be directly manipulated.
*
* @param $el the element to return an html representation of
*
* @return the parsed html of this element (INCLUDING ITS CHILDREN)
*/
public function asHtml(ElementNode $el)
{
if (!$this->hasValidInputs($el)) {
return $el->getAsBBCode();
}
$html = $this->getReplacementText();
if ($this->usesOption()) {
$options = $el->getAttribute();
if(count($options)==1){
$vals = array_values($options);
$html = str_ireplace('{option}', reset($vals), $html);
}
else{
foreach($options as $key => $val){
$html = str_ireplace('{' . $key . '}', $val, $html);
}
}
}
$content = $this->getContent($el);
$html = str_ireplace('{param}', $content, $html);
return $html;
}
protected function getContent(ElementNode $el){
if ($this->parseContent()) {
$content = "";
foreach ($el->getChildren() as $child)
$content .= $child->getAsHTML();
} else {
$content = "";
foreach ($el->getChildren() as $child)
$content .= $child->getAsBBCode();
}
return $content;
}
/**
* Accepts an ElementNode that is defined by this CodeDefinition and returns the text
* representation of the element. This may be overridden by a custom CodeDefinition.
*
* @param $el the element to return a text representation of
*
* @return the text representation of $el
*/
public function asText(ElementNode $el)
{
if (!$this->hasValidInputs($el)) {
return $el->getAsBBCode();
}
$s = "";
foreach ($el->getChildren() as $child)
$s .= $child->getAsText();
return $s;
}
/**
* Returns the tag name of this code definition
*
* @return this definition's associated tag name
*/
public function getTagName()
{
return $this->tagName;
}
/**
* Returns the replacement text of this code definition. This usually has little, if any meaning if the
* CodeDefinition class was extended. For default, html replacement CodeDefinitions this returns the html
* markup for the definition.
*
* @return the replacement text of this CodeDefinition
*/
public function getReplacementText()
{
return $this->replacementText;
}
/**
* Returns whether or not this CodeDefinition uses the optional {option}
*
* @return true if this CodeDefinition uses the option, false otherwise
*/
public function usesOption()
{
return $this->useOption;
}
/**
* Returns whether or not this CodeDefnition parses elements contained within it,
* or just treats its children as text.
*
* @return true if this CodeDefinition parses elements contained within itself
*/
public function parseContent()
{
return $this->parseContent;
}
/**
* Returns the limit of how many elements defined by this CodeDefinition may be
* nested together. If after parsing elements are nested beyond this limit, the
* subtrees formed by those nodes will be removed from the parse tree. A nest
* limit of -1 signifies no limit.
*/
public function getNestLimit()
{
return $this->nestLimit;
}
/**
* Sets the tag name of this CodeDefinition
*
* @deprecated
*
* @param the new tag name of this definition
*/
public function setTagName($tagName)
{
$this->tagName = strtolower($tagName);
}
/**
* Sets the html replacement text of this CodeDefinition
*
* @deprecated
*
* @param the new replacement text
*/
public function setReplacementText($txt)
{
$this->replacementText = $txt;
}
/**
* Sets whether or not this CodeDefinition uses the {option}
*
* @deprecated
*
* @param boolean $bool
*/
public function setUseOption($bool)
{
$this->useOption = $bool;
}
/**
* Sets whether or not this CodeDefinition allows its children to be parsed as html
*
* @deprecated
*
* @param boolean $bool
*/
public function setParseContent($bool)
{
$this->parseContent = $bool;
}
/**
* Increments the element counter. This is used for tracking depth of elements of the same type for next limits.
*
* @deprecated
*
* @return void
*/
public function incrementCounter()
{
$this->elCounter++;
}
/**
* Decrements the element counter.
*
* @deprecated
*
* @return void
*/
public function decrementCounter()
{
$this->elCounter--;
}
/**
* Resets the element counter.
*
* @deprecated
*/
public function resetCounter()
{
$this->elCounter = 0;
}
/**
* Returns the current value of the element counter.
*
* @deprecated
*
* @return int
*/
public function getCounter()
{
return $this->elCounter;
}
}

View file

@ -0,0 +1,160 @@
<?php
namespace JBBCode;
require_once "CodeDefinition.php";
/**
* Implements the builder pattern for the CodeDefinition class. A builder
* is the recommended way of constructing CodeDefinition objects.
*
* @author jbowens
*/
class CodeDefinitionBuilder
{
protected $tagName;
protected $useOption = false;
protected $replacementText;
protected $parseContent = true;
protected $nestLimit = -1;
protected $optionValidator = array();
protected $bodyValidator = null;
/**
* Construct a CodeDefinitionBuilder.
*
* @param $tagName the tag name of the definition to build
* @param $replacementText the replacement text of the definition to build
*/
public function __construct($tagName, $replacementText)
{
$this->tagName = $tagName;
$this->replacementText = $replacementText;
}
/**
* Sets the tag name the CodeDefinition should be built with.
*
* @param $tagName the tag name for the new CodeDefinition
*/
public function setTagName($tagName)
{
$this->tagName = $tagName;
return $this;
}
/**
* Sets the replacement text that the new CodeDefinition should be
* built with.
*
* @param $replacementText the replacement text for the new CodeDefinition
*/
public function setReplacementText($replacementText)
{
$this->replacementText = $replacementText;
return $this;
}
/**
* Set whether or not the built CodeDefinition should use the {option} bbcode
* argument.
*
* @param $option ture iff the definition includes an option
*/
public function setUseOption($option)
{
$this->useOption = $option;
return $this;
}
/**
* Set whether or not the built CodeDefinition should allow its content
* to be parsed and evaluated as bbcode.
*
* @param $parseContent true iff the content should be parsed
*/
public function setParseContent($parseContent)
{
$this->parseContent = $parseContent;
return $this;
}
/**
* Sets the nest limit for this code definition.
*
* @param $nestLimit a positive integer, or -1 if there is no limit.
* @throws \InvalidArgumentException if the nest limit is invalid
*/
public function setNestLimit($limit)
{
if(!is_int($limit) || ($limit <= 0 && -1 != $limit)) {
throw new \InvalidArgumentException("A nest limit must be a positive integer " .
"or -1.");
}
$this->nestLimit = $limit;
return $this;
}
/**
* Sets the InputValidator that option arguments should be validated with.
*
* @param $validator the InputValidator instance to use
*/
public function setOptionValidator(\JBBCode\InputValidator $validator, $option=null)
{
if(empty($option)){
$option = $this->tagName;
}
$this->optionValidator[$option] = $validator;
return $this;
}
/**
* Sets the InputValidator that body ({param}) text should be validated with.
*
* @param $validator the InputValidator instance to use
*/
public function setBodyValidator(\JBBCode\InputValidator $validator)
{
$this->bodyValidator = $validator;
return $this;
}
/**
* Removes the attached option validator if one is attached.
*/
public function removeOptionValidator()
{
$this->optionValidator = array();
return $this;
}
/**
* Removes the attached body validator if one is attached.
*/
public function removeBodyValidator()
{
$this->bodyValidator = null;
return $this;
}
/**
* Builds a CodeDefinition with the current state of the builder.
*
* @return a new CodeDefinition instance
*/
public function build()
{
$definition = CodeDefinition::construct($this->tagName,
$this->replacementText,
$this->useOption,
$this->parseContent,
$this->nestLimit,
$this->optionValidator,
$this->bodyValidator);
return $definition;
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace JBBCode;
require_once 'CodeDefinition.php';
use JBBCode\CodeDefinition;
/**
* An interface for sets of code definitons.
*
* @author jbowens
*/
interface CodeDefinitionSet
{
/**
* Retrieves the CodeDefinitions within this set as an array.
*/
public function getCodeDefinitions();
}

View file

@ -0,0 +1,75 @@
<?php
namespace JBBCode;
require_once 'CodeDefinition.php';
require_once 'CodeDefinitionBuilder.php';
require_once 'CodeDefinitionSet.php';
require_once 'validators/CssColorValidator.php';
require_once 'validators/UrlValidator.php';
/**
* Provides a default set of common bbcode definitions.
*
* @author jbowens
*/
class DefaultCodeDefinitionSet implements CodeDefinitionSet
{
/* The default code definitions in this set. */
protected $definitions = array();
/**
* Constructs the default code definitions.
*/
public function __construct()
{
/* [b] bold tag */
$builder = new CodeDefinitionBuilder('b', '<strong>{param}</strong>');
array_push($this->definitions, $builder->build());
/* [i] italics tag */
$builder = new CodeDefinitionBuilder('i', '<em>{param}</em>');
array_push($this->definitions, $builder->build());
/* [u] underline tag */
$builder = new CodeDefinitionBuilder('u', '<u>{param}</u>');
array_push($this->definitions, $builder->build());
$urlValidator = new \JBBCode\validators\UrlValidator();
/* [url] link tag */
$builder = new CodeDefinitionBuilder('url', '<a href="{param}">{param}</a>');
$builder->setParseContent(false)->setBodyValidator($urlValidator);
array_push($this->definitions, $builder->build());
/* [url=http://example.com] link tag */
$builder = new CodeDefinitionBuilder('url', '<a href="{option}">{param}</a>');
$builder->setUseOption(true)->setParseContent(true)->setOptionValidator($urlValidator);
array_push($this->definitions, $builder->build());
/* [img] image tag */
$builder = new CodeDefinitionBuilder('img', '<img src="{param}" />');
$builder->setUseOption(false)->setParseContent(false)->setBodyValidator($urlValidator);
array_push($this->definitions, $builder->build());
/* [img=alt text] image tag */
$builder = new CodeDefinitionBuilder('img', '<img src="{param}" alt="{option}" />');
$builder->setUseOption(true)->setParseContent(false)->setBodyValidator($urlValidator);
array_push($this->definitions, $builder->build());
/* [color] color tag */
$builder = new CodeDefinitionBuilder('color', '<span style="color: {option}">{param}</span>');
$builder->setUseOption(true)->setOptionValidator(new \JBBCode\validators\CssColorValidator());
array_push($this->definitions, $builder->build());
}
/**
* Returns an array of the default code definitions.
*/
public function getCodeDefinitions()
{
return $this->definitions;
}
}

View file

@ -0,0 +1,67 @@
<?php
namespace JBBCode;
require_once 'ElementNode.php';
/**
* A DocumentElement object represents the root of a document tree. All
* documents represented by this document model should have one as its root.
*
* @author jbowens
*/
class DocumentElement extends ElementNode
{
/**
* Constructs the document element node
*/
public function __construct()
{
parent::__construct();
$this->setTagName("Document");
$this->setNodeId(0);
}
/**
* (non-PHPdoc)
* @see JBBCode.ElementNode::getAsBBCode()
*
* Returns the BBCode representation of this document
*
* @return this document's bbcode representation
*/
public function getAsBBCode()
{
$s = "";
foreach($this->getChildren() as $child){
$s .= $child->getAsBBCode();
}
return $s;
}
/**
* (non-PHPdoc)
* @see JBBCode.ElementNode::getAsHTML()
*
* Documents don't add any html. They only exist as a container for their
* children, so getAsHTML() simply iterates through the document's children,
* returning their html.
*
* @return the HTML representation of this document
*/
public function getAsHTML()
{
$s = "";
foreach($this->getChildren() as $child)
$s .= $child->getAsHTML();
return $s;
}
public function accept(NodeVisitor $visitor)
{
$visitor->visitDocumentElement($this);
}
}

View file

@ -0,0 +1,241 @@
<?php
namespace JBBCode;
require_once 'Node.php';
/**
* An element within the tree. Consists of a tag name which defines the type of the
* element and any number of Node children. It also contains a CodeDefinition matching
* the tag name of the element.
*
* @author jbowens
*/
class ElementNode extends Node
{
/* The tagname of this element, for i.e. "b" in [b]bold[/b] */
protected $tagName;
/* The attribute, if any, of this element node */
protected $attribute;
/* The child nodes contained within this element */
protected $children;
/* The code definition that defines this element's behavior */
protected $codeDefinition;
/* How deeply this node is nested */
protected $nestDepth;
/**
* Constructs the element node
*/
public function __construct()
{
$this->children = array();
$this->nestDepth = 0;
}
/**
* Accepts the given NodeVisitor. This is part of an implementation
* of the Visitor pattern.
*
* @param $nodeVisitor the visitor attempting to visit this node
*/
public function accept(NodeVisitor $nodeVisitor)
{
$nodeVisitor->visitElementNode($this);
}
/**
* Gets the CodeDefinition that defines this element.
*
* @return this element's code definition
*/
public function getCodeDefinition()
{
return $this->codeDefinition;
}
/**
* Sets the CodeDefinition that defines this element.
*
* @param codeDef the code definition that defines this element node
*/
public function setCodeDefinition(CodeDefinition $codeDef)
{
$this->codeDefinition = $codeDef;
$this->setTagName($codeDef->getTagName());
}
/**
* Returns the tag name of this element.
*
* @return the element's tag name
*/
public function getTagName()
{
return $this->tagName;
}
/**
* Returns the attribute (used as the option in bbcode definitions) of this element.
*
* @return the attribute of this element
*/
public function getAttribute()
{
return $this->attribute;
}
/**
* Returns all the children of this element.
*
* @return an array of this node's child nodes
*/
public function getChildren()
{
return $this->children;
}
/**
* (non-PHPdoc)
* @see JBBCode.Node::getAsText()
*
* Returns the element as text (not including any bbcode markup)
*
* @return the plain text representation of this node
*/
public function getAsText()
{
if ($this->codeDefinition) {
return $this->codeDefinition->asText($this);
} else {
$s = "";
foreach ($this->getChildren() as $child)
$s .= $child->getAsText();
return $s;
}
}
/**
* (non-PHPdoc)
* @see JBBCode.Node::getAsBBCode()
*
* Returns the element as bbcode (with all unclosed tags closed)
*
* @return the bbcode representation of this element
*/
public function getAsBBCode()
{
$str = "[".$this->tagName;
if (!empty($this->attribute)) {
foreach($this->attribute as $key => $value){
if($key == $this->tagName){
$str .= "=".$value;
}
else{
$str .= " ".$key."=" . $value;
}
}
}
$str .= "]";
foreach ($this->getChildren() as $child) {
$str .= $child->getAsBBCode();
}
$str .= "[/".$this->tagName."]";
return $str;
}
/**
* (non-PHPdoc)
* @see JBBCode.Node::getAsHTML()
*
* Returns the element as html with all replacements made
*
* @return the html representation of this node
*/
public function getAsHTML()
{
if($this->codeDefinition) {
return $this->codeDefinition->asHtml($this);
} else {
return "";
}
}
/**
* Adds a child to this node's content. A child may be a TextNode, or
* another ElementNode... or anything else that may extend the
* abstract Node class.
*
* @param child the node to add as a child
*/
public function addChild(Node $child)
{
array_push($this->children, $child);
$child->setParent($this);
}
/**
* Removes a child from this node's contnet.
*
* @param child the child node to remove
*/
public function removeChild(Node $child)
{
foreach ($this->children as $key => $value) {
if ($value == $child)
unset($this->children[$key]);
}
}
/**
* Sets the tag name of this element node.
*
* @param tagName the element's new tag name
*/
public function setTagName($tagName)
{
$this->tagName = $tagName;
}
/**
* Sets the attribute (option) of this element node.
*
* @param attribute the attribute of this element node
*/
public function setAttribute($attribute)
{
$this->attribute = $attribute;
}
/**
* Traverses the parse tree upwards, going from parent to parent, until it finds a
* parent who has the given tag name. Returns the parent with the matching tag name
* if it exists, otherwise returns null.
*
* @param str the tag name to search for
*
* @return the closest parent with the given tag name
*/
public function closestParentOfType($str)
{
$str = strtolower($str);
$currentEl = $this;
while (strtolower($currentEl->getTagName()) != $str && $currentEl->hasParent()) {
$currentEl = $currentEl->getParent();
}
if (strtolower($currentEl->getTagName()) != $str) {
return null;
} else {
return $currentEl;
}
}
}

View file

@ -0,0 +1,20 @@
<?php
namespace JBBCode;
/**
* Defines an interface for validation filters for bbcode options and
* parameters.
*
* @author jbowens
* @since May 2013
*/
interface InputValidator
{
/**
* Returns true iff the given input is valid, false otherwise.
*/
public function validate($input);
}

109
vendor/jbbcode/jbbcode/JBBCode/Node.php vendored Normal file
View file

@ -0,0 +1,109 @@
<?php
namespace JBBCode;
/**
* A node within the document tree.
*
* Known subclasses: TextNode, ElementNode
*
* @author jbowens
*/
abstract class Node
{
/* Pointer to the parent node of this node */
protected $parent;
/* The node id of this node */
protected $nodeid;
/**
* Returns the node id of this node. (Not really ever used. Dependent upon the parse tree the node exists within.)
*
* @return this node's id
*/
public function getNodeId()
{
return $this->nodeid;
}
/**
* Returns this node's immediate parent.
*
* @return the node's parent
*/
public function getParent()
{
return $this->parent;
}
/**
* Determines if this node has a parent.
*
* @return true if this node has a parent, false otherwise
*/
public function hasParent()
{
return $this->parent != null;
}
/**
* Returns true if this is a text node. Returns false otherwise.
* (Overridden by TextNode to return true)
*
* @return true if this node is a text node
*/
public function isTextNode()
{
return false;
}
/**
* Accepts a NodeVisitor
*
* @param nodeVisitor the NodeVisitor traversing the graph
*/
abstract public function accept(NodeVisitor $nodeVisitor);
/**
* Returns this node as text (without any bbcode markup)
*
* @return the plain text representation of this node
*/
abstract public function getAsText();
/**
* Returns this node as bbcode
*
* @return the bbcode representation of this node
*/
abstract public function getAsBBCode();
/**
* Returns this node as HTML
*
* @return the html representation of this node
*/
abstract public function getAsHTML();
/**
* Sets this node's parent to be the given node.
*
* @param parent the node to set as this node's parent
*/
public function setParent(Node $parent)
{
$this->parent = $parent;
}
/**
* Sets this node's nodeid
*
* @param nodeid this node's node id
*/
public function setNodeId($nodeid)
{
$this->nodeid = $nodeid;
}
}

View file

@ -0,0 +1,20 @@
<?php
namespace JBBCode;
/**
* Defines an interface for a visitor to traverse the node graph.
*
* @author jbowens
* @since January 2013
*/
interface NodeVisitor
{
public function visitDocumentElement(DocumentElement $documentElement);
public function visitTextNode(TextNode $textNode);
public function visitElementNode(ElementNode $elementNode);
}

View file

@ -0,0 +1,662 @@
<?php
namespace JBBCode;
require_once 'ElementNode.php';
require_once 'TextNode.php';
require_once 'DefaultCodeDefinitionSet.php';
require_once 'DocumentElement.php';
require_once 'CodeDefinition.php';
require_once 'CodeDefinitionBuilder.php';
require_once 'CodeDefinitionSet.php';
require_once 'NodeVisitor.php';
require_once 'ParserException.php';
require_once 'Tokenizer.php';
require_once 'visitors/NestLimitVisitor.php';
require_once 'InputValidator.php';
use JBBCode\CodeDefinition;
/**
* BBCodeParser is the main parser class that constructs and stores the parse tree. Through this class
* new bbcode definitions can be added, and documents may be parsed and converted to html/bbcode/plaintext, etc.
*
* @author jbowens
*/
class Parser
{
const OPTION_STATE_DEFAULT = 0;
const OPTION_STATE_TAGNAME = 1;
const OPTION_STATE_KEY = 2;
const OPTION_STATE_VALUE = 3;
const OPTION_STATE_QUOTED_VALUE = 4;
const OPTION_STATE_JAVASCRIPT = 5;
/* The root element of the parse tree */
protected $treeRoot;
/* The list of bbcodes to be used by the parser. */
protected $bbcodes;
/* The next node id to use. This is used while parsing. */
protected $nextNodeid;
/**
* Constructs an instance of the BBCode parser
*/
public function __construct()
{
$this->reset();
$this->bbcodes = array();
}
/**
* Adds a simple (text-replacement only) bbcode definition
*
* @param string $tagName the tag name of the code (for example the b in [b])
* @param string $replace the html to use, with {param} and optionally {option} for replacements
* @param boolean $useOption whether or not this bbcode uses the secondary {option} replacement
* @param boolean $parseContent whether or not to parse the content within these elements
* @param integer $nestLimit an optional limit of the number of elements of this kind that can be nested within
* each other before the parser stops parsing them.
* @param InputValidator $optionValidator the validator to run {option} through
* @param BodyValidator $bodyValidator the validator to run {param} through (only used if $parseContent == false)
*
* @return Parser
*/
public function addBBCode($tagName, $replace, $useOption = false, $parseContent = true, $nestLimit = -1,
InputValidator $optionValidator = null, InputValidator $bodyValidator = null)
{
$builder = new CodeDefinitionBuilder($tagName, $replace);
$builder->setUseOption($useOption);
$builder->setParseContent($parseContent);
$builder->setNestLimit($nestLimit);
if ($optionValidator) {
$builder->setOptionValidator($optionValidator);
}
if ($bodyValidator) {
$builder->setBodyValidator($bodyValidator);
}
$this->addCodeDefinition($builder->build());
return $this;
}
/**
* Adds a complex bbcode definition. You may subclass the CodeDefinition class, instantiate a definition of your new
* class and add it to the parser through this method.
*
* @param CodeDefinition $definition the bbcode definition to add
*
* @return Parser
*/
public function addCodeDefinition(CodeDefinition $definition)
{
array_push($this->bbcodes, $definition);
return $this;
}
/**
* Adds a set of CodeDefinitions.
*
* @param CodeDefinitionSet $set the set of definitions to add
*
* @return Parser
*/
public function addCodeDefinitionSet(CodeDefinitionSet $set) {
foreach ($set->getCodeDefinitions() as $def) {
$this->addCodeDefinition($def);
}
return $this;
}
/**
* Returns the entire parse tree as text. Only {param} content is returned. BBCode markup will be ignored.
*
* @return string a text representation of the parse tree
*/
public function getAsText()
{
return $this->treeRoot->getAsText();
}
/**
* Returns the entire parse tree as bbcode. This will be identical to the inputted string, except unclosed tags
* will be closed.
*
* @return string a bbcode representation of the parse tree
*/
public function getAsBBCode()
{
return $this->treeRoot->getAsBBCode();
}
/**
* Returns the entire parse tree as HTML. All BBCode replacements will be made. This is generally the method
* you will want to use to retrieve the parsed bbcode.
*
* @return string a parsed html string
*/
public function getAsHTML()
{
return $this->treeRoot->getAsHTML();
}
/**
* Accepts the given NodeVisitor at the root.
*
* @param NodeVisitor a NodeVisitor
*
* @return Parser
*/
public function accept(NodeVisitor $nodeVisitor)
{
$this->treeRoot->accept($nodeVisitor);
return $this;
}
/**
* Constructs the parse tree from a string of bbcode markup.
*
* @param string $str the bbcode markup to parse
*
* @return Parser
*/
public function parse($str)
{
/* Set the tree root back to a fresh DocumentElement. */
$this->reset();
$parent = $this->treeRoot;
$tokenizer = new Tokenizer($str);
while ($tokenizer->hasNext()) {
$parent = $this->parseStartState($parent, $tokenizer);
if ($parent->getCodeDefinition() && false ===
$parent->getCodeDefinition()->parseContent()) {
/* We're inside an element that does not allow its contents to be parseable. */
$this->parseAsTextUntilClose($parent, $tokenizer);
$parent = $parent->getParent();
}
}
/* We parsed ignoring nest limits. Do an O(n) traversal to remove any elements that
* are nested beyond their CodeDefinition's nest limit. */
$this->removeOverNestedElements();
return $this;
}
/**
* Removes any elements that are nested beyond their nest limit from the parse tree. This
* method is now deprecated. In a future release its access privileges will be made
* protected.
*
* @deprecated
*/
public function removeOverNestedElements()
{
$nestLimitVisitor = new \JBBCode\visitors\NestLimitVisitor();
$this->accept($nestLimitVisitor);
}
/**
* Removes the old parse tree if one exists.
*/
protected function reset()
{
// remove any old tree information
$this->treeRoot = new DocumentElement();
/* The document element is created with nodeid 0. */
$this->nextNodeid = 1;
}
/**
* Determines whether a bbcode exists based on its tag name and whether or not it uses an option
*
* @param string $tagName the bbcode tag name to check
* @param boolean $usesOption whether or not the bbcode accepts an option
*
* @return bool true if the code exists, false otherwise
*/
public function codeExists($tagName, $usesOption = false)
{
foreach ($this->bbcodes as $code) {
if (strtolower($tagName) == $code->getTagName() && $usesOption == $code->usesOption()) {
return true;
}
}
return false;
}
/**
* Returns the CodeDefinition of a bbcode with the matching tag name and usesOption parameter
*
* @param string $tagName the tag name of the bbcode being searched for
* @param boolean $usesOption whether or not the bbcode accepts an option
*
* @return CodeDefinition if the bbcode exists, null otherwise
*/
public function getCode($tagName, $usesOption = false)
{
foreach ($this->bbcodes as $code) {
if (strtolower($tagName) == $code->getTagName() && $code->usesOption() == $usesOption) {
return $code;
}
}
return null;
}
/**
* Adds a set of default, standard bbcode definitions commonly used across the web.
*
* This method is now deprecated. Please use DefaultCodeDefinitionSet and
* addCodeDefinitionSet() instead.
*
* @deprecated
*/
public function loadDefaultCodes()
{
$defaultSet = new DefaultCodeDefinitionSet();
$this->addCodeDefinitionSet($defaultSet);
}
/**
* Creates a new text node with the given parent and text string.
*
* @param $parent the parent of the text node
* @param $string the text of the text node
*
* @return TextNode the newly created TextNode
*/
protected function createTextNode(ElementNode $parent, $string)
{
if (count($parent->getChildren())) {
$children = $parent->getChildren();
$lastElement = end($children);
reset($children);
if ($lastElement->isTextNode()) {
$lastElement->setValue($lastElement->getValue() . $string);
return $lastElement;
}
}
$textNode = new TextNode($string);
$textNode->setNodeId(++$this->nextNodeid);
$parent->addChild($textNode);
return $textNode;
}
/**
* jBBCode parsing logic is loosely modelled after a FSM. While not every function maps
* to a unique DFSM state, each function handles the logic of one or more FSM states.
* This function handles the beginning parse state when we're not currently in a tag
* name.
*
* @param ElementNode $parent the current parent node we're under
* @param Tokenizer $tokenizer the tokenizer we're using
*
* @return ElementNode the new parent we should use for the next iteration.
*/
protected function parseStartState(ElementNode $parent, Tokenizer $tokenizer)
{
$next = $tokenizer->next();
if ('[' == $next) {
return $this->parseTagOpen($parent, $tokenizer);
}
else {
$this->createTextNode($parent, $next);
/* Drop back into the main parse loop which will call this
* same method again. */
return $parent;
}
}
/**
* This function handles parsing the beginnings of an open tag. When we see a [
* at an appropriate time, this function is entered.
*
* @param ElementNode $parent the current parent node
* @param Tokenizer $tokenizer the tokenizer we're using
*
* @return ElementNode the new parent node
*/
protected function parseTagOpen(ElementNode $parent, Tokenizer $tokenizer)
{
if (!$tokenizer->hasNext()) {
/* The [ that sent us to this state was just a trailing [, not the
* opening for a new tag. Treat it as such. */
$this->createTextNode($parent, '[');
return $parent;
}
$next = $tokenizer->next();
/* This while loop could be replaced by a recursive call to this same method,
* which would likely be a lot clearer but I decided to use a while loop to
* prevent stack overflow with a string like [[[[[[[[[...[[[.
*/
while ('[' == $next) {
/* The previous [ was just a random bracket that should be treated as text.
* Continue until we get a non open bracket. */
$this->createTextNode($parent, '[');
if (!$tokenizer->hasNext()) {
$this->createTextNode($parent, '[');
return $parent;
}
$next = $tokenizer->next();
}
if (!$tokenizer->hasNext()) {
$this->createTextNode($parent, '['.$next);
return $parent;
}
$after_next = $tokenizer->next();
$tokenizer->stepBack();
if ($after_next != ']')
{
$this->createTextNode($parent, '['.$next);
return $parent;
}
/* At this point $next is either ']' or plain text. */
if (']' == $next) {
$this->createTextNode($parent, '[');
$this->createTextNode($parent, ']');
return $parent;
} else {
/* $next is plain text... likely a tag name. */
return $this->parseTag($parent, $tokenizer, $next);
}
}
protected function parseOptions($tagContent)
{
$buffer = "";
$tagName = "";
$state = static::OPTION_STATE_TAGNAME;
$keys = array();
$values = array();
$options = array();
$len = strlen($tagContent);
$done = false;
$idx = 0;
try{
while(!$done){
$char = $idx < $len ? $tagContent[$idx]:null;
switch($state){
case static::OPTION_STATE_TAGNAME:
switch($char){
case '=':
$state = static::OPTION_STATE_VALUE;
$tagName = $buffer;
$keys[] = $tagName;
$buffer = "";
break;
case ' ':
$state = static::OPTION_STATE_DEFAULT;
$tagName = $buffer;
$buffer = '';
$keys[] = $tagName;
break;
case null:
$tagName = $buffer;
$buffer = '';
$keys[] = $tagName;
break;
default:
$buffer .= $char;
}
break;
case static::OPTION_STATE_DEFAULT:
switch($char){
case ' ':
// do nothing
default:
$state = static::OPTION_STATE_KEY;
$buffer .= $char;
}
break;
case static::OPTION_STATE_VALUE:
switch($char){
case '"':
$state = static::OPTION_STATE_QUOTED_VALUE;
break;
case null: // intentional fall-through
case ' ': // key=value<space> delimits to next key
$values[] = $buffer;
$buffer = "";
$state = static::OPTION_STATE_KEY;
break;
case ":":
if($buffer=="javascript"){
$state = static::OPTION_STATE_JAVASCRIPT;
}
$buffer .= $char;
break;
default:
$buffer .= $char;
}
break;
case static::OPTION_STATE_JAVASCRIPT:
switch($char){
case ";":
$buffer .= $char;
$values[] = $buffer;
$buffer = "";
$state = static::OPTION_STATE_KEY;
break;
default:
$buffer .= $char;
}
break;
case static::OPTION_STATE_KEY:
switch($char){
case '=':
$state = static::OPTION_STATE_VALUE;
$keys[] = $buffer;
$buffer = '';
break;
case ' ': // ignore <space>key=value
break;
default:
$buffer .= $char;
break;
}
break;
case static::OPTION_STATE_QUOTED_VALUE:
switch($char){
case null:
case '"':
$state = static::OPTION_STATE_KEY;
$values[] = $buffer;
$buffer = '';
// peek ahead. If the next character is not a space or a closing brace, we have a bad tag and need to abort
if(isset($tagContent[$idx+1]) && $tagContent[$idx+1]!=" " && $tagContent[$idx+1]!="]" ){
throw new ParserException("Badly formed attribute: $tagContent");
}
break;
default:
$buffer .= $char;
break;
}
break;
default:
if(!empty($char)){
$state = static::OPTION_STATE_KEY;
}
}
if($idx >= $len){
$done = true;
}
$idx++;
}
if(count($keys) && count($values)){
if(count($keys)==(count($values)+1)){
array_unshift($values, "");
}
$options = array_combine($keys, $values);
}
}
catch(ParserException $e){
// if we're in this state, then something evidently went wrong. We'll consider everything that came after the tagname to be the attribute for that keyname
$options[$tagName]= substr($tagContent, strpos($tagContent, "=")+1);
}
return array($tagName, $options);
}
/**
* This is the next step in parsing a tag. It's possible for it to still be invalid at this
* point but many of the basic invalid tag name conditions have already been handled.
*
* @param ElementNode $parent the current parent element
* @param Tokenizer $tokenizer the tokenizer we're using
* @param string $tagContent the text between the [ and the ], assuming there is actually a ]
*
* @return ElementNode the new parent element
*/
protected function parseTag(ElementNode $parent, Tokenizer $tokenizer, $tagContent)
{
$next;
if (!$tokenizer->hasNext() || ($next = $tokenizer->next()) != ']') {
/* This is a malformed tag. Both the previous [ and the tagContent
* is really just plain text. */
$this->createTextNode($parent, '[');
$this->createTextNode($parent, $tagContent);
return $parent;
}
/* This is a well-formed tag consisting of [something] or [/something], but
* we still need to ensure that 'something' is a valid tag name. Additionally,
* if it's a closing tag, we need to ensure that there was a previous matching
* opening tag.
*/
/* There could be attributes. */
list($tmpTagName, $options) = $this->parseOptions($tagContent);
// $tagPieces = explode('=', $tagContent);
// $tmpTagName = $tagPieces[0];
$actualTagName;
if ('' != $tmpTagName && '/' == $tmpTagName[0]) {
/* This is a closing tag name. */
$actualTagName = substr($tmpTagName, 1);
} else {
$actualTagName = $tmpTagName;
}
if ('' != $tmpTagName && '/' == $tmpTagName[0]) {
/* This is attempting to close an open tag. We must verify that there exists an
* open tag of the same type and that there is no option (options on closing
* tags don't make any sense). */
$elToClose = $parent->closestParentOfType($actualTagName);
if (null == $elToClose || count($options) > 1) {
/* Closing an unopened tag or has an option. Treat everything as plain text. */
$this->createTextNode($parent, '[');
$this->createTextNode($parent, $tagContent);
$this->createTextNode($parent, ']');
return $parent;
} else {
/* We're closing $elToClose. In order to do that, we just need to return
* $elToClose's parent, since that will change our effective parent to be
* elToClose's parent. */
return $elToClose->getParent();
}
}
/* Verify that this is a known bbcode tag name. */
if ('' == $actualTagName || !$this->codeExists($actualTagName, !empty($options))) {
/* This is an invalid tag name! Treat everything we've seen as plain text. */
$this->createTextNode($parent, '[');
$this->createTextNode($parent, $tagContent);
$this->createTextNode($parent, ']');
return $parent;
}
/* If we're here, this is a valid opening tag. Let's make a new node for it. */
$el = new ElementNode();
$el->setNodeId(++$this->nextNodeid);
$code = $this->getCode($actualTagName, !empty($options));
$el->setCodeDefinition($code);
if (!empty($options)) {
/* We have an attribute we should save. */
$el->setAttribute($options);
}
$parent->addChild($el);
return $el;
}
/**
* Handles parsing elements whose CodeDefinitions disable parsing of element
* contents. This function uses a rolling window of 3 tokens until it finds the
* appropriate closing tag or reaches the end of the token stream.
*
* @param ElementNode $parent the current parent element
* @param Tokenizer $tokenizer the tokenizer we're using
*
* @return ElementNode the new parent element
*/
protected function parseAsTextUntilClose(ElementNode $parent, Tokenizer $tokenizer)
{
/* $parent's code definition doesn't allow its contents to be parsed. Here we use
* a sliding window of three tokens until we find [ /tagname ], signifying the
* end of the parent. */
if (!$tokenizer->hasNext()) {
return $parent;
}
$prevPrev = $tokenizer->next();
if (!$tokenizer->hasNext()) {
$this->createTextNode($parent, $prevPrev);
return $parent;
}
$prev = $tokenizer->next();
if (!$tokenizer->hasNext()) {
$this->createTextNode($parent, $prevPrev);
$this->createTextNode($parent, $prev);
return $parent;
}
$curr = $tokenizer->next();
while ('[' != $prevPrev || '/'.$parent->getTagName() != strtolower($prev) ||
']' != $curr) {
$this->createTextNode($parent, $prevPrev);
$prevPrev = $prev;
$prev = $curr;
if (!$tokenizer->hasNext()) {
$this->createTextNode($parent, $prevPrev);
$this->createTextNode($parent, $prev);
return $parent;
}
$curr = $tokenizer->next();
}
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace JBBCode;
use Exception;
class ParserException extends Exception{
}

View file

@ -0,0 +1,102 @@
<?php
namespace JBBCode;
require_once 'Node.php';
/**
* Represents a piece of text data. TextNodes never have children.
*
* @author jbowens
*/
class TextNode extends Node
{
/* The value of this text node */
protected $value;
/**
* Constructs a text node from its text string
*
* @param string $val
*/
public function __construct($val)
{
$this->value = $val;
}
public function accept(NodeVisitor $visitor)
{
$visitor->visitTextNode($this);
}
/**
* (non-PHPdoc)
* @see JBBCode.Node::isTextNode()
*
* returns true
*/
public function isTextNode()
{
return true;
}
/**
* Returns the text string value of this text node.
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* (non-PHPdoc)
* @see JBBCode.Node::getAsText()
*
* Returns the text representation of this node.
*
* @return this node represented as text
*/
public function getAsText()
{
return $this->getValue();
}
/**
* (non-PHPdoc)
* @see JBBCode.Node::getAsBBCode()
*
* Returns the bbcode representation of this node. (Just its value)
*
* @return this node represented as bbcode
*/
public function getAsBBCode()
{
return $this->getValue();
}
/**
* (non-PHPdoc)
* @see JBBCode.Node::getAsHTML()
*
* Returns the html representation of this node. (Just its value)
*
* @return this node represented as HTML
*/
public function getAsHTML()
{
return $this->getValue();
}
/**
* Edits the text value contained within this text node.
*
* @param newValue the new text value of the text node
*/
public function setValue($newValue)
{
$this->value = $newValue;
}
}

View file

@ -0,0 +1,105 @@
<?php
namespace JBBCode;
/**
* This Tokenizer is used while constructing the parse tree. The tokenizer
* handles splitting the input into brackets and miscellaneous text. The
* parser is then built as a FSM ontop of these possible inputs.
*
* @author jbowens
*/
class Tokenizer
{
protected $tokens = array();
protected $i = -1;
/**
* Constructs a tokenizer from the given string. The string will be tokenized
* upon construction.
*
* @param $str the string to tokenize
*/
public function __construct($str)
{
$strStart = 0;
for ($index = 0; $index < strlen($str); ++$index) {
if (']' == $str[$index] || '[' == $str[$index]) {
/* Are there characters in the buffer from a previous string? */
if ($strStart < $index) {
array_push($this->tokens, substr($str, $strStart, $index - $strStart));
$strStart = $index;
}
/* Add the [ or ] to the tokens array. */
array_push($this->tokens, $str[$index]);
$strStart = $index+1;
}
}
if ($strStart < strlen($str)) {
/* There are still characters in the buffer. Add them to the tokens. */
array_push($this->tokens, substr($str, $strStart, strlen($str) - $strStart));
}
}
/**
* Returns true if there is another token in the token stream.
*/
public function hasNext()
{
return count($this->tokens) > 1 + $this->i;
}
/**
* Advances the token stream to the next token and returns the new token.
*/
public function next()
{
if (!$this->hasNext()) {
return null;
} else {
return $this->tokens[++$this->i];
}
}
/**
* Retrieves the current token.
*/
public function current()
{
if ($this->i < 0) {
return null;
} else {
return $this->tokens[$this->i];
}
}
/**
* Moves the token stream back a token.
*/
public function stepBack()
{
if ($this->i > -1) {
$this->i--;
}
}
/**
* Restarts the tokenizer, returning to the beginning of the token stream.
*/
public function restart()
{
$this->i = -1;
}
/**
* toString method that returns the entire string from the current index on.
*/
public function toString()
{
return implode('', array_slice($this->tokens, $this->i + 1));
}
}

View file

@ -0,0 +1,12 @@
<?php
require_once "/path/to/jbbcode/Parser.php";
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$text = "The default codes include: [b]bold[/b], [i]italics[/i], [u]underlining[/u], ";
$text .= "[url=http://jbbcode.com]links[/url], [color=red]color![/color] and more.";
$parser->parse($text);
print $parser->getAsHtml();

View file

@ -0,0 +1,10 @@
<?php
require_once "/path/to/jbbcode/Parser.php";
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$text = "The bbcode in here [b]is never closed!";
$parser->parse($text);
print $parser->getAsBBCode();

View file

@ -0,0 +1,11 @@
<?php
require_once "/path/to/jbbcode/Parser.php";
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$text = "[b][u]There is [i]a lot[/i] of [url=http://en.wikipedia.org/wiki/Markup_language]markup[/url] in this";
$text .= "[color=#333333]text[/color]![/u][/b]";
$parser->parse($text);
print $parser->getAsText();

View file

@ -0,0 +1,7 @@
<?php
require_once "/path/to/jbbcode/Parser.php";
$parser = new JBBCode\Parser();
$parser->addBBCode("quote", '<div class="quote">{param}</div>');
$parser->addBBCode("code", '<pre class="code">{param}</pre>', false, false, 1);

View file

@ -0,0 +1,22 @@
<?php
require_once("../Parser.php");
require_once("../visitors/SmileyVisitor.php");
error_reporting(E_ALL);
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
if (count($argv) < 2) {
die("Usage: " . $argv[0] . " \"bbcode string\"\n");
}
$inputText = $argv[1];
$parser->parse($inputText);
$smileyVisitor = new \JBBCode\visitors\SmileyVisitor();
$parser->accept($smileyVisitor);
echo $parser->getAsHTML() . "\n";

View file

@ -0,0 +1,23 @@
<?php
require_once("../Parser.php");
require_once("../visitors/TagCountingVisitor.php");
error_reporting(E_ALL);
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
if (count($argv) < 3) {
die("Usage: " . $argv[0] . " \"bbcode string\" <tag name to check>\n");
}
$inputText = $argv[1];
$tagName = $argv[2];
$parser->parse($inputText);
$tagCountingVisitor = new \JBBCode\visitors\TagCountingVisitor();
$parser->accept($tagCountingVisitor);
echo $tagCountingVisitor->getFrequency($tagName) . "\n";

View file

@ -0,0 +1,85 @@
<?php
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
/**
* Test cases testing the functionality of parsing bbcode and
* retrieving a bbcode well-formed bbcode representation.
*
* @author jbowens
*/
class BBCodeToBBCodeTest extends PHPUnit_Framework_TestCase
{
/**
* A utility method for these tests that will evaluate its arguments as bbcode with
* a fresh parser loaded with only the default bbcodes. It returns the
* bbcode output, which in most cases should be in the input itself.
*/
private function defaultBBCodeParse($bbcode)
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse($bbcode);
return $parser->getAsBBCode();
}
/**
* Asserts that the given bbcode matches the given text when
* the bbcode is run through defaultBBCodeParse
*/
private function assertBBCodeOutput($bbcode, $text)
{
$this->assertEquals($this->defaultBBCodeParse($bbcode), $text);
}
public function testEmptyString()
{
$this->assertBBCodeOutput('', '');
}
public function testOneTag()
{
$this->assertBBCodeOutput('[b]this is bold[/b]', '[b]this is bold[/b]');
}
public function testOneTagWithSurroundingText()
{
$this->assertBBCodeOutput('buffer text [b]this is bold[/b] buffer text',
'buffer text [b]this is bold[/b] buffer text');
}
public function testMultipleTags()
{
$bbcode = 'this is some text with [b]bold tags[/b] and [i]italics[/i] and ' .
'things like [u]that[/u].';
$bbcodeOutput = 'this is some text with [b]bold tags[/b] and [i]italics[/i] and ' .
'things like [u]that[/u].';
$this->assertBBCodeOutput($bbcode, $bbcodeOutput);
}
public function testCodeOptions()
{
$code = 'This contains a [url=http://jbbcode.com]url[/url] which uses an option.';
$codeOutput = 'This contains a [url=http://jbbcode.com]url[/url] which uses an option.';
$this->assertBBCodeOutput($code, $codeOutput);
}
/**
* @depends testCodeOptions
*/
public function testOmittedOption()
{
$code = 'This doesn\'t use the url option [url]http://jbbcode.com[/url].';
$codeOutput = 'This doesn\'t use the url option [url]http://jbbcode.com[/url].';
$this->assertBBCodeOutput($code, $codeOutput);
}
public function testUnclosedTags()
{
$code = '[b]bold';
$codeOutput = '[b]bold[/b]';
$this->assertBBCodeOutput($code, $codeOutput);
}
}

View file

@ -0,0 +1,78 @@
<?php
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
/**
* Test cases testing the ability to parse bbcode and retrieve a
* plain text representation without any markup.
*
* @author jbowens
*/
class BBCodeToTextTest extends PHPUnit_Framework_TestCase
{
/**
* A utility method for these tests that will evaluate
* its arguments as bbcode with a fresh parser loaded
* with only the default bbcodes. It returns the
* text output.
*/
private function defaultTextParse($bbcode)
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse($bbcode);
return $parser->getAsText();
}
/**
* Asserts that the given bbcode matches the given text when
* the bbcode is run through defaultTextParse
*/
private function assertTextOutput($bbcode, $text)
{
$this->assertEquals($text, $this->defaultTextParse($bbcode));
}
public function testEmptyString()
{
$this->assertTextOutput('', '');
}
public function testOneTag()
{
$this->assertTextOutput('[b]this is bold[/b]', 'this is bold');
}
public function testOneTagWithSurroundingText()
{
$this->assertTextOutput('buffer text [b]this is bold[/b] buffer text',
'buffer text this is bold buffer text');
}
public function testMultipleTags()
{
$bbcode = 'this is some text with [b]bold tags[/b] and [i]italics[/i] and ' .
'things like [u]that[/u].';
$text = 'this is some text with bold tags and italics and things like that.';
$this->assertTextOutput($bbcode, $text);
}
public function testCodeOptions()
{
$code = 'This contains a [url=http://jbbcode.com]url[/url] which uses an option.';
$text = 'This contains a url which uses an option.';
$this->assertTextOutput($code, $text);
}
/**
* @depends testCodeOptions
*/
public function testOmittedOption()
{
$code = 'This doesn\'t use the url option [url]http://jbbcode.com[/url].';
$text = 'This doesn\'t use the url option http://jbbcode.com.';
$this->assertTextOutput($code, $text);
}
}

View file

@ -0,0 +1,54 @@
<?php
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';
/**
* Test cases for the default bbcode set.
*
* @author jbowens
* @since May 2013
*/
class DefaultCodesTest extends PHPUnit_Framework_TestCase
{
/**
* Asserts that the given bbcode string produces the given html string
* when parsed with the default bbcodes.
*/
public function assertProduces($bbcode, $html)
{
$parser = new \JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse($bbcode);
$this->assertEquals($html, $parser->getAsHtml());
}
/**
* Tests the [b] bbcode.
*/
public function testBold()
{
$this->assertProduces('[b]this should be bold[/b]', '<strong>this should be bold</strong>');
}
/**
* Tests the [color] bbcode.
*/
public function testColor()
{
$this->assertProduces('[color=red]red[/color]', '<span style="color: red">red</span>');
}
/**
* Tests the example from the documentation.
*/
public function testExample()
{
$text = "The default codes include: [b]bold[/b], [i]italics[/i], [u]underlining[/u], ";
$text .= "[url=http://jbbcode.com]links[/url], [color=red]color![/color] and more.";
$html = 'The default codes include: <strong>bold</strong>, <em>italics</em>, <u>underlining</u>, ';
$html .= '<a href="http://jbbcode.com">links</a>, <span style="color: red">color!</span> and more.';
$this->assertProduces($text, $html);
}
}

View file

@ -0,0 +1,77 @@
<?php
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
/**
* Test cases testing the HTMLSafe visitor, which escapes all html characters in the source text
*
* @author astax-t
*/
class HTMLSafeTest extends PHPUnit_Framework_TestCase
{
/**
* Asserts that the given bbcode string produces the given html string
* when parsed with the default bbcodes.
*/
public function assertProduces($bbcode, $html)
{
$parser = new \JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse($bbcode);
$htmlsafer = new JBBCode\visitors\HTMLSafeVisitor();
$parser->accept($htmlsafer);
$this->assertEquals($html, $parser->getAsHtml());
}
/**
* Tests escaping quotes and ampersands in simple text
*/
public function testQuoteAndAmp()
{
$this->assertProduces('te"xt te&xt', 'te&quot;xt te&amp;xt');
}
/**
* Tests escaping quotes and ampersands inside a BBCode tag
*/
public function testQuoteAndAmpInTag()
{
$this->assertProduces('[b]te"xt te&xt[/b]', '<strong>te&quot;xt te&amp;xt</strong>');
}
/**
* Tests escaping HTML tags
*/
public function testHtmlTag()
{
$this->assertProduces('<b>not bold</b>', '&lt;b&gt;not bold&lt;/b&gt;');
$this->assertProduces('[b]<b>bold</b>[/b] <hr>', '<strong>&lt;b&gt;bold&lt;/b&gt;</strong> &lt;hr&gt;');
}
/**
* Tests escaping ampersands in URL using [url]...[/url]
*/
public function testUrlParam()
{
$this->assertProduces('text [url]http://example.com/?a=b&c=d[/url] more text', 'text <a href="http://example.com/?a=b&amp;c=d">http://example.com/?a=b&amp;c=d</a> more text');
}
/**
* Tests escaping ampersands in URL using [url=...] tag
*/
public function testUrlOption()
{
$this->assertProduces('text [url=http://example.com/?a=b&c=d]this is a "link"[/url]', 'text <a href="http://example.com/?a=b&amp;c=d">this is a &quot;link&quot;</a>');
}
/**
* Tests escaping ampersands in URL using [url=...] tag when URL is in quotes
*/
public function testUrlOptionQuotes()
{
$this->assertProduces('text [url="http://example.com/?a=b&c=d"]this is a "link"[/url]', 'text <a href="http://example.com/?a=b&amp;c=d">this is a &quot;link&quot;</a>');
}
}

View file

@ -0,0 +1,46 @@
<?php
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';
/**
* Test cases for CodeDefinition nest limits. If an element is nested beyond
* its CodeDefinition's nest limit, it should be removed from the parse tree.
*
* @author jbowens
* @since May 2013
*/
class NestLimitTest extends PHPUnit_Framework_TestCase
{
/**
* Tests that when elements have no nest limits they may be
* nested indefinitely.
*/
public function testIndefiniteNesting()
{
$parser = new JBBCode\Parser();
$parser->addBBCode('b', '<strong>{param}</strong>', false, true, -1);
$parser->parse('[b][b][b][b][b][b][b][b]bold text[/b][/b][/b][/b][/b][/b][/b][/b]');
$this->assertEquals('<strong><strong><strong><strong><strong><strong><strong><strong>' .
'bold text' .
'</strong></strong></strong></strong></strong></strong></strong></strong>',
$parser->getAsHtml());
}
/**
* Test over nesting.
*/
public function testOverNesting()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->addBBCode('quote', '<blockquote>{param}</blockquote>', false, true, 2);
$bbcode = '[quote][quote][quote]wut[/quote] huh?[/quote] i don\'t know[/quote]';
$parser->parse($bbcode);
$expectedBbcode = '[quote][quote] huh?[/quote] i don\'t know[/quote]';
$expectedHtml = '<blockquote><blockquote> huh?</blockquote> i don\'t know</blockquote>';
$this->assertEquals($expectedBbcode, $parser->getAsBBCode());
$this->assertEquals($expectedHtml, $parser->getAsHtml());
}
}

View file

@ -0,0 +1,97 @@
<?php
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';
/**
* Test cases for the code definition parameter that disallows parsing
* of an element's content.
*
* @author jbowens
*/
class ParseContentTest extends PHPUnit_Framework_TestCase
{
/**
* Tests that when a bbcode is created with parseContent = false,
* its contents actually are not parsed.
*/
public function testSimpleNoParsing()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->addBBCode('verbatim', '{param}', false, false);
$parser->parse('[verbatim]plain text[/verbatim]');
$this->assertEquals('plain text', $parser->getAsHtml());
$parser->parse('[verbatim][b]bold[/b][/verbatim]');
$this->assertEquals('[b]bold[/b]', $parser->getAsHtml());
}
public function testNoParsingWithBufferText()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->addBBCode('verbatim', '{param}', false, false);
$parser->parse('buffer text[verbatim]buffer text[b]bold[/b]buffer text[/verbatim]buffer text');
$this->assertEquals('buffer textbuffer text[b]bold[/b]buffer textbuffer text', $parser->getAsHtml());
}
/**
* Tests that when a tag is not closed within an unparseable tag,
* the BBCode output does not automatically close that tag (because
* the contents were not parsed).
*/
public function testUnclosedTag()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->addBBCode('verbatim', '{param}', false, false);
$parser->parse('[verbatim]i wonder [b]what will happen[/verbatim]');
$this->assertEquals('i wonder [b]what will happen', $parser->getAsHtml());
$this->assertEquals('[verbatim]i wonder [b]what will happen[/verbatim]', $parser->getAsBBCode());
}
/**
* Tests that an unclosed tag with parseContent = false ends cleanly.
*/
public function testUnclosedVerbatimTag()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->addBBCode('verbatim', '{param}', false, false);
$parser->parse('[verbatim]yo this [b]text should not be bold[/b]');
$this->assertEquals('yo this [b]text should not be bold[/b]', $parser->getAsHtml());
}
/**
* Tests a malformed closing tag for a verbatim block.
*/
public function testMalformedVerbatimClosingTag()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->addBBCode('verbatim', '{param}', false, false);
$parser->parse('[verbatim]yo this [b]text should not be bold[/b][/verbatim');
$this->assertEquals('yo this [b]text should not be bold[/b][/verbatim', $parser->getAsHtml());
}
/**
* Tests an immediate end after a verbatim.
*/
public function testVerbatimThenEof()
{
$parser = new JBBCode\Parser();
$parser->addBBCode('verbatim', '{param}', false, false);
$parser->parse('[verbatim]');
$this->assertEquals('', $parser->getAsHtml());
}
}

View file

@ -0,0 +1,130 @@
<?php
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
/**
* A series of test cases for various potential parsing edge cases. This
* includes a lot of tests using brackets for things besides genuine tag
* names.
*
* @author jbowens
*
*/
class ParsingEdgeCaseTest extends PHPUnit_Framework_TestCase
{
/**
* A utility method for these tests that will evaluate
* its arguments as bbcode with a fresh parser loaded
* with only the default bbcodes. It returns the
* html output.
*/
private function defaultParse($bbcode)
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse($bbcode);
return $parser->getAsHtml();
}
/**
* Asserts that the given bbcode matches the given html when
* the bbcode is run through defaultParse.
*/
private function assertProduces($bbcode, $html)
{
$this->assertEquals($html, $this->defaultParse($bbcode));
}
/**
* Tests attempting to use a code that doesn't exist.
*/
public function testNonexistentCodeMalformed()
{
$this->assertProduces('[wat]', '[wat]');
}
/**
* Tests attempting to use a code that doesn't exist, but this
* time in a well-formed fashion.
*
* @depends testNonexistentCodeMalformed
*/
public function testNonexistentCodeWellformed()
{
$this->assertProduces('[wat]something[/wat]', '[wat]something[/wat]');
}
/**
* Tests a whole bunch of meaningless left brackets.
*/
public function testAllLeftBrackets()
{
$this->assertProduces('[[[[[[[[', '[[[[[[[[');
}
/**
* Tests a whole bunch of meaningless right brackets.
*/
public function testAllRightBrackets()
{
$this->assertProduces(']]]]]', ']]]]]');
}
/**
* Intermixes well-formed, meaningful tags with meaningless brackets.
*/
public function testRandomBracketsInWellformedCode()
{
$this->assertProduces('[b][[][[i]heh[/i][/b]',
'<strong>[[][<em>heh</em></strong>');
}
/**
* Tests an unclosed tag within a closed tag.
*/
public function testUnclosedWithinClosed()
{
$this->assertProduces('[url=http://jbbcode.com][b]oh yeah[/url]',
'<a href="http://jbbcode.com"><strong>oh yeah</strong></a>');
}
/**
* Tests half completed opening tag.
*/
public function testHalfOpenTag()
{
$this->assertProduces('[b', '[b');
$this->assertProduces('wut [url=http://jbbcode.com',
'wut [url=http://jbbcode.com');
}
/**
* Tests half completed closing tag.
*/
public function testHalfClosingTag()
{
$this->assertProduces('[b]this should be bold[/b',
'<strong>this should be bold[/b</strong>');
}
/**
* Tests lots of left brackets before the actual tag. For example:
* [[[[[[[[b]bold![/b]
*/
public function testLeftBracketsThenTag()
{
$this->assertProduces('[[[[[b]bold![/b]',
'[[[[<strong>bold!</strong>');
}
/**
* Tests a whitespace after left bracket.
*/
public function testWhitespaceAfterLeftBracketWhithoutTag()
{
$this->assertProduces('[ ABC ] ',
'[ ABC ] ');
}
}

View file

@ -0,0 +1,131 @@
<?php
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
class SimpleEvaluationTest extends PHPUnit_Framework_TestCase
{
/**
* A utility method for these tests that will evaluate
* its arguments as bbcode with a fresh parser loaded
* with only the default bbcodes. It returns the
* html output.
*/
private function defaultParse($bbcode)
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse($bbcode);
return $parser->getAsHtml();
}
/**
* Asserts that the given bbcode matches the given html when
* the bbcode is run through defaultParse.
*/
private function assertProduces($bbcode, $html)
{
$this->assertEquals($html, $this->defaultParse($bbcode));
}
public function testEmptyString()
{
$this->assertProduces('', '');
}
public function testOneTag()
{
$this->assertProduces('[b]this is bold[/b]', '<strong>this is bold</strong>');
}
public function testOneTagWithSurroundingText()
{
$this->assertProduces('buffer text [b]this is bold[/b] buffer text',
'buffer text <strong>this is bold</strong> buffer text');
}
public function testMultipleTags()
{
$bbcode = <<<EOD
this is some text with [b]bold tags[/b] and [i]italics[/i] and
things like [u]that[/u].
EOD;
$html = <<<EOD
this is some text with <strong>bold tags</strong> and <em>italics</em> and
things like <u>that</u>.
EOD;
$this->assertProduces($bbcode, $html);
}
public function testCodeOptions()
{
$code = 'This contains a [url=http://jbbcode.com/?b=2]url[/url] which uses an option.';
$html = 'This contains a <a href="http://jbbcode.com/?b=2">url</a> which uses an option.';
$this->assertProduces($code, $html);
}
public function testAttributes()
{
$parser = new JBBCode\Parser();
$builder = new JBBCode\CodeDefinitionBuilder('img', '<img src="{param}" height="{height}" alt="{alt}" />');
$parser->addCodeDefinition($builder->setUseOption(true)->setParseContent(false)->build());
$expected = 'Multiple <img src="http://jbbcode.com/img.png" height="50" alt="alt text" /> options.';
$code = 'Multiple [img height="50" alt="alt text"]http://jbbcode.com/img.png[/img] options.';
$parser->parse($code);
$result = $parser->getAsHTML();
$this->assertEquals($expected, $result);
$code = 'Multiple [img height=50 alt="alt text"]http://jbbcode.com/img.png[/img] options.';
$parser->parse($code);
$result = $parser->getAsHTML();
$this->assertEquals($expected, $result);
}
/**
* @depends testCodeOptions
*/
public function testOmittedOption()
{
$code = 'This doesn\'t use the url option [url]http://jbbcode.com[/url].';
$html = 'This doesn\'t use the url option <a href="http://jbbcode.com">http://jbbcode.com</a>.';
$this->assertProduces($code, $html);
}
public function testUnclosedTag()
{
$code = 'hello [b]world';
$html = 'hello <strong>world</strong>';
$this->assertProduces($code, $html);
}
public function testNestingTags()
{
$code = '[url=http://jbbcode.com][b]hello [u]world[/u][/b][/url]';
$html = '<a href="http://jbbcode.com"><strong>hello <u>world</u></strong></a>';
$this->assertProduces($code, $html);
}
public function testBracketInTag()
{
$this->assertProduces('[b]:-[[/b]', '<strong>:-[</strong>');
}
public function testBracketWithSpaceInTag()
{
$this->assertProduces('[b]:-[ [/b]', '<strong>:-[ </strong>');
}
public function testBracketWithTextInTag()
{
$this->assertProduces('[b]:-[ foobar[/b]', '<strong>:-[ foobar</strong>');
}
public function testMultibleBracketsWithTextInTag()
{
$this->assertProduces('[b]:-[ [fo[o[bar[/b]', '<strong>:-[ [fo[o[bar</strong>');
}
}

View file

@ -0,0 +1,74 @@
<?php
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Tokenizer.php');
/**
* Test cases testing the functionality of the Tokenizer. The tokenizer
* is used by the parser to make parsing simpler.
*
* @author jbowens
*/
class TokenizerTest extends PHPUnit_Framework_TestCase
{
public function testEmptyString()
{
$tokenizer = new JBBCode\Tokenizer('');
$this->assertFalse($tokenizer->hasNext());
}
public function testPlainTextOnly()
{
$tokenizer = new JBBCode\Tokenizer('this is some plain text.');
$this->assertEquals('this is some plain text.', $tokenizer->next());
$this->assertEquals('this is some plain text.', $tokenizer->current());
$this->assertFalse($tokenizer->hasNext());
}
public function testStartingBracket()
{
$tokenizer = new JBBCode\Tokenizer('[this has a starting bracket.');
$this->assertEquals('[', $tokenizer->next());
$this->assertEquals('[', $tokenizer->current());
$this->assertEquals('this has a starting bracket.', $tokenizer->next());
$this->assertEquals('this has a starting bracket.', $tokenizer->current());
$this->assertFalse($tokenizer->hasNext());
$this->assertEquals(null, $tokenizer->next());
}
public function testOneTag()
{
$tokenizer = new JBBCode\Tokenizer('[b]');
$this->assertEquals('[', $tokenizer->next());
$this->assertEquals('b', $tokenizer->next());
$this->assertEquals(']', $tokenizer->next());
$this->assertFalse($tokenizer->hasNext());
}
public function testMatchingTags()
{
$tokenizer = new JBBCode\Tokenizer('[url]http://jbbcode.com[/url]');
$this->assertEquals('[', $tokenizer->next());
$this->assertEquals('url', $tokenizer->next());
$this->assertEquals(']', $tokenizer->next());
$this->assertEquals('http://jbbcode.com', $tokenizer->next());
$this->assertEquals('[', $tokenizer->next());
$this->assertEquals('/url', $tokenizer->next());
$this->assertEquals(']', $tokenizer->next());
$this->assertFalse($tokenizer->hasNext());
}
public function testLotsOfBrackets()
{
$tokenizer = new JBBCode\Tokenizer('[[][]][');
$this->assertEquals('[', $tokenizer->next());
$this->assertEquals('[', $tokenizer->next());
$this->assertEquals(']', $tokenizer->next());
$this->assertEquals('[', $tokenizer->next());
$this->assertEquals(']', $tokenizer->next());
$this->assertEquals(']', $tokenizer->next());
$this->assertEquals('[', $tokenizer->next());
$this->assertFalse($tokenizer->hasNext());
}
}

View file

@ -0,0 +1,151 @@
<?php
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'validators' . DIRECTORY_SEPARATOR . 'UrlValidator.php';
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'validators' . DIRECTORY_SEPARATOR . 'CssColorValidator.php';
/**
* Test cases for InputValidators.
*
* @author jbowens
* @since May 2013
*/
class ValidatorTest extends PHPUnit_Framework_TestCase
{
/**
* Tests an invalid url directly on the UrlValidator.
*/
public function testInvalidUrl()
{
$urlValidator = new \JBBCode\validators\UrlValidator();
$this->assertFalse($urlValidator->validate('#yolo#swag'));
$this->assertFalse($urlValidator->validate('giehtiehwtaw352353%3'));
}
/**
* Tests a valid url directly on the UrlValidator.
*/
public function testValidUrl()
{
$urlValidator = new \JBBCode\validators\UrlValidator();
$this->assertTrue($urlValidator->validate('http://google.com'));
$this->assertTrue($urlValidator->validate('http://jbbcode.com/docs'));
$this->assertTrue($urlValidator->validate('https://www.maps.google.com'));
}
/**
* Tests an invalid url as an option to a url bbcode.
*
* @depends testInvalidUrl
*/
public function testInvalidOptionUrlBBCode()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse('[url=javascript:alert("HACKED!");]click me[/url]');
$this->assertEquals('[url=javascript:alert("HACKED!");]click me[/url]',
$parser->getAsHtml());
}
/**
* Tests an invalid url as the body to a url bbcode.
*
* @depends testInvalidUrl
*/
public function testInvalidBodyUrlBBCode()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse('[url]javascript:alert("HACKED!");[/url]');
$this->assertEquals('[url]javascript:alert("HACKED!");[/url]', $parser->getAsHtml());
}
/**
* Tests a valid url as the body to a url bbcode.
*
* @depends testValidUrl
*/
public function testValidUrlBBCode()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse('[url]http://jbbcode.com[/url]');
$this->assertEquals('<a href="http://jbbcode.com">http://jbbcode.com</a>',
$parser->getAsHtml());
}
/**
* Tests valid english CSS color descriptions on the CssColorValidator.
*/
public function testCssColorEnglish()
{
$colorValidator = new JBBCode\validators\CssColorValidator();
$this->assertTrue($colorValidator->validate('red'));
$this->assertTrue($colorValidator->validate('yellow'));
$this->assertTrue($colorValidator->validate('LightGoldenRodYellow'));
}
/**
* Tests valid hexadecimal CSS color values on the CssColorValidator.
*/
public function testCssColorHex()
{
$colorValidator = new JBBCode\validators\CssColorValidator();
$this->assertTrue($colorValidator->validate('#000'));
$this->assertTrue($colorValidator->validate('#ff0000'));
$this->assertTrue($colorValidator->validate('#aaaaaa'));
}
/**
* Tests valid rgba CSS color values on the CssColorValidator.
*/
public function testCssColorRgba()
{
$colorValidator = new JBBCode\validators\CssColorValidator();
$this->assertTrue($colorValidator->validate('rgba(255, 0, 0, 0.5)'));
$this->assertTrue($colorValidator->validate('rgba(50, 50, 50, 0.0)'));
}
/**
* Tests invalid CSS color values on the CssColorValidator.
*/
public function testInvalidCssColor()
{
$colorValidator = new JBBCode\validators\CssColorValidator();
$this->assertFalse($colorValidator->validate('" onclick="javascript: alert(\"gotcha!\");'));
$this->assertFalse($colorValidator->validate('"><marquee scrollamount="100'));
}
/**
* Tests valid css colors in a color bbcode.
*
* @depends testCssColorEnglish
* @depends testCssColorHex
*/
public function testValidColorBBCode()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse('[color=red]colorful text[/color]');
$this->assertEquals('<span style="color: red">colorful text</span>',
$parser->getAsHtml());
$parser->parse('[color=#00ff00]green[/color]');
$this->assertEquals('<span style="color: #00ff00">green</span>', $parser->getAsHtml());
}
/**
* Tests invalid css colors in a color bbcode.
*
* @depends testInvalidCssColor
*/
public function testInvalidColorBBCode()
{
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$parser->parse('[color=" onclick="alert(\'hey ya!\');]click me[/color]');
$this->assertEquals('[color=" onclick="alert(\'hey ya!\');]click me[/color]',
$parser->getAsHtml());
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace JBBCode\validators;
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'InputValidator.php';
/**
* An InputValidator for CSS color values. This is a very rudimentary
* validator. It will allow a lot of color values that are invalid. However,
* it shouldn't allow any invalid color values that are also a security
* concern.
*
* @author jbowens
* @since May 2013
*/
class CssColorValidator implements \JBBCode\InputValidator
{
/**
* Returns true if $input uses only valid CSS color value
* characters.
*
* @param $input the string to validate
*/
public function validate($input)
{
return (bool) preg_match('/^[A-z0-9\-#., ()%]+$/', $input);
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace JBBCode\validators;
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'InputValidator.php';
/**
* An InputValidator for urls. This can be used to make [url] bbcodes secure.
*
* @author jbowens
* @since May 2013
*/
class UrlValidator implements \JBBCode\InputValidator
{
/**
* Returns true iff $input is a valid url.
*
* @param $input the string to validate
*/
public function validate($input)
{
$valid = filter_var($input, FILTER_VALIDATE_URL);
return !!$valid;
}
}

View file

@ -0,0 +1,52 @@
<?php
namespace JBBCode\visitors;
/**
* This visitor escapes html content of all strings and attributes
*
* @author Alexander Polyanskikh
*/
class HTMLSafeVisitor implements \JBBCode\NodeVisitor
{
public function visitDocumentElement(\JBBCode\DocumentElement $documentElement)
{
foreach ($documentElement->getChildren() as $child) {
$child->accept($this);
}
}
public function visitTextNode(\JBBCode\TextNode $textNode)
{
$textNode->setValue($this->htmlSafe($textNode->getValue()));
}
public function visitElementNode(\JBBCode\ElementNode $elementNode)
{
$attrs = $elementNode->getAttribute();
if (is_array($attrs))
{
foreach ($attrs as &$el)
$el = $this->htmlSafe($el);
$elementNode->setAttribute($attrs);
}
foreach ($elementNode->getChildren() as $child) {
$child->accept($this);
}
}
protected function htmlSafe($str, $options = null)
{
if (is_null($options))
{
if (defined('ENT_DISALLOWED'))
$options = ENT_QUOTES | ENT_DISALLOWED | ENT_HTML401; // PHP 5.4+
else
$options = ENT_QUOTES; // PHP 5.3
}
return htmlspecialchars($str, $options, 'UTF-8');
}
}

View file

@ -0,0 +1,65 @@
<?php
namespace JBBCode\visitors;
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'CodeDefinition.php';
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'DocumentElement.php';
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'ElementNode.php';
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'NodeVisitor.php';
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TextNode.php';
/**
* This visitor is used by the jBBCode core to enforce nest limits after
* parsing. It traverses the parse graph depth first, removing any subtrees
* that are nested deeper than an element's code definition allows.
*
* @author jbowens
* @since May 2013
*/
class NestLimitVisitor implements \JBBCode\NodeVisitor
{
/* A map from tag name to current depth. */
protected $depth = array();
public function visitDocumentElement(\JBBCode\DocumentElement $documentElement)
{
foreach($documentElement->getChildren() as $child) {
$child->accept($this);
}
}
public function visitTextNode(\JBBCode\TextNode $textNode)
{
/* Nothing to do. Text nodes don't have tag names or children. */
}
public function visitElementNode(\JBBCode\ElementNode $elementNode)
{
$tagName = strtolower($elementNode->getTagName());
/* Update the current depth for this tag name. */
if (isset($this->depth[$tagName])) {
$this->depth[$tagName]++;
} else {
$this->depth[$tagName] = 1;
}
/* Check if $elementNode is nested too deeply. */
if ($elementNode->getCodeDefinition()->getNestLimit() != -1 &&
$elementNode->getCodeDefinition()->getNestLimit() < $this->depth[$tagName]) {
/* This element is nested too deeply. We need to remove it and not visit any
* of its children. */
$elementNode->getParent()->removeChild($elementNode);
} else {
/* This element is not nested too deeply. Visit all of its children. */
foreach ($elementNode->getChildren() as $child) {
$child->accept($this);
}
}
/* Now that we're done visiting this node, decrement the depth. */
$this->depth[$tagName]--;
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace JBBCode\visitors;
/**
* This visitor is an example of how to implement smiley parsing on the JBBCode
* parse graph. It converts :) into image tags pointing to /smiley.png.
*
* @author jbowens
* @since April 2013
*/
class SmileyVisitor implements \JBBCode\NodeVisitor
{
function visitDocumentElement(\JBBCode\DocumentElement $documentElement)
{
foreach($documentElement->getChildren() as $child) {
$child->accept($this);
}
}
function visitTextNode(\JBBCode\TextNode $textNode)
{
/* Convert :) into an image tag. */
$textNode->setValue(str_replace(':)',
'<img src="/smiley.png" alt=":)" />',
$textNode->getValue()));
}
function visitElementNode(\JBBCode\ElementNode $elementNode)
{
/* We only want to visit text nodes within elements if the element's
* code definition allows for its content to be parsed.
*/
if ($elementNode->getCodeDefinition()->parseContent()) {
foreach ($elementNode->getChildren() as $child) {
$child->accept($this);
}
}
}
}

View file

@ -0,0 +1,60 @@
<?php
namespace JBBCode\visitors;
/**
* This visitor traverses parse graph, counting the number of times each
* tag name occurs.
*
* @author jbowens
* @since January 2013
*/
class TagCountingVisitor implements \JBBcode\NodeVisitor
{
protected $frequencies = array();
public function visitDocumentElement(\JBBCode\DocumentElement $documentElement)
{
foreach ($documentElement->getChildren() as $child) {
$child->accept($this);
}
}
public function visitTextNode(\JBBCode\TextNode $textNode)
{
// Nothing to do here, text nodes do not have tag names or children
}
public function visitElementNode(\JBBCode\ElementNode $elementNode)
{
$tagName = strtolower($elementNode->getTagName());
// Update this tag name's frequency
if (isset($this->frequencies[$tagName])) {
$this->frequencies[$tagName]++;
} else {
$this->frequencies[$tagName] = 1;
}
// Visit all the node's childrens
foreach ($elementNode->getChildren() as $child) {
$child->accept($this);
}
}
/**
* Retrieves the frequency of the given tag name.
*
* @param $tagName the tag name to look up
*/
public function getFrequency($tagName)
{
if (!isset($this->frequencies[$tagName])) {
return 0;
} else {
return $this->frequencies[$tagName];
}
}
}

78
vendor/jbbcode/jbbcode/README.md vendored Normal file
View file

@ -0,0 +1,78 @@
jBBCode
=======
jBBCode is a bbcode parser written in php 5.3. It's relatively lightweight and parses
bbcodes without resorting to expensive regular expressions.
Documentation
-------------
For complete documentation and examples visit [jbbcode.com](http://jbbcode.com).
###A basic example
jBBCode includes a few optional, default bbcode definitions that may be loaded through the
`DefaultCodeDefinitionSet` class. Below is a simple example of using these codes to convert
a bbcode string to html.
```php
<?php
require_once "/path/to/jbbcode/Parser.php";
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
$text = "The default codes include: [b]bold[/b], [i]italics[/i], [u]underlining[/u], ";
$text .= "[url=http://jbbcode.com]links[/url], [color=red]color![/color] and more.";
$parser->parse($text);
print $parser->getAsHtml();
```
Contribute
----------
I would love help maintaining jBBCode. Look at [open issues](http://github.com/jbowens/jBBCode/issues) for ideas on
what needs to be done. Before submitting a pull request, verify that all unit tests still pass.
#### Running unit tests
To run the unit tests,
ensure that [phpunit](http://github.com/sebastianbergmann/phpunit) is installed, or install it through the composer
dev dependencies. Then run `phpunit ./tests` from the project directory. If you're adding new functionality, writing
additional unit tests is a great idea.
Author
------
jBBCode was written by Jackson Owens. You may reach him at [jackson_owens@brown.edu](mailto:jackson_owens@brown.edu).
Other languages
---------------
This library is in the process of being ported to java. For more information, see [jBBCode-java](https://github.com/jbowens/jBBCode-java).
License
-------
The MIT License
Copyright (c) 2011 Jackson Owens
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

31
vendor/jbbcode/jbbcode/composer.json vendored Normal file
View file

@ -0,0 +1,31 @@
{
"name": "jbbcode/jbbcode",
"type": "library",
"description": "A lightweight but extensible BBCode parser written in PHP 5.3.",
"keywords": ["BBCode", "BB"],
"homepage": "http://jbbcode.com/",
"license": "MIT",
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"config": {
"bin-dir": "/usr/local/bin"
},
"authors": [
{
"name": "Jackson Owens",
"email": "jackson_owens@brown.edu",
"homepage": "http://jbowens.org/",
"role": "Developer"
}
],
"autoload": {
"psr-0": {
"JBBCode": "."
}
},
"minimum-stability": "stable"
}

8
vendor/leafo/lessphp/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
*.swp
*~
/*.less
/*.css
tests/bootstrap
tests/tmp
vendor
composer.lock

17
vendor/leafo/lessphp/.travis.yml vendored Normal file
View file

@ -0,0 +1,17 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- hhvm
before_script:
- composer self-update
- composer install --no-interaction --prefer-source --dev
script:
- phpunit tests
matrix:
fast_finish: true

660
vendor/leafo/lessphp/LICENSE vendored Normal file
View file

@ -0,0 +1,660 @@
For ease of distribution, lessphp 0.4.0 is under a dual license.
You are free to pick which one suits your needs.
MIT LICENSE
Copyright (c) 2013 Leaf Corcoran, http://leafo.net/lessphp
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
GPL VERSION 3
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

7
vendor/leafo/lessphp/Makefile vendored Normal file
View file

@ -0,0 +1,7 @@
test:
phpunit --colors tests
release:
./package.sh

96
vendor/leafo/lessphp/README.md vendored Normal file
View file

@ -0,0 +1,96 @@
[![Build Status](https://travis-ci.org/leafo/lessphp.svg?branch=master)](https://travis-ci.org/leafo/lessphp)
# lessphp v0.5.0
### <http://leafo.net/lessphp>
`lessphp` is a compiler for LESS written in PHP. The documentation is great,
so check it out: <http://leafo.net/lessphp/docs/>.
Here's a quick tutorial:
### How to use in your PHP project
The only file required is `lessc.inc.php`, so copy that to your include directory.
The typical flow of **lessphp** is to create a new instance of `lessc`,
configure it how you like, then tell it to compile something using one built in
compile methods.
The `compile` method compiles a string of LESS code to CSS.
```php
<?php
require "lessc.inc.php";
$less = new lessc;
echo $less->compile(".block { padding: 3 + 4px }");
```
The `compileFile` method reads and compiles a file. It will either return the
result or write it to the path specified by an optional second argument.
```php
<?php
echo $less->compileFile("input.less");
```
The `compileChecked` method is like `compileFile`, but it only compiles if the output
file doesn't exist or it's older than the input file:
```php
<?php
$less->checkedCompile("input.less", "output.css");
```
If there any problem compiling your code, an exception is thrown with a helpful message:
```php
<?php
try {
$less->compile("invalid LESS } {");
} catch (exception $e) {
echo "fatal error: " . $e->getMessage();
}
```
The `lessc` object can be configured through an assortment of instance methods.
Some possible configuration options include [changing the output format][1],
[setting variables from PHP][2], and [controlling the preservation of
comments][3], writing [custom functions][4] and much more. It's all described
in [the documentation][0].
[0]: http://leafo.net/lessphp/docs/
[1]: http://leafo.net/lessphp/docs/#output_formatting
[2]: http://leafo.net/lessphp/docs/#setting_variables_from_php
[3]: http://leafo.net/lessphp/docs/#preserving_comments
[4]: http://leafo.net/lessphp/docs/#custom_functions
### How to use from the command line
An additional script has been included to use the compiler from the command
line. In the simplest invocation, you specify an input file and the compiled
css is written to standard out:
$ plessc input.less > output.css
Using the -r flag, you can specify LESS code directly as an argument or, if
the argument is left off, from standard in:
$ plessc -r "my less code here"
Finally, by using the -w flag you can watch a specified input file and have it
compile as needed to the output file:
$ plessc -w input-file output-file
Errors from watch mode are written to standard out.
The -f flag sets the [output formatter][1]. For example, to compress the
output run this:
$ plessc -f=compressed myfile.less
For more help, run `plessc --help`

25
vendor/leafo/lessphp/composer.json vendored Normal file
View file

@ -0,0 +1,25 @@
{
"name": "leafo/lessphp",
"type": "library",
"description": "lessphp is a compiler for LESS written in PHP.",
"homepage": "http://leafo.net/lessphp/",
"license": [
"MIT",
"GPL-3.0"
],
"authors": [
{
"name": "Leaf Corcoran",
"email": "leafot@gmail.com",
"homepage": "http://leafo.net"
}
],
"autoload": {
"classmap": ["lessc.inc.php"]
},
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
}
}
}

1400
vendor/leafo/lessphp/docs/docs.md vendored Normal file

File diff suppressed because it is too large Load diff

3768
vendor/leafo/lessphp/lessc.inc.php vendored Normal file

File diff suppressed because it is too large Load diff

23
vendor/leafo/lessphp/lessify vendored Normal file
View file

@ -0,0 +1,23 @@
#!/usr/bin/php
<?php
if (php_sapi_name() != "cli") {
err($fa.$argv[0]." must be run in the command line.");
exit(1);
}
$exe = array_shift($argv); // remove filename
if (!$fname = array_shift($argv)) {
exit("Usage: ".$exe." input-file\n");
}
require "lessify.inc.php";
try {
$parser = new lessify($fname);
echo $parser->parse();
} catch (exception $e) {
exit("Fatal error: ".$e->getMessage()."\n");
}

447
vendor/leafo/lessphp/lessify.inc.php vendored Normal file
View file

@ -0,0 +1,447 @@
<?php
/**
* lessify
* Convert a css file into a less file
* http://leafo.net/lessphp
* Copyright 2010, leaf corcoran <leafot@gmail.com>
*
* WARNING: THIS DOES NOT WORK ANYMORE. NEEDS TO BE UPDATED FOR
* LATEST VERSION OF LESSPHP.
*
*/
require "lessc.inc.php";
//
// check if the merge during mixin is overwriting values. should or should it not?
//
//
// 1. split apart class tags
//
class easyparse {
var $buffer;
var $count;
function __construct($str) {
$this->count = 0;
$this->buffer = trim($str);
}
function seek($where = null) {
if ($where === null) return $this->count;
else $this->count = $where;
return true;
}
function preg_quote($what) {
return preg_quote($what, '/');
}
function match($regex, &$out, $eatWhitespace = true) {
$r = '/'.$regex.($eatWhitespace ? '\s*' : '').'/Ais';
if (preg_match($r, $this->buffer, $out, null, $this->count)) {
$this->count += strlen($out[0]);
return true;
}
return false;
}
function literal($what, $eatWhitespace = true) {
// this is here mainly prevent notice from { } string accessor
if ($this->count >= strlen($this->buffer)) return false;
// shortcut on single letter
if (!$eatWhitespace and strlen($what) == 1) {
if ($this->buffer{$this->count} == $what) {
$this->count++;
return true;
}
else return false;
}
return $this->match($this->preg_quote($what), $m, $eatWhitespace);
}
}
class tagparse extends easyparse {
static private $combinators = null;
static private $match_opts = null;
function parse() {
if (empty(self::$combinators)) {
self::$combinators = '('.implode('|', array_map(array($this, 'preg_quote'),
array('+', '>', '~'))).')';
self::$match_opts = '('.implode('|', array_map(array($this, 'preg_quote'),
array('=', '~=', '|=', '$=', '*='))).')';
}
// crush whitespace
$this->buffer = preg_replace('/\s+/', ' ', $this->buffer).' ';
$tags = array();
while ($this->tag($t)) $tags[] = $t;
return $tags;
}
static function compileString($string) {
list(, $delim, $str) = $string;
$str = str_replace($delim, "\\".$delim, $str);
$str = str_replace("\n", "\\\n", $str);
return $delim.$str.$delim;
}
static function compilePaths($paths) {
return implode(', ', array_map(array('self', 'compilePath'), $paths));
}
// array of tags
static function compilePath($path) {
return implode(' ', array_map(array('self', 'compileTag'), $path));
}
static function compileTag($tag) {
ob_start();
if (isset($tag['comb'])) echo $tag['comb']." ";
if (isset($tag['front'])) echo $tag['front'];
if (isset($tag['attr'])) {
echo '['.$tag['attr'];
if (isset($tag['op'])) {
echo $tag['op'].$tag['op_value'];
}
echo ']';
}
return ob_get_clean();
}
function string(&$out) {
$s = $this->seek();
if ($this->literal('"')) {
$delim = '"';
} elseif ($this->literal("'")) {
$delim = "'";
} else {
return false;
}
while (true) {
// step through letters looking for either end or escape
$buff = "";
$escapeNext = false;
$finished = false;
for ($i = $this->count; $i < strlen($this->buffer); $i++) {
$char = $this->buffer[$i];
switch ($char) {
case $delim:
if ($escapeNext) {
$buff .= $char;
$escapeNext = false;
break;
}
$finished = true;
break 2;
case "\\":
if ($escapeNext) {
$buff .= $char;
$escapeNext = false;
} else {
$escapeNext = true;
}
break;
case "\n":
if (!$escapeNext) {
break 3;
}
$buff .= $char;
$escapeNext = false;
break;
default:
if ($escapeNext) {
$buff .= "\\";
$escapeNext = false;
}
$buff .= $char;
}
}
if (!$finished) break;
$out = array('string', $delim, $buff);
$this->seek($i+1);
return true;
}
$this->seek($s);
return false;
}
function tag(&$out) {
$s = $this->seek();
$tag = array();
if ($this->combinator($op)) $tag['comb'] = $op;
if (!$this->match('(.*?)( |$|\[|'.self::$combinators.')', $match)) {
$this->seek($s);
return false;
}
if (!empty($match[3])) {
// give back combinator
$this->count-=strlen($match[3]);
}
if (!empty($match[1])) $tag['front'] = $match[1];
if ($match[2] == '[') {
if ($this->ident($i)) {
$tag['attr'] = $i;
if ($this->match(self::$match_opts, $m) && $this->value($v)) {
$tag['op'] = $m[1];
$tag['op_value'] = $v;
}
if ($this->literal(']')) {
$out = $tag;
return true;
}
}
} elseif (isset($tag['front'])) {
$out = $tag;
return true;
}
$this->seek($s);
return false;
}
function ident(&$out) {
// [-]?{nmstart}{nmchar}*
// nmstart: [_a-z]|{nonascii}|{escape}
// nmchar: [_a-z0-9-]|{nonascii}|{escape}
if ($this->match('(-?[_a-z][_\w]*)', $m)) {
$out = $m[1];
return true;
}
return false;
}
function value(&$out) {
if ($this->string($str)) {
$out = $this->compileString($str);
return true;
} elseif ($this->ident($id)) {
$out = $id;
return true;
}
return false;
}
function combinator(&$op) {
if ($this->match(self::$combinators, $m)) {
$op = $m[1];
return true;
}
return false;
}
}
class nodecounter {
var $count = 0;
var $children = array();
var $name;
var $child_blocks;
var $the_block;
function __construct($name) {
$this->name = $name;
}
function dump($stack = null) {
if (is_null($stack)) $stack = array();
$stack[] = $this->getName();
echo implode(' -> ', $stack)." ($this->count)\n";
foreach ($this->children as $child) {
$child->dump($stack);
}
}
static function compileProperties($c, $block) {
foreach($block as $name => $value) {
if ($c->isProperty($name, $value)) {
echo $c->compileProperty($name, $value)."\n";
}
}
}
function compile($c, $path = null) {
if (is_null($path)) $path = array();
$path[] = $this->name;
$isVisible = !is_null($this->the_block) || !is_null($this->child_blocks);
if ($isVisible) {
echo $c->indent(implode(' ', $path).' {');
$c->indentLevel++;
$path = array();
if ($this->the_block) {
$this->compileProperties($c, $this->the_block);
}
if ($this->child_blocks) {
foreach ($this->child_blocks as $block) {
echo $c->indent(tagparse::compilePaths($block['__tags']).' {');
$c->indentLevel++;
$this->compileProperties($c, $block);
$c->indentLevel--;
echo $c->indent('}');
}
}
}
// compile child nodes
foreach($this->children as $node) {
$node->compile($c, $path);
}
if ($isVisible) {
$c->indentLevel--;
echo $c->indent('}');
}
}
function getName() {
if (is_null($this->name)) return "[root]";
else return $this->name;
}
function getNode($name) {
if (!isset($this->children[$name])) {
$this->children[$name] = new nodecounter($name);
}
return $this->children[$name];
}
function findNode($path) {
$current = $this;
for ($i = 0; $i < count($path); $i++) {
$t = tagparse::compileTag($path[$i]);
$current = $current->getNode($t);
}
return $current;
}
function addBlock($path, $block) {
$node = $this->findNode($path);
if (!is_null($node->the_block)) throw new exception("can this happen?");
unset($block['__tags']);
$node->the_block = $block;
}
function addToNode($path, $block) {
$node = $this->findNode($path);
$node->child_blocks[] = $block;
}
}
/**
* create a less file from a css file by combining blocks where appropriate
*/
class lessify extends lessc {
public function dump() {
print_r($this->env);
}
public function parse($str = null) {
$this->prepareParser($str ? $str : $this->buffer);
while (false !== $this->parseChunk());
$root = new nodecounter(null);
// attempt to preserve some of the block order
$order = array();
$visitedTags = array();
foreach (end($this->env) as $name => $block) {
if (!$this->isBlock($name, $block)) continue;
if (isset($visitedTags[$name])) continue;
foreach ($block['__tags'] as $t) {
$visitedTags[$t] = true;
}
// skip those with more than 1
if (count($block['__tags']) == 1) {
$p = new tagparse(end($block['__tags']));
$path = $p->parse();
$root->addBlock($path, $block);
$order[] = array('compressed', $path, $block);
continue;
} else {
$common = null;
$paths = array();
foreach ($block['__tags'] as $rawtag) {
$p = new tagparse($rawtag);
$paths[] = $path = $p->parse();
if (is_null($common)) $common = $path;
else {
$new_common = array();
foreach ($path as $tag) {
$head = array_shift($common);
if ($tag == $head) {
$new_common[] = $head;
} else break;
}
$common = $new_common;
if (empty($common)) {
// nothing in common
break;
}
}
}
if (!empty($common)) {
$new_paths = array();
foreach ($paths as $p) $new_paths[] = array_slice($p, count($common));
$block['__tags'] = $new_paths;
$root->addToNode($common, $block);
$order[] = array('compressed', $common, $block);
continue;
}
}
$order[] = array('none', $block['__tags'], $block);
}
$compressed = $root->children;
foreach ($order as $item) {
list($type, $tags, $block) = $item;
if ($type == 'compressed') {
$top = tagparse::compileTag(reset($tags));
if (isset($compressed[$top])) {
$compressed[$top]->compile($this);
unset($compressed[$top]);
}
} else {
echo $this->indent(implode(', ', $tags).' {');
$this->indentLevel++;
nodecounter::compileProperties($this, $block);
$this->indentLevel--;
echo $this->indent('}');
}
}
}
}

35
vendor/leafo/lessphp/package.sh vendored Normal file
View file

@ -0,0 +1,35 @@
#!/bin/sh
# creates tar.gz for current version
VERSION=`./plessc -v | sed -n 's/^v\(.*\)$/\1/p'`
OUT_DIR="tmp/lessphp"
TMP=`dirname $OUT_DIR`
mkdir -p $OUT_DIR
tar -c `git ls-files` | tar -C $OUT_DIR -x
rm $OUT_DIR/.gitignore
rm $OUT_DIR/package.sh
rm $OUT_DIR/lessify
rm $OUT_DIR/lessify.inc.php
OUT_NAME="lessphp-$VERSION.tar.gz"
tar -czf $OUT_NAME -C $TMP lessphp/
echo "Wrote $OUT_NAME"
rm -r $TMP
echo
echo "Don't forget to"
echo "* Update the version in lessc.inc.php (two places)"
echo "* Update the version in the README.md"
echo "* Update the version in docs.md (two places)"
echo "* Update the version in LICENSE"
echo "* Update @current_version in site.moon"
echo "* Add entry to feed.moon for changelog"
echo "* Update the -New- area on homepage with date and features"
echo

250
vendor/leafo/lessphp/plessc vendored Normal file
View file

@ -0,0 +1,250 @@
#!/usr/bin/env php
<?php
// Command line utility to compile LESS to STDOUT
// Leaf Corcoran <leafot@gmail.com>, 2013
$exe = array_shift($argv); // remove filename
$HELP = <<<EOT
Usage: $exe [options] input-file [output-file]
Options include:
-h, --help Show this message
-v Print the version
-f=format Set the output format, includes "default", "compressed"
-c Keep /* */ comments in output
-r Read from STDIN instead of input-file
-w Watch input-file, and compile to output-file if it is changed
-T Dump formatted parse tree
-X Dump raw parse tree
EOT;
$opts = getopt('hvrwncXTf:', array('help'));
while (count($argv) > 0 && preg_match('/^-([-hvrwncXT]$|[f]=)/', $argv[0])) {
array_shift($argv);
}
function has() {
global $opts;
foreach (func_get_args() as $arg) {
if (isset($opts[$arg])) return true;
}
return false;
}
if (has("h", "help")) {
exit($HELP);
}
error_reporting(E_ALL);
$path = realpath(dirname(__FILE__)).'/';
require $path."lessc.inc.php";
$VERSION = lessc::$VERSION;
$fa = "Fatal Error: ";
function err($msg) {
fwrite(STDERR, $msg."\n");
}
if (php_sapi_name() != "cli") {
err($fa.$argv[0]." must be run in the command line.");
exit(1);
}
function make_less($fname = null) {
global $opts;
$l = new lessc($fname);
if (has("f")) {
$format = $opts["f"];
if ($format != "default") $l->setFormatter($format);
}
if (has("c")) {
$l->setPreserveComments(true);
}
return $l;
}
function process($data, $import = null) {
global $fa;
$l = make_less();
if ($import) $l->importDir = $import;
try {
echo $l->parse($data);
exit(0);
} catch (exception $ex) {
err($fa."\n".str_repeat('=', 20)."\n".
$ex->getMessage());
exit(1);
}
}
if (has("v")) {
exit($VERSION."\n");
}
if (has("r")) {
if (!empty($argv)) {
$data = $argv[0];
} else {
$data = "";
while (!feof(STDIN)) {
$data .= fread(STDIN, 8192);
}
}
exit(process($data));
}
if (has("w")) {
// need two files
if (!is_file($in = array_shift($argv)) ||
null == $out = array_shift($argv))
{
err($fa.$exe." -w infile outfile");
exit(1);
}
echo "Watching ".$in.
(has("n") ? ' with notifications' : '').
", press Ctrl + c to exit.\n";
$cache = $in;
$last_action = 0;
while (true) {
clearstatcache();
// check if anything has changed since last fail
$updated = false;
if (is_array($cache)) {
foreach ($cache['files'] as $fname=>$_) {
if (filemtime($fname) > $last_action) {
$updated = true;
break;
}
}
} else $updated = true;
// try to compile it
if ($updated) {
$last_action = time();
try {
$cache = lessc::cexecute($cache);
echo "Writing updated file: ".$out."\n";
if (!file_put_contents($out, $cache['compiled'])) {
err($fa."Could not write to file ".$out);
exit(1);
}
} catch (exception $ex) {
echo "\nFatal Error:\n".str_repeat('=', 20)."\n".
$ex->getMessage()."\n\n";
if (has("n")) {
`notify-send -u critical "compile failed" "{$ex->getMessage()}"`;
}
}
}
sleep(1);
}
exit(0);
}
if (!$fname = array_shift($argv)) {
echo $HELP;
exit(1);
}
function dumpValue($node, $depth = 0) {
if (is_object($node)) {
$indent = str_repeat(" ", $depth);
$out = array();
foreach ($node->props as $prop) {
$out[] = $indent . dumpValue($prop, $depth + 1);
}
$out = implode("\n", $out);
if (!empty($node->tags)) {
$out = "+ ".implode(", ", $node->tags)."\n".$out;
}
return $out;
} elseif (is_array($node)) {
if (empty($node)) return "[]";
$type = $node[0];
if ($type == "block")
return dumpValue($node[1], $depth);
$out = array();
foreach ($node as $value) {
$out[] = dumpValue($value, $depth);
}
return "{ ".implode(", ", $out)." }";
} else {
if (is_string($node) && preg_match("/[\s,]/", $node)) {
return '"'.$node.'"';
}
return $node; // normal value
}
}
function stripValue($o, $toStrip) {
if (is_array($o) || is_object($o)) {
$isObject = is_object($o);
$o = (array)$o;
foreach ($toStrip as $removeKey) {
if (!empty($o[$removeKey])) {
$o[$removeKey] = "*stripped*";
}
}
foreach ($o as $k => $v) {
$o[$k] = stripValue($v, $toStrip);
}
if ($isObject) {
$o = (object)$o;
}
}
return $o;
}
function dumpWithoutParent($o, $alsoStrip=array()) {
$toStrip = array_merge(array("parent"), $alsoStrip);
print_r(stripValue($o, $toStrip));
}
try {
$less = make_less($fname);
if (has("T", "X")) {
$parser = new lessc_parser($less, $fname);
$tree = $parser->parse(file_get_contents($fname));
if (has("X"))
$out = print_r($tree, 1);
else
$out = dumpValue($tree)."\n";
} else {
$out = $less->parse();
}
if (!$fout = array_shift($argv)) {
echo $out;
} else {
file_put_contents($fout, $out);
}
} catch (exception $ex) {
err($fa.$ex->getMessage());
exit(1);
}
?>

196
vendor/leafo/lessphp/tests/ApiTest.php vendored Normal file
View file

@ -0,0 +1,196 @@
<?php
require_once __DIR__ . "/../lessc.inc.php";
class ApiTest extends PHPUnit_Framework_TestCase {
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array(__DIR__ . "/inputs/test-imports");
}
public function testPreserveComments() {
$input = <<<EOD
// what is going on?
/** what the heck **/
/**
Here is a block comment
**/
// this is a comment
/*hello*/div /*yeah*/ { //surew
border: 1px solid red; // world
/* comment above the first occurrence of a duplicated rule */
color: url('http://mage-page.com');
string: "hello /* this is not a comment */";
world: "// neither is this";
/* comment above the second occurrence of a duplicated rule */
color: url('http://mage-page.com');
string: 'hello /* this is not a comment */' /*what if this is a comment */;
world: '// neither is this' // hell world;
;
/* duplicate comments are retained */
/* duplicate comments are retained */
what-ever: 100px;
background: url(/*this is not a comment?*/); // uhh what happens here
}
EOD;
$outputWithComments = <<<EOD
/** what the heck **/
/**
Here is a block comment
**/
/*hello*/
/*yeah*/
div /*yeah*/ {
border: 1px solid red;
/* comment above the first occurrence of a duplicated rule */
/* comment above the second occurrence of a duplicated rule */
color: url('http://mage-page.com');
string: "hello /* this is not a comment */";
world: "// neither is this";
/*what if this is a comment */
string: 'hello /* this is not a comment */';
world: '// neither is this';
/* duplicate comments are retained */
/* duplicate comments are retained */
what-ever: 100px;
/*this is not a comment?*/
background: url();
}
EOD;
$outputWithoutComments = <<<EOD
div {
border: 1px solid red;
color: url('http://mage-page.com');
string: "hello /* this is not a comment */";
world: "// neither is this";
string: 'hello /* this is not a comment */';
world: '// neither is this';
what-ever: 100px;
background: url(/*this is not a comment?*/);
}
EOD;
$this->assertEquals($this->compile($input), trim($outputWithoutComments));
$this->less->setPreserveComments(true);
$this->assertEquals($this->compile($input), trim($outputWithComments));
}
public function testOldInterface() {
$this->less = new lessc(__DIR__ . "/inputs/hi.less");
$out = $this->less->parse(array("hello" => "10px"));
$this->assertEquals(trim($out), trim('
div:before {
content: "hi!";
}'));
}
public function testInjectVars() {
$out = $this->less->parse(".magic { color: @color; width: @base - 200; }",
array(
'color' => 'red',
'base' => '960px'
));
$this->assertEquals(trim($out), trim("
.magic {
color: red;
width: 760px;
}"));
}
public function testDisableImport() {
$this->less->importDisabled = true;
$this->assertEquals(
"/* import disabled */",
$this->compile("@import 'file3';"));
}
public function testUserFunction() {
$this->less->registerFunction("add-two", function($list) {
list($a, $b) = $list[2];
return $a[1] + $b[1];
});
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: 30;");
return $this->less;
}
/**
* @depends testUserFunction
*/
public function testUnregisterFunction($less) {
$less->unregisterFunction("add-two");
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: add-two(10,20);");
}
public function testFormatters() {
$src = "
div, pre {
color: blue;
span, .big, hello.world {
height: 20px;
color:#ffffff + #000;
}
}";
$this->less->setFormatter("compressed");
$this->assertEquals(
$this->compile($src), "div,pre{color:blue;}div span,div .big,div hello.world,pre span,pre .big,pre hello.world{height:20px;color:#fff;}");
// TODO: fix the output order of tags
$this->less->setFormatter("lessjs");
$this->assertEquals(
$this->compile($src),
"div,
pre {
color: blue;
}
div span,
div .big,
div hello.world,
pre span,
pre .big,
pre hello.world {
height: 20px;
color: #ffffff;
}");
$this->less->setFormatter("classic");
$this->assertEquals(
$this->compile($src),
trim("div, pre { color:blue; }
div span, div .big, div hello.world, pre span, pre .big, pre hello.world {
height:20px;
color:#ffffff;
}
"));
}
public function compile($str) {
return trim($this->less->parse($str));
}
}

View file

@ -0,0 +1,81 @@
<?php
require_once __DIR__ . "/../lessc.inc.php";
class ErrorHandlingTest extends PHPUnit_Framework_TestCase {
public function setUp() {
$this->less = new lessc();
}
public function compile() {
$source = join("\n", func_get_args());
return $this->less->compile($source);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .parametric-mixin is undefined
*/
public function testRequiredParametersMissing() {
$this->compile(
'.parametric-mixin (@a, @b) { a: @a; b: @b; }',
'.selector { .parametric-mixin(12px); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .parametric-mixin is undefined
*/
public function testTooManyParameters() {
$this->compile(
'.parametric-mixin (@a, @b) { a: @a; b: @b; }',
'.selector { .parametric-mixin(12px, 13px, 14px); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage unrecognised input
*/
public function testRequiredArgumentsMissing() {
$this->compile('.selector { rule: e(); }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage variable @missing is undefined
*/
public function testVariableMissing() {
$this->compile('.selector { rule: @missing; }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage .missing-mixin is undefined
*/
public function testMixinMissing() {
$this->compile('.selector { .missing-mixin; }');
}
/**
* @expectedException Exception
* @expectedExceptionMessage .flipped is undefined
*/
public function testGuardUnmatchedValue() {
$this->compile(
'.flipped(@x) when (@x =< 10) { rule: value; }',
'.selector { .flipped(12); }'
);
}
/**
* @expectedException Exception
* @expectedExceptionMessage .colors-only is undefined
*/
public function testGuardUnmatchedType() {
$this->compile(
'.colors-only(@x) when (iscolor(@x)) { rule: value; }',
'.selector { .colors-only("string value"); }'
);
}
}

View file

@ -0,0 +1,89 @@
<?php
require_once __DIR__ . "/../lessc.inc.php";
// Runs all the tests in inputs/ and compares their output to ouputs/
function _dump($value) {
fwrite(STDOUT, print_r($value, true));
}
function _quote($str) {
return preg_quote($str, "/");
}
class InputTest extends PHPUnit_Framework_TestCase {
protected static $importDirs = array("inputs/test-imports");
protected static $testDirs = array(
"inputs" => "outputs",
"inputs_lessjs" => "outputs_lessjs",
);
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array_map(function($path) {
return __DIR__ . "/" . $path;
}, self::$importDirs);
}
/**
* @dataProvider fileNameProvider
*/
public function testInputFile($inFname) {
if ($pattern = getenv("BUILD")) {
return $this->buildInput($inFname);
}
$outFname = self::outputNameFor($inFname);
if (!is_readable($outFname)) {
$this->fail("$outFname is missing, ".
"consider building tests with BUILD=true");
}
$input = file_get_contents($inFname);
$output = file_get_contents($outFname);
$this->assertEquals($output, $this->less->parse($input));
}
public function fileNameProvider() {
return array_map(function($a) { return array($a); },
self::findInputNames());
}
// only run when env is set
public function buildInput($inFname) {
$css = $this->less->parse(file_get_contents($inFname));
file_put_contents(self::outputNameFor($inFname), $css);
}
static public function findInputNames($pattern="*.less") {
$files = array();
foreach (self::$testDirs as $inputDir => $outputDir) {
$files = array_merge($files, glob(__DIR__ . "/" . $inputDir . "/" . $pattern));
}
return array_filter($files, "is_file");
}
static public function outputNameFor($input) {
$front = _quote(__DIR__ . "/");
$out = preg_replace("/^$front/", "", $input);
foreach (self::$testDirs as $inputDir => $outputDir) {
$in = _quote($inputDir . "/");
$rewritten = preg_replace("/$in/", $outputDir . "/", $out);
if ($rewritten != $out) {
$out = $rewritten;
break;
}
}
$out = preg_replace("/.less$/", ".css", $out);
return __DIR__ . "/" . $out;
}
}

24
vendor/leafo/lessphp/tests/README.md vendored Normal file
View file

@ -0,0 +1,24 @@
lessphp uses [phpunit](https://github.com/sebastianbergmann/phpunit/) for its tests
* `InputTest.php` iterates through all the less files in `inputs/`, compiles
them, then compares the result with the respective file in `outputs/`.
* `ApiTest.php` tests the behavior of lessphp's public API methods.
* `ErrorHandlingTest.php` tests that lessphp throws appropriate errors when
given invalid LESS as input.
From the root you can run `make` to run all the tests.
## lessjs tests
Tests found in `inputs_lessjs` are extracted directly from
[less.js](https://github.com/less/less.js). The following license applies to
those tests: https://github.com/less/less.js/blob/master/LICENSE
## bootstrap.sh
Clones twitter bootsrap, compiles it with lessc and lessphp, cleans up results
with sort.php, and outputs diff. To run it, you need to have git and lessc
installed.

38
vendor/leafo/lessphp/tests/bootstrap.sh vendored Normal file
View file

@ -0,0 +1,38 @@
#!/bin/sh
echo "This script clones Twitter Bootstrap, compiles it with lessc and lessphp,"
echo "cleans up results with sort.php, and outputs diff. To run it, you need to"
echo "have git and lessc installed."
echo ""
if [ -z "$input" ]; then
input="bootstrap/less/bootstrap.less"
fi
dest=$(basename "$input")
dest="${dest%.*}"
if [ -z "$@" ]; then
diff_tool="diff -b -u -t -B"
else
diff_tool=$@
fi
mkdir -p tmp
if [ ! -d 'bootstrap/' ]; then
echo ">> Cloning bootstrap to bootstrap/"
git clone https://github.com/twbs/bootstrap
fi
echo ">> lessc compilation ($input)"
lessc "$input" "tmp/$dest.lessc.css"
echo ">> lessphp compilation ($input)"
../plessc "$input" "tmp/$dest.lessphp.css"
echo ">> Cleanup and convert"
php sort.php "tmp/$dest.lessc.css" > "tmp/$dest.lessc.clean.css"
php sort.php "tmp/$dest.lessphp.css" > "tmp/$dest.lessphp.clean.css"
echo ">> Doing diff"
$diff_tool "tmp/$dest.lessc.clean.css" "tmp/$dest.lessphp.clean.css"

View file

@ -0,0 +1,36 @@
/* accessors */
#defaults {
@width: 960px;
@color: black;
.something {
@space: 10px;
@hello {
color: green;
}
}
}
.article { color: #294366; }
.comment {
width: #defaults[@width];
color: .article['color'];
padding: #defaults > .something[@space];
}
.wow {
height: .comment['width'];
background-color: .comment['color'];
color: #defaults > .something > @hello['color'];
padding: #defaults > non-existant['padding'];
margin: #defaults > .something['non-existant'];
}
.mix {
#defaults;
font-size: .something[@space];
}

View file

@ -0,0 +1,77 @@
// simple arity
.hello(@a) {
hello: one;
}
.hello(@a, @b) {
hello: two;
}
.hello(@a, @b, @c) {
hello: three;
}
.world(@a, @b, @c) {
world: three;
}
.world(@a, @b) {
world: two;
}
.world(@a) {
world: one;
}
.one {
.hello(1);
.world(1);
}
.two {
.hello(1, 1);
.world(1, 1);
}
.three {
.hello(1, 1, 1);
.world(1, 1, 1);
}
// arity with default values
.foo(@a, @b: cool) {
foo: two @b;
}
.foo(@a, @b: cool, @c: yeah) {
foo: three @b @c;
}
.baz(@a, @b, @c: yeah) {
baz: three @c;
}
.baz(@a, @b: cool) {
baz: two @b;
}
.multi-foo {
.foo(1);
.foo(1, 1);
.foo(1,1,1);
}
.multi-baz {
.baz(1);
.baz(1, 1);
.baz(1,1,1);
}

View file

@ -0,0 +1,41 @@
* { color: blue; }
E { color: blue; }
E[foo] { color: blue; }
[foo] { color: blue; }
[foo] .helloWorld { color: blue; }
[foo].helloWorld { color: blue; }
E[foo="barbar"] { color: blue; }
E[foo~="hello#$@%@$#^"] { color: blue; }
E[foo^="color: green;"] { color: blue; }
E[foo$="239023"] { color: blue; }
E[foo*="29302"] { color: blue; }
E[foo|="239032"] { color: blue; }
E:root { color: blue; }
E:nth-child(odd) { color: blue; }
E:nth-child(2n+1) { color: blue; }
E:nth-child(5) { color: blue; }
E:nth-last-child(-n+2) { color: blue; }
E:nth-of-type(2n) { color: blue; }
E:nth-last-of-type(n) { color: blue; }
E:first-child { color: blue; }
E:last-child { color: blue; }
E:first-of-type { color: blue; }
E:last-of-type { color: blue; }
E:only-child { color: blue; }
E:only-of-type { color: blue; }
E:empty { color: blue; }
E:lang(en) { color: blue; }
E::first-line { color: blue; }
E::before { color: blue; }
E#id { color: blue; }
E:not(:link) { color: blue; }
E F { color: blue; }
E > F { color: blue; }
E + F { color: blue; }
E ~ F { color: blue; }

View file

@ -0,0 +1,96 @@
// builtin
@something: "hello world";
@color: #112233;
@color2: rgba(44,55,66, .6);
body {
color: @something;
@num: 7 / 6;
num-basic: @num + 4;
num-floor: floor(@num) + 4px;
num-ceil: ceil(@num) + 4px;
@num2: 2 / 3;
num2: @num2;
num2-round: round(@num2);
num2-floor: floor(@num2);
num2-ceil: ceil(@num2);
round-lit: round(10px / 3);
rgba1: rgbahex(@color);
rgba2: rgbahex(@color2);
argb: argb(@color2);
}
format {
@r: 32;
format: %("rgb(%d, %d, %d)", @r, 128, 64);
format-string: %("hello %s", "world");
format-multiple: %("hello %s %d", "earth", 2);
format-url-encode: %('red is %A', #ff0000);
eformat: e(%("rgb(%d, %d, %d)", @r, 128, 64));
}
#functions {
str1: isstring("hello");
str2: isstring(one, two);
num1: isnumber(2323px);
num2: isnumber(2323);
num3: isnumber(4/5);
num4: isnumber("hello");
col1: iscolor(red);
col2: iscolor(hello);
col3: iscolor(rgba(0,0,0,0.3));
col4: iscolor(#fff);
key1: iskeyword(hello);
key2: iskeyword(3D);
px1: ispixel(10px);
px2: ispixel(10);
per1: ispercentage(10%);
per2: ispercentage(10);
em1: isem(10em);
em2: isem(10);
ex1: extract(1 2 3 4, 2);
ex2: extract(1 2, 1);
ex3: extract(1, 1);
@list: 1,2,3,4;
ex4: extract(@list, 2);
pow: pow(2,4);
pi: pi();
mod: mod(14,10);
tan: tan(1);
cos: cos(1);
sin: sin(1);
atan: atan(1);
acos: acos(1);
asin: asin(1);
sqrt: sqrt(8);
}
#unit {
@unit: "em";
unit-lit: unit(10px);
unit-arg: unit(10px, "s");
unit-arg2: unit(10px, @unit);
unit-math: unit(0.07407s) * 100%;
}

View file

@ -0,0 +1,154 @@
body {
color:rgb(red(#f00), red(#0F0), red(#00f));
color:rgb(red(#f00), green(#0F0), blue(#00f));
color:rgb(red(#0ff), green(#f0f), blue(#ff0));
color: hsl(34, 50%, 40%);
color: hsla(34, 50%, 40%, 0.3);
lighten1: lighten(#efefef, 10%);
lighten2: lighten(rgb(23, 53, 231), 22%);
lighten3: lighten(rgba(212, 103, 88, 0.5), 10%);
darken1: darken(#efefef, 10%);
darken2: darken(rgb(23, 53, 231), 22%);
darken3: darken(rgba(23, 53, 231, 0.5), 10%);
saturate1: saturate(#efefef, 10%);
saturate2: saturate(rgb(23, 53, 231), 22%);
saturate3: saturate(rgba(23, 53, 231, 0.5), 10%);
desaturate1: desaturate(#efefef, 10%);
desaturate2: desaturate(rgb(23, 53, 231), 22%);
desaturate3: desaturate(rgba(23, 53, 231, 0.5), 10%);
spin1: spin(#efefef, 12);
spin2: spin(rgb(23, 53, 231), 15);
spin3: spin(rgba(23, 53, 231, 0.5), 19);
spin2: spin(#efefef, -12);
spin3: spin(rgb(23, 53, 231), -15);
spin4: spin(rgba(23, 53, 231, 0.5), -19);
one1: fadein(#abcdef, 10%);
one2: fadeout(#abcdef, -10%);
two1: fadeout(#029f23, 10%);
two2: fadein(#029f23, -10%);
three1: fadein(rgba(1,2,3, 0.5), 10%);
three2: fadeout(rgba(1,2,3, 0.5), -10%);
four1: fadeout(rgba(1,2,3, 0), 10%);
four2: fadein(rgba(1,2,3, 0), -10%);
hue: hue(rgb(34,20,40));
sat: saturation(rgb(34,20,40));
lit: lightness(rgb(34,20,40));
@old: #34fa03;
@new: hsl(hue(@old), 45%, 90%);
what: @new;
zero1: saturate(#123456, -100%);
zero2: saturate(#123456, 100%);
zero3: saturate(#000000, 100%);
zero4: saturate(#ffffff, 100%);
zero5: lighten(#123456, -100%);
zero6: lighten(#123456, 100%);
zero7: lighten(#000000, 100%);
zero8: lighten(#ffffff, 100%);
zero9: spin(#123456, -100);
zeroa: spin(#123456, 100);
zerob: spin(#000000, 100);
zeroc: spin(#ffffff, 100);
}
alpha {
// g: alpha(red);
g1: alpha(rgba(0,0,0,0));
g2: alpha(rgb(155,55,0));
}
fade {
f1: fade(red, 50%);
f2: fade(#fff, 20%);
f3: fade(rgba(34,23,64,0.4), 50%);
}
@a: rgb(255,255,255);
@b: rgb(0,0,0);
.mix {
color1: mix(@a, @b, 50%);
color2: mix(@a, @b);
color3: mix(rgba(5,3,1,0.3), rgba(6,3,2, 0.8), 50%);
}
.contrast {
color1: contrast(#000, red, blue);
color2: contrast(#fff, red, blue);
}
.percent {
per: percentage(0.5);
}
// color keywords
.colorz {
color1: whitesmoke - 10;
color2: spin(red, 34);
color3: spin(blah);
}
// purposfuly whacky to match less.js
@color: #fcf8e3;
body {
start: @color;
spin: spin(@color, -10); // #fcf4e3
chained: darken(spin(@color, -10), 3%); // gives #fbeed5, should be #fbefd5
direct: darken(#fcf4e3, 3%); // #fbefd5
}
// spin around
pre {
@errorBackground: #f2dede;
spin: spin(@errorBackground, -10);
}
dd {
@white: #fff;
background-color: mix(@white, darken(@white, 10%), 60%);
}
// math
.ops {
c1: red * 0.3;
c2: green / 2;
c3: purple % 7;
c4: 4 * salmon;
c5: 1 + salmon;
c6: 132 / red;
c7: 132 - red;
c8: 132- red;
}
.transparent {
r: red(transparent);
g: green(transparent);
b: blue(transparent);
a: alpha(transparent);
}

View file

@ -0,0 +1,39 @@
@mixin {
height: 22px;
ul {
height: 20px;
li {
@color: red;
height: 10px;
div span, link {
margin: 10px;
color: @color;
}
}
div, p {
border: 1px;
&.hello {
color: green;
}
:what {
color: blue;
}
}
a {
b {
color: blue;
}
}
}
}
body {
@mixin;
}

View file

@ -0,0 +1,7 @@
.small {
background: data-uri("../hi.less");
}
.large {
background: data-uri('../../../lessc.inc.php');
}

View file

@ -0,0 +1,28 @@
@hello: "utf-8";
@charset @hello;
@-moz-document url-prefix(){
div {
color: red;
}
}
@page :left { margin-left: 4cm; }
@page :right { margin-left: 3cm; }
@page { margin: 2cm }
@-ms-viewport {
width: device-width;
}
@-moz-viewport {
width: device-width;
}
@-o-viewport {
width: device-width;
}
@viewport {
width: device-width;
}

View file

@ -0,0 +1,18 @@
body {
@hello: "world";
e1: e("this is simple");
e2: e("this is simple", "cool lad");
e3: e(1232);
e4: e(@hello);
e5: e("one" + 'more');
t1: ~"eating rice";
t2: ~"string cheese";
t3: a b c ~"string me" d e f;
t4: ~"string @{hello}";
}
.class {
filter: ~"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='image.png')";
}

View file

@ -0,0 +1,28 @@
@font-directory: 'fonts/';
@some-family: Gentium;
@font-face: maroon; // won't collide with @font-face { }
@font-face {
font-family: Graublau Sans Web;
src: url(@{font-directory}GraublauWeb.otf) format("opentype");
}
@font-face {
font-family: @some-family;
src: url('@{font-directory}Gentium.ttf');
}
@font-face {
font-family: @some-family;
src: url("@{font-directory}GentiumItalic.ttf");
font-style: italic;
}
h2 {
font-family: @some-family;
crazy: @font-face;
}

View file

@ -0,0 +1,74 @@
.simple(@hi) when (@hi) {
simple: yellow;
}
.something(@hi) when (@hi = cool) {
something: red;
}
.another(@x) when (@x > 10) {
another: green;
}
.flipped(@x) when (@x =< 10) {
flipped: teal;
}
.yeah(@arg) when (isnumber(@arg)) {
yeah-number: purple @arg;
}
.yeah(@arg) when (ispixel(@arg)) {
yeah-pixel: silver;
}
.hello(@arg) when not (@arg) {
hello: orange;
}
dd {
.simple(true);
}
b {
.something(cool);
.something(birthday);
}
img {
.another(12);
.flipped(2);
}
body {
.yeah(232px);
.yeah(232);
}
.something(@x) when (@x) and (@y), not (@x = what) {
something-complex: blue @x;
}
div {
@y: true;
.something(true);
}
.coloras(@g) when (iscolor(@g)) {
color: true @g;
}
link {
.coloras(red);
.coloras(#fff);
.coloras(#fffddd);
.coloras(rgb(0,0,0));
.coloras(rgba(0,0,0, .34));
}

View file

@ -0,0 +1,6 @@
// css hacks
:root .alert-message, :root .btn {
border-radius: 0 \0;
}

View file

@ -0,0 +1,5 @@
div:before {
content: "hi!";
}

View file

@ -0,0 +1,12 @@
foo {
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#c0ff3300, endColorstr=#ff000000);
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#c0ff3300, endColorstr=#ff000001);
}
foo {
filter: alpha(opacity=20);
filter: alpha(opacity=20, enabled=true);
filter: blaznicate(foo=bar, baz=bang bip, bart=#fa4600);
}

View file

@ -0,0 +1,56 @@
@import 'file1.less'; // file found and imported
@import "not-found";
@import "something.css" media;
@import url("something.css") media;
@import url(something.css) media, screen, print;
@color: maroon;
@import url(file2); // found and imported
body {
line-height: 10em;
@colors;
}
div {
@color: fuchsia;
@import "file2";
}
.mixin-import() {
@import "file3";
}
.one {
.mixin-import();
color: blue;
}
.two {
.mixin-import();
}
#merge-import-mixins {
@import "a";
@import "b";
div { .just-a-class; }
}
@import "inner/file1";
// test bubbling variables up from imports, while preserving order
pre {
color: @someValue;
}
@import "file3";

View file

@ -0,0 +1,47 @@
@cool-hello: "yes";
@cool-yes: "okay";
@var: "hello";
div {
interp1: ~"@{cool-hello}";
interp2: ~"@{cool-@{var}}";
interp3: ~"@{cool-@{cool-@{var}}}";
}
// interpolation in selectors
@hello: 10;
@world: "yeah";
@{hello}@{world} {
color: blue;
}
@{hello} {
color: blue;
}
hello world @{hello} {
color: red;
}
#@{world} {
color: "hello @{hello}";
}
@num: 3;
[prop],
[prop="value@{num}"],
[prop*="val@{num}"],
[|prop~="val@{num}"],
[*|prop$="val@{num}"],
[ns|prop^="val@{num}"],
[@{num}^="val@{num}"],
[@{num}=@{num}],
[@{num}] {
attributes: yes;
}

View file

@ -0,0 +1,52 @@
@keyframes 'bounce' {
from {
top: 100px;
animation-timing-function: ease-out;
}
25% {
top: 50px;
animation-timing-function: ease-in;
}
50% {
top: 100px;
animation-timing-function: ease-out;
}
75% {
top: 75px;
animation-timing-function: ease-in;
}
to {
top: 100px;
}
}
@-webkit-keyframes flowouttoleft {
0% { -webkit-transform: translateX(0) scale(1); }
60%, 70% { -webkit-transform: translateX(0) scale(.7); }
100% { -webkit-transform: translateX(-100%) scale(.7); }
}
div {
animation-name: 'diagonal-slide';
animation-duration: 5s;
animation-iteration-count: 10;
}
@keyframes 'diagonal-slide' {
from {
left: 0;
top: 0;
}
to {
left: 100px;
top: 100px;
}
}

View file

@ -0,0 +1,122 @@
.unary {
// all operators are parsable as unary operators, anything
// but - throws an error right now though,
// this gives two numbers
sub: 10 -5;
// add: 10 +5; // error
// div: 10 /5; // error
// mul: 10 *5; // error
}
.spaces {
// we can make the parser do math by leaving out the
// space after the first value, or putting spaces on both sides
sub1: 10-5;
sub2: 10 - 5;
add1: 10+5;
add2: 10 + 5;
// div: 10/5; // this wont work, read on
div: 10 / 5;
mul1: 10*5;
mul2: 10 * 5;
}
// these properties have divison not in parenthases
.supress-division {
border-radius: 10px / 10px;
border-radius: 10px/12px;
border-radius: hello (10px/10px) world;
@x: 10px;
font: @x/30 sans-serif;
font: 10px / 20px sans-serif;
font: 10px/22px sans-serif;
border-radius:0 15px 15px 15px / 0 50% 50% 50%;
}
.parens {
// if you are unsure, then just wrap the expression in parentheses and it will
// always evaluate.
// notice we no longer have unary operators, and these will evaluate
sub: (10 -5);
add: (10 +5);
div1: (10 /5);
div2: (10/5); // no longer interpreted as the shorthand
mul: (10 *5);
}
.keyword-names {
// watch out when doing math with keywords, - is a valid keyword character
@a: 100;
@b: 25;
@a-: "hello";
height: @a-@b; // here we get "hello" 25, not 75
}
.negation {
neg1: -(1px);
neg2: 0-(1px);
@something: 10;
neg3: -@something;
}
// and now here are the tests
.test {
single1: (5);
single2: 5+(5);
single3: (5)+((5));
parens: (5 +(5)) -2;
// parens: ((5 +(5)) -2); // FAILS - fixme
math1: (5 + 5)*(2 / 1);
math2: (5+5)*(2/1);
complex1: 2 * (4 * (2 + (1 + 6))) - 1;
complex2: ((2+3)*(2+3) / (9-4)) + 1;
complex3: (2px + 4px) 1em 2px 2;
@var: (2 * 2);
var1: (2 * @var) 4 4 (@var * 1px);
var2: (@var * @var) * 6;
var3: 4 * (5 + 5) / 2 - (@var * 2);
complex4: (7 * 7) + (8 * 8);
}
.percents {
p1: 100 * 10%;
p2: 10% * 100;
p3: 10% * 10%;
p4: 100px * 10%; // lessjs makes this px
p5: 10% * 100px; // lessjs makes this %
p6: 20% + 10%;
p7: 20% - 10%;
p8: 20% / 10%;
}
.misc {
x: 10px * 4em;
y: 10 * 4em;
}
.cond {
c1: 10 < 10;
c2: 10 >= 10;
}

View file

@ -0,0 +1,68 @@
@media screen, 3D {
P { color: green; }
}
@media print {
body { font-size: 10pt }
}
@media screen {
body { font-size: 13px }
}
@media screen, print {
body { line-height: 1.2 }
}
@media all and (min-width: 0px) {
body { line-height: 1.2 }
}
@media all and (min-width: 0) {
body { line-height: 1.2 }
}
@media
screen and (min-width: 102.5em) and (max-width: 117.9375em),
screen and (min-width: 150em) {
body { color: blue }
}
@media screen and (min-height: 100px + 10px) {
body { color: red; }
}
@cool: 100px;
@media screen and (height: @cool) and (width: @cool + 10), (size: @cool + 20) {
body { color: red; }
}
// media bubbling
@media test {
div {
height: 20px;
@media (hello) {
color: red;
pre {
color: orange;
}
}
}
}
// should not cross boundary
@media yeah {
@page {
@media cool {
color: red;
}
}
}
// variable in query
@mobile: ~"(max-width: 599px)";
@media @mobile {
.helloworld { color: blue }
}

View file

@ -0,0 +1,100 @@
@color: #fff;
@base_path: "/assets/images/";
@images: @base_path + "test/";
.topbar { background: url(@{images}topbar.png); }
.hello { test: empty-function(@images, 40%, to(@color)); }
.css3 {
background-image: -webkit-gradient(linear, 0% 0%, 0% 90%,
from(#E9A000), to(#A37000));
}
/**
Here is a block comment
**/
// this is a comment
.test, /*hello*/.world {
border: 1px solid red; // world
/* another property */
color: url(http://mage-page.com);
string: "hello /* this is not a comment */";
world: "// neither is this";
string: 'hello /* this is not a comment */' /*what if this is a comment */;
world: '// neither is this' // hell world;
;
what-/*something?*/ever: 100px;
background: url(/*no comment here*/);
}
.urls {
@var: "http://google.com";
background1: url(@var);
background2: url(@{var});
background3: url("@{var}");
}
.mix(@arg) { color: @arg; }
@aaa: aaa;
@bbb: bbb;
// make sure the opening selector isn't too greedy
.cool {.mix("@{aaa}, @{bbb}")}
.cool();
// merging of mixins
.span-17 { float: left; }
.span-17 { width: 660px; }
.x {.span-17;}
.hi {
pre {
color: red;
}
}
.hi {
pre {
color: blue;
}
}
.rad {
.hi;
}
hello {
numbers: 1.0 0.1 .1 1.;
numbers: 1.0s 0.1s .1s 1.s;
numbers: -1.0s -0.1s -.1s -1.s;
numbers: -1.0 -0.1 -.1 -1.;
}
#string {
hello: 'what\'s going on here';
hello: 'blah blag @{ blah blah';
join: 3434 + "hello";
join: 3434 + hello;
}
.duplicates {
hello: world;
hello: "world";
hello: world;
hello: "what";
hello: world;
hello: "world";
}

View file

@ -0,0 +1,33 @@
@outer: 10px;
@class(@var:22px, @car: 400px + @outer) {
margin: @var;
height: @car;
}
@group {
@f(@color) {
color: @color;
}
.cool {
border-bottom: 1px solid green;
}
}
.class(@width:200px) {
padding: @width;
}
body {
.class(2.0em);
@group > @f(red);
@class(10px, 10px + 2);
@group > .cool;
}
@lots(@a: 10px, @b: 20px, @c: 30px, @d: 40px, @e: 4px, @f:3px, @g:2px, @h: 1px) {
padding: @a @b @c @d;
margin: @e @f @g @h;
}

View file

@ -0,0 +1,100 @@
@tester {
p, div { height: 10px; }
}
#test1 {
div { color: red; }
@tester;
}
@cool {
a,b,i { width: 1px; }
}
#test2 {
b { color: red; }
@cool;
}
#test3 {
@cool;
b { color: red; }
}
@cooler {
a { margin: 1px; }
}
#test4 {
a, div, html { color: blue; }
@cooler;
}
@hi {
img, strong { float: right; }
}
#test5 {
img, strong { padding: 2px; }
@hi;
}
@nested {
div, span {
a {
color: red;
}
}
}
#test6 {
div, span {
a {
line-height: 10px;
}
}
@nested;
}
@broken-nesting {
div, span {
strong, b {
color: red;
}
}
}
#test7 {
div {
strong {
margin: 1px;
}
}
@broken-nesting;
}
@another-nest {
a,b {
i {
color: red;
}
s {
color: blue;
}
}
}
#test8 {
a, b {
i,s {
background: red;
}
}
@another-nest;
}

View file

@ -0,0 +1,197 @@
@rounded-corners {
border-radius: 10px;
}
.bold {
@font-size: 20px;
font-size: @font-size;
font-weight: bold;
}
body #window {
@rounded-corners;
.bold;
line-height: @font-size * 1.5;
}
#bundle {
.button {
display: block;
border: 1px solid black;
background-color: grey;
&:hover { background-color: white }
}
}
#header a {
color: orange;
#bundle > .button; // mixin the button class
}
div {
@abstract {
hello: world;
b {
color: blue;
}
}
@abstract > b;
@abstract;
}
@poop {
big: baby;
}
body {
div;
}
// not using > to list mixins
.hello {
.world {
color: blue;
}
}
.foobar {
.hello .world;
}
// arguments
.spam(@something: 100, @dad: land) {
@wow: 23434;
foo: @arguments;
bar: @arguments;
}
.eggs {
.spam(1px, 2px);
.spam();
}
.first(@one, @two, @three, @four: cool) {
cool: @arguments;
}
#hello {
.first(one, two, three);
}
#hello-important {
.first(one, two, three) !important;
}
.rad(@name) {
cool: @arguments;
}
#world {
@hello: "world";
.rad("@{hello}");
}
.second(@x, @y:skip, @z: me) {
things: @arguments;
}
#another {
.second(red, blue, green);
.second(red blue green);
}
.another(@x, @y:skip, @z:me) {
.cool {
color: @arguments;
}
}
#day {
.another(one,two, three);
.another(one two three);
}
.to-be-important() {
color: red;
@color: red;
height: 20px;
pre {
color: @color;
}
}
.mix-suffix {
.to-be-important() !important;
}
#search-all {
.red() {
color:#f00 !important;
}
}
#search-all {
.green() {
color: #0f0 !important;
}
}
.search-test {
#search-all > .red();
#search-all > .green();
}
// mixin self without infinite loop
.cowboy() {
color: blue;
}
.cowboy {
.cowboy;
}
// semicolon
.semi1(@color: red, blue, green;) {
color: @color;
}
.semi2(@color: red, blue, green; dad) {
color: @color;
}
.semi3(hello; world; piss) {
hello: world;
}
// self referencing skipping
.nav-divider(@color: red){
padding: 10px;
}
.nav {
.nav-divider {
.nav-divider();
}
}
.nav-divider {
.nav-divider();
}

View file

@ -0,0 +1,60 @@
#header {
color: black;
.navigation {
font-size: 12px;
.border {
.outside {
color: blue;
}
}
}
.logo {
width: 300px;
&:hover { text-decoration: none }
}
}
a { b { ul { li { color: green; } } } }
this { will { not { show { } } } }
.cool {
div & { color: green; }
p & span { color: yellow; }
}
another {
.cool;
}
b {
& .something {
color: blue;
}
&.something {
color: blue;
}
}
.foo {
.bar, .baz {
& .qux {
display: block;
}
.qux & {
display: inline;
}
.qux & .biz {
display: none;
}
}
}
b {
hello [x="&yeah"] {
color: red;
}
}

View file

@ -0,0 +1,157 @@
.demo (light, @color) {
color: lighten(@color, 10%);
}
.demo (@_, @color) {
display: block;
}
@switch: light;
.class {
.demo(@switch, #888);
}
// by arity
.mixin () {
zero: 0;
}
.mixin (@a: 1px) {
one: 1;
}
.mixin (@a) {
one-req: 1;
}
.mixin (@a: 1px, @b: 2px) {
two: 2;
}
.mixin (@a, @b, @c) {
three-req: 3;
}
.mixin (@a: 1px, @b: 2px, @c: 3px) {
three: 3;
}
.zero {
.mixin();
}
.one {
.mixin(1);
}
.two {
.mixin(1, 2);
}
.three {
.mixin(1, 2, 3);
}
//
.mixout ('left') {
left: 1;
}
.mixout ('right') {
right: 1;
}
.left {
.mixout('left');
}
.right {
.mixout('right');
}
//
.border (@side, @width) {
color: black;
.border-side(@side, @width);
}
.border-side (left, @w) {
border-left: @w;
}
.border-side (right, @w) {
border-right: @w;
}
.border-right {
.border(right, 4px);
}
.border-left {
.border(left, 4px);
}
//
.border-radius (@r) {
both: @r * 10;
}
.border-radius (@r, left) {
left: @r;
}
.border-radius (@r, right) {
right: @r;
}
.only-right {
.border-radius(33, right);
}
.only-left {
.border-radius(33, left);
}
.left-right {
.border-radius(33);
}
.hola(hello, @hello...) {
color: blue;
}
#hola {
.hola(hello, world);
}
.resty(@hello, @world, @the_rest...) {
padding: @hello @world;
rest: @the_rest;
}
.defaults(@aa, @bb:e343, @cc: "heah", ...) {
height: @aa;
}
#defaults_1 {
.defaults(one);
.defaults(two, one);
.defaults(three, two, one);
.defaults(four, three, two, one);
}
.thing() { color: green; }
.thing(...) { color: blue; }
.thing { color: red; }
#aa {
.thing();
}
#bb {
.thing;
}
#cc {
.thing(1);
}

View file

@ -0,0 +1,40 @@
@a: 10;
@some {
@b: @a + 10;
div {
@c: @b + 10;
other {
@d: @c + 10;
world {
@e: @d + 10;
height: @e;
}
}
}
}
body {
@some;
}
@some;
.test(@x: 10) {
height: @x;
.test(@y: 11) {
height: @y;
.test(@z: 12) {
height: @z;
}
.test;
}
.test;
}
pre {
.test;
}

View file

@ -0,0 +1,29 @@
@color: blue;
something @{color}, world {
color: blue;
}
.div {
@color: red;
(3434) {
height: 100px;
}
cool @{color} {
height: 4000px;
}
}
.heck(@a) { color: @a+10 }
.spanX (@index) when (@index > 0) {
.span@{index} { .heck(@index) }
.spanX(@index - 1);
}
.spanX (0) {}
.spanX (5);

View file

@ -0,0 +1,120 @@
// these are the demos from the lessphp homepage
default {
@base: 24px;
@border-color: #B2B;
.underline { border-bottom: 1px solid green }
#header {
color: black;
border: 1px solid @border-color + #222222;
.navigation {
font-size: @base / 2;
a {
.underline;
}
}
.logo {
width: 300px;
&:hover { text-decoration: none }
}
}
}
variables {
@a: 2;
@x: @a * @a;
@y: @x + 1;
@z: @x * 2 + @y;
@nice-blue: #5B83AD;
@light-blue: @nice-blue + #111;
@b: @a * 10;
@c: #888;
@fonts: "Trebuchet MS", Verdana, sans-serif;
.variables {
width: @z + 1cm; // 14cm
height: @b + @x + 0px; // 24px
color: @c;
background: @light-blue;
font-family: @fonts;
}
}
mixins {
.bordered {
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
#menu a {
color: #111;
.bordered;
}
.post a {
color: red;
.bordered;
}
}
nested-rules {
#header {
color: black;
.navigation {
font-size: 12px;
}
.logo {
width: 300px;
&:hover { text-decoration: none }
}
}
}
namespaces {
#bundle {
.button {
display: block;
border: 1px solid black;
background-color: grey;
&:hover { background-color: white }
}
}
#header a {
color: orange;
#bundle > .button; // mixin the button class
}
}
mixin-functions {
@outer: 10px;
@class(@var:22px, @car: 400px + @outer) {
margin: @var;
height: @car;
}
@group {
@f(@color) {
color: @color;
}
.cool {
border-bottom: 1px solid green;
}
}
.class(@width:200px) {
padding: @width;
}
body {
.class(2.0em);
@group > @f(red);
@class(10px, 10px + 2);
@group > .cool;
}
}

View file

@ -0,0 +1,6 @@
.just-a-class { background: red; }
.some-mixin() {
height: 200px;
}

View file

@ -0,0 +1,12 @@
.just-a-class { background: blue; }
.hello {
.some-mixin();
}
@media cool {
color: red;
.some-mixin();
}

View file

@ -0,0 +1,16 @@
/**
* This is a test import file
*/
@colors {
div.bright {
color: red;
}
div.sad {
color: blue;
}
}

View file

@ -0,0 +1,6 @@
b {
color: @color;
padding: 16px;
}

View file

@ -0,0 +1,7 @@
h2 {
background: url("../images/logo.png") no-repeat;
}
@someValue: hello-from-file-3;

View file

@ -0,0 +1,6 @@
.inner {
content: "inner/file1.less"
}
@import "file2"; // should get the one in inner

View file

@ -0,0 +1,4 @@
.inner {
content: "inner/file2.less"
}

View file

@ -0,0 +1,44 @@
@a: 2;
@x: @a * @a;
@y: @x + 1;
@z: @y + @x * 2;
@m: @z % @y;
@nice-blue: #5B83AD;
@light-blue: @nice-blue + #111;
@rgb-color: rgb(20%, 15%, 80%);
@rgba-color: rgba(23,68,149,0.5);
@b: @a * 10px;
@c: #888;
@fonts: "Trebuchet MS", Verdana, sans-serif;
.variables {
width: @z + 1cm; // 14cm
height: @b + @x + 0px; // 24px
margin-top: -@b; // -20px
margin-bottom: 10 - -@b; // 30px
@d: @c + #001;
color: @d;
background: @light-blue;
font-family: @fonts;
margin: @m + 0px; // 3px
font: 10px/12px serif;
font: 120%/120% serif;
}
.external {
color: @c;
border: 1px solid @rgb-color;
background: @rgba-color;
}
@hello: 44px;
@something: "hello";
@cool: something;
outer1: @@something;
outer2: @@@cool;

View file

@ -0,0 +1,205 @@
.mixin (@a: 1px, @b: 50%) {
width: (@a * 5);
height: (@b - 1%);
}
.mixina (@style, @width, @color: black) {
border: @width @style @color;
}
.mixiny
(@a: 0, @b: 0) {
margin: @a;
padding: @b;
}
.hidden() {
color: transparent; // asd
}
#hidden {
.hidden;
}
#hidden1 {
.hidden();
}
.two-args {
color: blue;
.mixin(2px, 100%);
.mixina(dotted, 2px);
}
.one-arg {
.mixin(3px);
}
.no-parens {
.mixin;
}
.no-args {
.mixin();
}
.var-args {
@var: 9;
.mixin(@var, (@var * 2));
}
.multi-mix {
.mixin(2px, 30%);
.mixiny(4, 5);
}
.maxa(@arg1: 10, @arg2: #f00) {
padding: (@arg1 * 2px);
color: @arg2;
}
body {
.maxa(15);
}
@glob: 5;
.global-mixin(@a:2) {
width: (@glob + @a);
}
.scope-mix {
.global-mixin(3);
}
.nested-ruleset (@width: 200px) {
width: @width;
.column { margin: @width; }
}
.content {
.nested-ruleset(600px);
}
//
.same-var-name2(@radius) {
radius: @radius;
}
.same-var-name(@radius) {
.same-var-name2(@radius);
}
#same-var-name {
.same-var-name(5px);
}
//
.var-inside () {
@var: 10px;
width: @var;
}
#var-inside { .var-inside; }
.mixin-arguments (@width: 0px, ...) {
border: @arguments;
width: @width;
}
.arguments {
.mixin-arguments(1px, solid, black);
}
.arguments2 {
.mixin-arguments();
}
.arguments3 {
.mixin-arguments;
}
.mixin-arguments2 (@width, @rest...) {
border: @arguments;
rest: @rest;
width: @width;
}
.arguments4 {
.mixin-arguments2(0, 1, 2, 3, 4);
}
// Edge cases
.edge-case {
.mixin-arguments("{");
}
// Division vs. Literal Slash
.border-radius(@r: 2px/5px) {
border-radius: @r;
}
.slash-vs-math {
.border-radius();
.border-radius(5px/10px);
.border-radius((3px * 2));
}
// semi-colon vs comma for delimiting
.mixin-takes-one(@a) {
one: @a;
}
.mixin-takes-two(@a; @b) {
one: @a;
two: @b;
}
.comma-vs-semi-colon {
.mixin-takes-two(@a : a; @b : b, c);
.mixin-takes-two(@a : d, e; @b : f);
.mixin-takes-one(@a: g);
.mixin-takes-one(@a : h;);
.mixin-takes-one(i);
.mixin-takes-one(j;);
.mixin-takes-two(k, l);
.mixin-takes-one(m, n;);
.mixin-takes-two(o, p; q);
.mixin-takes-two(r, s; t;);
}
.mixin-conflict(@a:defA, @b:defB, @c:defC) {
three: @a, @b, @c;
}
.mixin-conflict(@a:defA, @b:defB, @c:defC, @d:defD) {
four: @a, @b, @c, @d;
}
#named-conflict {
.mixin-conflict(11, 12, 13, @a:a);
.mixin-conflict(@a:a, 21, 22, 23);
}
@a: 3px;
.mixin-default-arg(@a: 1px, @b: @a, @c: @b) {
defaults: 1px 1px 1px;
defaults: 2px 2px 2px;
}
.test-mixin-default-arg {
.mixin-default-arg();
.mixin-default-arg(2px);
}
.mixin-comma-default1(@color; @padding; @margin: 2, 2, 2, 2) {
margin: @margin;
}
.selector {
.mixin-comma-default1(#33acfe; 4);
}
.mixin-comma-default2(@margin: 2, 2, 2, 2;) {
margin: @margin;
}
.selector2 {
.mixin-comma-default2();
}
.mixin-comma-default3(@margin: 2, 2, 2, 2) {
margin: @margin;
}
.selector3 {
.mixin-comma-default3(4,2,2,2);
}

Some files were not shown because too many files have changed in this diff Show more