Qeole / Enlight

Firefox add-on providing syntax highlighting for raw code, based on the highlight.js project.
Mozilla Public License 2.0
42 stars 2 forks source link

Feature-Request: "Go to line" via Anchors #3

Closed azine closed 8 years ago

azine commented 8 years ago

Hi,

nice add-on! Thanx a lot!

Would it be possible to add a "Go to line" feature that jumps to the right line when the window.location points to "...someFile.js#line213"? => scroll to line 213 ...or even better: scroll to line 213 (minus a few) and highlight the line 213.

This would be really handy to jump to the right place, comming from a stack-trace.

Cheers, D.

Qeole commented 8 years ago

Hi @azine,

Thanks for feedback! I'm glad to learn you appreciate the add-on. Your idea is really interesting and I like it. I started to look for a way to implement it.

Sadly the line numbering is performed in CSS, which makes a given line impossible to reach with a basic HTML target from the URL address. So at this point I see two ways to move to a line:

  1. changing line numbering and do it in JavaScript to add HTML IDs to the numbers placeholders, but this would most probably impact performances on numbering for long files;
  2. adding a JavaScript snippet to parse the window location and perform the move. Easy to do (I've implemented it tonight), but there is no event triggered on location modification. It means that it will work when one loads or refreshes the page, but not when they edit the URL bar (from loaded page) and just hit enter.

At this point I've not decided yet what approach I may retain. I will give it some further thinking when I can afford some time :)

Qeole commented 8 years ago

I chose the second option. On master branch since commit 3def0cd6350ed01d1cbb8674b070fcf4097c81fc (and the three following commits, also related to this functionality).

It will not be available on https://addons.mozilla.org until highlight.js v9.2 is out and I can upgrade to it, though.

azine commented 8 years ago

Cool! Thanx!

Qeole commented 8 years ago

Now in latest version on AMO: https://addons.mozilla.org/fr/firefox/addon/enlight/