makeEngine: Define a Backend

Description Usage Arguments Details Value Author(s)

View source: R/engine.R

Description

These functions can be used to define a backend that is used to perform HTML layout.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
makeEngine(layout, cssTransform=list())
makeLayout(type, name, x, y, width, height, baseline, text, family, 
    bold, italic, size, color, direction, backgroundColor, borderLeftWidth, 
    borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftStyle, 
    borderTopStyle, borderRightStyle, borderBottomStyle, borderLeftColor, 
    borderTopColor, borderRightColor, borderBottomColor,
    listStyleType, listStylePosition)
copyAssets(html, dir) 
fontFiles(fonts, device)
layoutFields

Arguments

layout

A function that performs HTML layout and returns the result (which should be the result of calling makeLayout).

cssTransform

A list of (optional) functions that a backend can define for transforming CSS properties. Currently used components are fontWeight and fontFile.

type, name, x, y, width, height, baseline, text, family, bold, italic, size, color, direction, backgroundColor, borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftStyle, borderTopStyle, borderRightStyle, borderBottomStyle, borderLeftColor, borderTopColor, borderRightColor, borderBottomColor, listStyleType, listStylePosition

Each argument represents a field that the layout result should return for each node in the HTML content. The type, name, location and size fields must be present, but most other fields can be NA. In particular, the fields relating to text content should be NA for non-text nodes.

html

A "flowedhtml" object (as generated by the flow function.

dir

A directory to copy asset files to.

fonts

A character vector containing R font family names.

device

The name of the device that will be used to render the layout.

Details

The makeEngine function should be used to create a backend for the layoutEngine package. This function should be supplied a function that accepts arguments html, width, height, fonts, and device, where html is an "htmlDocument" object (as produced by htmlDocument or htmlElement), width and height are the width and height that should be used to layout the HTML (in inches), and the other arguments are as described on this page. The function should return a "flowedhtml" object (as produced by "makeLayout").

The remainder of the functions are helper functions for use in the main backend function: copyAssets to copy assets to a useful place; fontFiles to locate font files (probably to copy them as well); and makeLayout to create the result of the layout. The layoutFields object is useful for providing the names of the columns in the layout result.

Value

makeEngine produces a "layoutengine" object.

makeLayout produces a "flowedhtml" object. At present this is just a data frame, but longer term something more hierarchical is probably going to be better.

Author(s)

Paul Murrell


pmur002/layoutengine documentation built on June 20, 2020, 10:32 p.m.