Skip to content

Commit

Permalink
Update diary, implement backref for Web
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Oct 8, 2024
1 parent b366875 commit 79d897e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
25 changes: 25 additions & 0 deletions bun/backref.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const citations = document.querySelectorAll('.link-reference > .link.local > a')

const citation_map = {}

for (const citation of citations) {
const href = citation.getAttribute('href')
citation_map[href] = citation_map[href] || 0
const citation_id = ++citation_map[href]
citation.setAttribute('id', `ref-${href.replace('.xml', '')}-${citation_id}`)
}

const references = document.querySelectorAll('article footer section[data-taxon="Reference"] details summary header h1 a')

for (const reference of references) {
const href = reference.getAttribute('href')
const citation_count = citation_map[href]
for (let i = 1; i <= citation_count; i++) {
// create a back reference
const back_reference = document.createElement('a')
back_reference.textContent = '↩'
back_reference.setAttribute('href', `#ref-${href.replace('.xml', '')}-${i}`)
back_reference.setAttribute('style', 'color: var(--uts-text-gentle) !important;text-decoration: none; margin-left: 0.5ex; margin-right: 0.5ex;')
reference.parentElement?.parentElement?.appendChild(back_reference)
}
}
2 changes: 1 addition & 1 deletion bun/markdownit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ for (let i = 0; i < markdownit_tags.length; i++) {
// we escape fr:tex tags to avoid conflicts with markdown syntax
// note that we need to use `+?` which is a lazy quantifier, meaning it matches as few characters as possible
.replaceAll(/\\([\[\(])(.+?)\\([\)\]])/g, '\\\\$1$2\\\\$3')
console.log(converted_source)
// console.log(converted_source)
markdownit_tag.innerHTML = md.render(converted_source)
markdownit_tag.classList.remove('grace-loading')
}
1 change: 1 addition & 0 deletions bun/uts-ondemand.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const register = (selector, script) => {
}

document.addEventListener('DOMContentLoaded', async () => {
// register('.link-reference', 'backref.js') // it works but not ideal
register('.markdownit', 'markdownit.js')
register('.typst-root', 'typst.js')
register('.pikchr-root', 'pikchr.js')
Expand Down
7 changes: 7 additions & 0 deletions trees/uts-0018.tree
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@
\subtree[2024-10]{
\title{October, 2024}

\mdblock{10-08}{
- add more plans in formal-land
- recovered [Research Codebase Manifesto](https://www.moderndescartes.com/essays/research_code/) from [Lean-MLIR](https://github.com/opencompl/lean-mlir)
}

\mdblock{10-07}{
- learned about [lobste.rs](https://lobste.rs/), a computing-focused community centered around link aggregation and discussion, a bit like Hacker News but less noise maybe
- read [Rewriting Rust](https://lobste.rs/s/29a1eo/rewriting_rust) and [Josh Triplett's comment](https://www.reddit.com/r/rust/comments/1fpomvp/rewriting_rust/lozktuv/)
- read \citek{wu2024multi} and learn about [mirage](https://github.com/mirage-project/mirage)
- port [[uts-001R]]
- make [the Railscasts theme for Zed](https://gist.github.com/utensil/a279928e07fe23558fa688ca4d82181e)
}

\mdblock{10-06}{
Expand Down

0 comments on commit 79d897e

Please sign in to comment.