Welcome to little lamb

Code » qmdoc » commit 09d948d

Tweak how the HTML is constructed re: <main>

author Olivier Brunel
2023-01-01 21:40:10 UTC
committer Olivier Brunel
2023-01-04 15:09:27 UTC
parent 6be99c8b835f40d8721debb483850e1161f7fe63

Tweak how the HTML is constructed re: <main>

That is, we will put our <header> *inside* the <main> instead of being
at the same level. That way it'll be easier to have included HTML
headers & footers for customization which do provide a "real" header
for the page, site-wide consistent.

base.htm +3 -1
common.css +8 -6
dark.css +10 -10
light.css +10 -10
main.c +3 -3
struct.css +33 -23

diff --git a/base.htm b/base.htm
index 4647f39..bec0bba 100644
--- a/base.htm
+++ b/base.htm
@@ -14,6 +14,7 @@
 <link rel="stylesheet" href="dark.css">
     </head>
     <body>
+        <main>
         <header>
             <section>
                 <h1>Foobar Documentation</h1>
@@ -61,7 +62,7 @@
                 </ul>
             </nav>
         </header>
-        <main>
+        <section>
             <section id="welcome_to_foobar">
                 <h1>Welcome to Foobar !</h1>
                 <p>This is the documentation for <strong>foobar</strong>. There will be
@@ -227,6 +228,7 @@ int main(int argc, char **argv)
                 <br>
                 <span class="generated">Generated with qmdoc</span>
             </footer>
+        </section>
         </main>
     </body>
 </html>
