HumHub Documentation (unofficial)

DiffRendererHtmlInline extends Diff_Renderer_Html_Array
in package

Renders diff to HTML. Output adjusted to be copy-paste friendly.

Tags
author

Alexander Makarov sam@rmcreative.ru

since
2.0

Table of Contents

Properties

$diff  : object
$defaultOptions  : array<string|int, mixed>
$options  : array<string|int, mixed>

Methods

__construct()  : mixed
The constructor. Instantiates the rendering engine and if options are passed, sets the options for the renderer.
fixSpaces()  : string
Replace a string containing spaces with a HTML representation using &nbsp;.
render()  : string
Render a and return diff with changes between the two sequences displayed inline (under each other)
setOptions()  : mixed
Set the options of the renderer to those supplied in the passed in array.
expandTabs()  : string
Replace tabs in a single line with a number of spaces as defined by the tabSize option.
formatLines()  : array<string|int, mixed>
Format a series of lines suitable for output in a HTML rendered diff.
getChangeExtent()  : array<string|int, mixed>
Given two strings, determine where the changes in the two strings begin, and where the changes in the two strings end.
htmlSafe()  : string
Make a string containing HTML safe for output on a page.

Properties

$diff

public object $diff

Instance of the diff class that this renderer is generating the rendered diff for.

$defaultOptions

protected array<string|int, mixed> $defaultOptions = array('tabSize' => 4)

Array of the default options that apply to this renderer.

$options

protected array<string|int, mixed> $options = array()

Array containing the user applied and merged default options for the renderer.

Methods

__construct()

The constructor. Instantiates the rendering engine and if options are passed, sets the options for the renderer.

public __construct([array<string|int, mixed> $options = array() ]) : mixed
Parameters
$options : array<string|int, mixed> = array()

Optionally, an array of the options for the renderer.

fixSpaces()

Replace a string containing spaces with a HTML representation using &nbsp;.

public static fixSpaces(string $matches) : string
Parameters
$matches : string

Regex matches array.

Return values
string

The HTML representation of the string.

render()

Render a and return diff with changes between the two sequences displayed inline (under each other)

public render() : string
Return values
string

The generated inline diff.

setOptions()

Set the options of the renderer to those supplied in the passed in array.

public setOptions(array<string|int, mixed> $options) : mixed

Options are merged with the default to ensure that there aren't any missing options.

Parameters
$options : array<string|int, mixed>

Array of options to set.

expandTabs()

Replace tabs in a single line with a number of spaces as defined by the tabSize option.

private expandTabs(string $line) : string
Parameters
$line : string

The containing tabs to convert.

Return values
string

The line with the tabs converted to spaces.

formatLines()

Format a series of lines suitable for output in a HTML rendered diff.

private formatLines(array<string|int, mixed> $lines) : array<string|int, mixed>

This involves replacing tab characters with spaces, making the HTML safe for output, ensuring that double spaces are replaced with   etc.

Parameters
$lines : array<string|int, mixed>

Array of lines to format.

Return values
array<string|int, mixed>

Array of the formatted lines.

getChangeExtent()

Given two strings, determine where the changes in the two strings begin, and where the changes in the two strings end.

private getChangeExtent(string $fromLine, string $toLine) : array<string|int, mixed>
Parameters
$fromLine : string

The first string.

$toLine : string

The second string.

Return values
array<string|int, mixed>

Array containing the starting position (0 by default) and the ending position (-1 by default)

htmlSafe()

Make a string containing HTML safe for output on a page.

private htmlSafe(string $string) : string
Parameters
$string : string

The string.

Return values
string

The string with the HTML characters replaced by entities.


        
On this page

Search results