-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
codly:0.1.0 #217
codly:0.1.0 #217
Conversation
Hi @Dherse, I was just about to submit a package named I think this feature would fit nicely into your #let diff(
prefix: true,
color-add: color.rgb("#2ecc403f"),
color-del: color.rgb("#ff41363f"),
document
) = {
show raw: it => {
if it.has("block") and it.block {
stack(dir: ttb, ..if it.lang != none and it.lang.starts-with("diff-") {
it.lines.map(line => box(
width: 100%,
height: 1em*3/2,
inset: (x: 1em*1/6, y: 1em*1/3),
fill:
if line.text.starts-with("+ ") { color-add }
else if line.text.starts-with("- ") { color-del }
else { none },
[
#if prefix {box(width: 1em*7/6, {
if line.text.starts-with("+ ") { text(color-add, raw("+")) }
else if line.text.starts-with("- ") { text(color-del, raw("-")) }
})}#box[
#raw(
if line.text.len() >= 2 { line.text.slice(2) } else { "" },
block: false,
lang: it.lang.trim("diff-", at: start)
)
]
]
))
} else {
it.lines.map(line => box(
width: 100%,
height: 1em*3/2,
inset: (x: 1em*1/6, y: 1em*1/3),
line
))
})
} else {
if it.lines.len() > 0 {
let line = it.lines.at(0)
if it.lang != none and it.lang.starts-with("diff-") {
box(
inset: (x: 1em*1/6, y: 0em),
outset: (y: 1em*1/3),
fill:
if line.text.starts-with("+ ") { color-add }
else if line.text.starts-with("- ") { color-del }
else { none },
[
#if prefix {box(width: 1em*7/6, {
if line.text.starts-with("+ ") { text(color-add, raw("+")) }
else if line.text.starts-with("- ") { text(color-del, raw("-")) }
})}#box[
#raw(
if line.text.len() >= 2 { line.text.slice(2) } else { "" },
block: false,
lang: if it.lang != none and it.lang.starts-with("diff-") {
it.lang.trim("diff-", at: start)
} else {
none
}
)
]
]
)
} else {
box(
inset: (x: 1em*1/6, y: 0em),
outset: (y: 1em*1/3),
line.body
)
}
}
}
}
document
} Besides a font size reduction when the |
@bastienvoirin I am very much open to it, I just need to look at how I can best implement it into the existing code ;) |
Co-authored-by: Ilia <[email protected]>
okay @laurmaedje I have resolved the issues. |
Thanks to everyone for commenting |
Thank you! |
I am submitting
Description: Pretty code blocks for Typst. Highly customizable and easy to use.
I have read and followed the submission guidelines and, in particular, I
typst.toml
file with all required keysREADME.md
with documentation for my packageLICENSE
file or linked one in myREADME.md
name:version
of the submitted package