ENH: Use section-title for HTML anchors in Report#11890
ENH: Use section-title for HTML anchors in Report#11890larsoner merged 9 commits intomne-tools:mainfrom
Conversation
hoechenberger
left a comment
There was a problem hiding this comment.
This looks good to me. Did you test locally if the anchors work as expected in the browser?
|
Yep, links like https://output.circle-artifacts.com/output/job/9ba0a65d-5ccb-4f10-ada5-3710c9ff93b2/artifacts/0/html/auto_tutorials/intro/report_events.html#Events_from__events_ work (sanitized from `Events from "events"). What I really want is a place I can click to get the anchor -- in chrome at least when I click the headings on the left the URL does not update or anything, so I have to inspect the HTML to get them. Once I figure that out it'll be good to go... |
I suppose you could modify this function: mne-python/mne/report/js_and_css/report.js Lines 152 to 163 in 4a041a7 and call |
Just pushed a fix 👍 FWIW I saw a lot of work |
| data-bs-target="#accordion-collapse-{{ id }}" aria-expanded="true" aria-controls="accordion-collapse-{{id}}"> | ||
| <div class="w-100"> | ||
| <span class="me-auto">{{ title }}</span> | ||
| <span class="me-auto"><a href="#{{ id }}" class="text-decoration-none">{{ title }}</a></span> |
There was a problem hiding this comment.
FYI I also added these for links in the main area at the top of each section. When you click them they don't go to that location, they still collapse the section -- but you can at least right-click-copy them. I think ideally these would live in a little anchor symbol that just set the URL at the top when you clicked it, but that wasn't trivial. This is at least some progress in the right direction I think.
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
| Bugs | ||
| ~~~~ | ||
| - Fix visualization dialog compatibility with matplotlib 3.7 (:gh:`11409` by `Daniel McCloy`_ and `Eric Larson`_) | ||
|
|
* upstream/main: [pre-commit.ci] pre-commit autoupdate (mne-tools#11911) [BUG, MRG] Remove check on `mne.viz.Brain.add_volume_labels` (mne-tools#11889) Small splits fix (mne-tools#11905) adds niseq package to "Related software" (mne-tools#11909) Minor fixes for ERDS maps example (mne-tools#11904) FIX: Fix pyvista rendering (mne-tools#11896) BUG: Fix epoch splits naming (mne-tools#11876) ENH: Use section-title for HTML anchors in Report (mne-tools#11890) CI: Deploy [circle deploy] MAINT: Clean up whats_new and doc versions (mne-tools#11888) Refactor test_epochs.py::test_split_saving (2 out of 2) (mne-tools#11884) Cross-figure event passing system (mne-tools#11685) MAINT: Post-release deprecations, updates [circle deploy] (mne-tools#11887) MAINT: Release 1.5.0 (mne-tools#11886) [pre-commit.ci] pre-commit autoupdate (mne-tools#11883) Refactor test_epochs.py::test_split_saving (1 out of 2) (mne-tools#11880) FIX: Missing Saccade information in Eyelink File (mne-tools#11877) Improve drawing of annotations with matplotlib (mne-tools#11855) MAINT: Work around NumPy deprecation (mne-tools#11878)
Closes #11794
Closes #11894
This PR changes the HTML
<div id="..."from"global-N"to"section-title"(with sanitization) ortitle(if no section), falling back to appending-Nwhen there are duplicates.DRYs code a bit by using a
_rendererhelper, and fixes shadowing of builtinsidandreprin a couple of places.I originally started by removing the global DOM ID business altogether and constructing it on the fly when creating the HTML, but this breaks backward compat with existing report saves. So instead this PR just makes it so that new reports will have the
content.dom_idset to something nicer -- old elements will still haveglobal-NIDs. It seemed like the best compromise.