Fossil Forum

improving file output in the web browser with line number
Login

improving file output in the web browser with line number

improving file output in the web browser with line number

(1) By Alfred M. Szmidt (ams) on 2021-09-22 14:54:29 [source]

When viewing files in Emacs, specifically the eww browser, it all looks slightly messed up, https://fossil-scm.org/home/file?udc=1&ln=on&ci=trunk&name=Makefile.in

 File Makefile.in artifact  45eba548 on branch trunk

------------------------------------------------------------------------------------------------------

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  #!/usr/bin/make  
  27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48  #  
  49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70  # This is the top-level makefile for Fossil when the build is occurring  
  71 72 73 74 75 76 77 78 79 80 81 82 83 84  # on a unix platform.  This works out-of-the-box on most unix platforms.  
    # But you are free to vary some of the definitions if desired.  
    #  

is it possible to somehow fix this, or rather where would the right fix be? It seems the lynx also does this messy output.

(2) By Stephan Beal (stephan) on 2021-09-22 15:13:14 in reply to 1 [link] [source]

is it possible to somehow fix this, or rather where would the right fix be

No text-mode browser is likely to work reasonably well with the new diffs and text-mode browsers have never been an active target for the project. If the web-mode diffs worked in the past on such browsers, it was very likely a "happy accident." We generally only actively target HTML5-capable conventional browsers.

(3) By Alfred M. Szmidt (ams) on 2021-09-22 18:21:04 in reply to 2 [link] [source]

But diffs do work well, either side-by-side (slightly messy on a small tty, but ok) or unifined -- you even get colored cross-over lines for removed lines. This was rather when showing line numbers with a file, not diffs per see.

eww is also not a text-mode browser, it is fully capable of showing images and tables.

(4) By Stephan Beal (stephan) on 2021-09-22 19:35:33 in reply to 3 [link] [source]

This was rather when showing line numbers with a file, not diffs per see.

Indeed, my apologies - i was working from a mobile device at the time and overlooked your link.

i think that can be easily improved for you without breaking the line-linking features, but i'll have to experiment with it to be certain.

(5) By Stephan Beal (stephan) on 2021-09-22 19:44:09 in reply to 3 [link] [source]

If you are able to test this CSS-only patch, that would be a big help. This patch is the least intrusive option i've come up with:

Index: src/default.css
==================================================================
--- src/default.css
+++ src/default.css
@@ -1305,14 +1305,18 @@
   vertical-align: top;
   padding: 0.25em 0 0 0 /*prevents slight overlap at top */;
 }
 table.numbered-lines td.line-numbers {
   width: 4.5em;
+  white-space: pre;
 }
 table.numbered-lines td.line-numbers > span:first-of-type {
   margin-top: 0.25em/*must match top PADDING of
                       td.file-content > pre > code*/;
+}
+table.numbered-lines td.line-numbers > span::after {
+  content: "\a";
 }
 table.numbered-lines td.line-numbers > span {
   display: block;
   margin: 0;
   padding: 0;

If that doesn't work, then there's a functionally equivalent change we can make in the C code which doesn't rely on the the ::after content CSS feature.

(6) By Stephan Beal (stephan) on 2021-09-23 04:50:36 in reply to 3 [link] [source]

This was rather when showing line numbers with a file, not diffs...

A presumed fix for this was just pushed to trunk. If you can, please try out that version and report any problems here. In short, the DOM structure was made to be more like that used in the diff views.

(7) By Alfred M. Szmidt (ams) on 2021-09-23 08:41:02 in reply to 6 [link] [source]

Thats lovley, it works super great! Thank you!

(8) By Alfred M. Szmidt (ams) on 2021-09-23 08:46:41 in reply to 7 [link] [source]

I'm not sure if it would be possible, and I think it works good enough. So mostly asking if those who know, might know if it is possible at all.

In text-only, the region of lines that might be pointed out in the URL isn't highlighted in any form. Is there any possibly that it could be shown in some form?

(9.1) By Stephan Beal (stephan) on 2021-09-23 09:35:19 edited from 9.0 in reply to 8 [link] [source]

In text-only, the region of lines that might be pointed out in the URL isn't highlighted in any form. Is there any possibly that it could be shown in some form?

That's done via CSS . If it's not being highlighted or bolded, your browser isn't applying the CSS styling. We "could" use explicit <U> tags to underline those, and hope that text-mode browsers can underline the text, but that would be a step backwards for the full-fledged browsers (where we don't really want those underlined). If you can suggest a workaround which works for you and does not negatively impact full-fledged browsers then i'm willing to try it.

We "could" add an extra character to the selected lines, but that would, IMO, look horrible for non-text browsers (and the server, where that would need to be generated, does not know anything significant about the browser).

(Edit: that was weird: post got submitted twice within 1 second of each other.)

(11) By Alfred M. Szmidt (ams) on 2021-09-23 09:39:55 in reply to 9.1 [link] [source]

Ah, so that might be a bug in eww then of what possible highlighting it can do. Since it does work correctly for diffs, added regions are in green and removed ones are in red.

(12) By Stephan Beal (stephan) on 2021-09-23 09:52:18 in reply to 11 [link] [source]

Since it does work correctly for diffs, added regions are in green and removed ones are in red.

Those are done using INS and DEL tags. Perhaps (i'm just speculating) eww can't style SPAN elements in arbitrary ways?

(10.1) By Stephan Beal (stephan) on 2021-09-23 09:34:54 edited from 10.0 in reply to 8 [link] [source]

Deleted