Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Markdown files are rendered a bit more fancifully. Be sure to read the help file

![presenting.vim Markdown demo](examples/FancyMarkdown.gif)

Markdown image links where handled by converting them into ascii.

![image2ascii markdown example](examples/image2ascii_demo.png)

## Installation

Use [pathogen][3] or [vundle][4] to install presenting.vim.
Expand Down
22 changes: 22 additions & 0 deletions autoload/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,28 @@ function! markdown#format(text, last_line, state)
endwhile
let new_text += [' ▐ '.l:text]

" Image - Centered image2ascii for markdown image: ![alt_text](img_url?r=radius&w=width&h=height)
elseif a:text =~? '\.*\!\[.*\]\(.*\)' && g:presenting_image2ascii && executable('image2ascii')
let alt_text = matchstr(a:text, '\.*\!\[\zs[^]]\+\ze')
let img_url = matchstr(a:text, '\.*\!\[.*\](\zs[^ ?)]\+\ze')
let size_query_string = matchstr(a:text, '\.*\!\[.*\](.*?\zs[^)]\+\ze')
let r = matchstr(size_query_string, '\.*r=\zs[0-9]*[.]\?[0-9]*\ze')
let w = matchstr(size_query_string, '\.*w=\zs[0-9]*\ze')
let h = matchstr(size_query_string, '\.*h=\zs[0-9]*\ze')
let size_params = ' -w 40 -g 40'
if r != ""
let size_params = ' -r ' .. r
elseif w != "" && h != ""
let size_params = ' -w ' .. w .. ' -g ' .. h
endif
let output = system('image2ascii -f ' .. img_url .. size_params .. ' -c=false')

if output =~? '\.*open image failed\.*'
" Show alt text if image url dose not exists
let new_text += s:Center([alt_text], '«img»')
else
let new_text += s:Center(split(output,"\n"), '«img»')
endif

" Return text as is.
else
Expand Down
17 changes: 17 additions & 0 deletions doc/presenting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,24 @@ These fonts can be changed with the the following variables: >
More information about figlets can be found at https://figlet.org and the
interactive website http://patorjk.com/software/taag can be used to test out
the different fonts.
------------------------------------------------------------------------------
*presenting_image2ascii*

Note: Currently, this applies only to Markdown files.

Markdown image embeddings can also been rendered into ascii by a tool called
image2ascii. This is on by default, and can be turned off by setting >
:let g:presenting_image2ascii = 0
>

You can append size paremeters (ratio or width and height) in http query
paremeters style after the URL of the graphic file to resize it. : >
![alt text](./image.png?r=0.4)
![alt text](./image.png?w=55&h=35)
>

More information about image2ascii can be found at
https://github.com/qeesung/image2ascii
==============================================================================
ISSUES *presenting-issues*

Expand Down
Binary file added examples/1200px-Vimlogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions examples/PresentingDemo.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ function Factorial(n)
endfunction
```

# Images

If [image2ascii](https://github.com/qeesung/image2ascii) is installed and enabled markdown image links are converted to ascii and displayed in the presentation buffer.
You can append `?r=ratio` or `?w=WIDTH&h=HEIGHT` after the URL of the graphic file to resize the image.

```bash
![vim logo](./1200px-Vimlogo.png?r=0.05)
```

Results into:

![vim logo](./1200px-Vimlogo.png?r=0.05)

# The End


Expand Down
Binary file added examples/image2ascii_demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions plugin/presenting.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ let g:presenting_figlets = get(g:, 'presenting_figlets', 1)
let g:presenting_font_large = get(g:, 'presenting_font_large', 'standard')
let g:presenting_font_small = get(g:, 'presenting_font_small', 'small')

let g:presenting_image2ascii = get(g:, 'presenting_image2ascii', 1)

let s:presenting_id = 0

let s:showtabline = &showtabline
Expand Down
4 changes: 4 additions & 0 deletions syntax/presenting_markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ highlight default link presentingH2 markdownH2
highlight default link presentingH3 markdownH3
highlight default link presentingH4 markdownH4

syntax match presentingImageMarker /^«img»/ conceal
syntax match presentingImage /^«img».*/ contains=presentingImageMarker
highlight default link presentingImage Normal

syntax match presentingOrderedListMarker /^\s*\d\+\./
syntax match presentingListMarker /^\s*•/
syntax match presentingCheckboxMarker /^\s*[■□]/
Expand Down