Returns string or array of strings with highlighted areas enclosed
by \ueeee and \ueeef.

@param array|string $fieldContent content of the field to highlight
@param array        $arguments

@return array|string
16369
protected static function highlightField($fieldContent, $arguments)
    {
        $highlightInfo = self::getHighlightInfo($arguments);

        if (is_array($fieldContent)) {
            $result = [];
            foreach ($fieldContent as $singleField) {
                $result[] = self::highlightSingleField($singleField, $highlightInfo, $arguments);
            }
        } else {
            $result = self::highlightSingleField($fieldContent, $highlightInfo, $arguments);
        }

        return $result;
    }
918423
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
    {
        $value = $arguments['value'];
        if ($value === null) {
            $value = $renderChildrenClosure();
        }
        $padTypes = array(
            'left' => STR_PAD_LEFT,
            'right' => STR_PAD_RIGHT,
            'both' => STR_PAD_BOTH
        );
        $padType = $arguments['padType'];
        if (!isset($padTypes[$padType])) {
            $padType = 'right';
        }
        return str_pad($value, $arguments['padLength'], $arguments['padString'], $padTypes[$padType]);
    }
336239
public function content($arg=null)
	{
		switch($this->format)
		{
			case 'json':
				if(!isset($arg))
				{
					$arg = false;
				}
				return $this->json($arg);
				break;
			case 'xml' :
				if(!isset($arg))
				{
					$arg = 'dom';
				}
				return $this->xml($arg);
				break;
			default :
				return $this->getContent();
				break;
		}
	}
427146
public function toContent($contents, $format, $options = array())
	{
		if (!($contents instanceof Registry))
		{
			$contents = new Registry($contents);
		}

		return $contents->toString($format, $options);
	}
599078
public function textareaRow(array $args = [])
    {
        $default_args = [
            // Required.
            'label' => '',

            // Suggested.
            'tip' => '',

            // Required.
            'name'  => '',
            'value' => '',

            // Optional.
            'placeholder' => '',
            'note'        => '',

            // Optional.
            'class' => '',
            'style' => '',
            'attrs' => '',

            // Optional.
            'if' => '',
        ];
        if (!array_key_exists('value', $args)) {
            throw $this->c::issue('Missing `value` key.');
        }
        $cfg = array_merge($default_args, $args);
        $cfg = array_intersect_key($cfg, $default_args);
        $cfg = array_map('strval', $cfg);

        if (!$cfg['name']) {
            throw $this->c::issue('Arg `name` is required.');
        }
        $cfg['var_name'] = $cfg['name']; // Internal copy.
        $cfg['id']       = $this->elementId($cfg['var_name']);
        $cfg['name']     = $this->elementName($cfg['var_name']);
        $cfg['class']    = $this->c::mbTrim($cfg['class'].' '.$this->elementClass($cfg['var_name']));

        $cfg['tip']  = $cfg['tip'] ? $this->s::menuPageTip($cfg['tip']) : '';
        $cfg['note'] = $cfg['note'] ? $this->s::menuPageNote($cfg['note']) : '';

        $markup = '<tr'.($cfg['if'] ? ' data-if="'.esc_attr($cfg['if']).'"' : '').'>';

        if ($cfg['label']) {
            $markup .= '<th scope="row">';
            $markup .= '<div>'; // For positioning.
            $markup .= $cfg['tip'];
            $markup .= '<label for="'.esc_attr($cfg['id']).'" title="'.esc_attr($cfg['label']).'">'.
                            $cfg['label'].
                       '</label>';
            $markup .= '</div>';
            $markup .= '</th>';
        }
        $markup .= '<td'.(!$cfg['label'] ? ' colspan="2"' : '').'>';
        $markup .= '<div>'; // For positioning.
        $markup .= '<textarea'.
                        ' name="'.esc_attr($cfg['name']).'" id="'.esc_attr($cfg['id']).'"'.
                        ' class="'.esc_attr($cfg['class']).'" style="'.esc_attr($cfg['style']).'"'.
                        ' placeholder="'.esc_attr($cfg['placeholder']).'" autocomplete="new-password"'.
                        ($cfg['attrs'] ? ' '.$cfg['attrs'] : '').
                        '>'.esc_textarea($cfg['value']).'</textarea>';
        $markup .= $cfg['note'];
        $markup .= '</div>';
        $markup .= '</td>';

        $markup .= '</tr>';

        return $markup;
    }
804179
private function prepareFileContent($fileContent)
    {
        // Remove 1 line comments
        $fileContent = preg_replace("#(.*)//(.*)#", " ", $fileContent);

        // Remove multi-line comments
        $fileContent = preg_replace("#/\*(.*)\*?/#", "", $fileContent);

        // Remove all new line characters
        $fileContent = preg_replace("/\n*/", "", $fileContent);

        // Add 2 new line characters after <?php
        $fileContent = str_replace("<?php", "<?php\n\n", $fileContent);

        // Add 1 new line characters after ;
        $fileContent = str_replace(";", ";\n", $fileContent);

        // Add 1 new line characters after {
        $fileContent = str_replace("{ ", "{\n", $fileContent);

        // Add 1 new line character after });
        $fileContent = str_replace("});", "});\n", $fileContent);

        return $fileContent;
    }
