$darkmode
Herb C Reference
html_util.c File Reference
#include "include/html_util.h"
#include "include/util.h"
#include "include/util/hb_buffer.h"
#include "include/util/hb_string.h"
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

Functions

bool is_void_element (hb_string_T tag_name)
 
hb_string_T html_closing_tag_string (hb_string_T tag_name)
 Creates a closing HTML tag string like "</tag_name>". More...
 
hb_string_T html_self_closing_tag_string (hb_string_T tag_name)
 Creates a self-closing HTML tag string like "<tag_name />". More...
 

Function Documentation

◆ is_void_element()

bool is_void_element ( hb_string_T  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:44

◆ 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:70