Slides

repository·main·Indexed 11 days ago

https://github.com/maaslalani/slides

A terminal-based presentation tool that uses Markdown as its primary format. It features live-reloading, the ability to execute code blocks during presentations (via Ctrl+e), and content pre-processing using shell commands. It supports custom themes via JSON, remote theme URLs, and the ability to serve presentations over SSH.

Tokens
3.9K
Snippets
28
Records
34
Agent score
93%

What's inside Slides

  1. Hide boilerplate code using `///`

    main

    When presenting code, you may want to hide verbose boilerplate (like package declarations or main functions) while still allowing the code to be executable.

    By prefixing lines with ///, those lines are hidden from the visual display in the slides but remain part of the code when executed via ctrl+e. Additionally, if you use the y key to yank (copy) the block, the full snippet including the /// lines will be returned.

    ///package main
    ///
    import "fmt"
    ///
    ///func main() {
    fmt.Println("Hello, world!")
    ///}
  2. Pre-process slides with custom commands

    main

    You can run commands before the slides are displayed by using a code block with three tildes (~~~). The text inside the block is passed as stdin to the command, and the block is replaced by the command's stdout.

    To keep proper formatting and newlines, wrap the resulting pre-processed block in triple backticks.

    Security Requirement: For security reasons, the markdown file must have execution permissions. Use chmod to enable this.

    chmod +x file.md

    Example usage in Markdown:

    [ A ] - to -> [ B ]
  3. Understand the Slides codebase structure

    main

    If you are extending the project, the core logic is organized as follows:

    • CLI Initialization & Defaults: Handled in cmd/root.go.
    • Interaction (Input/Output/Controls): Managed in internal/model/model.go.
    • Configuration & Metadata: Optional configurations (such as theme: dark) are processed in internal/meta/meta.go.
  4. Run and test Slides during development

    main

    To make changes and verify them, run the make command. This executes the application using a default example file (go run main.go examples/slides.md).

    If you are developing a new feature that depends on specific Markdown syntax, create a new test case file in the examples/ directory (e.g., examples/my-test-case.md) and run the application against that file to iterate on your changes.

    To ensure your changes haven't broken existing functionality, run the test suite using make test and verify that the CLI command slides examples/slides.md still executes correctly.

    # Run the application with the default example
    make
    
    # Run the test suite
    make test
  5. Serve slides over SSH

    main

    You can host a presentation on one machine and access it via SSH from another. This allows users to view slides without having slides installed locally.

    1. On the host machine, run:
      slides serve [file]
    2. On the client machine, connect to the port specified by the command:
      ssh 127.0.0.1 -p [PORT]
    slides serve presentation.md
  6. Execute code blocks in slides

    main

    Slides supports live code execution directly within your markdown slides. You can trigger the execution of a code block by pressing ctrl+e. The output of the execution will be displayed as virtual text within the slide.

    Supported languages include:

    • Shells: bash, zsh, fish
    • Scripting/General: elixir, go, javascript, lua, python, ruby, perl, rust, java, cpp, swift, dart, v, julia, scala
    ls
  7. Search for slides using regex

    main

    To jump to a specific slide, press /, enter your search term (interpreted as a regular expression), and press Enter.

    • Use the /i flag for case-insensitive searches.
    • Press ctrl+n after a search to move to the next search result.
  8. Customize the bottom information bar with metadata

    main

    You can customize the bottom information bar of your presentation by adding a YAML frontmatter block at the top of your slides.md file. The following keys are supported:

    • author: The name of the presenter or author.
    • date: The date of the presentation.
    • paging: A format string for page numbering. Use %d as a placeholder for the current page and the total page count (e.g., Page %d of %d).
    ---
    author: Gopher
    date: May 22, 2022
    paging: Page %d of %d
    ---
  9. Create presentations using Markdown

    main

    Slides uses standard Markdown files as the source for presentations. You can include headings (h1-h6), bulleted lists, numbered lists, tables, and code blocks. To define where one slide ends and the next begins, use triple dashes (---) on a separate line between content blocks.

    # Slide 1
    Some stuff
    
    ---
    
    # Slide 2
    Some other stuff