426882
protected function _argsToString(array $arguments) {
		$stringArguments = '';
		foreach ($arguments as $name => $value) {
			if (is_numeric($name)) {
				$stringArguments .= ' ' . $value;
			} else {
				$stringArguments .= ' ' . $name . ' ' . ProcessUtils::escapeArgument($value);
			}
		}

		return $stringArguments;
	}
930156
public function text($content, array $arguments = [])
    {
        $this->outbox->put($this->context->file, $arguments ? $this->generate($content, $arguments) : $content);
    }
1009010
private function extractTagIds(SiteContent $content, array $fields)
    {
        $tagsIdsGrouped = [[]];

        foreach ($fields as $identifier) {
            if (!$content->hasField($identifier)) {
                throw new InvalidArgumentException(
                    "Content does not contain field '{$identifier}'"
                );
            }

            $field = $content->getField($identifier);

            if ($field->fieldTypeIdentifier !== 'eztags') {
                throw new InvalidArgumentException(
                    "Field '{$identifier}' is not of 'eztags' type"
                );
            }

            /** @var $value \Netgen\TagsBundle\Core\FieldType\Tags\Value */
            $value = $field->value;
            $tagsIdsGrouped[] = array_map(function (Tag $tag) {return $tag->id;}, $value->tags);
        }

        return array_merge(...$tagsIdsGrouped);
    }
827100
public function textarea( array $args = [], $implode = false )
	{
		$attributes = $this->parseAttributes( self::TEXTAREA_ATTRIBUTES, $args );

		return $this->maybeImplode( $attributes, $implode );
	}
1181296
function getTextFromContent(contentNodes) {
  if (contentNodes === null) {
    return '';
  }
  const texts = [...contentNodes].map(node => node.textContent);
  const text = texts.join('').trim();
  return unescapeHtml(text);
}
360326
private function removeComments($fileContent)
    {
        return rtrim(
            implode(
                array_filter(
                    array_map(
                        function ($line) {
                            if (0 === mb_strpos(ltrim($line), '#')) {
                                return '';
                            }

                            return rtrim($line) . "\n";
                        },
                        explode("\n", $fileContent)
                    )
                )
            )
        ) . "\n";
    }
977681
function renderRunningContentBackMatterRightField( $args ) {
		unset( $args['label_for'], $args['class'] );
		$this->renderCustomSelect(
			[
				'id' => 'running_content_back_matter_right',
				'name' => 'running_content_back_matter_right',
				'value' => getset( $this->options, 'running_content_back_matter_right' ),
				'choices' => $args,
			]
		);
		$this->renderField(
			[
				'id' => 'running_content_back_matter_right_custom',
				'name' => 'pressbooks_theme_options_' . $this->getSlug(),
				'option' => 'running_content_back_matter_right',
				'value' => getset( $this->options, 'running_content_back_matter_right' ),
				'type' => 'text',
				'class' => 'regular-text code',
			]
		);
	}
74263
public function getContent(string $field)
    {
        return Arr::get($this->toArray(), $field) ?? Arr::get($this->getRelations(), $field);
    }
1168643
function renderRunningContentPartLeftField( $args ) {
		unset( $args['label_for'], $args['class'] );
		$this->renderCustomSelect(
			[
				'id' => 'running_content_part_left',
				'name' => 'running_content_part_left',
				'value' => getset( $this->options, 'running_content_part_left' ),
				'choices' => $args,
			]
		);
		$this->renderField(
			[
				'id' => 'running_content_part_left_custom',
				'name' => 'pressbooks_theme_options_' . $this->getSlug(),
				'option' => 'running_content_part_left',
				'value' => getset( $this->options, 'running_content_part_left' ),
				'type' => 'text',
				'class' => 'regular-text code',
			]
		);
	}
945584
public function highlightArrayOfWordsInContent($wordArray, $content)
    {
        if (is_array($wordArray) && count($wordArray)) {
            $highlightedWord = (!empty($this->conf['highlightedWord_stdWrap'])) ?
                $this->cObj->stdWrap('\0', $this->conf['highlightedWord_stdWrap']) :
                '<span class="hit">\0</span>';

            foreach ($wordArray as $word) {
                $word = preg_quote($word, '/');
                $word = htmlspecialchars($word);
                // Todo: Highlight hits within words when using ke_seaarch_premium
                // Todo: option "in word search" by removing the \b parameter
                //$content = preg_replace('/(' . $word . ')/iu', $highlightedWord, $content);
                $content = preg_replace('/\b(' . $word . ')/iu', $highlightedWord, $content);
            }
        }
        return $content;
    }
259522
public static function getStub(string $filename, array $tokens = [], string $defaultContent = ''): string
    {
        return self::getTemplate($filename, $tokens, $defaultContent, 'stub');
    }