dstein64 / highlight

A browser extension for automatically highlighting the important content on article pages.
MIT License
54 stars 13 forks source link

Feature request: avoid source code #5

Closed hmijail closed 3 years ago

hmijail commented 4 years ago

I find that pages which contain source code tend to get (parts of) it highlighted, which makes no sense. Additionally, it also seems to throws off the highlighting on the rest of the page.

So it'd be great if there was any possibility of avoiding source code when considering what to highlight; or if that's too hard / impossible, then to just disable highlighting if source code is detected.

As for how to detect source code, as a first guesstimation, I'd imagine that if there is some block of monospaced text, that's suspicious enough.

dstein64 commented 4 years ago

HI @hmijail. Do you have particular example pages that you can share? That would help for devising a workaround and testing that it works.

hmijail commented 4 years ago

A couple of examples: https://golang.org/ref/spec https://docs.python.org/3/library/argparse.html http://lamport.azurewebsites.net/tla/peterson.html?back-link=high-level-view.html#pluscal?unhideBut@EQhide-pluscal@AMPunhideDiv@EQpluscal

dstein64 commented 3 years ago

@hmijail, thanks for reporting the issue and providing the examples!

I've added a workaround that excludes text from consideration if it's in a <pre> tag and the page is not primarily comprised of such text. This handles the examples you've shared. Please let me know if you encounter any additional examples that remain problematic, or any pages that you believe this update may have introduced a new problem on.

I've submitted the updated extension to Chrome, Firefox, and Edge. It has been approved for Chrome and Firefox, and the review is still pending for Edge (it can take up to a few days, based on prior experience).