mirror of
https://github.com/szabodanika/microbin
synced 2024-11-15 05:27:07 +00:00
properly escape content
This commit is contained in:
parent
1e8b17bb89
commit
c39b778234
2 changed files with 9 additions and 1 deletions
|
@ -80,6 +80,10 @@ impl Pasta {
|
||||||
pub fn content_not_highlighted(&self) -> String {
|
pub fn content_not_highlighted(&self) -> String {
|
||||||
html_highlight(&self.content, "txt")
|
html_highlight(&self.content, "txt")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn content_escaped(&self) -> String {
|
||||||
|
self.content.replace("`", "\\`").replace("$", "\\$")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Pasta {
|
impl fmt::Display for Pasta {
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const btn = document.getElementById("copy-icon")
|
const btn = document.getElementById("copy-icon")
|
||||||
const content = `{{ pasta.content }}`
|
const content = `{{ pasta.content_escaped() }}`
|
||||||
|
|
||||||
btn.addEventListener("click", () => {
|
btn.addEventListener("click", () => {
|
||||||
navigator.clipboard.writeText(content)
|
navigator.clipboard.writeText(content)
|
||||||
|
@ -70,6 +70,10 @@ code-line::before {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.copy-button {
|
.copy-button {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
Loading…
Reference in a new issue