|
|
|
/* @settings |
|
|
|
name: Live preview list threading - active line |
|
id: live-preview-list-threading-active |
|
settings: |
|
- |
|
id: list-threading-active-elbow-location |
|
title: Threading line elbow location |
|
description: Where the threading line elbow is located |
|
type: class-select |
|
allowEmpty: false |
|
default: list-threading-active-elbow-top |
|
options: |
|
- |
|
label: "Top (priority for wrapped text)" |
|
value: list-threading-active-elbow-top |
|
- |
|
label: "Bottom (priority for images)" |
|
value: list-threading-active-elbow-bottom |
|
- |
|
id: list-threading-active-width |
|
title: Threading line width |
|
description: The width of the threading line |
|
type: variable-number |
|
default: 3 |
|
format: px |
|
- |
|
id: list-threading-active-offset-extra |
|
title: Thread line extra offset |
|
description: Extra offset for threading line |
|
type: variable-number |
|
default: 2 |
|
format: px |
|
- |
|
id: colors-section |
|
title: Colors |
|
type: heading |
|
level: 2 |
|
collapsed: false |
|
- |
|
id: list-threading-active-alpha |
|
title: Alpha |
|
description: The alpha (transparency) of all threading lines |
|
type: variable-number-slider |
|
default: 0.2 |
|
min: 0.0 |
|
max: 1.0 |
|
step: 0.05 |
|
- |
|
id: style-settings-bug-note |
|
title: Note |
|
description: "Style Settings seems to be [bugged](https://github.com/mgmeyers/obsidian-style-settings/issues/168). You may not see the actual colors here before interacting with each color picker." |
|
type: info-text |
|
markdown: true |
|
- |
|
id: list-threading-active-color-1 |
|
title: Color 1 |
|
type: variable-color |
|
opacity: false |
|
format: hsl-values |
|
default: 'hsl(23, 100%, 45%)' |
|
- |
|
id: list-threading-active-color-2 |
|
title: Color 2 |
|
type: variable-color |
|
opacity: false |
|
format: hsl-values |
|
default: 'hsl(46, 100%, 45%)' |
|
- |
|
id: list-threading-active-color-3 |
|
title: Color 3 |
|
type: variable-color |
|
opacity: false |
|
format: hsl-values |
|
default: 'hsl(70, 100%, 45%)' |
|
- |
|
id: list-threading-active-color-4 |
|
title: Color 4 |
|
type: variable-color |
|
opacity: false |
|
format: hsl-values |
|
default: 'hsl(105, 100%, 45%)' |
|
- |
|
id: list-threading-active-color-5 |
|
title: Color 5 |
|
type: variable-color |
|
opacity: false |
|
format: hsl-values |
|
default: 'hsl(187, 100%, 45%)' |
|
|
|
*/ |
|
|
|
.markdown-source-view .HyperMD-list-line { |
|
/* Unitless zero in variables is evil */ |
|
--list-padding-inline-start-fix: 0px; /*calc(1px * var(--list-indent-source));*/ |
|
} |
|
.markdown-source-view.is-live-preview .HyperMD-list-line { |
|
--list-padding-inline-start-fix: var(--list-indent-editing); |
|
} |
|
|
|
.HyperMD-list-line-1:not(:has(~ .HyperMD-list-line-1 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4, .HyperMD-list-line-3, .HyperMD-list-line-2).cm-active), |
|
.HyperMD-list-line-1:not(:has(~ .HyperMD-list-line-1 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-2.cm-active, ~ .HyperMD-list-line-2 ~ :is(.HyperMD-list-line-3, .HyperMD-list-line-4, .HyperMD-list-line-5, .HyperMD-list-line-6).cm-active), |
|
.HyperMD-list-line-2:not(:has(~ .HyperMD-list-line-2 ~ .HyperMD-list-line.cm-active)):is(.cm-active, :has(~ :is(.HyperMD-list-line-3, .HyperMD-list-line-4, .HyperMD-list-line-5, .HyperMD-list-line-6).cm-active)) > .cm-hmd-list-indent { |
|
&::before { |
|
--list-threading-active-color: hsl(var(--list-threading-active-color-1, 23, 100%, 45%), var(--list-threading-active-alpha, 0.2)); |
|
--list-threading-active-offset: calc(var(--list-threading-active-offset-extra, 2px) + var(--list-padding-inline-start-fix)); |
|
} |
|
} |
|
|
|
.HyperMD-list-line-2:not(:has(~ .HyperMD-list-line-2 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4, .HyperMD-list-line-3).cm-active), |
|
.HyperMD-list-line-2:not(:has(~ .HyperMD-list-line-2 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-3.cm-active, ~ .HyperMD-list-line-3 ~ :is(.HyperMD-list-line-4, .HyperMD-list-line-5, .HyperMD-list-line-6).cm-active), |
|
.HyperMD-list-line-3:not(:has(~ .HyperMD-list-line-3 ~ .HyperMD-list-line.cm-active)):is(.cm-active, :has(~ :is(.HyperMD-list-line-4, .HyperMD-list-line-5, .HyperMD-list-line-6).cm-active)) > .cm-hmd-list-indent { |
|
&::before { |
|
--list-threading-active-color: hsl(var(--list-threading-active-color-2, 46, 100%, 45%), var(--list-threading-active-alpha, 0.2)); |
|
--list-threading-active-offset: calc(var(--list-threading-active-offset-extra, 2px) + var(--list-padding-inline-start-fix) + var(--list-indent)); |
|
} |
|
} |
|
|
|
.HyperMD-list-line-3:not(:has(~ .HyperMD-list-line-3 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4).cm-active), |
|
.HyperMD-list-line-3:not(:has(~ .HyperMD-list-line-3 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-4.cm-active, ~ .HyperMD-list-line-4 ~ :is(.HyperMD-list-line-5, .HyperMD-list-line-6).cm-active), |
|
.HyperMD-list-line-4:not(:has(~ .HyperMD-list-line-4 ~ .HyperMD-list-line.cm-active)):is(.cm-active, :has(~ :is(.HyperMD-list-line-5, .HyperMD-list-line-6).cm-active)) > .cm-hmd-list-indent { |
|
&::before { |
|
--list-threading-active-color: hsl(var(--list-threading-active-color-3, 70, 100%, 45%), var(--list-threading-active-alpha, 0.2)); |
|
--list-threading-active-offset: calc(var(--list-threading-active-offset-extra, 2px) + var(--list-padding-inline-start-fix) + 2 * var(--list-indent)); |
|
} |
|
} |
|
|
|
.HyperMD-list-line-4:not(:has(~ .HyperMD-list-line-4 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5).cm-active), |
|
.HyperMD-list-line-4:not(:has(~ .HyperMD-list-line-4 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-5.cm-active, ~ .HyperMD-list-line-5 ~ :is(.HyperMD-list-line-6).cm-active), |
|
.HyperMD-list-line-5:not(:has(~ .HyperMD-list-line-5 ~ .HyperMD-list-line.cm-active)):is(.cm-active, :has(~ :is(.HyperMD-list-line-6).cm-active)) > .cm-hmd-list-indent { |
|
&::before { |
|
--list-threading-active-color: hsl(var(--list-threading-active-color-4, 105, 100%, 45%), var(--list-threading-active-alpha, 0.2)); |
|
--list-threading-active-offset: calc(var(--list-threading-active-offset-extra, 2px) + var(--list-padding-inline-start-fix) + 3 * var(--list-indent)); |
|
} |
|
} |
|
|
|
.HyperMD-list-line-5:not(:has(~ .HyperMD-list-line-5 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6).cm-active), |
|
.HyperMD-list-line-5:not(:has(~ .HyperMD-list-line-5 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-6.cm-active), |
|
.HyperMD-list-line-6:not(:has(~ .HyperMD-list-line-6 ~ .HyperMD-list-line.cm-active)):is(.cm-active) > .cm-hmd-list-indent { |
|
&::before { |
|
--list-threading-active-color: hsl(var(--list-threading-active-color-5, 187, 100%, 45%), var(--list-threading-active-alpha, 0.2)); |
|
--list-threading-active-offset: calc(var(--list-threading-active-offset-extra, 2px) + var(--list-padding-inline-start-fix) + 4 * var(--list-indent)); |
|
} |
|
} |
|
|
|
/* tails */ |
|
.HyperMD-list-line-1:not(:has(~ .HyperMD-list-line-1 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4, .HyperMD-list-line-3, .HyperMD-list-line-2).cm-active), |
|
.HyperMD-list-line-2:not(:has(~ .HyperMD-list-line-2 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4, .HyperMD-list-line-3).cm-active), |
|
.HyperMD-list-line-3:not(:has(~ .HyperMD-list-line-3 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4).cm-active), |
|
.HyperMD-list-line-4:not(:has(~ .HyperMD-list-line-4 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5).cm-active), |
|
.HyperMD-list-line-5:not(:has(~ .HyperMD-list-line-5 ~ .HyperMD-list-line.cm-active)):has(~ :is(.HyperMD-list-line-6).cm-active) { |
|
&::before { |
|
content: ""; |
|
position: absolute; |
|
left: var(--list-threading-active-offset); |
|
bottom: 0; |
|
width: var(--list-threading-active-width, 3px); |
|
background-color: var(--list-threading-active-color); |
|
height: calc(100% - 0.75em); |
|
} |
|
.is-live-preview &:is(.HyperMD-task-line)::before { |
|
max-height: calc(100% - 1.3em); |
|
} |
|
body.list-threading-active-elbow-bottom &::before { |
|
height: 0.8em; |
|
} |
|
body.list-threading-active-elbow-bottom .is-live-preview &:is(.HyperMD-task-line)::before { |
|
max-height: 0.275em; |
|
} |
|
} |
|
|
|
/* in-between lines */ |
|
.HyperMD-list-line-1:not(:has(~ .HyperMD-list-line-1 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-2.cm-active, ~ .HyperMD-list-line-2 ~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4, .HyperMD-list-line-3).cm-active), |
|
.HyperMD-list-line-2:not(:has(~ .HyperMD-list-line-2 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-3.cm-active, ~ .HyperMD-list-line-3 ~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4).cm-active), |
|
.HyperMD-list-line-3:not(:has(~ .HyperMD-list-line-3 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-4.cm-active, ~ .HyperMD-list-line-4 ~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5).cm-active), |
|
.HyperMD-list-line-4:not(:has(~ .HyperMD-list-line-4 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-5.cm-active, ~ .HyperMD-list-line-5 ~ :is(.HyperMD-list-line-6).cm-active), |
|
.HyperMD-list-line-5:not(:has(~ .HyperMD-list-line-5 ~ .HyperMD-list-line.cm-active)) ~ .HyperMD-list-line:has(~ .HyperMD-list-line-6.cm-active) { |
|
&::before { |
|
content: ""; |
|
position: absolute; |
|
left: var(--list-threading-active-offset); |
|
top: 0; |
|
height: 100%; |
|
width: var(--list-threading-active-width, 3px); |
|
background-color: var(--list-threading-active-color); |
|
} |
|
} |
|
|
|
/* elbows */ |
|
.HyperMD-list-line-2:not(:has(~ .HyperMD-list-line-2 ~ .HyperMD-list-line.cm-active)):is(.cm-active, :has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4, .HyperMD-list-line-3).cm-active)), |
|
.HyperMD-list-line-3:not(:has(~ .HyperMD-list-line-3 ~ .HyperMD-list-line.cm-active)):is(.cm-active, :has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5, .HyperMD-list-line-4).cm-active)), |
|
.HyperMD-list-line-4:not(:has(~ .HyperMD-list-line-4 ~ .HyperMD-list-line.cm-active)):is(.cm-active, :has(~ :is(.HyperMD-list-line-6, .HyperMD-list-line-5).cm-active)), |
|
.HyperMD-list-line-5:not(:has(~ .HyperMD-list-line-5 ~ .HyperMD-list-line.cm-active)):is(.cm-active, :has(~ :is(.HyperMD-list-line-6).cm-active)), |
|
.HyperMD-list-line-6:not(:has(~ .HyperMD-list-line-6 ~ .HyperMD-list-line.cm-active)):is(.cm-active) { |
|
& > .cm-hmd-list-indent::before { |
|
content: ""; |
|
position: absolute; |
|
left: var(--list-threading-active-offset); |
|
width: calc(var(--list-indent) - var(--list-threading-active-width, 3px)); |
|
top: 0; |
|
border-bottom-left-radius: var(--radius-m); |
|
border-bottom: var(--list-threading-active-width, 3px) solid var(--list-threading-active-color); |
|
border-left: var(--list-threading-active-width, 3px) solid var(--list-threading-active-color); |
|
height: calc(0.775em); |
|
} |
|
body.list-threading-active-elbow-bottom & > .cm-hmd-list-indent::before { |
|
height: calc(100% - 0.825em - var(--list-threading-active-width, 3px) / 2); |
|
} |
|
.is-live-preview &:is(.HyperMD-task-line) > .cm-hmd-list-indent::before { |
|
max-width: calc(var(--list-indent) - 0.35em - var(--list-threading-active-offset-extra, 2px)); |
|
} |
|
} |
@KillyMXI
Yeah, that fixed the elbows. Thanks!
Also for pointing out the indentation issue. It turns out, it's because I am using spaces for indentation (I have the settings Editor > Indent using tabs turned off), and the snippet doesn't seem to work with spaces.
For 3 spaces, it overshoots (see below), and for 4, it undershoots like above.
Is it possible to update the snippet so that it works with spaces as well?
I digress, but on that note, I also investigated this further and found that Tab indent size setting in Obsidian doesn't affect lists, which seem to have a fixed tab size, and their indentation is also unfased by the text font.
If I use the default font, Inter, it looks like this,

And if I use any other monospace font, in this case Fira Code (same results with Consolas), it looks like this,

Notice (for the second, monospace font case) how the tab size is not an integer number of spaces; it's somewhere between 3 and 4!
The compromise I guess is to just use tabs for indentation, but as a Python programmer it feels violating.
FYI, I am using the default theme. I am new to Obsidian, and have no experience with CSS.