Skip to content

Commit

Permalink
Fix callouts (#230)
Browse files Browse the repository at this point in the history
* Fix callouts

* Apply suggestions from code review
  • Loading branch information
JakeSCahill authored Nov 7, 2024
1 parent 21a7f53 commit cecc8ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/css/doc.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ html {
.doc h1 {
font-size: calc(44 / var(--rem-base) * 1rem);
}

.doc p:not(.tableblock) a {
white-space: nowrap;
}
}

.doc > h2#name + .sectionbody {
Expand Down Expand Up @@ -164,10 +168,6 @@ html {
color: var(--body-font-color);
}

.doc p:not(.tableblock) a {
white-space: nowrap;
}

.doc a:hover,
.doc .glossary-term:hover,
.doc p a > code:hover {
Expand Down Expand Up @@ -1562,6 +1562,8 @@ html[data-theme=dark] code[class*=language-] .token.function {
height: 1.25em;
letter-spacing: -0.25ex;
text-indent: -0.25ex;
color: var(--body-font-color);
margin-left: 4px;
}

.doc .conum[data-value]::after {
Expand Down
10 changes: 7 additions & 3 deletions src/js/11-editable-placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,13 @@ function unnestPlaceholders() {
if (!element || !element.textContent) {
return;
}

const pattern = /(\s\(<span class="token number">(\d+)<\/span>\)|(\s)\((\d+)\))$/gm;
element.innerHTML = element.innerHTML.replace(pattern, (match, p1, p2, p3, p4) => {
// Handle standalone numbers in parentheses, avoiding function-like patterns
const standalonePattern = /(?<!\w)\((\d+)\)(?!\w)$/g;
element.innerHTML = element.innerHTML.replace(standalonePattern, (match, num) => {
return `<i class="conum" data-value="${num}"></i>`;
});
const complexPattern = /(\s\(<span class="token number">(\d+)<\/span>\)|(\s)\((\d+)\))$/gm;
element.innerHTML = element.innerHTML.replace(complexPattern, (match, p1, p2, p3, p4) => {
return p3 ? `${p3}<i class="conum" data-value="${p4}"></i>` : `<i class="conum" data-value="${p2}"></i>`;
});
}
Expand Down

0 comments on commit cecc8ee

Please sign in to comment.