sobjornstad / TiddlyRemember

Embed Anki notes in your TiddlyWiki
https://sobjornstad.github.io/TiddlyRemember/
MIT License
65 stars 7 forks source link

Feature Request: Allow hiding questions from tiddlers #33

Closed ldorigo closed 2 years ago

ldorigo commented 3 years ago

Hi, this plugin/add-on is great, thanks.

I know it's doable by tinkering in the plugin tiddlers/css, and I'll probably do it once I have some time, but could you consider having a setting that allows hiding Q/A's from the rendered tiddlers (or just showing a small icon showing that an Anki question is present at that point? At the moment, the Q/A take up a lot of space, and are kind of redundant (as I will typically have the information as part of the Tiddler's text, and then the Q/A below it).

If you point me to where and how you'd like to see this implemented, I could probably whip up a pull request t some point.

sobjornstad commented 3 years ago

@ldorigo, I think the details of what you want to happen might be pretty important here. If you really just don't want them to show up at all, this is trivial -- just drop this CSS rule in a new tiddler and tag it $:/tags/Stylesheet:

.remembertwo, div.remembercz {
  display: none;
}

Note that this doesn't hide inline clozes (span.remembercz), since those are presumably part of a paragraph and you wouldn't want them disappearing. I wouldn't have a problem with putting this snippet behind a $reveal widget in the plugin's CSS tiddler depending on the value of a config tiddler, if other people want this, e.g.:

<$reveal type=match state="$:/config/TiddlyRemember/HideNotes" text="yes">
.remembertwo, div.remembercz {
  display: none;
}
</$reveal>

Now if you want some kind of icon, or expandable icon, to appear, which seems like it might be more useful so you don't lose track of where you put TiddlyRemember notes, that gets a bit trickier. If this is more what you're looking for, does the icon need to be expandable? Should all items in the tiddler be hidden together, or each one expandable separately?

I'm wondering if expandable questions are more complicated than TiddlyRemember should get into though. Serious users can easily implement an extra layer on top of TR that exactly matches what they need to use it for, and there are enough ways to distribute TR notes within a wiki (e.g., keeping them in separate tiddlers, transcluding them from tiddlers, including directly within the body) that it might be hard to find something that works really well for all of them.

sortega commented 3 years ago

That's exactly what I'm doing with the details widget plugin http://tid.li/tw5/plugins.html#DetailsWidget. I have a template to quickly insert a block named "trivia" that is collapsed by default. The result looks like this:

<$details summary="Trivia"> <<rememberp "20201204195928697" "Define: Berkson's Paradox" """Definition: Paradoxical negative correlation between measurements that are uncorrelated or even positively correlated in a population. [img[berksons_paradox.png]]""">> </$details>

You can add your own template quite easily:

[image: image.png]

On Sat, Jan 2, 2021 at 4:50 PM Soren Bjornstad notifications@github.com wrote:

@ldorigo https://github.com/ldorigo, I think the details of what you want to happen might be pretty important here. If you really just don't want them to show up at all, this is trivial -- just drop this CSS rule in a new tiddler and tag it $:/tags/Stylesheet:

.remembertwo, div.remembercz { display: none; }

Note that this doesn't hide inline clozes, since those are presumably part of a paragraph and you wouldn't want them disappearing. I wouldn't have a problem with putting this snippet behind a $reveal widget in the plugin's CSS tiddler depending on the value of a config tiddler, if other people want this, e.g.:

<$reveal type=match state="$:/config/TiddlyRemember/HideNotes" text="yes"> .remembertwo, div.remembercz { display: none; } </$reveal>

Now if you want some kind of icon, or expandable icon, to appear, which seems like it might be more useful so you don't lose track of where you put TiddlyRemember notes, that gets a bit trickier. If this is more what you're looking for, does the icon need to be expandable? Should all items in the tiddler be hidden together, or each one expandable separately?

I'm wondering if expandable questions are more complicated than TiddlyRemember should get into though. Serious users can easily implement an extra layer on top of TR that exactly matches what they need to use it for, and there are enough ways to distribute TR notes within a wiki (e.g., keeping them in separate tiddlers, transcluding them from tiddlers, including directly within the body) that it might be hard to find something that works really well for all of them.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sobjornstad/TiddlyRemember/issues/33#issuecomment-753489379, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB7MA27HZ4PSGK4YUKPAUDSX46F3ANCNFSM4VRBT34A .

-- Sebastián Ortega Tail of Data letgo: snap, post, chat & sell sebastian.ortega@letgo.com www.letgo.com

sobjornstad commented 3 years ago

@sortega, this is a great way to do it! I've started using it myself occasionally, thanks for the tip.

@ldorigo, with several options presented and no further comments for a couple of weeks, I'm going to assume this is sorted, but feel free to reopen if you think there's something else TiddlyRemember should be doing.

ldorigo commented 3 years ago

