Skip to content

Generalize Toc related tasks to function with other filetypes#295

Merged
lervag merged 4 commits intolervag:masterfrom
saccarosium:generalize_toc
Apr 27, 2023
Merged

Generalize Toc related tasks to function with other filetypes#295
lervag merged 4 commits intolervag:masterfrom
saccarosium:generalize_toc

Conversation

@saccarosium
Copy link
Copy Markdown
Contributor

fixes: #288

PR changes:

  • Makes WikiToc works with other filetypes
  • Makes WikiTocGenerate and WikiTocGenerateLocal works with other filetypes

Asciidoc

Asciidoc works without problems with WikiToc. For WikiTocGenerate, since asciidoc supports natively table of contents, I've implemented a minimal check that parse the lines between the first level heading and the next heading, and searches for some special keywords that asciidoc can understand. If no first level heading is found, it is created a new one with the name of the file. Then it will append to it the special keywords. It doesn't do anything if it found everything.

Showcase

Screen.Recording.2023-04-20.at.23.39.49.mov

Org

Org works without problems with WikiToc. For WikiTocGenerate I've tried to make it as compatible as possible with what I've found online, but since his poor standardization outside of Emacs and my ignorance of the filetype I don't think is the best implementation. It will append on top of the file the string #+OPTION toc: g:wiki_toc_depth.

Showcase

Screen.Recording.2023-04-20.at.23.47.55.mov

Next Step

If you like the idea I'll open a new issue to discuss the feature. I've in mind to generalise the plugin even more and come to a point were the user need only to specify a directory and a dictionary of filetypes he wants and that's it. In other words having a multi-filetype wiki were if I press enter in a markdown file it create a markdown link and if I am in an asciidoc file it does an asciidoc file.

I was thinking of something like this:

" renaming g:wiki_filetypes to something like g:wiki_extentions
let g:wiki_filetypes = {
  \ 'markdown' : {
      \ 'link_type' : 'wiki'|'md',
      \ 'extension' : 'md',
      \ 'heading'   : 'atx',
  \ },
  \ 'asciidoc' : {
     \ 'link_type' : 'wathever'
     \ 'extention' : 'adoc'
  \ },
  \ 'org' : {
     \ 'extension' : 'org'
  \ },
}

@lervag
Copy link
Copy Markdown
Owner

lervag commented Apr 22, 2023

Thanks, this seems very useful! I've been busy lately, but I'll find time to review this as soon as I can!

lervag added a commit that referenced this pull request Apr 27, 2023
@lervag lervag merged commit ca4f0d5 into lervag:master Apr 27, 2023
@lervag
Copy link
Copy Markdown
Owner

lervag commented Apr 27, 2023

Sorry for the delay. I made some small adjustments and merged this now. The main changes were:

  • Some simplifications and "generalization" of the splitting into by-filetype functions.
  • Add wiki as a filetype and fallback to it when &filetype is undefined.

@lervag
Copy link
Copy Markdown
Owner

lervag commented Apr 27, 2023

Next Step

If you like the idea I'll open a new issue to discuss the feature. I've in mind to generalise the plugin even more and come to a point were the user need only to specify a directory and a dictionary of filetypes he wants and that's it. In other words having a multi-filetype wiki were if I press enter in a markdown file it create a markdown link and if I am in an asciidoc file it does an asciidoc file.

I like this a lot! And I would greatly appreciate your help in realizing it. I will have opinions on how to this should be done, but you probably already know that by now.

I think your suggestion looks relevant. I think a first step would be to recognize which options should be considered filetype specific and thus part of the g:wiki_filetypes option.

Perhaps we should open a new issue to properly discuss this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generalize wiki#toc#gather_entries

2 participants