mfontanini / presenterm

A markdown terminal slideshow tool
https://mfontanini.github.io/presenterm/
BSD 2-Clause "Simplified" License
1.33k stars 32 forks source link

feature request: link to files #307

Open calebdw opened 3 months ago

calebdw commented 3 months ago

Hello!

First off, thanks for developing this! I just came across presenterm when I was looking at alternatives to lookatme (unfortunately development appears to have stagnated on that project) and I love it!

One feature from lookatme that would be nice here is the ability to link to a file and have it displayed as highlighted code---this would help clean up the markdown file and keep the source of truth as the external file.

Thanks!

mfontanini commented 3 months ago

Nice, I hadn't seen that feature and it sounds useful. I should be able to get to this soon.

DrunkenToast commented 3 months ago

Opened a draft for this issue! #327

mfontanini commented 3 months ago

@DrunkenToast can you mention what use case you have that needs this in the prepend/append form you implemented? To me the way lookatme does it is quite clean and should be enough. I get it that maybe you want some imports or something at the beginning of the file but not sure if it's worth adding support for that given you could just copy the same 2 lines in however many snippets you have (which is hopefully not 50 or so).

DrunkenToast commented 3 months ago

I simply hadn't seen the way lookatme does it to be quite frank. To me it made sense to simply prepend it, at which point, why also not append?

Use case I had was indeed simply adding code and calling a function below it, depending on the slide. I understand if that is too specific, understand your concerns.

Currently I simply append/prepend the content as if it was written inside the code block. If you think adding a custom "file" language is better then I am okay with that. It does however seem less flexible and more complex to me personally.

mfontanini commented 3 months ago

I think the lookatme format can also be extended to have prefix + suffix. What I like about is we don't have to deal with parsing and trying to pack too much into the code block info line. This way it's some yank that you can more intuitively write/extend/validate. E.g. the append/prepend operation with a substring is much more cryptic than a properly named yank attribute IMO.

mfontanini commented 3 months ago

The yaml could have either file or files the latter being a list that's appended together in the order they appear

DrunkenToast commented 3 months ago

I think the lookatme format can also be extended to have prefix + suffix.

At that point it will be a weird mix of yaml and text with no highlighting in your editor, so probably not.

In general you're completely right about the validation and extensibility. It's up to you what you decide.

Personally, I find the syntax, e.g. ,```rs +exec +append_file(snippet.rs), very appealing and consistent. But I wouldn't mind the yaml implementation either.

mfontanini commented 3 months ago

Oh no I don't mean to mix code with yaml. Just have a yaml with a list of file paths

DrunkenToast commented 3 months ago

Oh no I don't mean to mix code with yaml. Just have a yaml with a list of file paths

Oh I see, GitHub hadn't updated. I'm perfectly fine with that :)

calebdw commented 3 months ago

I think there's two similar but related things here:

  1. import code blocks (or a line range) from external files
  2. include other markdown files to compose the presentation

The latter could probably be done through the use of an include command, e.g.:

<!-- include:./section_foo.md -->
<!-- include(./section_foo.md) -->
mfontanini commented 3 months ago

include other markdown files to compose the presentation

This is a bit more annoying to implement that it would seem. It also has some subtleties that are unclear, like do includes pull in all slides in that other file and basically paste them? Can you include in the middle of a slide?

Have you had presentations that are long enough that they require this?

calebdw commented 3 months ago

@mfontanini, it depends on how you want to implement it. The simplest thing to do would be to just copy/paste the contents of the file into the location of the include. However, you could also set it up so that include is wrapped in end_slide commands to ensure they are on their own slides.

LaTeX does something similar: it has a \input command that just copy/pastes, and it has a \include command that wraps the content in \clearpage commands. I don't think we should implement both but just food for thought.

Have you had presentations that are long enough that they require this?

I have written presentations in LaTeX where it was easier to break the content up in different files (like my thesis presentation), but granted, LaTeX is a little more verbose than markdown

mfontanini commented 3 months ago

Going to give the code snippet one a try this weekend. I think the subsection thing should be moved to a separate ticket as it's unrelated to this one.

mfontanini commented 3 months ago

Initial support for this is in #328. For now it only supports a path and language attributes so it doesn't have any of the substring'ing that lookatme has but I think this should cover most cases and can be extended if needed. I'm actually curious why you'd want to pull in a sub section of a file, it feels like it makes this more complex than it could be.

@DrunkenToast the multi file should be a pretty straightforward extension to this, I'll probably have some time tomorrow.