Class yii\apidoc\helpers\ApiMarkdownLaTeX

Inheritanceyii\apidoc\helpers\ApiMarkdownLaTeX » cebe\markdown\latex\GithubMarkdown
Uses Traitsyii\apidoc\helpers\ApiMarkdownTrait
Available since extension's version2.0
Source Code https://github.com/yiisoft/yii2-apidoc/blob/master/helpers/ApiMarkdownLaTeX.php

A Markdown helper with support for class reference links.

Protected Properties

Hide inherited properties

Property Type Description Defined By

Public Methods

Hide inherited methods

Method Description Defined By
process() Converts markdown into HTML yii\apidoc\helpers\ApiMarkdownLaTeX

Property Details

Hide inherited properties

$renderer public static property
$renderingContext protected property
protected $renderingContext null

Method Details

Hide inherited methods

consumeQuote() protected method

Defined in: yii\apidoc\helpers\ApiMarkdownTrait::consumeQuote()

Consume lines for a blockquote element

protected void consumeQuote ( $lines, $current )
$lines
$current

                protected function consumeQuote($lines, $current)
{
    $block = parent::consumeQuote($lines, $current);
    $blockTypes = [
        'warning',
        'note',
        'info',
        'tip',
    ];
    // check whether this is a special Info, Note, Warning, Tip block
    $content = $block[0]['content'];
    $first = reset($content);
    if (isset($first[0]) && $first[0] === 'paragraph') {
        $parfirst = reset($first['content']);
        if (isset($parfirst[0]) && $parfirst[0] === 'text') {
            foreach ($blockTypes as $type) {
                if (strncasecmp("$type: ", $parfirst[1], $len = strlen($type) + 2) === 0) {
                    // remove block indicator
                    $block[0]['content'][0]['content'][0][1] = substr($parfirst[1], $len);
                    // add translated block indicator as bold text
                    array_unshift($block[0]['content'][0]['content'], [
                        'strong',
                        [
                            ['text', $this->translateBlockType($type)],
                        ],
                    ]);
                    $block[0]['blocktype'] = $type;
                    break;
                }
            }
        }
    }
    return $block;
}

            
parseApiLinks() protected method
protected void parseApiLinks ( $text )
$text

process() public static method

Converts markdown into HTML

public static string process ( $content, $context null, $paragraph false )
$content string
$context yii\apidoc\models\TypeDoc
$paragraph boolean

                public static function process($content, $context = null, $paragraph = false)
{
    if (!isset(Markdown::$flavors['api-latex'])) {
        Markdown::$flavors['api-latex'] = new static;
    }
    if (is_string($context)) {
        $context = static::$renderer->apiContext->getType($context);
    }
    Markdown::$flavors['api-latex']->renderingContext = $context;
    if ($paragraph) {
        return Markdown::processParagraph($content, 'api-latex');
    } else {
        return Markdown::process($content, 'api-latex');
    }
}

            
renderApiLink() protected method

protected void renderApiLink ( $block )
$block

renderBrokenApiLink() protected method

protected void renderBrokenApiLink ( $block )
$block

renderQuote() protected method

Renders a blockquote

protected void renderQuote ( $block )
$block

                protected function renderQuote($block)
{
    if (isset($block['blocktype'])) {
        // TODO render nice icon for different block types: note, info, warning, tip
        //$class = ' class="' . $block['blocktype'] . '"';
    }
    return '\begin{quote}' . $this->renderAbsy($block['content']) . "\\end{quote}\n";
}

            
translateBlockType() protected method (available since version 2.0.5)

protected void translateBlockType ( $type )
$type

                protected function translateBlockType($type)
{
    $key = ucfirst($type) . ':';
    if (isset(ApiMarkdown::$blockTranslations[$key])) {
        $translation = ApiMarkdown::$blockTranslations[$key];
    } else {
        $translation = $key;
    }
    return "$translation ";
}