2

Is there a robust/general way in eww browser (or alternatively w3m in emacs) by which I can get the character position in a rendered page from a known character position in the page source?

I'd like to use this to automatically jump to "important" parts of webpages I visit often.

On stackexchange.com I need to scroll down a whole page to see the relevant part (the question section). I would like to setup emacs to jump automatically to the section.

As an example, stackoverflow.com has a question header:

<h1 itemprop="name" class="grid--cell fs-headline1 fl1">
  <a href="..." class="question-hyperlink">
     Stack overflow question title
  </a>
</h1>

If I can find this location by html tags in the source, is there a way to then jump to get the corresponding position in the rendered page view.

2
  • I would suggest opening the page in question like you normally do in Emacs and then type M-x fundamental-mode and inspect what it looks like after w3m converted it. You then have two choices, intercept the page before it gets converted and do something with it that suits your needs, or deal with it after it has been converted and you know what to search for. Note that there are lots of w3m options that I have observed in the source code for rendering things like email, so changing the options to suit your needs may also be something to research.
    – lawlist
    Aug 10, 2018 at 14:34
  • For example, I don't like the way that w3m handles a "NO-BREAK SPACE" aka character code 160. I first change it to a semi-rare ascii character, and then let w3m do its thing, and then I change the semi-rare character into my preferred character; e.g., a regular space. If you have a repeating fact pattern, you can insert a preferred/special character or the like to find it quickly with a jump/search ... Now, there may be w3m command line options to deal with special characters in a preferred way -- I just haven't studied those options.
    – lawlist
    Aug 10, 2018 at 14:39

1 Answer 1

1

It occurs to me that an xml-query.el query could give you the tag body ("Stack overflow question title" in your example). Your code would then find that in the rendered page using search-forward.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.