Skip to content

Commit 1374548

Browse files
committed
Everything seems OK
1 parent aee5b5b commit 1374548

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ As the plugin can be used for note-taking, it may be desirable to access
157157
different indices in an ergonomic way. This can be achieved with the command
158158
`:MDEIndex` that takes `list<string>`, `list<list<string>>` or
159159
`dict<string>` as argument. If no argument is passed, it reads the content
160-
of `g:markdown_extras_indices`.
160+
of `g:markdown_extras_indices`. See `:h MDEIndex` for more info.
161161

162162
For more information about key-bindings, configuration, etc. take a look at
163163
`:h markdown-extras`.

autoload/mde_indices.vim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ def IndicesCallback(id: number, idx: number)
2222
selection = indices[selection_key]
2323
endif
2424

25-
echom "sel: " .. selection
26-
echom "typesel: " .. typename(eval(selection))
27-
2825
if !empty(selection)
29-
if typename(eval(selection)) =~ "^func("
30-
echom "IsFunc"
31-
var Tmp = eval(selection)
32-
Tmp()
3326
if links.IsURL(selection) && selection =~ '^file://'
3427
exe $'edit {fnameescape(links.URLToPath(selection))}'
3528
elseif links.IsURL(selection)
3629
exe $'Open {selection}'
37-
else
30+
elseif filereadable(fnameescape(selection))
3831
exe $'edit {fnameescape(selection)}'
32+
elseif selection =~ "^function("
33+
try
34+
var Tmp = eval(selection)
35+
Tmp()
36+
catch
37+
utils.Echoerr("Function must be global")
38+
endtry
3939
endif
4040
endif
4141

doc/markdown_extras.txt

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,26 +251,35 @@ COMMANDS *markdown-extras-commands*
251251
:MDEConvertLinks Convert inline links into reference-style links.
252252

253253
*:MDEIndex*
254-
:MDEIndex [{args}] Open a popup with all the URLs specified in {args}.
254+
:MDEIndex [{args}] Open a popup with what is specified in {args}.
255255
The type of {args} can be list<string>, list<list<string>>
256256
or dict<string>. If no argument is passed, then
257257
|g:markdown_extras_indices| is considered.
258258
Example:
259259
>
260-
:MDEIndex # Uses g:markdown_extras_indices
261-
:MDEIndex ['path1', 'path2', 'path3]
262-
:MDEIndex {foo: 'path1', bar: 'path2', baz: 'path3}
263-
:MDEIndex [['foo', 'path1'], ['bar', 'path2'], ['baz', 'path3]]
260+
:MDEIndex # Uses g:markdown_extras_indices
261+
:MDEIndex ['local/path', 'some%20url', 'function("some_Funcref")']
262+
:MDEIndex {foo: 'local/path', bar: 'some%20url', 'function("some_Funcref")'}
263+
:MDEIndex [['foo', 'local/path'], ['bar', 'some%20url'],
264+
['baz', 'function("some_Funcref")']]
264265
<
265-
Or you can use in a script, like for example:
266+
Or it can be used in a script, like for example:
266267
>
267-
const my_index = {
268-
foo: '/Users/ubaldot/home/Documents/foo.vim',
269-
bar: 'https://example.com',
270-
banana: '/mnt/c/files/bar.md'
271-
}
272-
execute $"MDEIndex {my_index}"
268+
def Foo()
269+
const my_index = {
270+
foo: '/Users/ubaldot/home/Documents/foo.vim',
271+
bar: 'https://example.com',
272+
banana: 'function("g:Foo")'
273+
}
274+
execute $"MDEIndex {my_index}"
275+
enddef
276+
277+
command! MyIndex Foo()
273278
<
279+
The string used in the various cases can be a local path,
280+
a valid URL or a function reference.
281+
In the latter case, the referenced function must be global
282+
and shall take no arguments.
274283

275284
*:MDEMake*
276285
:MDEMake Invoke |:make| and |:Open| the rendered file. It requires

plugin/markdown_extras.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Typically, they are quite accurate.
4242
2. `:MDEIndices` has been renamed to `:MDEIndex` and can take an argument, for
4343
example you can call as `:MDEIndices ['apple', 'banana', 'strawberry']`.
4444
Furthermore, such a command is no longer valid only for markdown files but
45-
it become global.
45+
it become global. See `:h :MDEIndex` for more info.
4646

4747
Press <Esc> to close this popup.
4848
FOO
@@ -125,4 +125,4 @@ endif
125125
command! -nargs=0 MDEReleaseNotes ShowReleaseNotes()
126126
command! -nargs=? MDEIndex indices.ShowIndices(<f-args>)
127127

128-
g:markdown_extras_loaded = false
128+
g:markdown_extras_loaded = true

0 commit comments

Comments
 (0)