Build the text view for a Markdown message.

@param  \Illuminate\Mail\Markdown  $markdown
@param  array  $data
@return string
15008
protected function buildMarkdownText($markdown, $data)
    {
        return $this->textView
                ?? $markdown->renderText($this->markdown, $data);
    }
511968
public StringBuffer markdown(SchemaMetadata meta, boolean include_input_fields, boolean include_output_fields) {
    MarkdownBuilder builder = new MarkdownBuilder();

    builder.comment("Preview with http://jbt.github.io/markdown-editor");
    builder.heading1("schema ", this.getClass().getSimpleName());
    builder.hline();
    // builder.paragraph(metadata.summary);

    // TODO: refactor with Route.markdown():

    // fields
    boolean first; // don't print the table at all if there are no rows

    try {
      if (include_input_fields) {
        first = true;
        builder.heading2("input fields");

        for (SchemaMetadata.FieldMetadata field_meta : meta.fields) {
          if (field_meta.direction == API.Direction.INPUT || field_meta.direction == API.Direction.INOUT) {
            if (first) {
              builder.tableHeader("name", "required?", "level", "type", "schema?", "schema", "default", "description", "values", "is member of frames", "is mutually exclusive with");
              first = false;
            }
            builder.tableRow(
                field_meta.name,
                String.valueOf(field_meta.required),
                field_meta.level.name(),
                field_meta.type,
                String.valueOf(field_meta.is_schema),
                field_meta.is_schema ? field_meta.schema_name : "", (null == field_meta.value ? "(null)" : field_meta.value.toString()), // Something better for toString()?
                field_meta.help,
                (field_meta.values == null || field_meta.values.length == 0 ? "" : Arrays.toString(field_meta.values)),
                (field_meta.is_member_of_frames == null ? "[]" : Arrays.toString(field_meta.is_member_of_frames)),
                (field_meta.is_mutually_exclusive_with == null ? "[]" : Arrays.toString(field_meta.is_mutually_exclusive_with))
            );
          }
        }
        if (first)
          builder.paragraph("(none)");
      }

      if (include_output_fields) {
        first = true;
        builder.heading2("output fields");
        for (SchemaMetadata.FieldMetadata field_meta : meta.fields) {
          if (field_meta.direction == API.Direction.OUTPUT || field_meta.direction == API.Direction.INOUT) {
            if (first) {
              builder.tableHeader("name", "type", "schema?", "schema", "default", "description", "values", "is member of frames", "is mutually exclusive with");
              first = false;
            }
            builder.tableRow(
                field_meta.name,
                field_meta.type,
                String.valueOf(field_meta.is_schema),
                field_meta.is_schema ? field_meta.schema_name : "",
                (null == field_meta.value ? "(null)" : field_meta.value.toString()), // something better than toString()?
                field_meta.help,
                (field_meta.values == null || field_meta.values.length == 0 ? "" : Arrays.toString(field_meta.values)),
                (field_meta.is_member_of_frames == null ? "[]" : Arrays.toString(field_meta.is_member_of_frames)),
                (field_meta.is_mutually_exclusive_with == null ? "[]" : Arrays.toString(field_meta.is_mutually_exclusive_with)));
          }
        }
        if (first)
          builder.paragraph("(none)");
      }

      // TODO: render examples and other stuff, if it's passed in
    }
    catch (Exception e) {
      IcedHashMapGeneric.IcedHashMapStringObject values = new IcedHashMapGeneric.IcedHashMapStringObject();
      values.put("schema", this);
      // TODO: This isn't quite the right exception type:
      throw new H2OIllegalArgumentException("Caught exception using reflection on schema: " + this,
          "Caught exception using reflection on schema: " + this + ": " + e,
          values);
    }
    return builder.stringBuffer();
  }
