Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A possible way for OneMore to "fix" OneNote's broken paragraph linking. #1747

Open
GrantRobertson opened this issue Jan 1, 2025 · 2 comments
Labels
feature-request New feature or request

Comments

@GrantRobertson
Copy link

OneMore fix for OneNote broken paragraph linking:

I think I have figured out how OneMore can "fix" the "Broken Paragraph Links" problem in OneNote, which is discussed thoroughly here. And it uses only "technology" that is already contained within OneMore. Do I think it will be easy to code? Oh heck no! That is why I am suggesting it to you. However, I think it will be incredibly useful to lots of people who use OneNote.

Now, to make this work, the user must do a bit of setup, but that can be automated, as I will describe much later in this post.

At a fundamental level, the fix consists of the following:

  1. Setting up the hyperlink:

    1. OneMore inserts a special "Safe Bookmark" hashtag in the paragraph (the "to" paragraph), to which the user intends to link.
      • The actual text of this hashtag can be very short. Maybe only a single symbol character. Perhaps a box with an arrow pointing into it, if you can find one.
    2. In that hashtag, OneMore creates a hyperlink that is not really a link at all.
      • This is the key to this entire system. It is merely a way of storing information on the page in a way that is not obtrusive to the user.
      • I have discovered that OneNote does not care what you store in a supposed hyperlink, as long as it starts with some text, followed by a colon. In this case the "hyperlink" will contain a historical list of all the Object IDs that have been assigned to a paragraph.
      • When OneMore first creates the "hyperlink," it will contain something like:
        `OneMore:{current Object ID of paragraph}``
      • As the "hyperlink" gets updated it will look more like this:
        `OneMore:{current Object ID of paragraph},{previous Object ID of paragraph}``
      • Even if the page gets moved and the Object ID of the paragraph is changed, the Object ID(s) listed in the "hyperlink" in the hashtag will not be changed by OneNote. So, they can be used as a permanent database of the past Object IDs…. Or anything else one can think of.
    3. Go ahead and copy the link to the paragraph to the clipboard as normal.
    4. The user creates the hyperlink, using that copied link, wherever they need to. Just as normal.
  2. The user moves the page containing the paragraph, thus changing the Object ID of said paragraph.
  3. The user tries to use the hyperlink and discovers that it only takes them to the page that contained the paragraph, but does not highlight the actual paragraph, thus making it hard for them to find said paragraph on the page. Frustration ensues.
  4. Fixing the hyperlink:

    1. User presses the "Back" button to go back to the "from" paragraph.
    2. User right-clicks on the hyperlink in the "from" paragraph, and chooses OneMore's new "Fix Paragraph Link" option. This does the following:
      1. Look in the right-clicked hyperlink and extract both the Page ID and the (now "old") Object ID of the linked-to paragraph.
      2. Go to the page referenced by said Page ID.
      3. Search through the page and find the special "Safe Bookmark" hashtag which contains the repurposed "hyperlink" which contains the matching "old" Object ID. You have now found the original "to" paragraph.
        • I am under the impression that this can be fast because OneMore already has an index of all hashtags in the entire collection of notebooks. Plus, it only needs to search one page.
      4. Extract the new Object ID from the "to" paragraph.
      5. Update the "hyperlink" in the "Safe Bookmark" hashtag, adding the new Object ID of the paragraph.
        • Never delete any old Object IDs from the "Safe Bookmark" "hyperlink." This is because we never know how many other actual hyperlinks still point to that old Object ID. So it has to remain there for the "Fix Paragraph Link" option to find.
      6. Go back to the "from" hyperlink, on the "from" page and update that hyperlink.
      • If you want to, for broken hyperlinks that do not have a matching "Safe Bookmark" hashtag, OneMore could allow the user to scroll through the page and manually find the paragraph that said broken link should have pointed to. Then OneMore can insert the "Safe Bookmark" hashtag (containing both the new Object ID and the old one from the broken hyperlink, so that other broken links will be easier to fix later). Then it can fix the original broken hyperlink.
  5. User can now use the hyperlink as normal and the paragraph will be highlighted as it should.

I feel I need to reiterate, that this cannot work automatically if there were no "Safe Bookmark" hashtags in place before the page got moved. So, many users may still be either out of luck, or need to do a lot more manual labor. But, it can still mitigate future disasters.

In actual usage, it would look like this to the user:

  1. User right-clicks in a paragraph and chooses OneMore's new "Safe Bookmark" option. (Or whatever you decide to call it.) This:
    1. Creates the "Safe Bookmark" hashtag and creates the special OneMore "hyperlink" within it.
      • It will be important to remind the users that this "hyperlink" is not a real hyperlink and won't take them anywhere. It is just used as a hack for storing data.
    2. Copies the hyperlink to the "to" paragraph as normal, so the user can create hyperlinks as normal.
  2. User creates hyperlink in "from" location as normal.
  3. If the user moves the page with the "to" paragraph, then tries to use a now broken hyperlink, they merely go back to the broken hyperlink, right-click on it, and choose OneMore's new "Fix Paragraph Link" option.
    • The screen jumps around a bit and then they are left back at the newly fixed "from" hyperlink.
    • Or, they may be presented with the option to look through the page and find the correct "to" paragraph.

There are ways that a lot of this could be automated:

  • There could be a OneMore option to preemptively set up these special "Safe Bookmark" hashtags for all paragraphs that have hyperlinks pointing to them from anywhere else in a selected context. Naturally, it would have to grind through all the notebooks, sections, & pages in that context, looking for hyperlinks that go to paragraphs. Then, it would have to go to those hyperlinked-to paragraphs and update or install a "Safe Bookmark" hashtag with that "not-a-hyperlink." Yeah, not a fast process.
    • It will be important to remind the users that they cannot select the context for the "linked to" paragraphs. This is because there is no way to tell which hyperlinks, where could be pointing to a given paragraph. It has to be done from the "from" side. So, they need to choose their context accordingly.
    • This will only work for actual hyperlinks that are not yet broken.
    • If run a second time, it would merely add missing "Safe Bookmark" hashtags, or update existing ones as necessary.
  • There could be an option that would grind through a specified context, look for all hyperlinks that point to paragraphs, check to see if the hyperlink is broken (by going to the linked-to page and looking for the Object ID that is listed in the hyperlink), then check to see if it can be repaired using an existing "Save Bookmark" in the "to" paragraph.
    • Yeah, this would take even longer than the first option.
    • I doubt any user would want to sit there and manually look up the correct "to" paragraphs for every broken hyperlink that is not automatically fixable in their OneNote database. But, maybe they would be willing to do that in several shorter sessions. So, this could be an option too. Simply having OneMore walk them through all the broken hyperlinks that it found would be a lot easier than hunting for broken hyperlinks manually.
  • There could be an option to generate and insert "Safe Bookmark" hashtags for every darned paragraph on a page. This might be overkill for most situations. But, if one has created a lot of hyperlinks to a lot of paragraphs on that page, but has forgotten which ones, then this might be a good, "cover all bases," safety measure.
  • There could be a OneMore option to "Safely Move Page." It could work in several different (possibly overlapping) modes:
    • Simply move the page and preemptively update any "Safe Bookmark" hashtags (adding the new Object IDs) after the page has been moved.
      • This won't fix any existing actual hyperlinks to these paragraphs. But, at least, they could be easily fixed as the user encounters them later.
    • Check a specified context to see if there are any hyperlinks going to paragraphs on this particular page and insert the appropriate "Safe Bookmark" hashtags in the linked-to paragraphs on this page. Temporarily remember where those hyperlinks are. Then, move the page. Then update all the "Safe Bookmark" hashtags. Then fix all the now-broken hyperlinks that you kept a list of before.
      • This might not take as long as other "hyperlink searching" options, because most users will likely have a smaller context to perform this search on.
    • Do the overkill option and add a "Safe Bookmark" hashtag to every paragraph, move the page, update all the "Safe Bookmark" hashtags.
    • Any combination of the above.
@GrantRobertson GrantRobertson added feature-request New feature or request unread I have seen it or had time to refine it yet labels Jan 1, 2025
@stevencohn
Copy link
Owner

Thanks for all of this. It's a good thought exercise, indeed. First point, instead of a "safe hyperlink", we can take advantage of internal Meta tags that can be placed on a page or on individual paragraphs. OneMore already uses these. In fact, if you look at the XML of any page with a #hashtag, you'll notice that there is a special page-level tag similar to this:

<one:Meta name="omPageID" content="7aebb38f292f48ba84aae8cf5cb96611" />

So OneMore already has a way of tracking pages even if the pageID attribute changes. (FYI, the intent is to use this strategy for Favorites, Reminders, the Navigator, etc.) We can add a Meta tag to individual paragraphs too. However, I'm not sure we would need to...

I like your last option the best - a Safe Move operation. It would require that the user only moves pages through this (not yet developed, just a theory) Safe Move command rather than any of OneNote's move capabilities, including drag/drop or the Move dialog. This way, OneMore can control the move entirely, patching page-to-page hyperlinks along the way. It's writer-makes-right rather than reader-makes-right. It would also depend on a scan of pages that link to this page and patch those in real time, which may take some time to sweep through sections and notebooks; that's the only drawback, but it's fully automated and can't be corrupted by a wayward keystroke that might break a visible hyperlink.

@stevencohn stevencohn removed the unread I have seen it or had time to refine it yet label Jan 1, 2025
@GrantRobertson
Copy link
Author

Ah ha... It had crossed my mind to suggest modifying the actual XML of the OneNote files, but I didn't know if we could trust OneNote to not purge those "out of schema" XML elements or attributes, at some point in the future. I guess I figured, you would tell me if you had better ways of hiding data. And so you did.

I don't know if even I would be up for a complete scan of all my notebooks every time I moved a page. I tend to do temporary work in one location (within OneNote), then move it to another location when/if it becomes a bigger project. And I definitely create lots of hyperlinks to specific paragraphs. So, that would be lots of long scans, quite often. Not every day, mind you. But enough to become tiresome if it takes longer than a minute.

Now, a massive database of all the hyperlinks between anything in OneNote would make that faster, but... OneMore would likely need to do some combination of:

  • Do a big scan of all notebooks to gather up all the existing hyperlinks.
    • It would likely also need to check each hyperlink to a paragraph to see if it was broken. (Then, mitigation measures may or may not be taken.)
    • This could be done on demand, or in the background.
  • Monitor the creation of all hyperlinks.
    • This would likely require that the user always create all hyperlinks using OneMore commands. And that is likely to be hit or miss for most people.

AND...

  • That would be a pretty huge database for some of us.
  • I doubt you are up for building a back-end database of all of OneNote's hyperlinks.

To be clear, I am not opposed to said database, unless the background maintenance slowed down OneNote. It is already laggy for some people some of the time. So, allowing the user to turn off background maintenance and opt for "on demand only" maintenance would be nice.

Now, one other huge benefit of said massive hyperlink database is that it would enable a "What links here?" feature.

Said massive hyperlink database would also enable utilities that could graphically show the network of hyperlinks within one's OneNote notebooks. Even if you aren't into that kind of thing, others could make use of OneMore's hyperlink database for graph data analysis.


An alternative to all of that scanning and/or database collecting would be to implement basically what I described in my original post, except with those totally hidden XML elements. Because the XML elements are hidden, it is more practical to simply insert them for every darned paragraph on a page. This could be triggered on demand (for a specified context), or during a "Safe Move" operation. This would allow relatively quick fixes, as broken hyperlinks are found later. But, without all the scanning and/or databases. All the scanning I suggested in my original post would be optional, rather than mandatory to make the system work. My system basically relies on the fact that OneNote will still know what page a hyperlink pointed to, even if it can't find the specific paragraph. So, the amount of scanning/looking necessary to find the correct paragraph is very minimal compared to scanning all of a user's notebooks on the regular.

One interesting thing to remember about human psychology is that we tend to ignore features that we never need to worry about any more. (I learned this as a network manager.) If OneMore could completely make the broken hyperlink problem go away (which you could do, with enough coding, background scanning, and getting users to always use OneMore commands to create hyperlinks) then users would forget that OneMore was what was solving their problem. Plus, any time they got a broken link, they would complain that OneMore had dropped the ball, rather than realize that they forgot to use OneMore commands to move pages or to create some hyperlink that they created months ago. ... However, if the user always has to fix the broken links that they find, they will always know that OneMore is the add-in that is allowing them to fix it. So, you actually look better in the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants