-
Notifications
You must be signed in to change notification settings - Fork 809
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
[toc2] use amd structure to avoid polluting the global namespace #1032
Conversation
I think this should work ok, but haven't tried html export - any chance you could give it a try at some point @jfbercher? I'm thinking I'll try to move toc2 over to using the inliner class which collapsible_headings is currently using, so that we can more easily export using both of them, so this would be useful to have before attempting that :) |
@jcb91 I have tested conversion today and apart a require error that appears in the console, it works! There is also a small backward compatibility issue to address. In old html conversions, the js tries to load directly |
Commit 466a78b does not address the backward compatibility issue. If we still want to support html files converted before the conversion of toc2 to a module -- which is a nice thing, I am afraid that we will have to define this module with some other name (eg |
I agree, backwards compatibility is a good thing to keep. However, I don't think we need any extra modules or anything - I think we can just fix this in if (!liveNotebook) {
// export main function for backwards compatibility
window.table_of_contents = table_of_contents;
} After all, adding just the single name |
26cfd09
to
69b6431
Compare
@jcb91 Nice idea. I tested it but it did not worked, probably because of a race condition --
|
@jcb91 For me this is working. Have you had a look to the mast commits? Do you think we can merge? |
Apologies @jfbercher, I've been away from a computer for a few days. I'll likely get a chance to look at things wednesday. This looks to me like it'll work, but it's a bit convoluted trying to figure out what gets defined in what order, so I'd like to simplify it a little if that's ok? Anyway, feel free to merge away if it's working ok, I can always make another pr later to satisfy my ocd ;) |
@jcb91 Sure. I have a little time myself. Simplifications will be welcome. We will merge when ready! |
We use a synchronous method for detecting the live notebook, otherwise we run into various timing issues
since it's only used there anyway
…s of toc2 this is accomplished by defining a window.table_of_contents function synchronously in the first pass of the file, so that it can be called by subsequent scripts in a page.
to cater for malformed exported notebooks
ok, I've attempted to rebase this onto the current master, and also made a stab at simplifying the config loading. Currently I've just replicated the existing behaviour in terms of what's per-notebook and what's not, but I have a feeling some (e.g. threshold?) may have been miscatergorized. Not sure. I've also removed some unused items: the |
nav_menu: {}, | ||
number_sections: true, | ||
sideBar: true, | ||
skip_h1_title: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that skip_1_title is a system-wide parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, it's per-notebook, as whether it makes sense depends on the notebook content?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we have nothing to change the behavior per notebook, except directly editing the metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done. I have attempted something like that in #1057. Will have to rebase and merge your version :-)
Ah sorry, it always gets messy here! 😆 |
Hmm, curious. It seems that |
I was investigated too. Either it is jquery-ui delay for loading or a delay in inserting toc-wrapper in the DOM. In such case we would have to wait for insertion, but seems a bit complicated; or add a timeout but seems a bit ridiculous too. |
It it were just a DOM inserting delay, we could add the |
Not sure I understand you here? |
I meant that things happens as |
Ah, ok. Well, from a breakpoint set at the draggable call, I see that when it happens, |
You should be right. Indeed, the fact that the target is not defined does not rise the error |
No description provided.