Last active
December 6, 2023 03:05
-
-
Save gboncoffee/9859fa6001d843b0c7842556824cafe6 to your computer and use it in GitHub Desktop.
Macros to generate HTML with the C preprocessor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __HTML_MACROS | |
#define __HTML_MACROS | |
#define HTML(l, head, body) <!DOCTYPE html> \ | |
<html lang=#l> \ | |
head \ | |
body \ | |
</html> | |
#define HEAD(...) <head> \ | |
<meta charset="utf-8"> \ | |
<title> \ | |
__VA_ARGS__ \ | |
</title> \ | |
</head> | |
#define BODY(...) <body> \ | |
__VA_ARGS__ \ | |
</body> | |
#define H1(...) <h1>__VA_ARGS__</h1> | |
#define H2(...) <h2>__VA_ARGS__</h2> | |
#define H3(...) <h3>__VA_ARGS__</h3> | |
#define H4(...) <h4>__VA_ARGS__</h4> | |
#define H5(...) <h5>__VA_ARGS__</h5> | |
#define IT(...) <em>__VA_ARGS__</em> | |
#define B(...) <b>__VA_ARGS__</b> | |
#define P(...) <p>__VA_ARGS__</p> | |
#define S(...) __VA_ARGS__ | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "html.h" | |
HTML( | |
en, | |
HEAD(Hello, World!), | |
BODY( | |
H1(Hello, World!) | |
P( | |
This is IT(just a test) on B(creating) html with the C preprocessor. | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment