webrender

module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause

README

Web render

This module implements a static renderer for the HTML, CSS and SVG formats.

It consists for the main part of a Golang port of the awesome Weasyprint python Html to Pdf library.

This is an ongoing work, not production ready just yet.

Scope

The main goal of this module is to process HTML or SVG inputs into laid out documents, ready to be paint, and to be compatible with various output formats (like raster images or PDF files). To do so, this module uses an abstraction of the output, whose implementation must be provided by an higher level package.

Outline of the module

From the lower level to the higher level, this module has the following structure :

  • the css package provides a CSS parser, with property validation and a CSS selector engine (css/selector).

  • the svg package implements a SVG parser and renderer, supporting CSS styling.

  • the html package implements an HTML renderer

  • the backend package defines the interfaces which must be implemented by output targets.

The main entry points are the html/document package for HTML rendering and the svg package if you only need SVG support.

HTML to PDF: an overview

The html package implements a static HTML renderer, which works by :

  • parsing the HTML input and fetching CSS files, and cascading the styles. This is implemented in the html/tree package

  • building a tree of boxes from the HTML structure (package html/boxes)

  • laying out this tree, that is attributing position and dimensions to the boxes, and performing line, paragraph and page breaks (package html/layout)

  • drawing the laid out tree to an output. Contrary to the Python library, this step is here performed on an abstract output, which must implement the backend.Document interface. This means than the core layout logic could easily be reused for other purposes, such as visualizing html document on a GUI application, or targetting other output file formats.

Directories

Path Synopsis
Package backend defines a common interface, providing graphics primitives.
Package backend defines a common interface, providing graphics primitives.
css
parser
Package parser implements the tokenization of a CSS input and the construction of the corresponding Abstract Syntax Tree.
Package parser implements the tokenization of a CSS input and the construction of the corresponding Abstract Syntax Tree.
properties
This package defines the types needed to handle the various CSS properties.
This package defines the types needed to handle the various CSS properties.
selector
Package selector is an implementation of CSS selectors.
Package selector is an implementation of CSS selectors.
html
boxes
Package boxes defines the basic elements of the formatting structure, as a tree of boxes.
Package boxes defines the basic elements of the formatting structure, as a tree of boxes.
document
This package implements the high level parts of the document generation, but is still backend independant.
This package implements the high level parts of the document generation, but is still backend independant.
layout
Transform a "before layout" box tree into an "after layout" tree, by breaking boxes across lines and pages; and determining the position and dimension of each box fragment.
Transform a "before layout" box tree into an "after layout" tree, by breaking boxes across lines and pages; and determining the position and dimension of each box fragment.
tree
This module takes care of steps 3 and 4 of “CSS 2.1 processing model”: Retrieve stylesheets associated with a document and annotate every Element with a value for every CSS property.
This module takes care of steps 3 and 4 of “CSS 2.1 processing model”: Retrieve stylesheets associated with a document and annotate every Element with a value for every CSS property.
Fetch and decode images in range various formats.
Fetch and decode images in range various formats.
Package logger provides two log.Logger emitting progress status and warning information.
Package logger provides two log.Logger emitting progress status and warning information.
Package matrix provides 2D affine transformations.
Package matrix provides 2D affine transformations.
Package svg implements parsing of SVG images.
Package svg implements parsing of SVG images.
draw
Package draw use a backend and a layout object to draw glyphs on the ouput.
Package draw use a backend and a layout object to draw glyphs on the ouput.
hyphen
Package hyphen hyphenates text using existing Hunspell hyphenation dictionaries.
Package hyphen hyphenates text using existing Hunspell hyphenation dictionaries.
testutils/tracer
Package tracer provides a function to dump the current layout tree, which may be used in debug mode.
Package tracer provides a function to dump the current layout tree, which may be used in debug mode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL