My style: Improving admonition + user script to fold admonitions #58
vgyenge6
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
Hi @vgyenge6 ! I'm not familiar with that plugin, but happy to see that you can make admonitions that look good. The defaults that I provided are quite ugly :D From your work we could do several things :
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
First of all, thank you for developing this plugin. Obsidian is great but doesn't provide any HTML output. Thus your plugin is a MUST!
I would like to contribute a little of my improvements for styling admonitions, and custom admonitions (as they look like in and by my Obsidian's Admonition plugin setup), extending with my user script to provide folding of the admonition content in your plugins's html output.
Put these styles' definitions into your Custom Stylesheet of this plugin. (Copy/paste from here and use your own colors and SVG icons.
Note: You need to set up the custom admonitions colors and icons first in Obsidian's Admonition plugin setup using a custom stylesheet or adding JSON definition there.)
/ * Callouts */
.callout[data-callout="abstract"],
.callout[data-callout="tldr"],
.callout[data-callout="hint"] {
--callout-color: 0, 191, 188;
--callout-content-background : 229, 248, 134;
}
.callout[data-callout="faq"],
.callout[data-callout="help"],
.callout[data-callout="caution"],
.callout[data-callout="attention"].,
.callout[data-callout="warning"] {
--callout-color: 236, 117, 0;
--callout-content-background: 253, 241, 229;
}
.callout[data-callout="success"],
.callout[data-callout="check"],
.callout[data-callout="done"] {
--callout-color: 8 185 78;
--callout-content-background: 230 248 237;
}
.callout[data-callout="missing"],
.callout[data-callout="bug"],
.callout[data-callout="failure"],
.callout[data-callout="danger"],
.callout[data-callout="error"] {
--callout-color: 233 49 71;
--callout-content-background: 254 234 236;
}
.callout[data-callout="example"]{
--callout-color: 139 106 240;
--callout-content-background: 241 237 253;
}
.callout[data-callout="quote"],
.callout[data-callout="cite"]{
--callout-color: 158 158 158;
--callout-content-background: 245 245 245;
}
/* custom callouts */
.callout[data-callout="info"]{
; }--callout-color: 199, 182, 0;
--callout-content-background:253, 251, 229;
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#C7B600"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="answer"]{
; }--callout-color: 0, 179, 134;
--callout-content-background: 229, 247, 243;
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#00B386"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="question"] {
; }--callout-color: 8, 109, 221;
--callout-content-background: 230 240 252;
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#086DDD"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="todo"]{
; }--callout-color: 158, 158, 158;
--callout-content-background: 245 245 245;
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#9E9E9E"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="summary"]{
; }--callout-color: 123, 0, 189;
--callout-content-background: 242 229 248;
/* --callout-icon: lucide-sigma; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#7B00BD"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="important"] {
; }--callout-color: 236, 117, 0;
--callout-content-background: 253, 241, 229;
/* --callout-icon: lucide-alert-circle; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#EC7500"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="tip"] {
; }--callout-color: 0, 191, 188;
--callout-content-background: 229, 248, 248;
/* --callout-icon: lucide-shield-alert; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#40CFCD"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="yellow"] {
; }--callout-color: 192, 182, 0;
--callout-content-background: 253,251, 229;
/* --callout-icon: lucide-arrow-big-right; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#EBD700"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="orange"] {
; }--callout-color: 236, 117, 0;
--callout-content-background: 253, 241,229;
/* --callout-icon: lucide-arrow-big-right; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#EC7500"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="red"] {
; }--callout-color: 233, 49, 71;
--callout-content-background: 253, 234, 236;
/* --callout-icon: lucide-arrow-big-right; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#E93147"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="turquise"] {
; }--callout-color: 0, 191, 188;
--callout-content-background: 229, 248, 248;
/* --callout-icon: lucide-arrow-big-right; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#EC7500"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="purple"] {
; }--callout-color: 123, 0, 189;
--callout-content-background: 241, 237, 253>
/* --callout-icon: lucide-arrow-big-right; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#00BFBC"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="blue"]{
; }--callout-color: 8, 109, 221;
--callout-content-background: 230, 240, 252;
/* --callout-icon: lucide-arrow-big-right; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#086DDD"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="green"]{
; }--callout-color: 0, 179, 134;
--callout-content-background: 229, 247, 243;
/* --callout-icon: lucide-arrow-big-right; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#00B386"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout[data-callout="grey"]{
; }--callout-color: 158, 158, 158;
--callout-content-background: 245 245 245;
/* --callout-icon: lucide-arrow-big-right; */
--callout-icon: <svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#9E9E9E"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
.callout {
overflow: hidden;
/* margin: 1em 0; /
/ box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
border-radius: 4px; */
background-color: rgb(var(--callout-content-background));
padding: 4px;
margin-top: 0px;
}
.callout-title {
padding: 0;
display: flex;
align-items: center;
gap: 4px;
font-size: inherit;
line-height: 1.3em;
color: rgb(var(--callout-color));
}
.callout-icon {
flex: 0 0 auto;
display: flex;
align-self: center;
color: rgb(var(--callout-color));
}
svg.svg-icon {
height: 18px;
width: 18px;
stroke-width: 1.75px;
color: rgb(var(--callout-color));
}
.callout-fold {
display:flex;
align-items:center;
padding-right:var(--size-4-2)
}
.callout-fold .svg-icon {
transition:transform .1s ease-in-out 0s
}
.callout-fold.is-collapsed .svg-icon {
transform:rotate(-90deg)
}
.callout-title-inner {
font-weight: bold;
font-size: inherit;
line-height: 1.3em;
color: rgb(var(--callout-color));
}
.callout-content {
overflow-x: auto;
padding: 0;
background-color:rgb(var(--callout-content-background));
}
Write a script to fold the admonition content. It will work fork embedded admonitions too.
Create a file myscripts_js.html. You need to add (insert) this script manually into the copied and saved html.
<script> document.onreadystatechange = function (){ console.log(document.readyState); if (document.readyState === 'complete') { initPage(); } } function initPage(){ let e = document; setupCallouts(e); function setupCallouts(e){ e.querySelectorAll(".callout-fold").forEach((function (e) { e.addEventListener("click", (function () { var t = this.parentElement.parentElement.childNodes[1]; e.classList.toggle("is-collapsed") if (t.style.display === "none") { t.style.display = "block"; } else { t.style.display = "none"; } } )) } )) } } </script>
Any response is welcome if this also works for you.
Beta Was this translation helpful? Give feedback.
All reactions