I'm sorry I didn't come back - been pretty busy with exams.

For inline clozes, you're right that they should stay in place.

For Q/As, I think that like you say, it would be nice if it just showed a small "anki" icon that indicates that there is a note. Sortega's idea is great, maybe it could be integrated as part of the anki plugin (an additional optional parameter to the macro?).

There is actually another usecase that I think would be even more useful, although maybe it warrants a separate feature request: questions with inline answers. Most often, the answers to the flashcard is already present in the tiddler text. So instead of having something like:

Vitamin D is a fat-soluble vitamin produced by epithelial cells in the presence of UV light. It is mainly needed for Calcium homeostasis and innate immunity.

<<rememberq "20200523175149066"
    "By what is Vitamin D produced?"
    "By epithelial cells.">>
<<rememberq "20200523175149066"
    "What is needed for vitamin D production?"
    "UV light">>
<<rememberq "20200523175149066"
    "What is vitamin D mainly needed for?"
    "Calcium homeostasis and innate immunity">>

Which includes a lot of repetition, it could be something like:

Vitamin D is a fat-soluble vitamin produced by <<rememberq_inline "12341241" "epithelial cells" "what is vitamin D produced by?">> in the presence of <<rememberq_inline "143212341" "UV light" "what is needed for vitamin D production?">>. It is mainly needed for <<rememberq_inline "324213" "Calcium homeostasis and innate immunity" "What is vitamin D mainly needed for?">>

This is admittedly a bit harder to read, but it's much, much faster to write and doesn't duplicate information (which it the whole philosophy of TiddlyWiki :-) ).

Note that the above wouldn't be rendered as a Q/A, but rather just display a small icon or maybe just render the answer in a different color to show that it's an Anki note.

ldorigo commented 3 years ago

It doesn't look like I can reopen the issue, but maybe you could do so?

sobjornstad commented 3 years ago

Sortega's idea is great, maybe it could be integrated as part of the anki plugin (an additional optional parameter to the macro?).

I don't actually think this is possible. A macro call can't open a $details widget and not close it -- TiddlyWiki will automatically close any elements that are unclosed at the end of a macro body. So it would have to create a separate $details widget for every question, which isn't what you want. To get the effect of collapsing all questions, you have to use another widget or HTML element around all of the macro calls, and it seems to me that might just as well be a $details widget as anything else -- there's not really much benefit to implementing separate syntax just for using the widget in this context.

I'd also be reluctant to add a dependency on the $details widget plugin when some people might never use the feature, but that's beside the point if it's not even possible. :-)

There is actually another usecase that I think would be even more useful, although maybe it warrants a separate feature request: questions with inline answers.

Gotta say, your example looks extremely confusing to me! But I'm starting to warm up to it a bit. Not sure if I'm ready to include it in core, but it is really easy to add your own custom layer on top of TiddlyRemember. Here's a simple implementation, adjust to taste:

\define rememberq_inline(id, answer, question, reference)
    [img height=15 [$:/plugins/sobjornstad/TiddlyRemember/icons/lightbulb-white.svg]][$answer$]<div style="display: none;"><$macrocall $name=rememberq id=<<__id__>> question=<<__question__>> answer=<<__answer__>> reference=<<__reference__>>/></div>
\end

image

I confirmed this synced successfully with your example. (Also note that you inverted the normal order of question and answer parameters – not sure if that was intentional? I did the parameter list to match, if it was wrong you can just put that back in the right order.)

Edit: If you weren't aware, to make that macro available on all tiddlers, put it in a tiddler tagged $:/tags/Macro.

sobjornstad commented 3 years ago

BTW, you might also be interested in this thread on RemNote-like hierarchical notes with TiddlyRemember.

ldorigo commented 3 years ago

Hey, thanks for the answers - and for the example implementation. I agree that it looks very confusing in tiddlytext, but the rendering is nicer and it is overall a lot quicker to write....

Another possibility might be to uncouple the question and the answer - so something like:

Vitamin D is a fat-soluble vitamin produced by <<rememberq_answer "ID_1" "epithelial cells" >> in the presence of <<rememberq_answer "ID_2" "UV light">>. It is mainly needed for <<rememberq_answer "ID_3" "Calcium homeostasis and innate immunity">>.

<<rememberq_question "ID_1" "what is vitamin D produced by?">>
<<rememberq_question "ID_2" "what is needed for vitamin D production?">>
<<rememberq_question "ID_3" "What is vitamin D mainly needed for?">>

That's more readable, but probably harder to implement and with a higher potential for errors. Anyway, I'm happy with the example you provided for the time being :-)

sobjornstad commented 2 years ago

I've added a full explanation of how to accomplish this to the documentation (see "Inline questions and answers" here), so I'm going to call this closed for now.

If others find that approach problematic or complicated for some reason and would like some other method – please post a new issue explaining and link to this one, and we'll talk about it again.