23884
public function getSnippetTextFromRevision($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
            
            return $response;
        }
        
        
        $revision=SnippetVersion::get()->byID(intval($data->id));
        if(!empty($revision) && $revision!==false && $revision->ID!=0) {
            $lang=$revision->Parent()->Language();
            
            $snippetScript='<script type="text/javascript" src="app:/tools/external/syntaxhighlighter/brushes/shBrush'.$lang->HighlightCode.'.js"></script>';
            if($lang->UserLanguage==true && !empty($lang->BrushFile)) {
                $snippetScript="<script type=\"text/javascript\">\n".@file_get_contents(Director::baseFolder().'/'.$lang->BrushFile)."\n</script>";
            }
            
            $response['data']='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
                                 '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'.
                                    '<head>'.
                                        '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.
                                        '<link type="text/css" rel="stylesheet" href="app:/tools/external/syntaxhighlighter/themes/shCore.css"/>'.
                                        '<link type="text/css" rel="stylesheet" href="app:/tools/external/syntaxhighlighter/themes/shCore'.$data->style.'.css"/>'.
                                        '<link type="text/css" rel="stylesheet" href="app:/tools/external/syntaxhighlighter/themes/shTheme'.$data->style.'.css"/>'.
                                        '<link type="text/css" rel="stylesheet" href="app:/tools/syntaxhighlighter.css"/>'.
                                        '<script type="text/javascript" src="app:/tools/external/syntaxhighlighter/brushes/shCore.js"></script>'.
                                        $snippetScript.
                                        '<script type="text/javascript" src="app:/tools/external/jquery-packed.js"></script>'.
                                        '<script type="text/javascript" src="app:/tools/highlight_helper.js"></script>'.
                                    '</head>'.
                                    '<body>'.
                                        '<pre class="brush: '.strtolower($lang->HighlightCode).'" style="font-size:10pt;">'.htmlentities(preg_replace('/\r\n|\n|\r/', "\n", $revision->Text), null, 'UTF-8').'</pre>'.
                                    '</body>'.
                                 '</html>';
        }else {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.REVISION_NOT_FOUND', '_Revision not found');
        }
        
        
        return $response;
    }
99346
public static function formatText(string $text, Tree $tree): string
    {
        switch ($tree->getPreference('FORMAT_TEXT')) {
            case 'markdown':
                return '<div class="markdown" dir="auto">' . self::markdown($text, $tree) . '</div>';
            default:
                return '<div class="markdown" style="white-space: pre-wrap;" dir="auto">' . self::expandUrls($text, $tree) . '</div>';
        }
    }
127594
public static function html($message, $data = null)
    {
        if (!static::$on) {
            return;
        }

        echo "<hr>";
        echo "<i>";
            static::indent();
            echo "<b>" . static::getTime() . " - " . $message . "</b>";
            if (is_array($data)) {
                Html::print_r($data);
            } elseif ($data) {
                static::indent();
                echo "&nbsp;&nbsp;&nbsp;&nbsp;" . $data . "<br>";
            }
        echo "</i>";
    }
1125468
protected function buildTextMessage(Html2PdfException $e, $data)
    {
        $this->message = 'Html2Pdf Error ['.$e->getCode().']'."\n";
        $this->message.= $e->getMessage()."\n";
        $this->message.= ' File: '.$e->getFile()."\n";
        $this->message.= ' Line: '.$e->getLine()."\n";

        if (!empty($data)) {
            foreach ($data as $key => $value) {
                $this->message .= ' '.ucwords($key).': '.trim($value)."\n";
            }
        }
    }
970703
public function output_html($data, $query='') {
        global $OUTPUT;

        $context = (object) [
            'name' => $this->get_full_name(),
            'emoticons' => [],
            'forceltr' => true,
        ];

        $i = 0;
        foreach ($data as $field => $value) {

            // When $i == 0: text.
            // When $i == 1: imagename.
            // When $i == 2: imagecomponent.
            // When $i == 3: altidentifier.
            // When $i == 4: altcomponent.
            $fields[$i] = (object) [
                'field' => $field,
                'value' => $value,
                'index' => $i
            ];
            $i++;

            if ($i > 4) {
                $icon = null;
                if (!empty($fields[1]->value)) {
                    if (get_string_manager()->string_exists($fields[3]->value, $fields[4]->value)) {
                        $alt = get_string($fields[3]->value, $fields[4]->value);
                    } else {
                        $alt = $fields[0]->value;
                    }
                    $icon = new pix_emoticon($fields[1]->value, $alt, $fields[2]->value);
                }
                $context->emoticons[] = [
                    'fields' => $fields,
                    'icon' => $icon ? $icon->export_for_template($OUTPUT) : null
                ];
                $fields = [];
                $i = 0;
            }
        }

        $context->reseturl = new moodle_url('/admin/resetemoticons.php');
        $element = $OUTPUT->render_from_template('core_admin/setting_emoticons', $context);
        return format_admin_setting($this, $this->visiblename, $element, $this->description, false, '', NULL, $query);
    }
351622
def markdown_to_text(self, source):
        """"""
        if self.comment and self.comment != "#'":
            source = copy(source)
            comment_magic(source, self.language, self.comment_magics)

        return comment_lines(source, self.comment)
533551
protected function buildMarkdownView()
    {
        $markdown = Container::getInstance()->make(Markdown::class);

        if (isset($this->theme)) {
            $markdown->theme($this->theme);
        }

        $data = $this->buildViewData();

        return [
            'html' => $markdown->render($this->markdown, $data),
            'text' => $this->buildMarkdownText($markdown, $data),
        ];
    }
