Herb C Reference
Loading...
Searching...
No Matches
html_util.c File Reference
#include "include/html_util.h"
#include "include/util.h"
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

Functions

bool is_void_element (const char *tag_name)
 
bool is_html4_void_element (const char *tag_name)
 
char * html_opening_tag_string (const char *tag_name)
 Creates an opening HTML tag string like "<tag_name>".
 
char * html_closing_tag_string (const char *tag_name)
 Creates a closing HTML tag string like "</tag_name>".
 
char * html_self_closing_tag_string (const char *tag_name)
 Creates a self-closing HTML tag string like "<tag_name />".
 

Function Documentation

◆ is_void_element()

bool is_void_element ( const char *  tag_name)

◆ is_html4_void_element()

bool is_html4_void_element ( const char *  tag_name)

◆ html_opening_tag_string()

char * html_opening_tag_string ( const char *  tag_name)

Creates an opening HTML tag string like "<tag_name>".

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

Example:

char* tag = html_opening_tag_string("div");
if (tag) {
printf("%s\n", tag); // Prints: <div>
free(tag);
}
char * html_opening_tag_string(const char *tag_name)
Creates an opening HTML tag string like "<tag_name>".
Definition html_util.c:56

◆ html_closing_tag_string()

char * html_closing_tag_string ( const char *  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:

char* tag = html_closing_tag_string("div");
if (tag) {
printf("%s\n", tag); // Prints: </div>
free(tag);
}
char * html_closing_tag_string(const char *tag_name)
Creates a closing HTML tag string like "</tag_name>".
Definition html_util.c:90

◆ html_self_closing_tag_string()

char * html_self_closing_tag_string ( const char *  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:

char* tag = html_self_closing_tag_string("br");
if (tag) {
printf("%s\n", tag); // Prints: <br />
free(tag);
}
char * html_self_closing_tag_string(const char *tag_name)
Creates a self-closing HTML tag string like "<tag_name />".
Definition html_util.c:125