Open HugoGranstrom opened 1 year ago
This is not priority but yesterday started tinkering with this in this public repl.it: https://replit.com/@pietroppeter/NimislidesAnimateCodeComments
not finished (does not run currently) and not planning to get back to it soon (I had to do a bit to get it out of the system, and did enough to get bored by it 😛 ). The idea is that code like this:
echo 1
echo 2 # -B >>>
echo 3 # D >>>
echo 4 # A- >>>
echo 5
echo 6 # -A >>>
echo 7 # D >>>
echo 8 # a normal comment
echo 9 # C- >>>
echo 10 # A >>>
should produce a highlightLines string like this : 4-6,10|1-2|9-10|3,7
and get stripped of those comment.
Incidentally I realized we could have a template animateCode*(highlightLines: string, body: untyped)
where we can give the highlight lines string as reveal js expects it.
Oh nice! Always nice to have something to start from :) I'd probably go with numbers instead of letters. Something else that would be nice that we are losing with this API is the ability to add a new animation between others. Say we have this:
echo 1 # 1- >>>
echo 2 # -1 >>>
echo "Hello"
echo 3 # 2- >>>
echo 4 # -2- >>>
What if we want to highlight the line echo "Hello"
between 1
and 2
? Then we have a similar problem to before that we have to adjust all the numbers again. I don't know if we could have the identifiers be floats instead of ints and they are simply executed in order of size. So adding a new animation between 1
and 2
int his case would be done using 1.5
:
...
echo "Hello" # 1.5 >>>
...
Am I just ranting or could this works? :rofl:
Well the thing is that you can pick any identifier and it would be sorted (thinking it as a string). So since I think this is valid: "1" < "1.5" (or also "11") < "2", it would work. In this way you would not really have to pick numbers instead of letters it could be left to the user the choice, who could pick bar, foo, goo, zoo and then use car if it wants to insert something between bar and foo.
This evaluates to true
though: "12" < "3"
. Having comparisons for strings doesn't make much sense in my brain tbh.
@pietroppeter had the idea for animateCode, that instead of specifying the lines of code to highlight using numbers (eg.
1..3, 4, 5..7
), the lines in the code are marked using comments instead. This would remove the need for updating all the line numbers if you change the code. The general idea is this:The number specifies the order of highlighting and the
$$$
(or something else), is a marker for our parser to find the lines. A number of questions are still unanswered, like what symbols to use and how to implement it in a simple way.