Crate domrs

Source
Expand description

§Overview

domrs is a powerful library designed to streamline the creation and serialization of HTML, CSS and SVG documents.

domrs empowers developers with a concise and intuitive interface to effortlessly construct structured and visually appealing documents.

Key features:

  • HTML, CSS and SVG support: seamlessly build HTML web pages, stylized CSS documents and dynamic SVG graphics using Rust’s strong typing and safety.

  • Builder pattern: enjoy the convenience of a builder pattern for creating complex document structures, ensuring code readability and maintainability.

  • Serialization: effortlessly serialize created documents into standard-compliant HTML, CSS or SVG files, facilitating easy integration into web applications, storage or reporting tools.

With its ergonomic design and robust functionality, domrs offers a hassle-free solution for developers seeking a reliable tool to craft web-based documents within Rust projects. Whether you’re building a web app, generating dynamic graphics, or managing stylesheets, domrs provides the tools you need.

Get started with domrs today and unlock the potential for efficient document creation and serialization in Rust!

§Getting started

§Create HTML document

use domrs::HtmlDocument;

let html = HtmlDocument::new();
assert_eq!("<html/>\n", html.to_string());

§Create CSS stylesheet

use domrs::CssDocument;

let css = CssDocument::new();
assert_eq!("", css.to_string());

§Create SVG graphics

use domrs::SvgDocument;

let svg = SvgDocument::new();
assert_eq!("<svg/>", svg.to_string());

Macros§

auto
border
css_num
div
em
h1
Creates <h1> HTML element. The section heading level 1 element.
h2
Creates <h2> HTML element. The section heading level 2 element.
h3
Creates <h3> HTML element. The section heading level 3 element.
h4
Creates <h4> HTML element. The section heading level 4 element.
h5
Creates <h5> HTML element. The section heading level 5 element.
h6
Creates <h6> HTML element. The section heading level 6 element.
perc
pt
px
span
zero

Structs§

CssBorder
CssDeclaration
CssDocument
CssFontFamily
CssGroup
CssNumber
A structure representing the CSS number.
CssRuleset
A structure representing CSS ruleset.
CssSelector
A structure representing the CSS selector.
CssSelectorPart
A structure representing a part of the CSS selector.
HtmlAttribute
A structure representing HTML attribute.
HtmlBodyElement
A structure representing HTML <body> element.
HtmlDocument
A structure representing HTML document.
HtmlElement
A structure representing HTML element.
HtmlHeadElement
A structure representing HTML <head> element.
HtmlLinkElement
A structure representing HTML <link> element.
HtmlStyleElement
A structure representing HTML <style> element.
SvgDocument
A structure representing the outermost svg element of SVG document.
SvgNumber
A structure representing the SVG number.

Enums§

CssAtRule
An enumeration representing a CSS @ rule.
CssBorderStyle
CssColor
An enumeration representing CSS colors.
CssElement
A structure representing CSS element.
CssFontGenericFamily
CssFontStyle
An enumeration representing a CSS font style.
CssProperty
CssUnit
CssValue
SvgAttribute
An enumeration representing attributes used in SVG elements.

Constants§

DEFAULT_CSS_INDENT
Default text indentation in CSS documents.
DEFAULT_CSS_OFFSET
Default text offset in CSS documents.
DEFAULT_HTML_DOCTYPE
Default DOCTYPE in HTML documents.
DEFAULT_HTML_INDENT
Default text indentation in HTML documents.
DEFAULT_HTML_LANGUAGE
Default language for HTML documents.
DEFAULT_HTML_NAMESPACE
Default namespace in HTML documents.
DEFAULT_HTML_OFFSET
Default text offset in HTML documents.
DEFAULT_SVG_INDENT
Default text indentation in SVG documents.
DEFAULT_SVG_OFFSET
Default text offset in SVG documents.

Traits§

ToText
A trait for converting value to a textual representation with provided offset and indentation.