SQLite Forum

.mode html should output lowercase HTML tags
Login

.mode html should output lowercase HTML tags

(1) By nat-418 on 2021-11-20 17:08:00 [link]

I know this might seem insignificant but I noticed that `.mode html` produces output with ALL CAPS HTML element tags like `<TR><TD>foo</TD><TD>bar</TD></TR>`. XHTML requires lowercase tags and it's normative in every HTML5 code-base I have seen to use lowercase tags. Below is a proof-of-concept to fix the issue:

```
Index: src/shell.c.in
==================================================================
--- src/shell.c.in
+++ src/shell.c.in
@@ -2231,26 +2231,26 @@
       }
       break;
     }
     case MODE_Html: {
       if( p->cnt++==0 && p->showHeader ){
-        raw_printf(p->out,"<TR>");
+        raw_printf(p->out,"<tr>");
         for(i=0; i<nArg; i++){
-          raw_printf(p->out,"<TH>");
+          raw_printf(p->out,"<th>");
           output_html_string(p->out, azCol[i]);
-          raw_printf(p->out,"</TH>\n");
+          raw_printf(p->out,"</th>\n");
         }
-        raw_printf(p->out,"</TR>\n");
+        raw_printf(p->out,"</tr>\n");
       }
       if( azArg==0 ) break;
-      raw_printf(p->out,"<TR>");
+      raw_printf(p->out,"<tr>");
       for(i=0; i<nArg; i++){
-        raw_printf(p->out,"<TD>");
+        raw_printf(p->out,"<td>");
         output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
-        raw_printf(p->out,"</TD>\n");
+        raw_printf(p->out,"</td>\n");
       }
-      raw_printf(p->out,"</TR>\n");
+      raw_printf(p->out,"</tr>\n");
       break;
     }
     case MODE_Tcl: {
       if( p->cnt++==0 && p->showHeader ){
         for(i=0; i<nArg; i++){


```

(2) By MBL (UserMBL) on 2021-11-20 17:47:14 in reply to 1 [link]

for compatibility maybe there could be one for each case as required

~~~
>.mode html     for the current capital tags
>.mode xhtml    for the new lower case tags
~~~

another idea could be to use the case of the keyword itself:

~~~
>.mode HTML
>.mode html     or  .xhtml
~~~

(3) By nat-418 on 2021-11-20 19:11:02 in reply to 2

As far as comptability goes the HTML spec defines case-insensitivity: http://w3c.github.io/html-reference/syntax.html .

In case anyone was depending on the ALL CAPS output for some odd reason I think either of your suggestions makes sense, but I prefer the HTML for majuscule and html for miniscule approach.