Herb C Reference
Loading...
Searching...
No Matches
html_util.h File Reference
#include "util/hb_string.h"
#include <stdbool.h>

Go to the source code of this file.

Functions

bool is_void_element (hb_string_T tag_name)
 
bool has_optional_end_tag (hb_string_T tag_name)
 
bool should_implicitly_close (hb_string_T open_tag_name, hb_string_T next_tag_name)
 
bool parent_closes_element (hb_string_T open_tag_name, hb_string_T parent_close_tag_name)
 
hb_string_T html_closing_tag_string (hb_string_T tag_name)
 Creates a closing HTML tag string like "</tag_name>".
 
hb_string_T html_self_closing_tag_string (hb_string_T tag_name)
 Creates a self-closing HTML tag string like "<tag_name />".
 

Function Documentation

◆ is_void_element()

bool is_void_element ( hb_string_T  tag_name)

◆ has_optional_end_tag()

bool has_optional_end_tag ( hb_string_T  tag_name)

◆ should_implicitly_close()

bool should_implicitly_close ( hb_string_T  open_tag_name,
hb_string_T  next_tag_name 
)

◆ parent_closes_element()

bool parent_closes_element ( hb_string_T  open_tag_name,
hb_string_T  parent_close_tag_name 
)

◆ html_closing_tag_string()

hb_string_T html_closing_tag_string ( hb_string_T  tag_name)

Creates a closing HTML tag string like "</tag_name>".

Parameters
tag_nameThe name of the HTML tag to be enclosed in a closing tag
Returns
A newly allocated string containing the closing tag, or NULL if memory allocation fails
Note
The caller is responsible for freeing the returned string

Example:

hb_string_T tag = html_closing_tag_string(hb_string("div"));
printf("%.*s\n", tag.length, tag.data); // Prints: </div>
free(tag.data);
hb_string_T html_closing_tag_string(hb_string_T tag_name)
Creates a closing HTML tag string like "</tag_name>".
Definition html_util.c:209

◆ html_self_closing_tag_string()

hb_string_T html_self_closing_tag_string ( hb_string_T  tag_name)

Creates a self-closing HTML tag string like "<tag_name />".

Parameters
tag_nameThe name of the HTML tag to be enclosed in a self-closing tag
Returns
A newly allocated string containing the self-closing tag, or NULL if memory allocation fails
Note
The caller is responsible for freeing the returned string

Example:

hb_string_T tag = html_self_closing_tag_string(hb_string("br"));
printf("%.*s\n", tag.length, tag.data); // Prints: <br />
free(tag);
hb_string_T html_self_closing_tag_string(hb_string_T tag_name)
Creates a self-closing HTML tag string like "<tag_name />".
Definition html_util.c:235