jszakmeister / markdown2ctags

Generate ctags-compatible tags files for Markdown documents.
BSD 3-Clause "New" or "Revised" License
121 stars 20 forks source link

not work for markdown #12

Closed anson2416 closed 5 years ago

anson2416 commented 5 years ago

hello, i am using vim8 with Ubuntu 18.04. following the wiki page to install Tagbar and markdown2ctags, i found that, it is NOT working. can you provide some guides on this issue?

~/.vimrc setup:

 Plug 'majutsushi/tagbar'   

let g:tagbar_type_markdown = {
     \ 'ctagstype': 'markdown',
     \ 'ctagsbin' : '~/.vim/markdown2ctags.py',
     \ 'ctagsargs' : '-f - --sort=yes',
     \ 'kinds' : [
       \ 's:sections',
       \ 'i:images'
     \ ],
     \ 'sro' : '|',
     \ 'kind2scope' : {
         \ 's' : 'section',
     \ },
     \ 'sort': 0,
 \ }
jszakmeister commented 5 years ago

You're going to have to provide more information than "it's not working". I can't work with that. Have you tried running markdown2ctags by hand?

~/.vim/markdown2ctags -f - --sort=yes /path/to/file.md

For instance, using the example in the repo:

:: ./markdown2ctags.py -f - --sort=yes test-docs/example.md
!_TAG_FILE_FORMAT   2
!_TAG_FILE_SORTED   1
Heading 1b  test-docs/example.md    /^Heading 1b$/;"    s   line:44
Heading 2   test-docs/example.md    /^Heading 2$/;" s   line:1
Heading 2a  test-docs/example.md    /^## Heading 2a$/;" s   line:14 section:\Heading 1
Heading 2b  test-docs/example.md    /^## Heading 2b$/;" s   line:24 section:\Heading 1
Heading 2c  test-docs/example.md    /^## Heading 2c$/;" s   line:29 section:\Heading 1
Heading 2d  test-docs/example.md    /^## Heading 2d$/;" s   line:39 section:\Heading 1
Heading 2e  test-docs/example.md    /^Heading 2e$/;"    s   line:56 section:Heading 1b
Heading 3   test-docs/example.md    /^### Heading 3$/;" s   line:19 section:\Heading 1|Heading 2a
Heading 4   test-docs/example.md    /^#### Heading 4$/;"    s   line:34 section:\Heading 1|Heading 2c
\Heading 1  test-docs/example.md    /^# \\Heading 1 ####$/;"    s   line:4

Also, which markdown plugin are you using? If you don't have a markdown plugin installed, then the filetype might not be setup correctly and tagbar will fail to make use of the settings in your .vimrc. FWIW, I use this one.

BTW, you said:

following the wiki page to install Tagbar and markdown2ctags

What wiki page? There's no wiki page for this in my project. Are you following directions from somewhere else?

jszakmeister commented 5 years ago

Note: if you don't have a Markdown plugin installed in your vim setup, then the default behavior is to associate .md files with Modula-2. I'd expect TagBar not to work as expected in that case.

anson2416 commented 5 years ago

hi @jszakmeister ,

  1. I follow this guide to install the tagbar for Markdown

https://github.com/majutsushi/tagbar/wiki#markdown

  1. running the markdown2ctag.py in vim, i got the error below: E488: 多余的尾部字符

but running in terminal, it works ok. image

  1. markdown-related plug-in list
    "markdown syntax plugin
    Plug 'godlygeek/tabular'
    Plug 'plasticboy/vim-markdown'
    Plug 'iamcco/markdown-preview.vim'
    Plug 'shime/vim-livedown'
anson2416 commented 5 years ago

HI @jszakmeister , just now I found that it WORKS.

The reason is that, thie file markdown2ctags.py did not have suficent authority. Following command resolves the issue. Thanks for your time!

BTW, E488 issue still exists.

jszakmeister commented 5 years ago

The reason is that, thie file markdown2ctags.py did not have suficent authority.

What do you mean? If you were able to run markdown2ctags.py on the command line, then you had the required permissions already.

Following command resolves the issue. Thanks for your time!

What command? You didn't post it. :-)

BTW, E488 issue still exists.

Again, you'll have to provide more information here for me to do anything. I can't really do much with the error provided as I can't read the error message and it doesn't appear to point to anything specific. Have you looked at the output of :messages in vim? You can also start vim with debug logging and save that to a file:

vim -V9debug.log file.txt

Then reproduce the error and take a look at the logs to see where it's coming from.

Also, does it only happen in a specific document or does it happen all the time? If it's a specific document, try running markdown2ctags.py on the command line against the file just to make sure it's not failing in some way. If it is, I definitely want to know that. If it's not, then the bug may be in TagBar (or some other plugin) and not in markdown2ctags.

anson2416 commented 5 years ago

Sorry to make you confused. I use copy command to recreate the file markdown2ctags.py then it works. In additional, i change the file authority with command: chmod 777 markdown2ctags.py

thanks for your info on the trouble shooting tips!

jszakmeister commented 5 years ago

You're welcome!

FYI, don't ever make an executable file world-writable... that's very bad from a security perspective. Use 0755 instead:

chmod 755 markdown2ctags.py