Open kleinerpirat opened 3 years ago
I had this concern myself for some time already.
One method for decreasing declutter was implemented in the last update, and that's block tags + optics. This would let you skip those individual setl
commands, like so:
[[#forli::setl]]
1. First item
2. Second item
[[/]]
which is then translated to:
1. [[setl1::First item]]
2. [[setl2::Second item]]
That's not exactly the same that you have, but functionally. I could also implement one version, that consumes the list, while it is replacing.
2. The second method, using colored spans for indicating Closet elements, can work as well, the question is just what the implementation should look like. A few ideas I had:
iocm
and ioce
elements).data-closet
as an attribute:
<span data-closet="iocm0">Cholin<span> wird über <span data-closet="iocm0">Cholin-Transporter (CHT1)</span> in die Nervenzelle aufgenommen.
// and transforms them to:
[[iocm0::Cholin]] wird über [[iocm0::Cholin-Transporter (CHT1)]] in die Nervenzelle aufgenommen.
// you could style them like so:
[data-closet="iocm0"] {
/* ... */
}
The issue with those would be, they might also be confusing, if they end up empty, and they're not visible in the fields anymore.
Do you have any other suggestion / or what did you envision?
One method for decreasing declutter was implemented in the last update, and that's block tags + optics.
This is beautiful. Thanks for that!
I could implement a "pre-template step", that scans the template text for specific HTML elements.
So this would basically the same thing I am doing with my template script. So far, it worked surprisingly well for my specific use case.
Enough dreaming for today. Simple syntax highlighting would be a great improvement already 👍🏻
Now that you'll soon be working on Closet again, I wanted to give you a brief update on how I tackle this issue nowadays.
I have fully committed to a visual pre-template syntax that is heavily focused on lists and implicit logic.
<ol>
's either translate into setlists (one list item -> one card) or context cloze lists, depending on the content of cmds 0
.
If no further cmds fields are filled, these lists are just normal lists.Screenshot: Setlist
Screenshot: Cloze list with context
<ul>
's get turned into multiple choice questions if at least one <li>
is underlined (which means it's a correct answer).Screenshot: Multiple Choice
Clozes or hints are marked with HTML tags like <u>
, <i>
, and <strike>
(all execCommands that can be toggled) instead of <span>
's because they are handled better by the webkit and they all have individual closing tags, which makes batch changes much easier. Their appearance is modified with shadow-root stylesheets.
I won't bother you with more details. Just rest assured that I am happy with the way Closet tags work right now, that my vision in the comment above was a bit narrow-minded and that there are plenty of ways to use Closet the way you want.
Hey Henrik, Things have changed in my workflow once again and I'd like to get back to you on this example for block tags + optics:
[[#forli::setl]] 1. First item 2. Second item [[/]]
I got this generic function to translate list items into closet commands, where the switch block will be expanded for a number of tags:
filterManager.registrar.register(
"forli",
e => {
const { hasBlock, hasInline, inlineValues, blockValues } = e;
if (hasInline) {
const [tag, ...args] = inlineValues;
switch (tag) {
case "setl": {
return setl(args, blockValues); /* <- What to do with this output? */
}
}
} else return null;
},
{
inlineOptics: [
closet.template.optics.separated({ sep: "::", trim: true }),
],
blockOptics: [
closet.template.optics.templated({
before: "<li>",
after: "</li>",
}),
],
}
);
Instead of reimplementing the standard effects within the user setup, I'd like to convert block values into existing tags (mc, setl, etc.) and rely mostly on Closet's predefined recipes.
Say my function setl()
returns
[[setl1::First item]][[setl2::Second item]][[sel]]
How would I proceed? Should I reiterate over that output with Closet? Or is there an easy way to invoke the respective functions directly within setl()
without another parsing round?
You mentioned on the add-on download page that Closet can detect meaningful content (such as list items). The only example for lists I could find is this one: https://github.com/hgiesel/closet/blob/766b4233f641725ff018cba72aba1ed736451fd7/docs/_data/setups/templated_shuffle.yml#L14-L21
But that wouldn't work for nested lists. "Meaningful" makes me think of DOM traversal :thinking: But I haven't found anything like that yet, so for now, I'm reopening the issue :)
Do you intend to implement the same sort of syntax highlighting you're using on your website for the add-on?
Without visual cues, Closet cards can get confusing rather quickly. For image occlusions with clozes and picking I'm currently wrapping text with
<span>
elements of two different classes in the editor, which are translated to commands in the template. Without this, it would be unfeasible to create big notes:Humans are good at pattern recognition, but we're not robots.
I would prefer to keep things as vanilla as possible, but without syntax highlighting (or even better, a way of using Closet via interactive HTML-elements *), I can't see myself (and much less my friends) using standard Closet commands for this type of notes.
* This is something I have experimented on during the christmas holidays, but university caught up to me and I had to drop this endeavour. Probably for the best, because Closet is still undergoing a lot of changes.