Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidb80 committed Aug 23, 2024
1 parent 39cd4cf commit 73d2c88
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
23 changes: 20 additions & 3 deletions src/browser/page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Utils ---------------------------------------------

function toArray(smth) {
return Array.from(smth)
}

function dedent(text) {
// removes common indentation from `text`
const lines = text.split('\n')
Expand Down Expand Up @@ -437,6 +441,12 @@ up.compiler('latex', el => {
katex.render(tex, bdo, opts)
})

up.compiler('kbd', el => {
let bdo = newElement("bdo", { "dir": "ltr" }) // to aviod conflict with rtl languages
bdo.innerHTML = el.innerHTML
el.replaceChildren(bdo)
})

// up.compiler('article', wrapper => {
// for (let codeEl of wrapper.querySelectorAll('code')) {
// let lang = codeEl.getAttribute("lang")
Expand Down Expand Up @@ -476,15 +486,22 @@ up.compiler('article', el => {
up.compiler('[footnote]', el => {
footnoteCounter++

let id = `fn-${footnoteCounter}`
let fnid = `fn-${footnoteCounter}`
let refid = `ref-${footnoteCounter}`
let fnwrapper = q`#footnotes`
let fnEl = newElement("li", { id }, el.innerHTML)
let replEl = newElement("a", { href: `#${id}`, digit: '' })
let fnEl = newElement("li", { id: fnid })
let replEl = newElement("a", { id: refid, href: `#${fnid}`, digit: '' })
let sup = newElement("sup", {}, `${footnoteCounter}`)

replEl.appendChild(sup)
el.outerHTML = replEl.outerHTML

fnEl.append(newElement("a", { href: `#${refid}` }, "🔼"))
console.log(toArray(el.childNodes))
let innerFnEl = newElement("div", { dir: "auto", 'class': 'wtf' },)
innerFnEl.append(...toArray(el.childNodes))
fnEl.append(innerFnEl)

fnwrapper.appendChild(fnEl)
})

Expand Down
7 changes: 6 additions & 1 deletion src/browser/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ article figure img {
font-optical-sizing: auto;
}

code, code * {
code,
code * {
font-family: "Fira Code";
}

Expand Down Expand Up @@ -60,3 +61,7 @@ html,
body {
min-height: 100vh;
}

.wtf{
direction: auto;
}

0 comments on commit 73d2c88

Please sign in to comment.