<commit_before><?php
namespace selvinortiz\doxter\models;

use craft\base\Model;

/**
 * Class Settings
 *
 * @package selvinortiz\doxter\models
 */
class SettingsModel extends Model
{
    public $codeBlockSnippet    = '';
    public $addHeaderAnchors    = true;
    public $addHeaderAnchorsTo  = ['h1', 'h2', 'h3'];
    public $addTypographyStyles = true;
    public $startingHeaderLevel = 1;
    public $parseReferenceTags  = true;
    public $parseShortcodes     = true;
    public $enableCpTab         = false;
    public $pluginAlias         = 'Doxter';

    public function rules()
    {
        return [
            [['codeBlockSnippet', 'addHeaderAnchors'], 'required']
        ];
    }
}<commit_msg>Add support for registering shortcode tags via a file config<commit_after><?php
namespace selvinortiz\doxter\models;

use craft\base\Model;

/**
 * Class Settings
 *
 * @package selvinortiz\doxter\models
 *
 * @method SettingsModel getSettings()
 */
class SettingsModel extends Model
{
    /**
     * Defines how shortcodes should be rendered
     *
     * @var array
     */
    public $shortcodes = [];

    /**
     * Defines how code blocks should be rendered
     *
     * @var string
     */
    public $codeBlockSnippet = '';

    /**
     * Whether or not anchors should be added to headers
     *
     * @var boolean
     */
    public $addHeaderAnchors = true;

    /**
     * Defines a list of headers to which anchors should be added
     *
     * @note Only applies if $addHeaderAnchors is true
     *
     * @var array
     */
    public $addHeaderAnchorsTo = ['h1', 'h2', 'h3'];

    /**
     * Defines the header level that will be considered the first (h1)
     *
     * @var integer
     */
    public $startingHeaderLevel = 1;

    /**
     * Whether or not typography styles should be applied to rendered content
     *
     * @var boolean
     */
    public $addTypographyStyles = true;

    /**
     * Whether or not Reference Tags should be parsed
     *
     * @var boolean
     */
    public $parseReferenceTags = true;

    /**
     * Whether or not Shortcodes should be parsed
     *
     * @var boolean
     */
    public $parseShortcodes = true;

    /**
     * Whether or not the plugin icon/link should be displayed on the sidebar
     *
     * @var boolean
     */
    public $enableCpTab = false;

    /**
     * An alternate name/title for the plugin (e.g Markdown)
     *
     * @var string
     */
    public $pluginAlias = 'Doxter';

    /**
     * Whether or not shortcode tags have been registered
     *
     * @var bool
     */
    protected $_didRegisterShortcodeTags = false;

    public function rules()
    {
        return [
            [['codeBlockSnippet', 'addHeaderAnchors'], 'required']
        ];
    }

    /**
     * Returns a list of registered shortcode tags
     *
     * e.g. ['audio', 'vimeo:youtube']
     *
     * @return array
     */
    public function getRegisteredShortcodeTags()
    {
        if (!$this->_didRegisterShortcodeTags)
        {
            $map  = $this->shortcodes['tags'] ?? [];
            $tags = [];

            if (!empty($map))
            {
                foreach ($map as $tag => $template)
                {
                    $aliases = explode(':', $tag);

                    foreach ($aliases as $alias)
                    {
                        $tags[$alias] = $template;
                    }
                }
            }

            $this->shortcodes['tags']        = $tags;
            $this->_didRegisterShortcodeTags = true;
        }

        return $this->shortcodes['tags'];
    }
}
{'fraction_non_alphanumeric': 0.11262135922330097, 'fraction_numerical': 0.0024965325936199723, 'mean_word_length': 1.8238057948316366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '638949', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1028, 'n_words': 282}