Class Var<T extends Var<T>>


public class Var<T extends Var<T>> extends PhrasingContentElement<T>
Represents an HTML <var> element for marking up variables in mathematical expressions or programming contexts.

This class provides functionality to create semantic markup for variables, including mathematical variables, function parameters, placeholder values, and other variable names in technical or programming documentation. The <var> element is typically rendered in italics by default, helping to visually distinguish variables from regular text. This semantic markup improves code documentation, mathematical notation, and makes technical content more accessible.

Features:

  • Semantically marks up variables in expressions and documentation
  • Typically rendered in italic font style
  • Suitable for mathematical variables and programming identifiers
  • Improves accessibility of technical content
  • Supports text initialization through constructor
  • Extends
    invalid reference
    TextElement
    for text content management

Usage:


 // Mathematical expression
 P equation = new P();
 equation.addElement(new Var("x"));
 equation.addElement(new Text(" = "));
 equation.addElement(new Var("y"));
 equation.addElement(new Text(" + 5"));
 // Renders as: x = y + 5 (with x and y in italics)

 // Function documentation
 Code funcDoc = new Code();
 funcDoc.addElement(new Text("calculateArea("));
 funcDoc.addElement(new Var("width"));
 funcDoc.addElement(new Text(", "));
 funcDoc.addElement(new Var("height"));
 funcDoc.addElement(new Text(")"));

 // Placeholder in template
 P instruction = new P();
 instruction.addElement(new Text("Replace "));
 instruction.addElement(new Var("username"));
 instruction.addElement(new Text(" with your actual username."));

 // Empty variable for dynamic content
 Var variable = new Var();
 variable.setText("n");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Var

      public Var()
      Constructs an empty Var element.

      Creates a new <var> element with no initial text content. Text can be added later using methods inherited from

      invalid reference
      TextElement
      .

    • Var

      public Var(String text)
      Constructs a Var element with the specified variable name.

      Creates a new <var> element containing the provided text, which represents a variable name that will typically be rendered in italics.

      Parameters:
      text - the variable name or identifier to mark up