Fossil SCM
In /artifact and similar pages, put HTML code tag inside pre with class="language-zExt" where zExt is the extension from the artifact's file name, if any. This allows JS code highlighting plugins to style such pre blocks automatically based on file name extension.
Commit
f3b9171498f5d10dea974c11be2a19ed6354d0e2b7c0c2b8920164ab3d09662f
Parent
ab2b8de8962831e…
1 file changed
+11
-1
+11
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -2288,14 +2288,24 @@ | ||
| 2288 | 2288 | } |
| 2289 | 2289 | blob_to_utf8_no_bom(&content, 0); |
| 2290 | 2290 | zMime = mimetype_from_content(&content); |
| 2291 | 2291 | @ <blockquote> |
| 2292 | 2292 | if( zMime==0 ){ |
| 2293 | - const char *z; | |
| 2293 | + const char *z, *zFileName, *zExt; | |
| 2294 | 2294 | z = blob_str(&content); |
| 2295 | + zFileName = db_text(0, | |
| 2296 | + "SELECT name FROM mlink, filename" | |
| 2297 | + " WHERE filename.fnid=mlink.fnid" | |
| 2298 | + " AND mlink.fid=%d", | |
| 2299 | + rid); | |
| 2300 | + zExt = zFileName ? strrchr(zFileName, '.') : 0; | |
| 2295 | 2301 | if( zLn ){ |
| 2296 | 2302 | output_text_with_line_numbers(z, zLn); |
| 2303 | + }else if( zExt && zExt[1] ){ | |
| 2304 | + @ <pre> | |
| 2305 | + @ <code class="language-%s(zExt+1)">%h(z)</code> | |
| 2306 | + @ </pre> | |
| 2297 | 2307 | }else{ |
| 2298 | 2308 | @ <pre> |
| 2299 | 2309 | @ %h(z) |
| 2300 | 2310 | @ </pre> |
| 2301 | 2311 | } |
| 2302 | 2312 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -2288,14 +2288,24 @@ | |
| 2288 | } |
| 2289 | blob_to_utf8_no_bom(&content, 0); |
| 2290 | zMime = mimetype_from_content(&content); |
| 2291 | @ <blockquote> |
| 2292 | if( zMime==0 ){ |
| 2293 | const char *z; |
| 2294 | z = blob_str(&content); |
| 2295 | if( zLn ){ |
| 2296 | output_text_with_line_numbers(z, zLn); |
| 2297 | }else{ |
| 2298 | @ <pre> |
| 2299 | @ %h(z) |
| 2300 | @ </pre> |
| 2301 | } |
| 2302 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -2288,14 +2288,24 @@ | |
| 2288 | } |
| 2289 | blob_to_utf8_no_bom(&content, 0); |
| 2290 | zMime = mimetype_from_content(&content); |
| 2291 | @ <blockquote> |
| 2292 | if( zMime==0 ){ |
| 2293 | const char *z, *zFileName, *zExt; |
| 2294 | z = blob_str(&content); |
| 2295 | zFileName = db_text(0, |
| 2296 | "SELECT name FROM mlink, filename" |
| 2297 | " WHERE filename.fnid=mlink.fnid" |
| 2298 | " AND mlink.fid=%d", |
| 2299 | rid); |
| 2300 | zExt = zFileName ? strrchr(zFileName, '.') : 0; |
| 2301 | if( zLn ){ |
| 2302 | output_text_with_line_numbers(z, zLn); |
| 2303 | }else if( zExt && zExt[1] ){ |
| 2304 | @ <pre> |
| 2305 | @ <code class="language-%s(zExt+1)">%h(z)</code> |
| 2306 | @ </pre> |
| 2307 | }else{ |
| 2308 | @ <pre> |
| 2309 | @ %h(z) |
| 2310 | @ </pre> |
| 2311 | } |
| 2312 |