https://kotlinlang.org logo
#feed
Title
# feed
p

pambrose

05/15/2022, 1:21 AM
Hello everyone, If you have the need for authoring slides with embedded code and/or animated HTML, I wrote a DSL wrapper for the revealjs.com framework that you might find useful. It is also great for presenting Kotlin Playgrounds. I am a big fan of using reveal-js for doing slides, but using Kotlin for authoring slides is far superior to drowning in pages of JS and HTML tags. You can see a demo at: https://kslides.com I would appreciate any feedback. Cheers, Paul
🆒 11
K 12
a

altavir

05/15/2022, 7:42 AM
Thanks, looks very interesting. We are working on several similar projects and maybe will integrate your wrapper into it as well.
Here it is. https://github.com/altavir/kslides-plotly/blob/528b102ec2cfaf4a11ec6b6022c7cc83cbc8b9a7/src/main/kotlin/Slides.kt#L80. I've encountered a minor problem. Plotly script has to be loaded before rendering (it is fixed in VisionForge implementation), so I had to manually load the script instead of adding it to scripts builder. Because scripts builders a loaded in the footer.
p

pambrose

05/15/2022, 3:12 PM
I love it! Let me add an option so you can specify where the script is loaded. In general, using plotly with the HTML DSL would be a winner.
a

altavir

05/15/2022, 3:17 PM
We have much larger VisionForge project (https://github.com/mipt-npm/visionforge), it allows solving initialization problem and have wider range of visualization plugins, but I am not sure it makes sense to bring heavier frameworks into slides. Plots seem to cover most uses.
p

pambrose

05/15/2022, 3:50 PM
Let me ask you a question: in the case of kotlin playgrounds, I saw weird css interference between reveal.js and playground.js, so I solved the issue by loading the playground content via an iframe and kept the two separate. Do you think that would be a wise approach in this case?
a

altavir

05/15/2022, 3:54 PM
JS/CSS interference is a huge problem. I do not think IFrame approach is recommended for anything but embedded content, but it you can't access the source code of libraries you use, it could be the only solution. With access to the sources, I've just added a prefix to all CSS selectors so they work only inside some class. Another solution is to dynamically load CSS vis JS for given nodes.
p

pambrose

05/15/2022, 4:07 PM
Let me give the iframe approach a try and we can see what you think.
a

altavir

05/15/2022, 4:36 PM
I had a lot of problems with iframes in Jupyter because they prevent sharing JS scripts between cells.
p

pambrose

05/16/2022, 6:57 AM
Hi Alexander, Using iframes is better, but for it to be acceptable, we need to be able to specify the dimensions of the plotly output — and I do not know how to do that. To try it yourself, add these two slides: https://gist.github.com/pambrose/ca2b82a5a5c7981c5f25aef203704af2 and change the version of kslides to 344a56b You will see a new plotlyConfig{} block in the DslSlide, where you can control the iframe characteristics. If we could control the dimensions of the plotly output, we would be in good shape. You can see the contents of the iframes in the docs/plotly dir. The other weird thing is if you refresh the page, you will see the iframe changing sizes. I am not sure what is causing that.
a

altavir

05/16/2022, 7:34 AM
There are two ways to adjust size. There is a flag that allows automatic resize of the plot and there are layout parameters that could be adjusted to fixed size in pixels. I will write a comment to your gist, but we can move to #science channel or other channel that better suits you for detailed discussion.
p

pambrose

05/17/2022, 4:26 AM
Have a look at https://plotly-integration--kslides.netlify.app/#/9 and see what you think, You can arrow down to see the slide definitions and other examples. The only bit of ugliness is getting the plotly layout dimensions right and then matching the iframe dimensions to the layout dimensions. I would love to hide it, but I do not see any pattern to the sizing. Doing it manually usually takes 4 or 5 quick iterations, so it is not too bad, The iframe-related config details are be specified globally or on a plotly() call with a config arg, which matches the approach taken by plot(). I have an open mind to better approaches. If you want to try it locally, use version 4cff04e. This is the Slides.kt file: https://github.com/kslides/kslides/blob/plotly-integration/kslides-examples/src/main/kotlin/Slides.kt
a

altavir

05/17/2022, 6:35 AM
Looks nice. I will try to attach full VisionForge later.
And of course we can try to use lets-plot. It generates images.
p

pambrose

05/17/2022, 6:44 AM
I reread your gist comment about collapsing plotly{} and plot{} into a single call. Let me give that a try and see if it cleans things up a bit.
VisionForge integration would be very cool.
Hi Alexander. Your gist suggestion of folding plot{} into plotly{} was brilliant. The code is much cleaner. It acts as yet another reason why I love Kotlin so much. Here is the new usage: https://plotly-integration--kslides.netlify.app/#/9/1 If you do not have any objections, I will push out the plotly integration in a new release. Thanks so much for your help.
👍 1
p

Pasha Finkelshteyn

06/04/2022, 4:40 PM
Looks very interesting! Did you consider implementing markdown DSL too?
a

altavir

06/04/2022, 4:43 PM
What do you mean by markdown dsl? There is a Kotlin Markdown parser we use <http://"""%20%20%20%20%20%20%20%20%20%20%20%20%20#%20VisionForge%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20This%20is%20a%20demo%20for%20current%20VisionForge%20features.%20This%20text%20is%20written%20in%20[MarkDown](https://github.com/JetBrains/markdown)%20%20%20%20%20%20%20%20%20""".trimIndent()|in VisionForge>, but it is not a DSL.
By the way, Kotlin-markdown seems to requires some additional work both on bugs and API
p

Pasha Finkelshteyn

06/04/2022, 5:19 PM
I just don't like huge string literals with markdown inside. I would prefer to compose it
a

altavir

06/04/2022, 7:52 PM
The kotlinx-html would be more effective for that. Markdown is for large text blocks.
p

Pasha Finkelshteyn

06/06/2022, 1:24 PM
kotlinx-html requires you to use html, while mardown doesnt 🙂
a

altavir

06/06/2022, 4:01 PM
Yeah. Markdown requires raw strings... and produces html.
By the way, you could be interested in our SNARK project. One of the aims is to provide DSL for making content blocks for interactive documents. It has a prototype already, but not public yet. Tag me if you are.
p

Pasha Finkelshteyn

06/06/2022, 8:14 PM
I'm not sure if I'm ready for something SO serious
4 Views