Thanks very much, Harald. On 10/26/2016 09:40 AM, Harald Schilly wrote:
Hello, do you mean normal anchor links? Usually, that makes no sense, since in many codemirror based editors those parts of the document aren't part of the webpage at all -- they only show the region where you're currently in (performance, etc.)
Yes, I'm trying to duplicate how a cross-reference would work in HTML from one page to another, when you want to land at a definite place. I'm not surprised that this is not so easy, since CodeMirror does not have the whole file/page.
What I can offer is a way to reference a concrete line number in such an editor. Here is the slightly dusted ticket: https://github.com/sagemathinc/smc/issues/161 I'm aware that this ticket doesn't solve what you want to accomplish.
If I could predict the line numbers of the targets of the pages I'm building in advance, then this might work. But at this moment I think that is way too complicated to predict, especially since the line count includes the rendered HTML. Is there any intermediate step on the CodeMirror side that would translate an identifier of some sort from the origin page to a line number of the target page? The search/replace functionality or the bookmarks? In other words, I can write *anything* into the link/cross-reference and I can write *anything* in the vicinity of the target, and these can share a unique identifier. But I'm going to guess that to go from one to the other would take some non-trivial Javascript to work through the CodeMirror API to get a line number from the target page.
My take is: we should strip away everything beginning from the hash-sign to the end when opening a URL. That should be a small change to avoid such a stupidity. Second, would you expect that such a file is being created when you land on the page, or rather to be told that the file doesn't exist?
For SMC, a short-term fix would be to strip the post-# part for an internal/relative URL. If the target page/worksheet does not exist, I'd expect to get back "... does not exist" rather than creating a new empty one.
For my textbook project, the best thing to do now is to break the book into small units (subsubsections?) up to whatever granularity an author provides, and not even try to include a #-fragment in the URL. Then the reader will need to scan/scroll the target page for what they expect to find.
Many (all?) of these cross-references in HTML are implemented as knowls. I'm just assuming having knowls inside SMC is a big job best saved for later (or maybe always a bad idea within CodeMirror). But as somebody who is knowledgeable about knowls, I'd be very interested in your opinion on the feasibility of that.
Thanks again for the reply. Rob -- You received this message because you are subscribed to the Google Groups "sage-cloud" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/MTAwMDAyOC5iZWV6ZXI.1477502477%40quikprotect. For more options, visit https://groups.google.com/d/optout.
