mfontanini / presenterm Goto Github PK
View Code? Open in Web Editor NEWA markdown terminal slideshow tool
Home Page: https://mfontanini.github.io/presenterm/
License: BSD 2-Clause "Simplified" License
A markdown terminal slideshow tool
Home Page: https://mfontanini.github.io/presenterm/
License: BSD 2-Clause "Simplified" License
When working on a presentation you often modify images but because presenterm internally caches those, thse modifications won't be reflected when hot reloading. It would be nice to have some key combo like <C-r>
which tells presenterm to refresh all resources, which are currently images and external themes, and reloads the presentation on the current slide/chunk.
I just installed presenterm
, tmux
, and presenterm-export
and tried to export my presentation via presenterm -e presentation.md
, however the following error message is being raised:
minimum presenterm-export version (0.2.0) not met
.
pip list
lists presenterm-export
at 0.2.0
, presenterm
is at 0.4.0
, installed via cargo install presenterm
.
I think it's important feature that output presenterm's format of present markdown to different binary format, such as PDF.
BTW, I really like this idea! Thanks for your great job!
OS: Ubuntu 22.04.3 LTS
error: linker `cc` not found
|
= note: No such file or directory (os error 2)
error: could not compile `serde` (build script) due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `proc-macro2` (build script) due to previous error
error: could not compile `crossbeam-utils` (build script) due to previous error
error: could not compile `syn` (build script) due to previous error
error: could not compile `libc` (build script) due to previous error
error: failed to compile `presenterm v0.2.1`, intermediate artifacts can be found at `/tmp/cargo-installYpdS8K`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Image colour (background and foreground) is not changing even after changing the config file
OS: MacOS
Terminal: Wezterm
Config file:
typst:
ppi: 300
colors:
background: ffffff
foreground: 000000
From the above config, I assume background should be white and foreground should be black.
I was trying to display a gif with presenterm in iTerm2, and found it rendered the first frame, but didn't animate it. It would be very useful if I could embed gifs in presentations.
viuer
is able to handle this case, but it seems to need to print from a file, as otherwise it encodes the image as a PNG. Here's how the viu
tool does it.
diff --git a/src/builder.rs b/src/builder.rs
index 5c9021d..a1f95a5 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -367,7 +367,7 @@ impl<'a> PresentationBuilder<'a> {
fn push_image(&mut self, path: PathBuf) -> Result<(), BuildError> {
let image = self.resources.image(&path)?;
- self.chunk_operations.push(RenderOperation::RenderImage(image));
+ self.chunk_operations.push(RenderOperation::RenderImage {image, path});
self.chunk_operations.push(RenderOperation::SetColors(self.theme.default_style.colors.clone()));
Ok(())
}
diff --git a/src/diff.rs b/src/diff.rs
index 47bd691..2aaa972 100644
--- a/src/diff.rs
+++ b/src/diff.rs
@@ -71,7 +71,7 @@ impl ContentDiff for RenderOperation {
(RenderText { alignment: original, .. }, RenderText { alignment: updated, .. }) if original != updated => {
false
}
- (RenderImage(original), RenderImage(updated)) if original != updated => true,
+ (RenderImage { image: original, .. }, RenderImage{ image: updated, ..}) if original != updated => true,
(RenderPreformattedLine(original), RenderPreformattedLine(updated)) if original != updated => true,
(InitColumnLayout { columns: original }, InitColumnLayout { columns: updated }) if original != updated => {
true
diff --git a/src/presentation.rs b/src/presentation.rs
index 6c75430..36de14f 100644
--- a/src/presentation.rs
+++ b/src/presentation.rs
@@ -5,7 +5,7 @@ use crate::{
theme::{Alignment, Margin, PresentationTheme},
};
use serde::Deserialize;
-use std::{fmt::Debug, rc::Rc};
+use std::{fmt::Debug, rc::Rc, path::PathBuf};
/// A presentation.
pub(crate) struct Presentation {
@@ -361,7 +361,7 @@ pub(crate) enum RenderOperation {
RenderLineBreak,
/// Render an image.
- RenderImage(Image),
+ RenderImage { image: Image, path: PathBuf},
/// Render a preformatted line.
///
diff --git a/src/render/engine.rs b/src/render/engine.rs
index 16a467c..9812e93 100644
--- a/src/render/engine.rs
+++ b/src/render/engine.rs
@@ -13,7 +13,7 @@ use crate::{
style::Colors,
theme::Alignment,
};
-use std::{io, mem};
+use std::{io, mem, path::PathBuf};
pub(crate) struct RenderEngine<'a, W>
where
@@ -54,7 +54,7 @@ where
RenderOperation::JumpToBottomRow { index } => self.jump_to_bottom(*index),
RenderOperation::RenderText { line: texts, alignment } => self.render_text(texts, alignment),
RenderOperation::RenderLineBreak => self.render_line_break(),
- RenderOperation::RenderImage(image) => self.render_image(image),
+ RenderOperation::RenderImage{ image, path } => self.render_image(image, path),
RenderOperation::RenderPreformattedLine(operation) => self.render_preformatted_line(operation),
RenderOperation::RenderDynamic(generator) => self.render_dynamic(generator.as_ref()),
RenderOperation::RenderOnDemand(generator) => self.render_on_demand(generator.as_ref()),
@@ -132,10 +132,10 @@ where
Ok(())
}
- fn render_image(&mut self, image: &Image) -> RenderResult {
+ fn render_image(&mut self, image: &Image, path: &PathBuf) -> RenderResult {
let position = CursorPosition { row: self.terminal.cursor_row, column: self.current_rect().start_column };
MediaRender
- .draw_image(image, position, self.current_dimensions())
+ .draw_image(image, path, position, self.current_dimensions())
.map_err(|e| RenderError::Other(Box::new(e)))?;
// TODO try to avoid
self.terminal.sync_cursor_row()?;
diff --git a/src/render/media.rs b/src/render/media.rs
index 0767b7b..2f8cec3 100644
--- a/src/render/media.rs
+++ b/src/render/media.rs
@@ -1,6 +1,6 @@
use crate::render::properties::WindowSize;
use image::{DynamicImage, ImageError};
-use std::{fmt::Debug, io, rc::Rc};
+use std::{fmt::Debug, io, rc::Rc, path::PathBuf};
use viuer::ViuError;
use super::properties::CursorPosition;
@@ -41,6 +41,7 @@ impl MediaRender {
pub(crate) fn draw_image(
&self,
image: &Image,
+ image_path: &PathBuf,
position: CursorPosition,
dimensions: &WindowSize,
) -> Result<(), RenderImageError> {
@@ -73,12 +74,13 @@ impl MediaRender {
let start_column = dimensions.columns / 2 - (width_in_columns / 2) as u16;
let start_column = start_column + position.column;
let config = viuer::Config {
+
width: Some(width_in_columns),
x: start_column,
y: position.row as i16,
..Default::default()
};
- viuer::print(image, &config)?;
+ viuer::print_from_file(image_path, &config)?;
Ok(())
}
}
Some things that the above code wants:
Testing/fallback for sixel support -- I couldn't get building presenterm
to find libsixel
so didn't go too far here. viu
has a fallback method it uses.
Support for kitty protocol; I didn't test this at all
Correct positioning/resizing; this layout bug appears if there's not enough space:
Understanding of why this speeds up loading large PNG images, to make sure those gains are realized (i.e. maybe don't switch to only printing from file for gifs, but maybe for all iterm2 images?)
When you navigate to a slide with a gif, it takes a second for the gif to load in. Are there easy fixes for this? (Delay showing slide, have stand-in rectangle displayed so gif popping in is less jarring)
cat output
and get the gif displayed, and it still took ~1s.I'm on a linux machine, kitty terminal, and I added a config.yaml @ ~/.config/presenterm
but presenterm
is not respecting it at all, no matter what I put there.
defaults:
themes: terminal-dark
footer:
style: progress_bar
# Optional!
character: π
options:
footer:
style: progress_bar
# Optional!
character: π
It seems like neovim saves by deleting and moving a file on top of the original one. If presenterm tries to reload it right then it fails badly. We should instead show an error temporarily, and then reload again once we find the file has shown up again (or stay in that state forever otherwise).
Is there a workaround for making text appear in the middle of the page instead of at the top?
Actually, How I could achieve syntax highlighting for a language that appears not to be supported officially in Sublime Text (syntect).
With the following markdown:
Hello!
---
1. One
<!-- pause -->
2. Two
<!-- pause -->
3. Three
4. Four
As slides are navigated, the numbers for the list items get reset to 1 after each pause:
Hello!
1. One
1. Two
1. Three
2. Four
Tested with presenterm
version 0.2.0 (commit da0dd9e), although I don't think newer versions have fixed it, judging from the commits since then.
I understood that images are checked to fit in the width of the presentation.
However, the more I zoom (increase my terminal font size), the more the image shrinks.
At the font size I feel confortable with regarding text, my image looks absolutely tiny. It then only takes a fraction of the available space. I tried resizing the image to various sizes but it didn't help.
For example when I change columns from [2,1]
to [1,1]
it still reloads, but doesn't jump to the page I changed.
Is there any way to set the background color to either be transparent or use "none" as background color so it would automatically just use the background color defined for the terminal?
I'm thinking this likely has to do with my terminal colours, but would be good to confirm.
Basically, the text output here is light grey on a darker grey background. I'm not sure why it's so light, since it's even harder to see than comment text on my presentation.
I'd like to know:
One of the main benefits of using pure text formats is ability to use a good text editor. One of the useful features of a good text editor is ability to fold and unfold boring parts of text. For example in vim anything between special tags {{{
and }}}
can be folded into a single line. In most languages you'd use it along with comment specific to that language, in Rust it would be // {{{
and // }}}
.
Markdown uses HTML comments and vim automatically inserts them as <!-- {{{ -->
and <!-- }}} -->
. Sadly this makes presenterm
very unhappy...
What I want is to be able to have text like this and presenterm
behaving as if comments are not there
thread 'main' has overflowed its stack<!--{{{-->
fatal runtime error: stack overflow<!--}}}-->
Prettier automatically converts presenterm's slide title format into a level-2 heading, so it's necessary to add a <!-- prettier-ignore -->
comment.
Slide Heading
---
becomes
## Slide Heading
I saw the fix in #23, but, in my opinion, single-line comments should be expanded to allow anything inside. It's much more disruptive to have errors when you write a single-line comment than to accidentally write a comment command.
You could just write
<!--
prettier-ignore
-->
Slide Heading
---
but this seems like a pointless limitation.
Hi, is there a way to get a theme to use the terminal's colors (background, foreground, primary colors)?
The default themes look fine but:
If so, it would also be nice to have a built-in theme that uses them.
I'm happy to contribute (especially with a few pointers) if you agree that this would be desirable.
It seems that overriding the default section of a theme affects the footer style as well (the issue might generalize to other overrides affecting other style sections).
Reproduction:
---
theme:
override:
default:
margin:
percent: 6
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
Notice that the footer now shows a left-aligned slide count rather than the default progress bar.
While I'm presenting, I would like others in the talk to be able to see the slide on their machine so they can copy paste scripts/code content.
Few additional features that could be implemented in the future.
Here is an example of terminal rendering in the browser.
https://papigers.github.io/rutty/
Here is another one. https://github.com/btwiuse/wetty.
Wondering if these can be built in to presenterm.
It's totally possible that I've missed it, but I didn't see any way to configure font sizes. If it already doesn't exist, is it on the roadmap/something you want to support at all? If so, I'd be happy to contribute to the feature, maybe with the smallest amount of direction π
Hi, I've recenly discovered presenterm and I like it :)
However I'd like that there I would like adding pauses between list items to be less cumbersome, somewhat like:
intrementalmode: true
in global configuration, per presentation or per slide. Let's assume that you have some slides with 4 or five items, it's a bit annoying I to have to put a tag for each item in a list.
What do you think?
Would be great if there is a keybinding to see the slide number along with the title so one can easily navigate to a particular slide with up/down, j/k vim bindings. Even better if there is some sort of fuzzy finder.
1. Introduction slide
2. Headers
3. Other headers
4. Ending slides
....
It says that images are not supported on windows. Might be considering using termwiz? https://docs.rs/termwiz/latest/termwiz/escape/struct.Sixel.html
Would you consider supporting an alternative syntax for the commands that currently use HTML comments?
I understand that they are "more correct", but I also miss the writability (mitigated by the use of snippets) and readability of https://github.com/maaslalani/slides/ documents a little bit.
Continuing from the original PDF export issue..
Seems like I figured out the main reason.
I had different footer than in the demo, and that caused "drifting away". I had page numbering on right side.
Maybe this is endless cat and mice competition, since there can be quite many variations for the footers?
By using progress footer, the accuracy is much better for exporting. Other issues are solved by making terminal larger.
It would be great if presenterm had code execution the way slides does. You'd have a code block, and by pressing ctrl+e
the code block would be executed.
This is a follow-up to #97.
presenterm version: 0.4.0
presenterm-export version: 0.2.0
OS: MacOS Sonoma 14.2.1
Architecture: Apple Silicon
Used Terminal: iTerm2
Installed Python modules:
β pip list
Package Version
----------------- -------
ansi2html 1.8.0
Brotli 1.1.0
cffi 1.16.0
cssselect2 0.7.0
dataclass-wizard 0.22.2
fonttools 4.47.0
html5lib 1.1
libtmux 0.23.2
Pillow 10.1.0
pip 23.3.1
presenterm-export 0.2.0
pycparser 2.21
pydyf 0.8.0
pyphen 0.14.0
setuptools 68.2.2
six 1.16.0
tinycss2 1.2.1
weasyprint 60.1
webencodings 0.5.1
zopfli 0.2.3
When exporting the following presentation, I end up with the stacktrace below:
---
title: Some Title
sub_title: Some Subtitle
author: Daniel Bodky
theme:
name: dark
override:
footer:
style: template
left: "@d_bodky"
center: "{current_slide} / {total_slides}"
right: Hello World!
---
# Hello
![Doge](./doge.png)
β presenterm -e presentation.md
Writing temporary files into /var/folders/5k/zvc1ysc154988bw5xs4y_9w00000gn/T/tmp07u5k8e9
Running presentation to capture slide...
Captured 1 slides so far...
Captured 2 slides so far...
Captured 2 slides
Converting slides to HTML...
Replacing images...
Transforming color block #ffbad3 into image /Users/daniel/repositories/private/presenterm-test/doge.png
'presenterm-export' execution failed:
Traceback (most recent call last):
File "/Users/daniel/repositories/private/presenterm-test/.venv/bin/presenterm-export", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/daniel/repositories/private/presenterm-test/.venv/lib/python3.11/site-packages/presenterm_export/cli.py", line 111, in main
run(args, metadata)
File "/Users/daniel/repositories/private/presenterm-test/.venv/lib/python3.11/site-packages/presenterm_export/cli.py", line 58, in run
presentation_html = processor.replace_final_images(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/daniel/repositories/private/presenterm-test/.venv/lib/python3.11/site-packages/presenterm_export/image.py", line 39, in replace_final_images
Edit 1: The referenced image doge.png
is taken from this repository's examples folder.
Edit 2: Added the used terminal, in case it got to do with how the image(s) get rendered.
Using right arrow or left arrow to navigate seems to only go to the main slide and odd number of slides.
I installed presenterm-export
and tmux
and upon running the command to export to pdf, the below message is displayed:
[~/Downloads/presenterm-0.2.1]$ ./presenterm --export-pdf ../hw1.md
error: unexpected argument '--export-pdf' found
tip: to pass '--export-pdf' as a value, use '-- --export-pdf'
Usage: presenterm [OPTIONS] <PATH>
For more information, try '--help'.
When presenting a file with overrides set, the lack of a footer key is interpreted as an empty footer, which is parsed as the default footer, which overrides the theme's footer.
Reproduction:
presenterm examples/demo.md
(see progress bar)demo.md
to include:
theme:
override:
default:
presenterm examples/demo.md
(see 1/9 in footer)Can't wait to try presenterm! I tried scouting for a feature that I love about sli.dev
, the tool that I use for most of my presentations: code highlight. Would you be interested in presenterm supporting it?
Is there a possibility to show slide numbers?
So the audience can refer to them when they ask questions...
Thanks!
sh
is note supported in codeblocks
If we try to use sh
while creating a code block
E.g
```sh
cat hello world
```
Throws this error.
thread 'main' panicked at /home/eyepatch/.cargo/registry/src/index.crates.io-6f17d22bba15001f/presenterm-0.1.0/src/render/highlighting.rs:31:69:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Since bash
works perfectly fine, it would be convenient to have sh
as an alias to bash
Sometimes, mostly when writing code blocks, it overflows the terminal/screen vertical viewport. I would be awesome the ability to βscroll downβ to a slide content, if it is even possible.
For now the solution is to break the code block into smaller ones to fit the screen size, on different sldies.
Using pauses increases the number of total slides and results in slide number incrementing per pause.
This isn't a huge issue, but might break the immersion slightly.
Verified on presenterm 0.2.1
It could be nice to support speaker notes. The idea would be to have a way to hook up another <something>
(likely another instance of presenterm
) which displays any speaker notes in the current slide, where notes would likely be some form of HTML comment.
I don't personally use speaker notes, but I'm keeping this issue open so that those who want speaker note support state their expectations so we don't implement something blindly.
The following presentation gets the necessary line break that should normally be in between the list and the paragraph removed and looks off.
* Hi
<!-- pause -->
mom
I think it would be valuable to be able to specify colors for text, so that certain text elements could be emphasized.
I imagine it would be similar to how markdown is able to render it via html e.g.:
<span style="color:blue">some *blue* text</span>.
I noticed this compiles on Windows and you even build a Windows release, but when I try to run a presentation it says Failed to run presentation: io: Window pixel size not implemented for Windows API
. This happens in Windows Terminal, WezTerm, and VSCode console, all on win11
The template style footer is on the very last row which makes it look a bit too far down. I think it should instead be moved one row up so there's one blank margin line at the bottom.
Thanks for your work on this interesting tool.
I'm using it on Archlinux, using a "recipe", https://aur.archlinux.org/packages/presenterm-bin that uses the released tar.gz on github.
Currently the contents of that tar.gz include,
$ tar tf presenterm-0.4.1-aarch64-unknown-linux-gnu.tar.gz
presenterm-0.4.1/
presenterm-0.4.1/presenterm
presenterm-0.4.1/LICENSE
presenterm-0.4.1/README.md
That's very little.
You also have much more,
$ ls presenterm/
assets build.rs Cargo.toml docs flake.lock LICENSE rustfmt.toml src
bat Cargo.lock CHANGELOG.md examples flake.nix README.md scripts themes
$ ls presenterm/docs/
config.md highlighting.md install.md intro.md latex.md layouts.md parse.md pdf-export.md README.md themes.md
$ ls presenterm/examples/
demo.md doge.png
$ ls presenterm/themes/
dark.yaml light.yaml terminal-dark.yaml terminal-light.yaml tokyonight-storm.yaml
These are very usefull.I like to have them locally on my PC, without the need to go to the Internet again.
Please include the content of that "docs", "examples", "themes" etc, folders in the released tar.gz.
Also the CHANGELOG.
Thanks in advance.
Thanks for the great app! :)
Is it possible to show a date on the introduction slide defined by the front matter at the beginning of the markdown file:
---
title: My presentation title
sub_title: An optional subtitle
author: Your name which will appear somewhere in the bottom
date: 2023-10-18 ???
---
Thanks!
I've used Marp
and slidev
and both tools follow a syntax where ---
is the directive for new slide
.
In presenterm
however, its like <-----!end slide ---->
IMH:
I really like presenterm
and I'm wondering if it is possible to add option/ cli flag to choose syntax. I don't feel like its a low hanging fruit.
The advantage would be interopability and drop-in replacement for other popular tools.
Thanks.
Haven't tried it in other OS. but would be great if Esc would close the slide index. Currently we have to hit to close it.
When a comment command parsing fails, we're currently showing the yaml parse error as-is, which isn't very helpful. This should instead keep track of the line:pos in the original file and include that in the error message.
cc @pacak
I tried downloading the binary in the releases and also tried building it but still had the same problem.
The terminal just hangs whenever it's the image part and could not proceed further through the slides.
I tried running without tmux and it was working just fine.
Hello! First of all, nice project!
I'm trying to use kitty and I need to build presenterm with sixel. However I can't seem to do it.
brew install libsixel
cargo install presenterm --features sixel
note: ld: warning: search path '/var/folders/m5/b92jz17n7dlbqkj_h87rz3tm0000gn/T/cargo-installTjvtEI/release/build/sixel-sys-c42a6b2c444c7b67/out/lib' not found
ld: library 'sixel' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Would it be possible to introduce some mathematical expression support? I have seen unicode rendering done in the past of math expressions, but perhaps even some iterm/sexel magic could be done to embed equations.
Thank you for all your work on this project, by the way! It's quite phenomenal!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.