Merged
Conversation
Contributor
|
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 |
Contributor
Author
|
@bastienvoirin I am very much open to it, I just need to look at how I can best implement it into the existing code ;) |
istudyatuni
reviewed
Nov 5, 2023
Co-authored-by: Ilia <[email protected]>
laurmaedje
reviewed
Nov 6, 2023
Contributor
Author
|
okay @laurmaedje I have resolved the issues. |
Contributor
Author
|
Thanks to everyone for commenting |
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tomlfile with all required keysREADME.mdwith documentation for my packageLICENSEfile or linked one in myREADME.mdname:versionof the submitted package