sotte / presenting.vim

A simple tool for presenting slides in vim based on text files.
MIT License
300 stars 50 forks source link

Make the Markdown presentations fancier when being shown #26

Closed PhilRunninger closed 3 years ago

PhilRunninger commented 3 years ago

There is a lot to unpack in this one. I wanted to make my presentations a bit spiffier, as if rendered to HTML. Of course, we're limited by what we can do with mono-spaced characters in a Vim buffer. So here's what I did.

Markdown-specific Changes

  1. Only # and ## headings are used as slide separators now.
  2. #, ##, and ### headings are replaced by the output of the program figlet, if it's installed and g:presenting_figlets is 1. The fonts for both large and small headings can be overridden by the user.
  3. #, ##, ###, and #### headings are centered in the window. This at least partially addresses #22.
  4. Bullets are replaced by the Unicode bullet operator:
  5. Numbered lists are autonumbered, and respect the original indentation.
  6. Github-flavored Markdown's checkboxes are rendered with respective Unicode characters: and
  7. Github-flavored Markdown's tables are rendered with box drawing characters. Some special considerations need to be observed with tables.
  8. Quote blocks are word-wrapped and have a left border:
  9. Code blocks are preceded and followed by a horizontal line:
  10. Comments can be added to slides. Lines starting with // will not be displayed when presenting.
  11. Markdown syntax highlighting is extended to highlight the new text described above.

Here is an animated GIF showing the changes. It is also embedded in the README.

FancyMarkdown

General Changes

  1. The keys used to advance, rewind, and quit a slide show are now configurable.
  2. Default slide separator regex strings are set in filetype plugin files (ftplugin/*.vim) as opposed to autocommands. This puts the code in a location that better matches its purpose. If additional statements are needed, they fit better in these files than in an autocommand.
  3. A standard, extendable framework is introduced in the form of the s:Format() function and the related autoload/markdown.vim file. Following the pattern set forth therein, custom formatting can be implemented for other filetypes as well. For example, to enable custom formatting for RST files, do the following:
    1. Write the function rst#format(text, state) in the new file autoload/rst.vim. This function takes the current line of text and a state dictionary that describes the current state of the process. state can be used to remember such things as "We're inside a code block," which would change how the current text is formatted. An updated state is returned by this function, and is passed back in for the next line of text.
    2. If custom syntax highlighting is desired, create the file syntax/presenting_rst.vim, and include the appropriate syntax and highlight commands in it.
PhilRunninger commented 3 years ago

@sotte , I've heard it said that software is never finished; it's just released. With that in mind, I made a few changes after creating the pull request, but I'm done now. Go ahead and merge this if you approve it.

sotte commented 3 years ago

Wow @PhilRunninger, this is quite the PR! Thank you and I'm glad you're enjoying the presenting.vim. Also thanks for the small commits with proper commit messages! I'll try to review it this weekend.

Can you please add some screenshots to the PR showing off the new features especially figlet.

I'm thinking of re-recording the asciicast in the README.

PhilRunninger commented 3 years ago

@sotte, I created an animated GIF of the new Markdown formatting. It is embedded in the README and (now) in the PR description.

sotte commented 3 years ago

Thank you so much. This is a really nice feature, I'm impressed!

I also like the attention to detail ;)

sotte commented 3 years ago

I'm trying it out now. Do you plan to add any more features to this PR or is it feature complete? @PhilRunninger

sotte commented 3 years ago

I don't get any of the cool new features. I think vimwiki (when using markdown) collides with presenting.vim. Debugging...

sotte commented 3 years ago

Yes, it was vimwiki. Without vimwiki I get the new features. But I still have some issues with figlet.

image

PhilRunninger commented 3 years ago

I'm done with this PR. If I think of anything else, I'll create another one.

My Mac installation of figlet includes the figlist command which shows all the installed figlet fonts. Alternatively you can try figlet -I 2 to display the folder where fonts are installed. You can then specify a different font by putting, for example, let g:presenting_font_small = 'mini' in your .vimrc.

sotte commented 3 years ago

Hey @PhilRunninger, thanks for the quick response and the help!

Two things:

Default font: standard                                                                        
Font directory: /usr/share/figlet                                                             
Figlet fonts in this directory:                                                               
banner                                                                                        
big                                                                                           
block                                                                                         
bubble                                                                                        
digital                                                                                       
ivrit                                                                                         
lean                                                                                          
mini                                                                                          
mnemonic                                                                                      
script                                                                                        
shadow                                                                                        
slant                                                                                         
small                                                                                         
smscript
smshadow
smslant
standard
term

After that I'll merge it.

PhilRunninger commented 3 years ago

@sotte I'll do you one better on that vimwiki issue. I added a simple check for the vimwiki filetype, and changed that back to markdown when preparing the slide show.

The more direct replacement for straight would have been mini, but I decided that I like the blocky fonts better, so I picked standard and small for the defaults.

sotte commented 3 years ago

@PhilRunninger great feature and great commits! I'm excited to use it for my next presentation.

Thank you so much!

PhilRunninger commented 3 years ago

My pleasure. I'm interested to see if anyone else implements this custom formatting for the other file types.

sotte commented 3 years ago

Me too. I created a ticket for it: #27