Is there way to insert ids & anchors on gutter line numbers?


I’m looking to be able to send a url to a page which renders lengthy content using CodeMirror. I’d like the browser to scroll to a specific line as indicated in the url. Normally I’d handle that appending #id_of_interest to the url.

Is there a way to make CodeMirror generate proper ids on linenumber gutter divs?

Secondly, is there a way to insert anchors in the gutter which reference these ids so that a user can easily capture the appropriate line link to share with another user?

Or might you suggest an alternative solution for achieving the same result?



This wouldn’t work, since CodeMirror only renders a small viewport into the document, and leaves most of the scrolled-out-of-view code unrendered. You’ll have to write some code that reads the hash from the url and does the scrolling.