182411
public function substituteFileContent($markdown, array $meta = array())
    {
        $variables = array();

        // replace %version%
        $variables['%version%'] = static::VERSION;

        // replace %site_title%
        $variables['%site_title%'] = $this->getConfig('site_title');

        // replace %base_url%
        if ($this->isUrlRewritingEnabled()) {
            // always use `%base_url%?sub/page` syntax for internal links
            // we'll replace the links accordingly, depending on enabled rewriting
            $variables['%base_url%?'] = $this->getBaseUrl();
        } else {
            // actually not necessary, but makes the URL look a little nicer
            $variables['%base_url%?'] = $this->getBaseUrl() . '?';
        }
        $variables['%base_url%'] = rtrim($this->getBaseUrl(), '/');

        // replace %theme_url%
        $variables['%theme_url%'] = $this->getBaseThemeUrl() . $this->getConfig('theme');

        // replace %meta.*%
        if ($meta) {
            foreach ($meta as $metaKey => $metaValue) {
                if (is_scalar($metaValue) || ($metaValue === null)) {
                    $variables['%meta.' . $metaKey . '%'] = (string) $metaValue;
                }
            }
        }

        return str_replace(array_keys($variables), $variables, $markdown);
    }
1326916
public function markdown($name = null, $value = null) 
	{
		Argument::i()
			->test(1, 'string', 'null')
			->test(2, 'scalar', 'null');
			
		$field = Markdown::i();
		
		if(!is_null($name)) {
			$field->setName($name);
		}
		
		if(!is_null($value)) {
			$field->setValue($value);
		}
		
		return $field;
	}
559001
public function markdown($view, array $data = [])
    {
        $this->markdown = $view;
        $this->viewData = $data;

        $this->view = null;

        return $this;
    }
751232
protected function getHtmlTitleFormatForPage(array $data)
    {
        if (empty($data['page']['title'])) {
            return $data['site']['name'];
        }

        return Str::replace($this->formats['page'], $data);
    }
197306
public static function output($message, $data = null)
    {
        if (static::$mode == "html") {
            static::html($message, $data);
        } else {
            static::text($message, $data);
        }
    }
1255266
public function view($data)
    {
        if (array_key_exists('current', $data)) {
            $this->current = $data['current'];
        }
        if (array_key_exists('title_formatter', $data)) {
            $tf = $data['title_formatter'];
        }
        if (array_key_exists('descr_formatter', $data)) {
            $df = $data['descr_formatter'];
        }
        $i = 1;
        foreach ($this->steps as $step) {
            $sdiv = new Element('div');
            $sstyle = $this->getStyle('step');
            if ($i == $this->current) {
                $sdiv->addClass($this->getClass('current'));
                $sstyle .= $this->getStyle('current');
            } elseif ($i < $this->current) {
                $sdiv->addClass($this->getClass('completed'));
                $sstyle .= $this->getStyle('completed');
            }
            $sdiv->addClass($this->getClass('step'))->setAttribute('style', $sstyle);
            $title = array_key_exists('title', $step) ? $step['title'] : '';
            $descr = array_key_exists('descr', $step) ? $step['descr'] : '';
            if (isset($tf) && is_callable($tf)) {
                $title = $tf($title);
            }
            if (isset($df) && is_callable($df)) {
                $descr = $df($descr);
            }
            $contdiv = new Element('div');
            $contdiv->addClass($this->getClass('content'))->setAttribute('style', $this->getStyle('content'));
            $tdiv = new Element('div', new Text($title));
            $tdiv->addClass($this->getClass('title'))->setAttribute('style', $this->getStyle('title'));
            $ddiv = new Element('div', new Text($descr));
            $ddiv->addClass($this->getClass('descr'))->setAttribute('style', $this->getStyle('descr'));
            $contdiv->appendChild($tdiv)->appendChild($ddiv);
            $sdiv->appendChild($contdiv);
            $this->appendChild($sdiv);
            $i++;
        }
        return $this->render();
    }
164477
protected function makeEditAction($data)
    {
        extract($data);

        // Make markup
        $editable = app('decoy.user')->can('update', $controller);
        return sprintf('<a href="%s" class="action-edit js-tooltip"
            data-placement="left" title="%s">
                <span class="glyphicon glyphicon-%s"></span>
            </a>',
            $this->getAdminEditUri($controller, $many_to_many), // URL
            $editable ? // Label
                __('decoy::base.action.edit') :
                __('decoy::base.action.read') ,
            $editable ? 'pencil' : 'zoom-in' // Icon
        );
    }
674536
public function textTemplate($template, $data=[]) {
		$data['message'] = $this;
		$res = $this->buildTemplate($template, $data);
		return $this->text($res);
	}