Closed goldsky closed 9 years ago
I believe it's [list]
and [olist]
, but I don't see why we couldn't add the HTML equivalent names.
I'm using http://www.sceditor.com/ for my editor, which needs [ul]
and [ol]
parser.
So, on my experiment, this fix fits my goal:
<?php
/**
* @copyright 2006-2014, Miles Johnson - http://milesj.me
* @license https://github.com/milesj/decoda/blob/master/license.md
* @link http://milesj.me/code/php/decoda
*/
namespace Decoda\Filter;
use Decoda\Decoda;
/**
* Provides tags for ordered and unordered lists.
*/
class ListFilter extends AbstractFilter {
const LIST_TYPE = '/^[-a-z]+$/i';
/**
* Supported tags.
*
* @type array
*/
protected $_tags = array(
'olist' => array(
'htmlTag' => 'ol',
'displayType' => Decoda::TYPE_BLOCK,
'allowedTypes' => Decoda::TYPE_BOTH,
'lineBreaks' => Decoda::NL_REMOVE,
'childrenWhitelist' => array('li', '*'),
'onlyTags' => true,
'attributes' => array(
'default' => array(self::LIST_TYPE, 'type-{default}')
),
'mapAttributes' => array(
'default' => 'class'
),
'htmlAttributes' => array(
'class' => 'decoda-olist'
)
),
'ol' => array(
'htmlTag' => 'ol',
'displayType' => Decoda::TYPE_BLOCK,
'allowedTypes' => Decoda::TYPE_BOTH,
'lineBreaks' => Decoda::NL_REMOVE,
'childrenWhitelist' => array('li', '*'),
'onlyTags' => true,
'attributes' => array(
'default' => array(self::LIST_TYPE, 'type-{default}')
),
'mapAttributes' => array(
'default' => 'class'
),
'htmlAttributes' => array(
'class' => 'decoda-olist'
)
),
'list' => array(
'htmlTag' => 'ul',
'displayType' => Decoda::TYPE_BLOCK,
'allowedTypes' => Decoda::TYPE_BOTH,
'lineBreaks' => Decoda::NL_REMOVE,
'childrenWhitelist' => array('li', '*'),
'onlyTags' => true,
'attributes' => array(
'default' => array(self::LIST_TYPE, 'type-{default}')
),
'mapAttributes' => array(
'default' => 'class'
),
'htmlAttributes' => array(
'class' => 'decoda-list'
)
),
'ul' => array(
'htmlTag' => 'ul',
'displayType' => Decoda::TYPE_BLOCK,
'allowedTypes' => Decoda::TYPE_BOTH,
'lineBreaks' => Decoda::NL_REMOVE,
'childrenWhitelist' => array('li', '*'),
'onlyTags' => true,
'attributes' => array(
'default' => array(self::LIST_TYPE, 'type-{default}')
),
'mapAttributes' => array(
'default' => 'class'
),
'htmlAttributes' => array(
'class' => 'decoda-list'
)
),
'li' => array(
'htmlTag' => 'li',
'displayType' => Decoda::TYPE_BLOCK,
'allowedTypes' => Decoda::TYPE_BOTH,
'parent' => array('olist', 'list', 'ol', 'ul')
),
'*' => array(
'htmlTag' => 'li',
'displayType' => Decoda::TYPE_BLOCK,
'allowedTypes' => Decoda::TYPE_BOTH,
'childrenBlacklist' => array('olist', 'list', 'ol', 'ul', 'li'),
'parent' => array('olist', 'list', 'ol', 'ul')
)
);
}
Added.
Hi, I figured that the
$code->defaults();
is missing table filter.(I needed to add table filter manually)
Second question, the
ListFilter()
doesn't parse[ul]
and[ol]
as http://www.bbcode.org/examples/?id=12 (I just copy-pasted theolist
andlist
to fix them).Are these intentionally?