1. Find a Foo
+Blah blah blah, foo
+1.1. bar
+foo
+diff --git a/Pipfile b/Pipfile index c896d18738..258e91c90f 100644 --- a/Pipfile +++ b/Pipfile @@ -4,7 +4,7 @@ url = "https://pypi.org/simple" verify_ssl = true [dev-packages] -bikeshed = {editable = true,path = "."} +bikeshed = {editable = true, path = "."} [packages] aiofiles = "==22.1.0" diff --git a/bikeshed/boilerplate.py b/bikeshed/boilerplate.py index 182f6c3d00..988ea6a687 100644 --- a/bikeshed/boilerplate.py +++ b/bikeshed/boilerplate.py @@ -776,6 +776,105 @@ def addIDLSection(doc: t.SpecT) -> None: h.addClass(doc, container, "highlight") +bookmarkCss = """ + .material-symbols-outlined { + font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24 + } + .heading { + position: relative; + } + .bookmark-tooltip { + opacity: 0; + display: block; + position: absolute; + bottom: 100%; + left: 0; + pointer-events: auto; + border: shadow 2px gray; + padding: 0; + margin: 0; + background: rgb(200 200 200 / 50%); + color: black; + border-radius: 5px; + } + a.has-bookmark-tooltip { + display: block; + } + .bookmark-tooltip button { + padding: 0; + background: rgb(100 100 100 / 50%); + } + .has-bookmark-tooltip:hover .bookmark-tooltip { + opacity: 0.8; + } + .bookmarksSection { + margin-left: 2em; + } + """ + +bookmarkScript = """ + "use strict"; + // Add tooltip behavior to all headers. + const headers = document.querySelectorAll('.heading'); + // We need to get the createElement method now, or else it is not available!? + const createElement = document.createElement; + const makeTag = (tag) => { + return createElement.call(document, tag); + } + + for (let h of headers) { + const textElement = h.querySelector('span.content'); + insertTooltipAction(h, 'bookmark_add', 'Add bookmark', (event) => { + addBookmark(h, textElement.textContent); }) + } + + function insertTooltipAction(element, className, title, action) { + const tooltipSpan = makeTag('span'); + tooltipSpan.className = 'bookmark-tooltip'; + const button = makeTag('button'); + button.setHTML( + `${className}`); + button.addEventListener('click', action); + tooltipSpan.insertAdjacentElement('beforeend', button); + element.insertAdjacentElement('beforeend', tooltipSpan); + element.classList.add('has-bookmark-tooltip'); + } + + function addBookmark(header, text) { + // console.info('add bookmark for', header); + let bookmarksSection = document.querySelector('.bookmarksSection'); + if (bookmarksSection == null) { + const tocContents = document.querySelector('#toc #contents'); + bookmarksSection = makeTag('div'); + bookmarksSection.className = 'bookmarksSection'; + bookmarksSection.setHTML('Bookmarks
Test algorithm auto-naming.
+Blah blah blah, foo
+foo
+