diff --git a/common.css b/common.css
index 237a52f..5cb09ed 100644
--- a/common.css
+++ b/common.css
@@ -22,14 +22,15 @@ main blockquote cite::before {
 main q {
     font-style: italic;
 }
-main a {
+main section a {
     text-decoration: underline;
 }
-main h1 a::before, main h2 a::before, main h3 a::before,
-main h4 a::before, main h5 a::before, main h6 a::before {
+main section h1 a::before, main section h2 a::before, main section h3 a::before,
+main section h4 a::before, main section h5 a::before, main section h6 a::before {
     content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAiCAYAAABWQVnHAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5AoRDzABQAmaNwAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAABOUlEQVRIx+2UsU4CQRCGvyUk+ABeBxWUVlbSHckk+AA+go/lI9hr8Udb6OwFC8VKOivMJWczlyybPdDQ3laX2Zl/Z79/50JVVZyyepy4OgHo/yXJzB6AURTaSLoGCMdsNLMnYAoMovAOWEiaHRTw4ktg60W40BCogU2rQFT8IqlM9l6BcSvEqO1tWhxdASD0WoBNgbModvcfGycNMEkTM3sHbszsMcoZAD/Aup+xKvhmQ33osbHnPQOFu1D2kjt/SZoAG6A2s1pS0+XI4RXAsmHT9+AQ+JQ08+Q1cA58J20j6SJlMHZgDVkkzYF7SSMzW7nnO+AtBzHk6Eq69c/amSxcuNWFQcbSPWC5g0JZlitnAPCRPNki9xL3BKqqak66ygzM8lDx3jT6Q0lHdn5s1EP3V+4EOgEAfgElA4h8m56jlAAAAABJRU5ErkJggg==);
 }
-main h1 a, main h2 a, main h3 a, main h4 a, main h5 a, main h6 a {
+main section h1 a, main section h2 a, main section h3 a,
+main section h4 a, main section h5 a, main section h6 a {
     display: none;
     max-width: 16px;
     max-height: 24px;
@@ -41,8 +42,9 @@ h1:hover a, h2:hover a, h3:hover a, h4:hover a, h5:hover a, h6:hover a {
     display: inline-block;
     text-decoration: none !important;
 }
-main h1 a:hover::after, main h2 a:hover::after, main h3 a:hover::after,
-main h4 a:hover::after, main h5 a:hover::after, main h6 a:hover::after {
+main section h1 a:hover::after, main section h2 a:hover::after,
+main section h3 a:hover::after, main section h4 a:hover::after,
+main section h5 a:hover::after, main section h6 a:hover::after {
     content: "Permalink to this headline";
     display: block;
     padding: 8px;
diff --git a/dark.css b/dark.css
index 5e840f5..7474f9a 100644
--- a/dark.css
+++ b/dark.css
@@ -2,29 +2,29 @@
     :root {
         color-scheme: dark;
     }
-    header {
+    main header {
         background: #17679B;
     }
-    header section h1 {
+    main header section h1 {
         color: #ccc6c6;
     }
-    header section h2 {
+    main header section h2 {
         color: #56b5ee;
     }
-    header nav {
+    main header nav {
         background: #343131;
     }
-    header nav ul li a:hover {
+    main header nav ul li a:hover {
         background: #4e4a4a;
     }
-    header nav ul li a {
+    main header nav ul li a {
         color: #b3b3b3;
         /*color: #55a5d9;*/
     }
-    header nav > ul > li > a { /* PAGE */
+    main header nav > ul > li > a { /* PAGE */
         color: #55a5d9;
     }
-    header nav > ul > li > ul > li > a { /* h1 */
+    main header nav > ul > li > ul > li > a { /* h1 */
         color: #a3a802;
     }
     main, main footer {
@@ -50,10 +50,10 @@
         background: #086abf;
         color: #eee;
     }
-    main a {
+    main section a {
         color: blue;
     }
-    main a:visited {
+    main section a:visited {
         color: purple;
     }
     main kbd {
diff --git a/light.css b/light.css
index 367b0ac..63c4eb2 100644
--- a/light.css
+++ b/light.css
@@ -1,28 +1,28 @@
 :root {
     color-scheme: light;
 }
-header {
+main header {
     background: #2980B9;
 }
-header section h1 {
+main header section h1 {
     color: #fcfcfc;
 }
-header section h2 {
+main header section h2 {
     color: #56b5ee;
 }
-header nav {
+main header nav {
     background: #343131;
 }
-header nav ul li a:hover {
+main header nav ul li a:hover {
     background: #4e4a4a;
 }
-header nav ul li a {
+main header nav ul li a {
     color: #b3b3b3;
 }
-header nav > ul > li > a { /* PAGE */
+main header nav > ul > li > a { /* PAGE */
     color: #55a5d9;
 }
-header nav > ul > li > ul > li > a { /* h1 */
+main header nav > ul > li > ul > li > a { /* h1 */
     color: #a3a802;
 }
 main, main footer {
@@ -48,10 +48,10 @@ main pre.lineno + pre > span {
     background: #217ed0;
     color: #eee;
 }
-main a {
+main section a {
     color: blue;
 }
-main a:visited {
+main section a:visited {
     color: purple;
 }
 main kbd {
diff --git a/main.c b/main.c
index 217f45e..dcf7b48 100644
--- a/main.c
+++ b/main.c
@@ -328,7 +328,7 @@ enter_block(MD_BLOCKTYPE type, void *details, void *ctx_)
                         return ERR_PARSER_ENTER_BLOCK;
                     }
                 }
-                if (!raw_str(ctx, "</head><body><header><section><h1>")
+                if (!raw_str(ctx, "</head><body><main><header><section><h1>")
                         || !escape_text(ctx, ctx->doc.title, strlen(ctx->doc.title))
                         || !raw_str(ctx, "</h1></section><nav><ul>"))
                     return ERR_PARSER_ENTER_BLOCK;
@@ -359,7 +359,7 @@ enter_block(MD_BLOCKTYPE type, void *details, void *ctx_)
 #undef str_title
 #undef str_file
 
-                if (!raw_str(ctx, "</ul></nav></header><main>"))
+                if (!raw_str(ctx, "</ul></nav></header><section>"))
                         return ERR_PARSER_ENTER_BLOCK;
             }
             break;
@@ -537,7 +537,7 @@ leave_block(MD_BLOCKTYPE type, void *details, void *ctx_)
                     || !escape_text(ctx, ctx->doc.author, strlen(ctx->doc.author))
                     || !raw_str(ctx, "<br>"
                                 "<span class=\"generated\">Generated with qmdoc</span>"
-                                "</footer></main></body></html>"))
+                                "</footer></section></main></body></html>"))
                 return ERR_PARSER_LEAVE_BLOCK;
             break;
 
diff --git a/struct.css b/struct.css
index 50dc1b7..4d0a791 100644
--- a/struct.css
+++ b/struct.css
@@ -18,28 +18,28 @@ time, mark, audio, video {
 html, body {
     height: 100%;
 }
-header {
+main header {
     position: fixed;
     width: 300px;
     height: 100%;
     padding-top: 88px;
 }
-header section {
+main header section {
     height: 88px;
     margin-top: -88px;
 }
-header section h1 {
+main header section h1 {
     margin-top: 23px;
     text-align: center;
     font-size: 1.42em;
     font-weight: 800;
 }
-header section h2 {
+main header section h2 {
     margin-top: 8px;
     text-align: center;
     font-weight: 700;
 }
-header nav {
+main header nav {
     position: relative;
     padding: 8px;
     padding-bottom: 42px; /* 23 (section h1 margin-top) + 19 */
@@ -47,42 +47,42 @@ header nav {
     min-height: 100%;
     overflow: hidden scroll;
 }
-header nav li a {
+main header nav li a {
     line-height: 1.1em;
     padding: 4px 6px;
     white-space: nowrap;
 }
-header nav li a {
+main header nav li a {
     display: inline-block;
     width: 100%;
 }
-header nav > ul > li > a { /* PAGE */
+main header nav > ul > li > a { /* PAGE */
     margin-top: 8px;
     font-weight: 600;
     text-transform: uppercase;
 }
-header nav > ul > li > ul > li > a { /* h1 */
+main header nav > ul > li > ul > li > a { /* h1 */
     text-transform: uppercase;
     font-weight: 600;
     padding-left: 12px;
 }
-header nav > ul > li > ul > li > ul > li > a { /* h2 */
+main header nav > ul > li > ul > li > ul > li > a { /* h2 */
     font-weight: 400;
     padding-left: 24px;
 }
-header nav > ul > li > ul > li > ul > li > ul > li > a { /* h3 */
+main header nav > ul > li > ul > li > ul > li > ul > li > a { /* h3 */
     padding-left: 36px;
 }
-header nav > ul > li > ul > li > ul > li > ul > li > ul > li > a { /* h4 */
+main header nav > ul > li > ul > li > ul > li > ul > li > ul > li > a { /* h4 */
     padding-left: 48px;
 }
-header nav > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > a { /* h5 */
+main header nav > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > a { /* h5 */
     padding-left: 60px;
 }
-header nav > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > a { /* h6 */
+main header nav > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > a { /* h6 */
     padding-left: 72px;
 }
-main {
+main > section {
     position: relative;
     margin-left: 300px;
     padding: 23px 42px 0 42px;
@@ -143,38 +143,48 @@ main pre code {
     margin: 12px 12px 0px 2px;
     overflow: hidden;
 }
-main h1 {
+main section h1 {
     text-transform: uppercase;
     padding-top: 23px;
     padding-bottom: 15px;
     font-weight: 800;
     font-size: 175%;
 }
-main h2 {
+main header section h1 {
+    text-transform: inherit;
+    padding-top: inherit;
+    padding-bottom: inherit;
+}
+main section h2 {
     padding-top: 15px;
     padding-bottom: 8px;
     font-weight: 700;
     font-size: 150%;
 }
-main h3, main h4, main h5, main h6 {
+main header section h2 {
+    padding-top: inherit;
+    padding-bottom: inherit;
+    font-size: inherit;
+}
+main section h3, main section h4, main section h5, main section h6 {
     font-weight: 600;
 }
-main h3 {
+main section h3 {
     padding-top: 15px;
     padding-bottom: 8px;
     font-size: 130%;
 }
-main h4 {
+main section h4 {
     padding-top: 15px;
     padding-bottom: 8px;
     font-size: 110%;
 }
-main h5 {
+main section h5 {
     padding-top: 15px;
     padding-bottom: 8px;
     font-size: 95%;
 }
-main h6 {
+main section h6 {
     padding-top: 15px;
     padding-bottom: 8px;
     font-size: 80%;
@@ -185,7 +195,7 @@ main blockquote {
 main div.indent {
     margin: -8px 23px 4px 42px;
 }
-main ul, main ol {
+main section ul, main section ol {
     padding-left: 42px;
 }
 main div.box {