8 Commits

Author SHA1 Message Date
EinfachToll 86289a8493 Merge branch 'dev' into path-handling
Conflicts:
	autoload/vimwiki/base.vim
	autoload/vimwiki/diary.vim
	autoload/vimwiki/vars.vim
	ftplugin/vimwiki.vim
2019-01-28 07:30:08 +01:00
EinfachToll e45380e3d2 Unify path handling -- part 6 2018-05-15 20:47:12 +02:00
EinfachToll 21e65cf4da Unify path handling -- part 5 2018-04-30 21:27:00 +02:00
EinfachToll b1393a34f7 Merge branch 'dev' into path-handling
Conflicts:
	autoload/vimwiki/base.vim
	autoload/vimwiki/diary.vim
	autoload/vimwiki/html.vim
	autoload/vimwiki/path.vim
	autoload/vimwiki/tags.vim
	autoload/vimwiki/u.vim
	autoload/vimwiki/vars.vim
	ftplugin/vimwiki.vim
	plugin/vimwiki.vim
2018-04-25 21:46:00 +02:00
EinfachToll ca07da33c8 Unify path handling -- part 4 2018-04-25 18:02:23 +02:00
EinfachToll f76e75d117 Unify path handling -- part 3 2018-02-22 08:21:23 +01:00
EinfachToll 12d6265193 Unify path handling -- part 2 2017-11-08 21:56:59 +01:00
EinfachToll 8d0d1561c5 Unify path handling 2017-04-16 16:41:43 +02:00
22 changed files with 765 additions and 756 deletions
-11
View File
@@ -1,11 +0,0 @@
# Issue Checks
Prior to submitting a new issue make sure to complete these steps:
1. Checkout the `dev` branch and confirm the issue is present there as well.
The `dev` branch contains fixes that may not have been merged to `master` yet.
2. Post the syntax you are using (default/mediawiki/markdown) **and** your vimwiki settings from your `.vimrc`
3. Provide a detailed description of the problem including **steps to reproduce the issue**.
4. Include the output of `:VimwikiShowVersion`.
**DELETE THIS TEMPLATE TEXT PRIOR TO SUBMITTING THE ISSUE**
-9
View File
@@ -1,9 +0,0 @@
# Pull Request Checks
1. **ALL** pull requests should be made against the `dev` branch!
2. Take a look at [CONTRIBUTING.MD](https://github.com/vimwiki/vimwiki/blob/dev/CONTRIBUTING.md)
3. Reference any related issues.
4. Provide a description of the proposed changes and any testing that was done.
5. Make sure to update the documentation in `doc/vimwiki.txt` if applicable.
**DELETE THIS TEMPLATE TEXT PRIOR TO SUBMITTING YOUR PULL REQUEST**
+3 -20
View File
@@ -6,36 +6,18 @@ https://github.com/vimwiki/vimwiki/tree/dev to see if your problem is already fi
Issues can be filed at https://github.com/vimwiki/vimwiki/issues/ .
# Creating a pull request
If you want to provide a pull request on GitHub, please start from the `dev` branch, not from the
`master` branch. (Caution, GitHub shows `master` as the default branch from which to start a PR.)
Make sure to update `doc/vimwiki.txt` with the following information:
1. Update the changelog to include information on the new feature the PR introduces or the bug it
is fixing.
2. Add a help section to describe any new features or options.
2. If you are a first time contributor add your name to the list of contributors.
# More info and advice for (aspiring) core developers
- Before implementing a non-trivial feature, think twice what it means for the user. We should
always try to keep backward compatibility. If you are not sure, discuss it on GitHub.
- Also, when thinking about adding a new feature, it should be something which fits into the
overall design of Vimwiki and which a significant portion of the users may like. Keep in mind
that everybody has their own way to use Vimwiki.
- Keep the coding style consistent.
- Test your changes. Keep in mind that Vim has a ton of options and the users tons of different
setups. Take a little time to think about under which circumstances your changes could break.
# More info for (aspiring) core developers
## Git branching model
- there are two branches with eternal lifetime:
- `dev`: This is where the main development happens. Tasks which are done in one or only a few
commits go here directly. Always try to keep this branch in a working state, that is, if the
task you work on requires multiple commits, make sure intermediate commits don't make Vimwiki
unusable (or at least push these commits at one go).
- `master`: This branch is for released states only. Whenever a reasonable set of changes has
- `master`: This branches is for released states only. Whenever a reasonable set of changes has
piled up in the `dev` branch, a [release is done](#Preparing a release). After a release,
`dev` has been merged into `master` and `master` got exactly one additional commit in which
the version number in `plugin/vimwiki.vim` is updated. Apart from these commits and the merge
@@ -60,4 +42,5 @@ Make sure to update `doc/vimwiki.txt` with the following information:
forget this plan.
11. Tell the world.
%% vim:tw=99
View File
+55 -85
View File
@@ -1,62 +1,63 @@
VimWiki —— Vim 个人 Wiki 插件
一个私人的维基——vim插件
==============================================================================
[English](README.md)
![screenshot1](doc/screenshot_1.png)
![screenshot2](doc/screenshot_2.png) *
![screenshot2](doc/screenshot_2.png)
介绍
------------------------------------------------------------------------------
Vimwiki 是 Vim 中的个人 Wiki —— 一组链接起来的、有独特语法高亮的文本文件。
Vimwiki是私人维基的vim插件 -- 许多有自己代码高亮的text文件。
通过 Vimwiki,你可以:
通过Vimwiki,你可以:
* 组织笔记和想法
* 管理待办事项
* 写文档
* 坚持写日记
* 将这一切导出成 HTML 网页
* 制作代办事项
* 写文档
马上开始!按下 `<Leader>ww`(通常是 `\ww`)进入作为目录页的 wiki 文件,这个文件默认存放在 `~/vimwiki/index.wiki`
一个快速的开始,通常使用`<Leader>ww`(一般是`\ww`),然后创建你的index wiki文件
通常,它在:
在该文件中输入以下示例:
~/vimwiki/index.wiki
= 我的个人知识库 =
* 任务列表 -- _昨天_ 就该完成的事!!!
* Gutenberg 计划 -- 好书给我力量。
* 草稿 -- 临时记录一些东西。
在这个文件,输入如下的例子:
把光标移到 `任务` 二字上,按 Enter(回车)创建链接。按下后,`任务`二字会变成 `[[任务]]` —— 这是一个 Vimwiki 链接。再次按 Enter 即可进入这个链接(打开新的 wiki 文件)。编辑这个新文件,保存,然后按 Backspace(退格)就能回到目录页。
= My knowledge base =
* Tasks -- things to be done _yesterday_!!!
* Project Gutenberg -- good books are power.
* Scratchpad -- various temporary stuff.
如果 Vimwiki 链接长度不止一个单词(指的是英文单词),只需在 Visual 模式选择这段文本后按 Enter 即可。用上面的 `Gutenberg 计划` 试试吧。最终结果是这样:
将你的光标放到`Tasks`(任务)上,并且按回车键去创建一个链接。一旦按下,`Task`将会
变成`[[Tasks]]` -- 一个vimwiki的链接。再按一次回车去打开它。编辑文件,保存它,
然后按backspace来返回你的index。
= 我的个人知识库 =
* [[任务列表]] -- _昨天_ 就该完成的事!!!
* [[Gutenberg 计划]] -- 好书给我力量。
* 草稿 -- 临时记录一些东西。
一个vimwiki链接可以一句话创建。只需要通过选择visual模式选择这个句子,然后按回车。
你可以通过选择`Project Gutenberg`来尝试。结果像是这个样子:
= My knowledge base =
* [[Tasks]] -- things to be done _yesterday_!!!
* [[Project Gutenberg]] -- good books are power.
* Scratchpad -- various temporary stuff.
基本标记
------------------------------------------------------------------------------
= 一级标题 =
== 二级标题 ==
=== 三级标题 ===
= Header1 =
== Header2 ==
=== Header3 ===
*bold* -- 粗体文本
_italic_ -- 斜体文本
(应用于句中的汉字文本时,必须在标记前后加空格,例如:一段 *中文* 文本)
*bold* -- bold text
_italic_ -- italic text
[[wiki link]] -- wiki 链接
[[wiki link|description]] -- 带有描述文本的 wiki 链接
[[wiki link]] -- wiki link
[[wiki link|description]] -- wiki link with description
列表
列表:
* bullet list item 1(无编号列表)
* bullet list item 1
- bullet list item 2
- bullet list item 3
* bullet list item 4
@@ -66,13 +67,13 @@ Vimwiki 是 Vim 中的个人 Wiki —— 一组链接起来的、有独特语法
- bullet list item 8
- bullet list item 9
1. numbered list item 1(有编号列表)
1. numbered list item 1
2. numbered list item 2
a) numbered list item 3
b) numbered list item 4
更多格式说明,请阅 `:h vimwiki-syntax`
查看`:h vimwiki-syntax`
键位绑定
@@ -80,49 +81,46 @@ Vimwiki 是 Vim 中的个人 Wiki —— 一组链接起来的、有独特语法
normal 模式:
* `<Leader>ww` -- 打开默认的 wiki 目录文件
* `<Leader>wt` -- 在新标签(Tab)中打开 wiki 目录文件
* `<Leader>ws` -- 在多个 wiki 中选择并打开该 wiki 的目录文件
* `<Leader>wd` -- 删除当前 wiki 文件
* `<Leader>wr` -- 重命名当前 wiki 文件
* `<Enter>` -- 创建或打开 wiki 链接
* `<Shift-Enter>` -- 先上下分屏再打开 wiki 链接(若非链接则先创建)
* `<Ctrl-Enter>` -- 先左右分屏再打开 wiki 链接(若非链接则先创建)
* `<Backspace>` -- 返回之前浏览的 wiki 文件
* `<Tab>` -- 跳到本文件中下一个 wiki 链接
* `<Shift-Tab>` -- 跳到本文件中上一个 wiki 链接
* `<Leader>ww` -- 打开默认的wiki index文件
* `<Leader>wt` -- 通过tab实现上一个功能
* `<Leader>ws` -- 选择并打开index文件
* `<Leader>wd` -- 删除进入的wiki文件
* `<Leader>wr` -- 重命名你进入的wiki文件
* `<Enter>` -- 进入/创建 wiki 链接
* `<Shift-Enter>` -- 通过分屏模式sp,进入/创建wiki链接
* `<Ctrl-Enter>` -- 通过分屏模式vs,进入/创建wiki链接
* `<Backspace>` -- 返回父节点
* `<Tab>` -- 寻找下一个wiki链接
* `<Shift-Tab>` -- 寻找上一个wiki链接
更多快捷键说明,请阅 `:h vimwiki-mappings`
查看`:h vimwiki-mappings`
命令
------------------------------------------------------------------------------
* `:Vimwiki2HTML` -- 当前 wiki 文件转换成 HTML 网页
* `:VimwikiAll2HTML` -- 把所有 wiki 文件转换成 HTML 网页
* `:Vimwiki2HTML` -- 转换当前wiki成为html
* `:VimwikiAll2HTML` -- 转化你的全部wiki到html
* `:help vimwiki-commands` -- 显示全部命令
安装
安装细节
==============================================================================
准备工作
在安装之前,你需要做的
------------------------------------------------------------------------------
保在 `vimrc` 中加入了以下设置:
定在`vimrc`中,你的设置是这样的。
set nocompatible
filetype plugin on
syntax on
没有这些设置Vimwiki 将无法正常工作。
如果没有他们Vimwiki将无法正常工作。
通过 [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) 安装(Vim 7.4.1528 后)
------------------------------------------------------------------------------
git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki
通过 [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332) 安装
使用 pathogen (译者注:一个插件) (http://www.vim.org/scripts/script.php?script_id=2332 )
------------------------------------------------------------------------------
cd ~/.vim
@@ -130,32 +128,4 @@ normal 模式:
cd bundle
git clone https://github.com/vimwiki/vimwiki.git
通过 [Vim-Plug](https://github.com/junegunn/vim-plug) 安装
------------------------------------------------------------------------------
`vimrc` 中加入以下插件设置:
Plug 'vimwiki/vimwiki'
然后运行 `:PlugInstall`
通过 [Vundle](https://github.com/VundleVim/Vundle.vim) 安装
------------------------------------------------------------------------------
`vimrc` 中加入 `Plugin 'vimwiki/vimwiki'`,然后执行:
vim +PluginInstall +qall
或者下载 [zip 压缩包](https://github.com/vimwiki/vimwiki/archive/master.zip)然后解压到 `~/.vim/bundle/` 目录下。
安装后,启动 Vim 并执行 `:Helptags` 以及 `:help vimwiki`,检查安装是否成功。
获取帮助
==============================================================================
遇到问题?在 Freenode 的 IRC 频道 `#vimwiki`[网页聊天](https://webchat.freenode.net/?channels=#vimwiki))提问,或者发送问题到[邮件列表](https://groups.google.com/forum/#!forum/vimwiki)上吧。
----
\* 前面截图中用的是 [solarized 配色方案](https://github.com/altercation/vim-colors-solarized)以及 [lightline](https://github.com/itchyny/lightline.vim) 插件。
然后启动vim,使用`:Helptags` 然后 `:help vimwiki`来确保他已经被安装了。
+119 -188
View File
@@ -1,180 +1,88 @@
# VimWiki: A Personal Wiki For Vim
A Personal Wiki For Vim
==============================================================================
[中文](README-cn.md)
![screenshot1](doc/screenshot_1.png)
![screenshot2](doc/screenshot_2.png) *
- [Intro](#intro)
- [Installation](#installation)
- [Prerequisites](#prerequisites)
- [VIM Packages](#installation-using-vim-packages-since-vim-741528)
- [Pathogen](#installation-using-pathogen)
- [Vim-Plug](#installation-using-vim-plug)
- [Vundle](#installation-using-vundle)
- [Basic Markup](#basic-markup)
- [Lists](#lists)
- [Key Bindings](#key-bindings)
- [Commands](#commands)
- [Changing Wiki Syntax](#changing-wiki-syntax)
- [Getting Help](#getting-help)
- [Helping VimWiki](#helping-vimwiki)
- [Wiki](https://github.com/vimwiki/vimwiki/wiki)
- [License](#license)
Intro
------------------------------------------------------------------------------
## Intro
VimWiki is a personal wiki for Vim -- a number of linked text files that have
Vimwiki is a personal wiki for Vim -- a number of linked text files that have
their own syntax highlighting.
With VimWiki you can:
With Vimwiki you can:
* Organize notes and ideas
* Manage to-do lists
* Write documentation
* Maintain a diary
* Export everything to HTML
* organize notes and ideas
* manage todo-lists
* write documentation
* maintain a diary
* export everything to HTML
To do a quick start press `<Leader>ww` (this is usually `\ww`) to go to your
index wiki file. By default it is located in `~/vimwiki/index.wiki`.
To do a quick start press `<Leader>ww` (this is usually `\ww`) to go to your index
wiki file. By default it is located in `~/vimwiki/index.wiki`.
Feed it with the following example:
```
= My knowledge base =
* Tasks -- things to be done _yesterday_!!!
* Project Gutenberg -- good books are power.
* Scratchpad -- various temporary stuff.
= My knowledge base =
* Tasks -- things to be done _yesterday_!!!
* Project Gutenberg -- good books are power.
* Scratchpad -- various temporary stuff.
```
Place your cursor on `Tasks` and press Enter to create a link. Once pressed,
`Tasks` will become `[[Tasks]]` -- a VimWiki link. Press Enter again to
open it. Edit the file, save it, and then press Backspace to jump back to your
Place your cursor on `Tasks` and press Enter to create a link. Once pressed,
`Tasks` will become `[[Tasks]]` -- a Vimwiki link. Press Enter again to
open it. Edit the file, save it, and then press Backspace to jump back to your
index.
A VimWiki link can be constructed from more than one word. Just visually
select the words to be linked and press Enter. Try it with `Project Gutenberg`.
A Vimwiki link can be constructed from more than one word. Just visually
select the words to be linked and press Enter. Try it with `Project Gutenberg`.
The result should look something like:
```
= My knowledge base =
* [[Tasks]] -- things to be done _yesterday_!!!
* [[Project Gutenberg]] -- good books are power.
* Scratchpad -- various temporary stuff.
```
## Screenshots
![Lists View](doc/lists.png)
![Entries View](doc/entries.png)
![Todos View](doc/todos.png)
![Wiki View](doc/wiki.png)
## Installation
### Prerequisites
Make sure you have these settings in your vimrc file:
```vim
set nocompatible
filetype plugin on
syntax on
```
Without them VimWiki will not work properly.
= My knowledge base =
* [[Tasks]] -- things to be done _yesterday_!!!
* [[Project Gutenberg]] -- good books are power.
* Scratchpad -- various temporary stuff.
#### Installation using [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528)
Basic Markup
------------------------------------------------------------------------------
```sh
git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki
```
#### Installation using [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332)
```sh
cd ~/.vim
mkdir bundle
cd bundle
git clone https://github.com/vimwiki/vimwiki.git
```
#### Installation using [Vim-Plug](https://github.com/junegunn/vim-plug)
Add the following to the plugin-configuration in your vimrc:
```vim
Plug 'vimwiki/vimwiki'
```
Then run `:PlugInstall`.
#### Installation using [Vundle](https://github.com/VundleVim/Vundle.vim)
Add `Plugin 'vimwiki/vimwiki'` to your vimrc file and run
```sh
vim +PluginInstall +qall
```
Or download the [zip
archive](https://github.com/vimwiki/vimwiki/archive/master.zip) and extract it
in `~/.vim/bundle/`
Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was
installed.
## Basic Markup
```
= Header1 =
== Header2 ==
=== Header3 ===
= Header1 =
== Header2 ==
=== Header3 ===
*bold* -- bold text
_italic_ -- italic text
*bold* -- bold text
_italic_ -- italic text
[[wiki link]] -- wiki link
[[wiki link|description]] -- wiki link with description
```
[[wiki link]] -- wiki link
[[wiki link|description]] -- wiki link with description
### Lists:
```
* bullet list item 1
- bullet list item 2
- bullet list item 3
* bullet list item 4
* bullet list item 5
* bullet list item 6
* bullet list item 7
- bullet list item 8
- bullet list item 9
Lists:
* bullet list item 1
- bullet list item 2
- bullet list item 3
* bullet list item 4
* bullet list item 5
* bullet list item 6
* bullet list item 7
- bullet list item 8
- bullet list item 9
1. numbered list item 1
2. numbered list item 2
a) numbered list item 3
b) numbered list item 4
1. numbered list item 1
2. numbered list item 2
a) numbered list item 3
b) numbered list item 4
```
For other syntax elements, see `:h vimwiki-syntax`
## Key bindings
Normal mode:
Key bindings
------------------------------------------------------------------------------
normal mode:
* `<Leader>ww` -- Open default wiki index file.
* `<Leader>wt` -- Open default wiki index file in a new tab.
@@ -190,61 +98,84 @@ Normal mode:
For more keys, see `:h vimwiki-mappings`
## Commands
* `:VimWiki2HTML` -- Convert current wiki link to HTML
* `:VimWikiAll2HTML` -- Convert all your wiki links to HTML
Commands
------------------------------------------------------------------------------
* `:Vimwiki2HTML` -- Convert current wiki link to HTML
* `:VimwikiAll2HTML` -- Convert all your wiki links to HTML
* `:help vimwiki-commands` -- list all commands
* `:help vimwiki` -- General vimwiki help docs
## Changing Wiki Syntax
VimWiki currently ships with 3 syntaxes: VimWiki (default), Markdown
(markdown), and MediaWiki (media)
Changing Wiki Syntax
------------------------------------------------------------------------------
If you would prefer to use either Markdown or MediaWiki syntaxes, set the
following option in your .vimrc:
Vimwiki currently ships with 3 syntaxes: Vimwiki (default), Markdown (markdown), and MediaWiki (media)
```vim
If you would prefer to use either Markdown or MediaWiki syntaxes, set the following option in your .vimrc:
```
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
```
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
```
Installation
==============================================================================
## Getting help
Prerequisites
------------------------------------------------------------------------------
**Have a question?**
Visit the IRC channel [`#vimwiki`](https://webchat.freenode.net/?channels=#vimwiki) on Freenode ([webchat](https://webchat.freenode.net/?channels=#vimwiki), also synced to Matrix/Riot: `#freenode_#vimwiki:matrix.org`) or post to the [mailing list](https://groups.google.com/forum/#!forum/vimwiki).
Make sure you have these settings in your vimrc file:
## Helping VimWiki
set nocompatible
filetype plugin on
syntax on
VimWiki has a lot of users but only very few recurring developers or people
helping the community. Your help is therefore appreciated. Everyone can help!
See [#625](https://github.com/vimwiki/vimwiki/issues/625) for information on
how you can help.
Without them Vimwiki will not work properly.
## License
MIT License
Installation using [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528)
------------------------------------------------------------------------------
Copyright (c) 2008-2010 Maxim Kim
2013-2017 Daniel Schemala
git clone https://github.com/vimwiki/vimwiki.git ~/.vim/pack/plugins/start/vimwiki
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Installation using [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332)
------------------------------------------------------------------------------
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
cd ~/.vim
mkdir bundle
cd bundle
git clone https://github.com/vimwiki/vimwiki.git
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Installation using [Vim-Plug](https://github.com/junegunn/vim-plug)
------------------------------------------------------------------------------
Add the following to the plugin-configuration in your vimrc:
Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
Then run `:PlugInstall`.
Installation using [Vundle](https://github.com/VundleVim/Vundle.vim)
------------------------------------------------------------------------------
Add `Plugin 'vimwiki/vimwiki'` to your vimrc file and run
vim +PluginInstall +qall
Or download the [zip archive](https://github.com/vimwiki/vimwiki/archive/master.zip) and extract it in `~/.vim/bundle/`
Then launch Vim, run `:Helptags` and then `:help vimwiki` to verify it was installed.
Getting help
==============================================================================
Have a question? Visit the IRC channel `#vimwiki` on Freenode ([webchat](https://webchat.freenode.net/?channels=#vimwiki))
or post to the [mailing list](https://groups.google.com/forum/#!forum/vimwiki).
----
\* Screenshots made with the [solarized colorscheme](https://github.com/altercation/vim-colors-solarized)
and [lightline](https://github.com/itchyny/lightline.vim)
+85 -108
View File
@@ -43,55 +43,17 @@ function! vimwiki#base#file_pattern(files)
endfunction
"FIXME TODO slow and faulty
function! vimwiki#base#subdir(path, filename)
let path = a:path
" ensure that we are not fooled by a symbolic link
"FIXME if we are not "fooled", we end up in a completely different wiki?
if a:filename !~# '^scp:'
let filename = resolve(a:filename)
else
let filename = a:filename
endif
let idx = 0
"FIXME this can terminate in the middle of a path component!
while path[idx] ==? filename[idx]
let idx = idx + 1
endwhile
let p = split(strpart(filename, idx), '[/\\]')
let res = join(p[:-2], '/')
if len(res) > 0
let res = res.'/'
endif
return res
endfunction
function! vimwiki#base#current_subdir()
return vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), expand('%:p'))
endfunction
function! vimwiki#base#invsubdir(subdir)
return substitute(a:subdir, '[^/\.]\+/', '../', 'g')
endfunction
" Returns: the number of the wiki a file belongs to or -1 if it doesn't belong
" to any registered wiki.
" The path can be the full path or just the directory of the file
function! vimwiki#base#find_wiki(path)
function! vimwiki#base#find_wiki(file)
let bestmatch = -1
let bestlen = 0
let path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(a:path))
for idx in range(vimwiki#vars#number_of_wikis())
let idx_path = expand(vimwiki#vars#get_wikilocal('path', idx))
let idx_path = vimwiki#path#path_norm(vimwiki#path#chomp_slash(idx_path))
let common_pfx = vimwiki#path#path_common_pfx(idx_path, path)
if vimwiki#path#is_equal(common_pfx, idx_path)
if len(common_pfx) > bestlen
let bestlen = len(common_pfx)
let wiki_path = expand(vimwiki#vars#get_wikilocal('path', idx))
let common_prefix = vimwiki#path#path_common_pfx(wiki_path, a:file)
if vimwiki#path#is_equal(common_prefix, wiki_path)
if len(common_prefix) > bestlen
let bestlen = len(common_prefix)
let bestmatch = idx
endif
endif
@@ -101,10 +63,9 @@ function! vimwiki#base#find_wiki(path)
endfunction
" THE central function of Vimwiki. Extract infos about the target from a link.
" If the second parameter is present, which should be an absolute file path, it
" is assumed that the link appears in that file. Without it, the current file
" is used.
" Extract infos about the target from a link. If the second parameter is present, which should be a
" file object, it is assumed that the link appears in that file. Without it, the current file is
" used.
function! vimwiki#base#resolve_link(link_text, ...)
if a:0
let source_wiki = vimwiki#base#find_wiki(a:1)
@@ -118,13 +79,16 @@ function! vimwiki#base#resolve_link(link_text, ...)
let link_infos = {
\ 'index': -1,
\ 'index': 0,
\ 'scheme': '',
\ 'filename': '',
\ 'is_file': 0, " 1 for a file, 0 for a URL (e.g. when the link was [[http://foo.bar]]),
\ " -1 if the whole link was malformed
\ 'target': '', " this is a file or dir object if is_file == 1, otherwise a string
\ 'anchor': '',
\ }
if link_text == ''
let link_infos.is_file = -1
return link_infos
endif
@@ -135,10 +99,14 @@ function! vimwiki#base#resolve_link(link_text, ...)
let link_infos.scheme = scheme
if link_infos.scheme !~# '\mwiki\d\+\|diary\|local\|file'
let link_infos.filename = link_text " unknown scheme, may be a weblink
" unknown scheme, may be a weblink
let link_infos.is_file = 0
let link_infos.target = link_text
return link_infos
endif
let link_infos.is_file = 1
let link_text = matchstr(link_text, '^'.vimwiki#vars#get_global('rxSchemes').':\zs.*\ze')
endif
@@ -152,16 +120,12 @@ function! vimwiki#base#resolve_link(link_text, ...)
let link_infos.anchor = join(split_lnk[1:], '#')
endif
if link_text == '' " because the link was of the form '#anchor'
let expected_ext = vimwiki#u#escape(vimwiki#vars#get_wikilocal('ext')).'$'
if source_file =~# expected_ext
" Source file has expected extension. Remove it, it will be added later on
let ext_len = strlen(vimwiki#vars#get_wikilocal('ext'))
let link_text = fnamemodify(source_file, ':p:t')[:-ext_len-1]
endif
let link_text = vimwiki#path#filename_without_extension(source_file)
endif
endif
let link_tail = vimwiki#path#file_segment(link_text)
" check if absolute or relative path
if is_wiki_link && link_text[0] == '/'
if link_text != '/'
@@ -172,7 +136,7 @@ function! vimwiki#base#resolve_link(link_text, ...)
let is_relative = 0
else
let is_relative = 1
let root_dir = fnamemodify(source_file, ':p:h') . '/'
let root_dir = vimwiki#path#directory_of_file(source_file)
endif
@@ -180,45 +144,52 @@ function! vimwiki#base#resolve_link(link_text, ...)
if link_infos.scheme =~# '\mwiki\d\+'
let link_infos.index = eval(matchstr(link_infos.scheme, '\D\+\zs\d\+\ze'))
if link_infos.index < 0 || link_infos.index >= vimwiki#vars#number_of_wikis()
let link_infos.is_file = -1
let link_infos.index = -1
let link_infos.filename = ''
return link_infos
endif
if !is_relative || link_infos.index != source_wiki
if link_text[0] == '/' || link_infos.index != source_wiki
let root_dir = vimwiki#vars#get_wikilocal('path', link_infos.index)
endif
let link_infos.filename = root_dir . link_text
if vimwiki#path#is_link_to_dir(link_text)
if vimwiki#vars#get_global('dir_link') != ''
let link_infos.filename .= vimwiki#vars#get_global('dir_link') .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
if link_text != '/'
let link_text = link_text[1:]
endif
else
let link_infos.filename .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
let root_dir = vimwiki#path#directory_of_file(source_file)
endif
if link_text =~# '\m[/\\]$'
if vimwiki#vars#get_global('dir_link') == ''
let target_dir = vimwiki#path#dir_segment(link_text)
let link_infos.target = vimwiki#path#join_dir(root_dir, target_dir)
else
let link_text .= vimwiki#vars#get_global('dir_link') .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
let target_file = vimwiki#path#file_segment(link_text)
let link_infos.target = vimwiki#path#join(root_dir, target_file)
endif
else
let link_text .= vimwiki#vars#get_wikilocal('ext', link_infos.index)
let target_file = vimwiki#path#file_segment(link_text)
let link_infos.target = vimwiki#path#join(root_dir, target_file)
endif
elseif link_infos.scheme ==# 'diary'
let link_infos.index = source_wiki
let link_infos.filename =
\ vimwiki#vars#get_wikilocal('path', link_infos.index) .
\ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) .
\ link_text .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local') && is_relative
let link_infos.filename = simplify(root_dir . link_text)
else " absolute file link
" collapse repeated leading "/"'s within a link
let link_text = substitute(link_text, '\m^/\+', '/', '')
" expand ~/
let link_text = fnamemodify(link_text, ':p')
let link_infos.filename = simplify(link_text)
let root_dir = vimwiki#vars#get_wikilocal('diary_path', link_infos.index)
let target_file = vimwiki#path#file_segment(link_text .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index))
let link_infos.target = vimwiki#path#join(root_dir, target_file)
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local') &&
\ vimwiki#path#is_absolute(link_text)
let link_infos.target = vimwiki#path#file_obj(link_text)
else " relative file link
let root_dir = vimwiki#path#directory_of_file(source_file)
let target_file = vimwiki#path#file_segment(link_text)
let link_infos.target = vimwiki#path#join(root_dir, target_file)
endif
let link_infos.filename = vimwiki#path#normalize(link_infos.filename)
return link_infos
endfunction
@@ -284,7 +255,7 @@ function! vimwiki#base#open_link(cmd, link, ...)
let link_infos = vimwiki#base#resolve_link(a:link)
endif
if link_infos.filename == ''
if link_infos.is_file == -1
if link_infos.index == -1
echomsg 'Vimwiki Error: No registered wiki ''' . link_infos.scheme . '''.'
else
@@ -296,7 +267,7 @@ function! vimwiki#base#open_link(cmd, link, ...)
let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+' || link_infos.scheme =~# 'diary'
let update_prev_link = is_wiki_link &&
\ !vimwiki#path#is_equal(link_infos.filename, vimwiki#path#current_wiki_file())
\ !vimwiki#path#is_equal(link_infos.target, vimwiki#path#current_wiki_file())
let vimwiki_prev_link = []
" update previous link for wiki pages
@@ -310,10 +281,10 @@ function! vimwiki#base#open_link(cmd, link, ...)
" open/edit
if is_wiki_link
call vimwiki#base#edit_file(a:cmd, link_infos.filename, link_infos.anchor,
call vimwiki#base#edit_file(a:cmd, link_infos.target, link_infos.anchor,
\ vimwiki_prev_link, update_prev_link)
else
call vimwiki#base#system_open_link(link_infos.filename)
call vimwiki#base#system_open_link(link_infos.target)
endif
endfunction
@@ -343,7 +314,7 @@ endfunction
function! vimwiki#base#generate_links()
let lines = []
let links = vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
let links = vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0, 0)
call sort(links)
let bullet = repeat(' ', vimwiki#lst#get_list_margin()) . vimwiki#lst#default_symbol().' '
@@ -399,7 +370,9 @@ function! vimwiki#base#backlinks()
endfunction
" Returns: a list containing all files of the given wiki as absolute file path.
" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX kann das weg?
" Returns: a list containing all files of the given wiki as file objects.
" If the given wiki number is negative, the diary of the current wiki is used
" If the second argument is not zero, only directories are found
function! vimwiki#base#find_files(wiki_nr, directories_only)
@@ -407,8 +380,7 @@ function! vimwiki#base#find_files(wiki_nr, directories_only)
if wiki_nr >= 0
let root_directory = vimwiki#vars#get_wikilocal('path', wiki_nr)
else
let root_directory = vimwiki#vars#get_wikilocal('path') .
\ vimwiki#vars#get_wikilocal('diary_rel_path')
let root_directory = vimwiki#vars#get_wikilocal('diary_path')
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
endif
if a:directories_only
@@ -430,14 +402,18 @@ endfunction
" Returns: a list containing the links to get from the current file to all wiki
" files in the given wiki.
" If the given wiki number is negative, the diary of the current wiki is used.
" If also_absolute_links is nonzero, also return links of the form /file
function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
let files = vimwiki#base#find_files(a:wiki_nr, 0)
" If a:diary_only is nonzero, the diary of the wiki is used.
" If a:also_absolute_links is nonzero, also return links of the form /file.
function! vimwiki#base#get_wikilinks(wiki_nr, diary_only, also_absolute_links)
if a:diary_only
let files = vimwiki#path#files_in_dir_recursive(vimwiki#vars#get_wikilocal('diary_path'))
else
let files = vimwiki#path#files_in_dir_recursive(vimwiki#vars#get_wikilocal('path'))
endif
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
let cwd = vimwiki#path#wikify_path(expand('%:p:h'))
elseif a:wiki_nr < 0
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
let cwd = vimwiki#vars#get_wikilocal('diary_path')
else
let cwd = vimwiki#vars#get_wikilocal('path', a:wiki_nr)
endif
@@ -452,7 +428,7 @@ function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
if a:wiki_nr == vimwiki#vars#get_bufferlocal('wiki_nr')
let cwd = vimwiki#vars#get_wikilocal('path')
elseif a:wiki_nr < 0
let cwd = vimwiki#vars#get_wikilocal('path') . vimwiki#vars#get_wikilocal('diary_rel_path')
let cwd = vimwiki#vars#get_wikilocal('diary_path')
endif
let wikifile = fnamemodify(wikifile, ':r') " strip extension
let wikifile = '/'.vimwiki#path#relpath(cwd, wikifile)
@@ -614,7 +590,7 @@ function! s:get_links(wikifile, idx)
endif
let link_count += 1
let target = vimwiki#base#resolve_link(link_text, a:wikifile)
if target.filename != '' && target.scheme =~# '\mwiki\d\+\|diary\|file\|local'
if target.is_file != -1 && target.scheme =~# '\mwiki\d\+\|diary\|file\|local'
call add(links, [target.filename, target.anchor, lnum, col])
endif
endwhile
@@ -1921,11 +1897,11 @@ endfunction
function! s:is_diary_file(filename)
let file_path = vimwiki#path#path_norm(a:filename)
let rel_path = vimwiki#vars#get_wikilocal('diary_rel_path')
let diary_path = vimwiki#path#path_norm(vimwiki#vars#get_wikilocal('path') . rel_path)
return rel_path != '' && file_path =~# '^'.vimwiki#u#escape(diary_path)
endfunction
let diary_path = vimwiki#path#path_norm(vimwiki#vars#get_wikilocal('diary_path'))
return !vimwiki#path#equal(vimwiki#vars#get_wikilocal('path'),
\ vimwiki#vars#get_wikilocal('diary_path'))
\ && file_path =~# '^'.vimwiki#u#escape(diary_path)
endfunction " }}}
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template)
let url = matchstr(a:str, a:rxUrl)
@@ -1950,8 +1926,7 @@ endfunction
function! s:normalize_link_in_diary(lnk)
let link = a:lnk . vimwiki#vars#get_wikilocal('ext')
let link_wiki = vimwiki#vars#get_wikilocal('path') . '/' . link
let link_diary = vimwiki#vars#get_wikilocal('path') . '/'
\ . vimwiki#vars#get_wikilocal('diary_rel_path') . '/' . link
let link_diary = vimwiki#vars#get_wikilocal('diary_path') . '/' . link
let link_exists_in_diary = filereadable(link_diary)
let link_exists_in_wiki = filereadable(link_wiki)
let link_is_date = a:lnk =~# '\d\d\d\d-\d\d-\d\d'
@@ -1962,8 +1937,10 @@ function! s:normalize_link_in_diary(lnk)
let rxDesc = ''
let template = vimwiki#vars#get_global('WikiLinkTemplate1')
elseif link_exists_in_wiki
let depth = len(split(vimwiki#vars#get_wikilocal('diary_rel_path'), '/'))
let str = repeat('../', depth) . a:lnk . '|' . a:lnk
let relative_link =
\ vimwiki#path#relpath(vimwiki#vars#get_wikilocal('diary_path'),
\ vimwiki#vars#get_wikilocal('path'))
let str = relative_link . a:lnk . '|' . a:lnk
let rxUrl = '^.*\ze|'
let rxDesc = '|\zs.*$'
let template = vimwiki#vars#get_global('WikiLinkTemplate2')
+4 -6
View File
@@ -23,7 +23,7 @@ endfunction
function! s:diary_path(...)
let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1
return vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx)
return vimwiki#vars#get_wikilocal('diary_path', idx)
endfunction
@@ -90,8 +90,7 @@ endfunction
function! s:get_diary_files()
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(vimwiki#vars#get_wikilocal('path').
\ vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext'))
let s_files = glob(vimwiki#vars#get_wikilocal('diary_path') . '*' . vimwiki#vars#get_wikilocal('ext'))
let files = split(s_files, '\n')
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
@@ -194,8 +193,7 @@ function! vimwiki#diary#make_note(wnum, ...)
" TODO: refactor it. base#goto_index uses the same
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', wiki_nr).
\ vimwiki#vars#get_wikilocal('diary_rel_path', wiki_nr))
call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('diary_path', wiki_nr))
let cmd = 'edit'
if a:0
@@ -320,7 +318,7 @@ endfunction
function vimwiki#diary#calendar_sign(day, month, year)
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let sfile = vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path').
let sfile = vimwiki#vars#get_wikilocal('diary_path') .
\ a:year.'-'.month.'-'.day.vimwiki#vars#get_wikilocal('ext')
return filereadable(expand(sfile))
endfunction
+138 -197
View File
@@ -10,8 +10,8 @@ endif
let g:loaded_vimwiki_html_auto = 1
function! s:root_path(subdir)
return repeat('../', len(split(a:subdir, '[/\\]')))
function! s:path_from_subdir_to_root(subdir)
return vimwiki#path#relpath(a:subdir, vimwiki#vars#get_wikilocal('path_html'))
endfunction
@@ -43,87 +43,67 @@ function! s:is_img_link(lnk)
endfunction
function! s:has_abs_path(fname)
if a:fname =~# '\(^.:\)\|\(^/\)'
function! s:corresponding_html_file(wiki_file)
let relative_wiki_path = vimwiki#path#subtract(vimwiki#vars#get_wikilocal('path'), a:wiki_file)
let html_file = vimwiki#path#join(vimwiki#vars#get_wikilocal('path_html'), relative_wiki_path)
let html_file = vimwiki#path#set_extension(html_file, 'html')
return html_file
endfunction
function! s:corresponding_wiki_file(html_file)
let html_path = vimwiki#path#subtract(vimwiki#vars#get_wikilocal('path_html'), a:html_file)
let wiki_file = vimwiki#path#join(vimwiki#vars#get_wikilocal('path'), html_path)
let wiki_file = vimwiki#path#set_extension(wiki_file, vimwiki#vars#get_wikilocal('ext'))
return wiki_file
endfunction
function! s:default_CSS_full_name()
return vimwiki#path#join(vimwiki#vars#get_wikilocal('path_html'),
\ vimwiki#vars#get_wikilocal('css_name'))
endfunction
" Returns: 1 if it was created, 0 if it already existed
function! s:create_default_CSS()
let css_full_name = s:default_CSS_full_name()
if vimwiki#path#exists(css_full_name)
return 0
else
let default_css = vimwiki#path#find_autoload_file('style.css')
call vimwiki#path#copy_file(default_css, css_full_name)
return 1
endif
return 0
endfunction
function! s:find_autoload_file(name)
for path in split(&runtimepath, ',')
let fname = path.'/autoload/vimwiki/'.a:name
if glob(fname) != ''
return fname
endif
endfor
return ''
endfunction
function! s:default_CSS_full_name(path)
let path = expand(a:path)
let css_full_name = path . vimwiki#vars#get_wikilocal('css_name')
return css_full_name
endfunction
function! s:create_default_CSS(path)
let css_full_name = s:default_CSS_full_name(a:path)
if glob(css_full_name) == ""
call vimwiki#path#mkdir(fnamemodify(css_full_name, ':p:h'))
let default_css = s:find_autoload_file('style.css')
if default_css != ''
let lines = readfile(default_css)
call writefile(lines, css_full_name)
return 1
endif
endif
return 0
endfunction
function! s:template_full_name(name)
if a:name == ''
let name = vimwiki#vars#get_wikilocal('template_default')
else
let name = a:name
endif
let fname = expand(vimwiki#vars#get_wikilocal('template_path').
\ name . vimwiki#vars#get_wikilocal('template_ext'))
if filereadable(fname)
return fname
else
return ''
endif
let filename = vimwiki#path#file_segment(name . vimwiki#vars#get_wikilocal('template_ext'))
let template_file = vimwiki#path#join(vimwiki#vars#get_wikilocal('template_path'), filename)
return template_file
endfunction
function! s:get_html_template(template)
" TODO: refactor it!!!
let lines=[]
if a:template != ''
let template_name = s:template_full_name(a:template)
function! s:get_html_template(template_name)
if a:template_name != ''
let template_file = s:template_full_name(a:template)
try
let lines = readfile(template_name)
let lines = readfile(vimwiki#path#to_string(template_file))
return lines
catch /E484/
echomsg 'Vimwiki: HTML template '.template_name. ' does not exist!'
echomsg 'Vimwiki: HTML template '.vimwiki#path#to_string(template_file). ' does not exist!'
endtry
return []
else
let default_template_file =
\ s:template_full_name(vimwiki#vars#get_wikilocal('template_default'))
if !vimwiki#path#exists(default_template_file)
let default_template_file = vimwiki#path#find_autoload_file('default.tpl')
endif
let lines = readfile(default_tpl)
return lines
endif
let default_tpl = s:template_full_name('')
if default_tpl == ''
let default_tpl = s:find_autoload_file('default.tpl')
endif
let lines = readfile(default_tpl)
return lines
endfunction
@@ -151,26 +131,25 @@ function! s:safe_html_line(line)
endfunction
function! s:delete_html_files(path)
let htmlfiles = split(glob(a:path.'**/*.html'), '\n')
for fname in htmlfiles
function! s:delete_html_files()
let htmlfiles =
\ vimwiki#path#files_in_dir_recursive(vimwiki#vars#get_wikilocal('path_html'), 'html')
for html_file in htmlfiles
" ignore user html files, e.g. search.html,404.html
if stridx(vimwiki#vars#get_global('user_htmls'), fnamemodify(fname, ":t")) >= 0
if index(vimwiki#vars#get_global('user_htmls'), vimwiki#path#filename(html_file)) >= 0
continue
endif
" delete if there is no corresponding wiki file
let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path_html'), fname)
let wikifile = vimwiki#vars#get_wikilocal('path').subdir.
\fnamemodify(fname, ":t:r").vimwiki#vars#get_wikilocal('ext')
if filereadable(wikifile)
if vimwiki#path#exists(s:corresponding_wiki_file(html_file))
continue
endif
try
call delete(fname)
call delete(vimwiki#path#to_string(html_file))
catch
echomsg 'Vimwiki Error: Cannot delete '.fname
echomsg 'Vimwiki Error: Cannot delete '.vimwiki#path#to_string(html_file)
endtry
endfor
endfunction
@@ -231,21 +210,15 @@ endfunction
function! s:is_html_uptodate(wikifile)
let tpl_time = -1
let htmlfile_ftime = getftime(vimwiki#path#to_string(s:corresponding_html_file(a:wikifile)))
let tpl_file = s:template_full_name('')
if tpl_file != ''
let tpl_time = getftime(tpl_file)
endif
" The HTML file should also be considered out of date if the default template has been changed in
" the meantime. This is not completely correct, because the wiki file could use a template which
" is not the default one. But it's better than nothing.
let tpl_file = s:template_full_name(vimwiki#vars#get_wikilocal('template_default'))
let tpl_time = getftime(tpl_file)
let wikifile = fnamemodify(a:wikifile, ":p")
let htmlfile = expand(vimwiki#vars#get_wikilocal('path_html') .
\ vimwiki#vars#get_bufferlocal('subdir') . fnamemodify(wikifile, ":t:r").".html")
if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
return 1
endif
return 0
return getftime(wikifile) <= htmlfile_ftime && tpl_time <= htmlfile_ftime
endfunction
@@ -410,17 +383,18 @@ function! s:tag_wikiincl(value)
let link_infos = vimwiki#base#resolve_link(url_0)
if link_infos.scheme =~# '\mlocal\|wiki\d\+\|diary'
let url = vimwiki#path#relpath(fnamemodify(s:current_html_file, ':h'), link_infos.filename)
let url = vimwiki#path#relpath(vimwiki#path#directory_of_file(s:current_html_file),
\ link_infos.target)
" strip the .html extension when we have wiki links, so that the user can
" simply write {{image.png}} to include an image from the wiki directory
if link_infos.scheme =~# '\mwiki\d\+\|diary'
let url = fnamemodify(url, ':r')
let url = vimwiki#path#filename_without_extension(url)
endif
else
let url = link_infos.filename
let url = link_infos.target
endif
let url = escape(url, '#')
let url = escape(vimwiki#path#to_string(url), '#')
let line = s:linkify_image(url, descr, verbatim_str)
endif
return line
@@ -447,20 +421,17 @@ function! s:tag_wikilink(value)
if link_infos.scheme ==# 'file'
" external file links are always absolute
let html_link = link_infos.filename
let html_link = vimwiki#path#to_string(link_infos.target)
elseif link_infos.scheme ==# 'local'
let html_link = vimwiki#path#relpath(fnamemodify(s:current_html_file, ':h'),
\ link_infos.filename)
let html_link = vimwiki#path#to_string(vimwiki#path#relpath(
\ vimwiki#path#directory_of_file(s:current_html_file), link_infos.target))
elseif link_infos.scheme =~# '\mwiki\d\+\|diary'
" wiki links are always relative to the current file
let html_link = vimwiki#path#relpath(
\ fnamemodify(s:current_wiki_file, ':h'),
\ fnamemodify(link_infos.filename, ':r'))
if html_link !~ '\m/$'
let html_link .= '.html'
endif
let target_html_file = s:corresponding_html_file(link_infos.target)
let html_link = vimwiki#path#to_string(vimwiki#path#relpath(
\ vimwiki#path#directory_of_file(s:current_html_file), target_html_file))
else " other schemes, like http, are left untouched
let html_link = link_infos.filename
let html_link = link_infos.target
endif
if link_infos.anchor != ''
@@ -1072,9 +1043,7 @@ function! s:process_tag_h(line, id)
let h_text = num.' '.h_text
endif
let h_complete_id = s:escape_html_attribute(h_complete_id)
let h_part = '<div id="'.h_complete_id.'">'
let h_part .= '<h'.h_level.' id="'.h_id.'" class="header">'
let h_part .= '<a href="#'.h_complete_id.'"'
let h_part = '<div id="'.h_complete_id.'"><h'.h_level.' id="'.h_id.'"'
else
@@ -1090,7 +1059,7 @@ function! s:process_tag_h(line, id)
let h_text = s:process_inline_tags(h_text, a:id)
let line = h_part.h_text.'</a></h'.h_level.'></div>'
let line = h_part.h_text.'</h'.h_level.'></div>'
let processed = 1
endif
@@ -1394,57 +1363,61 @@ endfunction
function! s:use_custom_wiki2html()
let custom_wiki2html = vimwiki#vars#get_wikilocal('custom_wiki2html')
return !empty(custom_wiki2html) &&
\ (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html))
return vimwiki#path#is_executable(custom_wiki2html)
endfunction
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force)
call vimwiki#path#mkdir(a:path)
echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '.
\ a:force. ' '.
\ vimwiki#vars#get_wikilocal('syntax'). ' '.
\ strpart(vimwiki#vars#get_wikilocal('ext'), 1). ' '.
\ shellescape(a:path). ' '.
\ shellescape(a:wikifile). ' '.
\ shellescape(s:default_CSS_full_name(a:path)). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_path')) > 1 ?
\ shellescape(expand(vimwiki#vars#get_wikilocal('template_path'))) : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_default')) > 0 ?
\ vimwiki#vars#get_wikilocal('template_default') : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('template_ext')) > 0 ?
\ vimwiki#vars#get_wikilocal('template_ext') : '-'). ' '.
\ (len(vimwiki#vars#get_bufferlocal('subdir')) > 0 ?
\ shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '.
\ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ?
\ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-'))
function! s:call_custom_wiki2HTML(output_dir, wikifile, force)
call vimwiki#path#mkdir(a:output_dir)
let arguments = [
\ a:force,
\ vimwiki#vars#get_wikilocal('syntax'),
\ strpart(vimwiki#vars#get_wikilocal('ext'), 1),
\ vimwiki#path#to_string(a:output_dir),
\ vimwiki#path#to_string(a:wikifile),
\ vimwiki#path#to_string(s:default_CSS_full_name()),
\ vimwiki#path#to_string(vimwiki#vars#get_wikilocal('template_path')),
\ vimwiki#vars#get_wikilocal('template_default'),
\ vimwiki#vars#get_wikilocal('template_ext'),
\ vimwiki#path#to_string(s:path_from_subdir_to_root(a:output_dir)),
\ vimwiki#vars#get_wikilocal('custom_wiki2html_args')
\ ]
for i in range(len(arguments))
if arguments[i] =~# '\m^\s*$'
let arguments[i] = '-'
endif
let arguments[i] = shellescape(arguments[i])
endfor
echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '. join(arguments, ' '))
endfunction
function! s:convert_file(path_html, wikifile)
function! s:convert_file(wikifile)
let done = 0
let wikifile = fnamemodify(a:wikifile, ":p")
let path_html = expand(a:path_html).vimwiki#vars#get_bufferlocal('subdir')
let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
let html_file = s:corresponding_html_file(a:wikifile)
" the currently processed file name is needed when processing links
" yeah yeah, shame on me for using (quasi-) global variables
let s:current_wiki_file = wikifile
let s:current_html_file = path_html . htmlfile
let s:current_wiki_file = a:wikifile
let s:current_html_file = html_file
let output_dir = vimwiki#path#directory_of_file(html_file)
if s:use_custom_wiki2html()
let force = 1
call vimwiki#html#CustomWiki2HTML(path_html, wikifile, force)
call s:call_custom_wiki2HTML(output_dir, wikifile, force)
let done = 1
endif
if s:syntax_supported() && done == 0
let lsource = readfile(wikifile)
let lsource = readfile(vimwiki#path#to_string(a:wikifile))
let ldest = []
call vimwiki#path#mkdir(path_html)
call vimwiki#path#mkdir(output_dir)
" nohtml placeholder -- to skip html generation.
let nohtml = 0
@@ -1510,7 +1483,7 @@ function! s:convert_file(path_html, wikifile)
if nohtml
echon "\r"."%nohtml placeholder found"
return ''
return vimwiki#path#null_file()
endif
call s:remove_blank_lines(ldest)
@@ -1527,7 +1500,7 @@ function! s:convert_file(path_html, wikifile)
call s:close_tag_table(state.table, lines, state.header_ids)
call extend(ldest, lines)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
let title = s:process_title(placeholders, vimwiki#path#filename(a:wikifile))
let date = s:process_date(placeholders, strftime('%Y-%m-%d'))
let html_lines = s:get_html_template(template_name)
@@ -1536,10 +1509,9 @@ function! s:convert_file(path_html, wikifile)
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
call map(html_lines, 'substitute(v:val, "%date%", "'. date .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")')
\ s:path_from_subdir_to_root(output_dir) .'", "g")')
let css_name = expand(vimwiki#vars#get_wikilocal('css_name'))
let css_name = substitute(css_name, '\', '/', 'g')
let css_name = vimwiki#path#to_string(vimwiki#vars#get_wikilocal('css_name'))
call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")')
let enc = &fileencoding
@@ -1550,30 +1522,30 @@ function! s:convert_file(path_html, wikifile)
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
call writefile(html_lines, path_html.htmlfile)
call writefile(html_lines, vimwiki#path#to_string(html_file))
let done = 1
endif
if done == 0
echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax'
return ''
return vimwiki#path#null_file()
endif
return path_html.htmlfile
return html_file
endfunction
function! vimwiki#html#Wiki2HTML(path_html, wikifile)
let result = s:convert_file(a:path_html, a:wikifile)
if result != ''
call s:create_default_CSS(a:path_html)
function! vimwiki#html#Wiki2HTML(wikifile)
let result = s:convert_file(a:wikifile)
if !vimwiki#path#is_null(result)
call s:create_default_CSS()
endif
return result
endfunction
function! vimwiki#html#WikiAll2HTML(path_html)
function! vimwiki#html#WikiAll2HTML()
if !s:syntax_supported() && !s:use_custom_wiki2html()
echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax'
return
@@ -1589,76 +1561,45 @@ function! vimwiki#html#WikiAll2HTML(path_html)
endtry
let &eventignore = save_eventignore
let path_html = expand(a:path_html)
let path_html = vimwiki#vars#get_wikilocal('path_html')
call vimwiki#path#mkdir(path_html)
echomsg 'Vimwiki: Deleting non-wiki html files ...'
call s:delete_html_files(path_html)
call s:delete_html_files()
echomsg 'Vimwiki: Converting wiki to html files ...'
let setting_more = &more
setlocal nomore
" temporarily adjust current_subdir global state variable
let current_subdir = vimwiki#vars#get_bufferlocal('subdir')
let current_invsubdir = vimwiki#vars#get_bufferlocal('invsubdir')
let wikifiles = split(glob(vimwiki#vars#get_wikilocal('path').'**/*'.
\ vimwiki#vars#get_wikilocal('ext')), '\n')
let wikifiles = vimwiki#path#files_in_dir_recursive(vimwiki#vars#get_wikilocal('path'),
\ vimwiki#vars#get_wikilocal('ext'))
for wikifile in wikifiles
let wikifile = fnamemodify(wikifile, ":p")
" temporarily adjust 'subdir' and 'invsubdir' state variables
let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), wikifile)
call vimwiki#vars#set_bufferlocal('subdir', subdir)
call vimwiki#vars#set_bufferlocal('invsubdir', vimwiki#base#invsubdir(subdir))
if !s:is_html_uptodate(wikifile)
echomsg 'Vimwiki: Processing '.wikifile
call s:convert_file(path_html, wikifile)
echomsg 'Vimwiki: Processing '.vimwiki#path#to_string(wikifile)
call s:convert_file(wikifile)
else
echomsg 'Vimwiki: Skipping '.wikifile
echomsg 'Vimwiki: Skipping '.vimwiki#path#to_string(wikifile)
endif
endfor
" reset 'subdir' state variable
call vimwiki#vars#set_bufferlocal('subdir', current_subdir)
call vimwiki#vars#set_bufferlocal('invsubdir', current_invsubdir)
let created = s:create_default_CSS(path_html)
let created = s:create_default_CSS()
if created
echomsg 'Vimwiki: Default style.css has been created'
endif
echomsg 'Vimwiki: HTML exported to '.path_html
echomsg 'Vimwiki: HTML exported to '.vimwiki#path#to_string(path_html)
echomsg 'Vimwiki: Done!'
let &more = setting_more
endfunction
function! s:file_exists(fname)
return !empty(getftype(expand(a:fname)))
endfunction
function! s:binary_exists(fname)
return executable(expand(a:fname))
endfunction
function! s:get_wikifile_url(wikifile)
return vimwiki#vars#get_wikilocal('path_html') .
\ vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), a:wikifile).
\ fnamemodify(a:wikifile, ":t:r").'.html'
endfunction
function! vimwiki#html#PasteUrl(wikifile)
execute 'r !echo file://'.s:get_wikifile_url(a:wikifile)
execute 'r !echo file://'.s:corresponding_html_file(a:wikifile)
endfunction
function! vimwiki#html#CatUrl(wikifile)
execute '!echo file://'.s:get_wikifile_url(a:wikifile)
execute '!echo file://'.s:corresponding_html_file(a:wikifile)
endfunction
+275 -15
View File
@@ -49,13 +49,6 @@ function! vimwiki#path#path_norm(path)
endfunction
function! vimwiki#path#is_link_to_dir(link)
" Check if link is to a directory.
" It should be ended with \ or /.
return a:link =~# '\m[/\\]$'
endfunction
function! vimwiki#path#abs_path_of_link(link)
return vimwiki#path#normalize(expand("%:p:h").'/'.a:link)
endfunction
@@ -124,22 +117,21 @@ endfunction
" If the optional argument provided and nonzero,
" it will ask before creating a directory
" Returns: 1 iff directory exists or successfully created
function! vimwiki#path#mkdir(path, ...)
let path = expand(a:path)
function! vimwiki#path#mkdir(dir_obj, ...)
if path =~# '^scp:'
if a:dir_obj.protocoll ==# 'scp'
" we can not do much, so let's pretend everything is ok
return 1
endif
if isdirectory(path)
if vimwiki#path#exists(a:dir_obj)
return 1
else
if !exists("*mkdir")
return 0
endif
let path = vimwiki#path#chomp_slash(path)
let path = vimwiki#path#to_string(a:dir_obj)
if vimwiki#u#is_windows() && !empty(vimwiki#vars#get_global('w32_dir_enc'))
let path = iconv(path, &enc, vimwiki#vars#get_global('w32_dir_enc'))
endif
@@ -154,11 +146,11 @@ function! vimwiki#path#mkdir(path, ...)
endfunction
function! vimwiki#path#is_absolute(path)
function! vimwiki#path#is_absolute(path_string)
if vimwiki#u#is_windows()
return a:path =~? '\m^\a:'
return a:path_string =~? '\m^\a:'
else
return a:path =~# '\m^/\|\~/'
return a:path_string =~# '\m^/\|\~/'
endif
endfunction
@@ -181,3 +173,271 @@ else
endfunction
endif
"----------------------------------------------------------
" Path manipulation, i.e. functions which do stuff with the paths of (not necessarily existing) files
"----------------------------------------------------------
" The used data types are
"
" - directory object:
" - used for an absolute path to a directory
" - internally, it is a dictionary with the following entries:
" - 'protocoll' -- how to access the file. Supported are 'scp' or 'file'
" - 'is_unix' -- 1 if it's supposed to be a unix-like path
" - 'path' -- a list containing the directory names starting at the root
" - file object:
" - for an absolute path to a file
" - internally a list [dir_obj, file name]
" - file segment:
" - for a relative path to a file or a part of an absolute path
" - internally a list where the first element is a list of directory names and the second the
" file name
" - directory segment:
" - for a relative path to a directory or a part of an absolute path
" - internally a list of directory names
" create and return a file object from a string. It is assumed that the given
" path is absolute and points to a file (not a directory)
function! vimwiki#path#file_obj(filepath)
if a:filepath == ''
return vimwiki#path#null_file()
else
let filename = fnamemodify(a:filepath, ':p:t')
let path = fnamemodify(a:filepath, ':p:h')
return [vimwiki#path#dir_obj(path), filename]
endif
endfunction
function! vimwiki#path#null_file()
return []
endfunction
function! vimwiki#path#is_null(file)
return empty(a:file)
endfunction
" create and return a dir object from a string. The given path should be
" absolute and point to a directory.
function! vimwiki#path#dir_obj(dirpath)
if a:dirpath =~# '^scp:'
let dirpath = a:dirpath[4:]
let protocoll = 'scp'
else
let dirpath = resolve(fnamemodify(a:dirpath, ':p'))
let protocoll = 'file'
endif
let path = split(vimwiki#path#chomp_slash(dirpath), '\m[/\\]', 1)
let is_unix = dirpath[0] ==# '/'
let result = {
\ 'is_unix' : is_unix,
\ 'protocoll' : protocoll,
\ 'path' : path,
\}
return result
endfunction
" Assume it is not an absolute path
function! vimwiki#path#file_segment(path_segment)
let filename = fnamemodify(a:path_segment, ':t')
let path = fnamemodify(a:path_segment, ':h')
let path_list = (path ==# '.' ? [] : split(path, '\m[/\\]', 1))
return [path_list, filename]
endfunction
" Assume it is not an absolute path
function! vimwiki#path#dir_segment(path_segment)
return split(a:path_segment, '\m[/\\]', 1)
endfunction
function! vimwiki#path#extension(file_object)
return fnamemodify(a:file_object[1], ':e')
endfunction
function! vimwiki#path#set_extension(file_obj, new_ext)
let new_filename = vimwiki#path#filename_without_extension(a:file_obj) . '.' . a:new_ext
let a:file_obj[1] = new_filename
return a:file_obj
endfunction
function! vimwiki#path#filename_without_extension(file_object)
return fnamemodify(a:file_object[1], ':r')
endfunction
" Returns: the dir of the file object as dir object
function! vimwiki#path#directory_of_file(file_object)
return copy(a:file_object[0])
endfunction
" Returns: the file_obj's file name as a string
function! vimwiki#path#filename(file_object)
return a:file_object[1]
endfunction
" Returns: the dir_obj, file_obj, file segment or dir segment as string, ready
" to be used with the regular path handling functions in Vim
function! vimwiki#path#to_string(obj)
if type(a:obj) == 4 " dir object
let separator = a:obj.is_unix ? '/' : '\'
let address = join(dir_obj.path, separator) . separator
return address
elseif type(a:obj[0]) == 4 " file object
let dir_obj = type(a:obj) == 4 ? a:obj : a:obj[0]
let separator = a:obj[0].is_unix ? '/' : '\'
let address = join(a:obj[0].path, separator) . separator . a:obj[1]
return address
elseif type(a:obj[0]) == 3 " file segment
" XXX: what about the separator?
return join(a:obj[0], '/') . '/' . a:obj[1]
elseif type(a:obj[0]) == 1 " directory segment
return join(a:obj, '/') . '/'
else
call vimwiki#u#error('Invalid argument ' . string(a:obj))
endif
endfunction
" Returns: the given a:dir_obj with a:str appended to the dir name
function! vimwiki#path#append_to_dirname(dir_obj, str)
let a:dir_obj.path[-1] .= a:str
return a:dir_obj
endfunction
" Returns a file object made from a dir object plus a file semgent
function! vimwiki#path#join(dir_obj, file_segment)
let new_dir_object = copy(a:dir_obj)
let new_dir_object.path += a:file_segment[0]
return [new_dir_object, a:file_segment[1]]
endfunction
" Returns a dir object made from a dir object plus a dir semgent
function! vimwiki#path#join_dir(dir_path, dir_segment)
let new_dir_object = copy(a:dir_path)
let new_dir_object.path += a:dir_segment
return new_dir_object
endfunction
" returns the file segment fs, so that join(dir, fs) == file
" we just assume the file is somewhere in dir
function! vimwiki#path#subtract(dir_object, file_object)
let path_rest = a:file_object[0].path[len(a:dir_object.path):]
return [path_rest, file_object[1]]
endfunction
" Returns: the relative path from a:dir to a:file
" XXX wenn die beiden identisch sind, sollte . rauskommen
function! vimwiki#path#relpath(dir1_object, dir2_object)
let dir1_path = copy(a:dir1_object.path)
let dir2_path = copy(a:dir2_object.path)
let result_path = []
while (len(dir) > 0 && len(file) > 0) && vimwiki#path#is_equal(dir1_path[0], dir2_path[0])
call remove(dir1_path, 0)
call remove(dir2_path, 0)
endwhile
for segment in dir1_path
let result += ['..']
endfor
for segment in dir2_path
let result += [segment]
endfor
let result = {
\ 'is_unix' : a:dir1_object.is_unix,
\ 'protocoll' : a:dir1_object.protocoll,
\ 'path' : result_path,
\}
return result
endfunction
function! vimwiki#path#is_file_in_dir(file, dir)
let file_path_segments = a:file[0].path
let dir_path_segments = a:dir.path
if len(dir_path_segments) > len(file_path_segments)
return 0
endif
for i in range(len(a:dir.path))
if !vimwiki#path#is_equal(a:dir.path[i], file_path_segments[i])
return 0
endif
endfor
return 1
endfunction
"-----------------
" File manipulation, i.e. do stuff with actually existing files
"-----------------
function! vimwiki#path#current_file()
return vimwiki#path#file_obj(expand('%:p'))
endfunction
function! vimwiki#path#exists(object)
if type(a:object) == 4
return isdirectory(vimwiki#path#to_string(a:object))
else
if vimwiki#path#is_null(a:object)
return 0
endif
" glob() checks whether or not a file exists (readable or writable)
return glob(vimwiki#path#to_string(a:object)) != ''
endif
endfunction
function! vimwiki#path#is_executable(file)
return vimwiki#path#exists(a:file) && executable(vimwiki#path#to_string(a:file))
endfunction
" this must be outside a function, because only outside a function <sfile> expands
" to the directory where this file is in
let s:vimwiki_autoload_dir = expand('<sfile>:p:h')
function! vimwiki#path#find_autoload_file(filename)
let autoload_dir = vimwiki#path#dir_obj(s:vimwiki_autoload_dir)
let filename_obj = vimwiki#path#file_segment(a:filename)
let file = vimwiki#path#join(autoload_dir, filename_obj)
if !vimwiki#path#exists(file)
echom 'Vimwiki Error: ' . vimwiki#path#to_string(file) . ' not found'
endif
return file
endfunction
function! vimwiki#path#copy_file(file_obj, dir_obj)
call vimwiki#path#mkdir(a:dir_obj)
let new_file = deepcopy(a:file_obj)
let new_file[0] = copy(a:dir_obj)
let lines = readfile(vimwiki#path#to_string(a:file_obj))
let ok = writefile(lines, vimwiki#path#to_string(new_file))
if ok < 0
call vimwiki#u#error('Could not write ' . vimwiki#path#to_string(new_file))
endif
endfunction
" Returns: a list of all files somewhere in a:dir_obj with extension a:ext
function! vimwiki#path#files_in_dir_recursive(dir_obj, ext)
let separator = a:dir_obj.is_unix ? '/' : '\'
let glob_expression = vimwiki#path#to_string(a:dir_obj) . '**' . separator . '*.' . a:ext
let file_strings = split(glob(glob_expression), '\n')
return map(file_strings, 'vimwiki#path#file_obj(v:val)')
endfunction
-1
View File
@@ -25,7 +25,6 @@ del {text-decoration: line-through; color: #777777;}
.justcenter {text-align: center;}
.center {margin-left: auto; margin-right: auto;}
.tag {background-color: #eeeeee; font-family: monospace; padding: 2px;}
.header a {text-decoration: none; color: inherit;}
/* classes for items of todo lists */
.rejected {
+14 -8
View File
@@ -31,7 +31,7 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files)
let all_files = a:all_files != ''
if !a:full_rebuild
" Updating for one page (current)
let page_name = vimwiki#vars#get_bufferlocal('subdir') . expand('%:t:r')
let page_name = s:page_name(vimwiki#path#current_file())
" Collect tags in current file
let tags = s:scan_tags(getline(1, '$'), page_name)
" Load metadata file
@@ -44,13 +44,12 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files)
call s:write_tags_metadata(metadata)
else " full rebuild
let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0)
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
let tags_file_last_modification = getftime(vimwiki#tags#metadata_file_path())
let tags_file_last_modification =
\ getftime(vimwiki#path#to_string(vimwiki#tags#metadata_file_path()))
let metadata = s:load_tags_metadata()
for file in files
if all_files || getftime(file) >= tags_file_last_modification
let subdir = vimwiki#base#subdir(wiki_base_dir, file)
let page_name = subdir . fnamemodify(file, ':t:r')
if all_files || getftime(vimwiki#path#to_string(file)) >= tags_file_last_modification
let page_name = s:page_name(file)
let tags = s:scan_tags(readfile(file), page_name)
let metadata = s:remove_page_from_tags(metadata, page_name)
let metadata = s:merge_tags(metadata, page_name, tags)
@@ -61,6 +60,13 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files)
endfunction
function! s:page_name(file_obj)
let wiki_base_dir = vimwiki#vars#get_wikilocal('path')
let segment = vimwiki#path#subtract(wiki_base_dir, a:file_obj)
return vimwiki#path#to_string(segment)
endfunction
" Scans the list of text lines (argument) and produces tags metadata as a list of tag entries.
function! s:scan_tags(lines, page_name)
@@ -142,8 +148,8 @@ endfunction
" Returns tags metadata file path
function! vimwiki#tags#metadata_file_path() abort
return fnamemodify(vimwiki#path#join_path(vimwiki#vars#get_wikilocal('path'),
\ s:TAGS_METADATA_FILE_NAME), ':p')
return vimwiki#path#join(vimwiki#vars#get_wikilocal('path'),
\ vimwiki#path#file_segment(s:TAGS_METADATA_FILE_NAME))
endfunction
+4
View File
@@ -70,3 +70,7 @@ else
endfunc
endif
function vimwiki#u#error(message)
echom 'Vimwiki Error: ' . a:message
endfunction
+25 -15
View File
@@ -85,8 +85,8 @@ function! s:populate_global_variables()
" this regexp defines what can form a link when the user presses <CR> in the
" buffer (and not on a link) to create a link
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
" non-Ascii characters, except that . is not accepted as the last character
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]*[^[:blank:]!"$%&''()*+.,:;<=>?\[\]\\^`{}]'
" non-Ascii characters
let g:vimwiki_global_vars.rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
let g:vimwiki_global_vars.rx_wikilink_prefix1 = g:vimwiki_global_vars.rx_wikilink_prefix .
\ g:vimwiki_global_vars.rxWikiLinkUrl . g:vimwiki_global_vars.rx_wikilink_separator
@@ -222,6 +222,9 @@ endfunction
function! s:normalize_global_settings()
let g:vimwiki_global_vars.dir_link =
\ vimwiki#path#file_segment(g:vimwiki_global_vars.dir_link)
let keys = keys(g:vimwiki_global_vars.ext2syntax)
for ext in keys
" ensure the file extensions in ext2syntax start with a dot
@@ -235,6 +238,13 @@ function! s:normalize_global_settings()
let g:vimwiki_global_vars.ext2syntax[ext] = 'media'
endif
endfor
let new_user_htmls = []
for file_name in split(g:vimwiki_global_vars.user_htmls, ',')
let trimmed = vimwiki#u#trim(file_name)
call add(new_user_htmls, vimwiki#path#file_segment(trimmed))
endfor
let g:vimwiki_global_vars.user_htmls = new_user_htmls
endfunction
@@ -381,18 +391,23 @@ endfunction
function! s:normalize_wikilocal_settings()
for wiki_settings in g:vimwiki_wikilocal_vars
let wiki_settings['path'] = s:normalize_path(wiki_settings['path'])
let wiki_settings.css_name = vimwiki#path#file_segment(wiki_settings.css_name)
let wiki_settings.custom_wiki2html = vimwiki#path#file_object(wiki_settings.custom_wiki2html)
let wiki_settings['path'] = vimwiki#path#dir_obj(wiki_settings['path'])
let path_html = wiki_settings['path_html']
if !empty(path_html)
let wiki_settings['path_html'] = s:normalize_path(path_html)
let wiki_settings['path_html'] = vimwiki#path#dir_obj(path_html)
else
let wiki_settings['path_html'] = s:normalize_path(
\ substitute(wiki_settings['path'], '[/\\]\+$', '', '').'_html/')
let wiki_settings['path_html'] = vimwiki#path#append_to_dirname(wiki_settings['path'],
\ '_html')
endif
let wiki_settings['template_path'] = s:normalize_path(wiki_settings['template_path'])
let wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path'])
let wiki_settings['template_path'] = vimwiki#path#dir_obj(wiki_settings['template_path'])
let wiki_settings['diary_path'] = vimwiki#path#join_dir(wiki_settings['path'],
\ vimwiki#path#dir_segment(wiki_settings['diary_rel_path']))
let ext = wiki_settings['ext']
if !empty(ext) && ext[0] != '.'
@@ -774,15 +789,10 @@ function! vimwiki#vars#get_bufferlocal(key, ...)
if type(value) != 1 || value !=# '/\/\'
return value
elseif a:key ==# 'wiki_nr'
call setbufvar(buffer, 'vimwiki_wiki_nr', vimwiki#base#find_wiki(expand('%:p')))
elseif a:key ==# 'subdir'
call setbufvar(buffer, 'vimwiki_subdir', vimwiki#base#current_subdir())
elseif a:key ==# 'invsubdir'
let subdir = vimwiki#vars#get_bufferlocal('subdir')
call setbufvar(buffer, 'vimwiki_invsubdir', vimwiki#base#invsubdir(subdir))
call setbufvar(buffer, 'vimwiki_wiki_nr', vimwiki#base#find_wiki(vimwiki#path#current_file()))
elseif a:key ==# 'existing_wikifiles'
call setbufvar(buffer, 'vimwiki_existing_wikifiles',
\ vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 1))
\ vimwiki#base#get_wikilinks(vimwiki#vars#get_bufferlocal('wiki_nr'), 0, 1))
elseif a:key ==# 'existing_wikidirs'
call setbufvar(buffer, 'vimwiki_existing_wikidirs',
\ vimwiki#base#get_wiki_directories(vimwiki#vars#get_bufferlocal('wiki_nr')))
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 KiB

+16 -45
View File
@@ -9,7 +9,7 @@
|___| |___| |_| |_||__| |__||___| |___| |_||___| ~
Version: 2.4.1
Version: 2.4
==============================================================================
CONTENTS *vimwiki*
@@ -707,7 +707,7 @@ Vimwiki file.
*:VimwikiGoto*
Goto link provided by an argument. For example: >
:VimwikiGoto HelloWorld
< opens/creates HelloWorld wiki page.
< opens opens/creates HelloWorld wiki page.
Supports |cmdline-completion| for link name.
@@ -1423,7 +1423,7 @@ Hit |zr| one more time :
Note: If you use the default Vimwiki syntax, folding on list items will work
properly only if all of them are indented using the current 'shiftwidth'.
For Markdown and MediaWiki syntax, * or # should be in the first column.
For MediaWiki syntax, * or # should be in the first column.
To turn folding on/off check |g:vimwiki_folding|.
@@ -2280,8 +2280,8 @@ local mappings |vimwiki_glstar|, |vimwiki_gl#| |vimwiki_gl-|, |vimwiki_gl-|,
|vimwiki_gl1|, |vimwiki_gla|, |vimwiki_glA|, |vimwiki_gli|, |vimwiki_glI| and
|vimwiki_i_<C-L>_<C-M>|.
Note: if you use Markdown or MediaWiki syntax, you probably would like to set
this option to 0, because every indented line is considered verbatim text.
Note: if you use MediaWiki syntax, you probably would like to set this option
to 0, because every indented line is considered verbatim text.
*vimwiki-option-auto_tags*
@@ -2321,7 +2321,7 @@ Global options are configured using the following pattern: >
Highlight headers with =Reddish=, ==Greenish==, ===Blueish=== colors.
Value Description~
1 Use VimwikiHeader1 - VimwikiHeader6 group colors to highlight
1 Use VimwikiHeader1-VimwikiHeader6 group colors to highlight
different header levels.
0 Use |hl-Title| color for headers.
Default: 0
@@ -2338,13 +2338,11 @@ Highlight checked list items with a special color:
Value Description~
0 Don't highlight anything.
1 Highlight only the first line of a checked [X] list item.
2 Highlight a complete checked list item and all its child items.
1 Highlight checked [X] list item with |group-name| "Comment".
2 Highlight checked [X] list item and all its child items.
Default: 0
The |group-name| "Comment" is used for highlighting.
Note: Option 2 does not work perfectly. Specifically, it might break if the
list item contains preformatted text or if you mix tabs and spaces for
indenting. Also, indented headers can be highlighted erroneously.
@@ -2550,11 +2548,11 @@ A second example handles a new scheme, "vfile:", which behaves similar to
return 0
endif
let link_infos = vimwiki#base#resolve_link(link)
if link_infos.filename == ''
if link_infos.is_file == -1
echomsg 'Vimwiki Error: Unable to resolve link!'
return 0
else
exe 'tabnew ' . fnameescape(link_infos.filename)
exe 'tabnew ' . fnameescape(vimwiki#path#to_string(link_infos.target))
return 1
endif
endfunction
@@ -2579,11 +2577,12 @@ right place. >
function! VimwikiLinkConverter(link, source_wiki_file, target_html_file)
if a:link =~# '^local:'
let link_infos = vimwiki#base#resolve_link(a:link)
let target_file = vimwiki#path#to_string(link_infos.target)
let html_link = vimwiki#path#relpath(
\ fnamemodify(a:source_wiki_file, ':h'), link_infos.filename)
\ fnamemodify(a:source_wiki_file, ':h'), target_file)
let relative_link =
\ fnamemodify(a:target_html_file, ':h') . '/' . html_link
call system('cp ' . fnameescape(link_infos.filename) .
call system('cp ' . fnameescape(target_file) .
\ ' ' . fnameescape(relative_link))
return html_link
endif
@@ -2959,7 +2958,7 @@ Contributors and their Github usernames in roughly chronological order:
- Daniel Trnka (@trnila)
- Yuchen Pei (@ycpei)
- @maqiv
- Dawid Ciężarkiewicz (@dpc)
- @dpc
- Drew Hays (@Dru89)
- Daniel Etrata (@danetrata)
- Keith Haber (@kjhaber)
@@ -2973,22 +2972,6 @@ Contributors and their Github usernames in roughly chronological order:
- Zhuang Ma (@mzlogin)
- Huy Le (@huynle)
- Nick Borden (@hcwndbyw)
- John Campbell (@johnmarcampbell)
- Petrus (@PetrusZ)
- Steven Stallion (@sstallion)
- Daniel Quomsieh (@DQuomsieh)
- Fredrik Arnerup (@farnerup)
- CUI Hao (@cuihaoleo)
- Benjamin Brandtner (@BenjaminBrandtner)
- @sreejith994
- Raphael Feng (@raphaelfeng)
- Kasper Socha (@fte10kso)
- Nicolas Brailovsky (@nicolasbrailo)
- @BenMcH
- Stefan Huber (@shuber2)
- Hugo Hörnquist (@HugoNikanor)
- Rane Brown (@ranebrown)
- @monkinco
==============================================================================
@@ -3001,13 +2984,7 @@ http://code.google.com/p/vimwiki/issues/list. They may be accessible from
https://github.com/vimwiki-backup/vimwiki/issues.
2.4.1 (2019-02-20)~
Fixed:
* Fix VimwikiShowVersion function.
* strikethrough `~` characters were not hidden within tables
* Update and format README.md and update screen shots
2.4 (2019-03-24)~
2.4 (not yet released)~
New:~
* Add the option |g:vimwiki_text_ignore_newline|.
@@ -3027,8 +3004,6 @@ New:~
* Add the %date placeholder, see |vimwiki-date|.
* Add the option |vimwiki-option-custom_wiki2html_args|.
* Add support for HTML-style comments when using markdown syntax.
* Made headings link to themselves in HTML output.
* Add |:VimwikiShowVersion| to check the version
Removed:~
* Remove the undocumented and buggy command :VimwikiReadLocalOptions
@@ -3053,10 +3028,6 @@ Fixed:~
* Opening the diary and wikis from the menu works correctly now.
* Issue #497: Make |:VimwikiMakeDiaryNote| work outside a wiki buffer.
* Use markdown syntax in the diary when appropriate.
* Improve handling of errors on opening files.
* Update links when renaming a page with |:VimwikiRenameLink|.
* Fix losing the highlighting in various situations.
* Improved link normalisation.
* Various other minor fixes.
@@ -3279,7 +3250,7 @@ http://code.google.com/p/vimwiki/issues/list
* Issue 210: HTML: para enclose header.
* Issue 214: External links containing Chinese characters get trimmed.
* Issue 218: Command to generate HTML file and open it in webbrowser. See
|:Vimwiki2HTMLBrowse|(bind to <Leader>whh)
|:Vimwiki2HTMLBrowse|(bind to <leader>whh)
* NEW: Added <Leader>wh mapping to call |:Vimwiki2HTML|
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 KiB

+20 -18
View File
@@ -19,7 +19,7 @@ endif
execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('ext')
setlocal isfname-=[,]
exe "setlocal tags+=" . escape(vimwiki#tags#metadata_file_path(), ' \|"')
exe "setlocal tags+=" . escape(vimwiki#path#to_string(vimwiki#tags#metadata_file_path()), ' \|"')
@@ -68,19 +68,22 @@ function! Complete_wikifiles(findstart, base)
if wikinumber >= vimwiki#vars#number_of_wikis()
return []
endif
let diary = 0
let prefix = matchstr(a:base, '\m^wiki\d\+:\zs.*')
let scheme = matchstr(a:base, '\m^wiki\d\+:\ze')
elseif a:base =~# '^diary:'
let wikinumber = -1
let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr')
let diary = 1
let prefix = matchstr(a:base, '^diary:\zs.*')
let scheme = matchstr(a:base, '^diary:\ze')
else " current wiki
let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr')
let diary = 0
let prefix = a:base
let scheme = ''
endif
let links = vimwiki#base#get_wikilinks(wikinumber, 1)
let links = vimwiki#base#get_wikilinks(wikinumber, diary, 1)
let result = []
for wikifile in links
if wikifile =~ '^'.vimwiki#u#escape(prefix)
@@ -93,9 +96,11 @@ function! Complete_wikifiles(findstart, base)
" we look for anchors in the given wikifile
let segments = split(a:base, '#', 1)
let given_wikifile = segments[0] == '' ? expand('%:t:r') : segments[0]
let given_wikifile = segments[0] == '' ?
\ vimwiki#path#filename_without_extension(vimwiki#path#current_file())
\ : segments[0]
let link_infos = vimwiki#base#resolve_link(given_wikifile.'#')
let wikifile = link_infos.filename
let wikifile = link_infos.target
let syntax = vimwiki#vars#get_wikilocal('syntax', link_infos.index)
let anchors = vimwiki#base#get_anchors(wikifile, syntax)
@@ -237,19 +242,18 @@ endfunction
command! -buffer Vimwiki2HTML
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))
\ let res = vimwiki#html#Wiki2HTML(vimwiki#path#current_file())
\ <bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '
\ . expand(vimwiki#vars#get_wikilocal('path_html')) | endif
\ if !vimwiki#path#is_null(res) | echo 'Vimwiki: HTML conversion is done, output: '
\ . vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path_html')) | endif
command! -buffer Vimwiki2HTMLBrowse
\ if filewritable(expand('%')) | silent noautocmd w | endif
\ <bar>
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
\ expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%')))
\ let result = vimwiki#html#Wiki2HTML(vimwiki#path#current_file())
\ <bar>
\ if !vimwiki#path#is_null(result) | call vimwiki#base#system_open_link(result) | endif
command! -buffer VimwikiAll2HTML
\ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('path_html')))
\ call vimwiki#html#WikiAll2HTML()
command! -buffer VimwikiTOC call vimwiki#base#table_of_contents(1)
@@ -272,10 +276,10 @@ command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
\ escape(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
\ escape(vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path')).'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
\ escape(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
\ escape(vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path')).'**/*'.vimwiki#vars#get_wikilocal('ext'), ' ')
command! -buffer -nargs=+ -complete=custom,vimwiki#base#complete_links_escaped
\ VimwikiGoto call vimwiki#base#goto(<f-args>)
@@ -677,9 +681,7 @@ nnoremap <silent><buffer> <Plug>VimwikiGoToPrevSiblingHeader :
if vimwiki#vars#get_wikilocal('auto_export')
" Automatically generate HTML on page write.
augroup vimwiki
au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
\ expand('%'))
au BufWritePost <buffer> call vimwiki#html#Wiki2HTML(vimwiki#path#current_file())
augroup END
endif
+6 -29
View File
@@ -9,11 +9,6 @@ if exists("g:loaded_vimwiki") || &cp
endif
let g:loaded_vimwiki = 1
" Set to version number for release, otherwise -1 for dev-branch
let s:plugin_vers = "2.4.1"
" Get the directory the script is installed in
let s:plugin_dir = expand('<sfile>:p:h:h')
let s:old_cpo = &cpo
set cpo&vim
@@ -44,8 +39,9 @@ endfunction
" create a new temporary wiki for the current buffer
function! s:create_temporary_wiki()
let path = expand('%:p:h')
let ext = '.'.expand('%:e')
let current_file = vimwiki#path#current_file()
let path = vimwiki#path#directory_of_file(current_file)
let ext = '.'.vimwiki#path#extension(current_file)
let syntax_mapping = vimwiki#vars#get_global('ext2syntax')
if has_key(syntax_mapping, ext)
@@ -188,28 +184,11 @@ function! s:set_windowlocal_options()
endif
if vimwiki#vars#get_global('auto_chdir')
exe 'lcd' vimwiki#vars#get_wikilocal('path')
exe 'lcd' vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path'))
endif
endfunction
function! s:get_version()
if s:plugin_vers != -1
echo "Stable version: " . string(s:plugin_vers)
else
let l:plugin_rev = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --short HEAD")
let l:plugin_branch = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --abbrev-ref HEAD")
let l:plugin_date = system("git --git-dir " . s:plugin_dir . "/.git show -s --format=%ci")
if v:shell_error == 0
echo "Branch: " . l:plugin_branch
echo "Revision: " . l:plugin_rev
echo "Date: " . l:plugin_date
else
echo "Unknown version"
endif
endif
endfunction
" Initialization of Vimwiki starts here. Make sure everything below does not
@@ -303,8 +282,6 @@ command! -count=1 VimwikiMakeTomorrowDiaryNote
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
command! VimwikiShowVersion call s:get_version()
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
@@ -362,8 +339,8 @@ nnoremap <unique><script> <Plug>VimwikiMakeTomorrowDiaryNote
function! s:build_menu(topmenu)
for idx in range(vimwiki#vars#number_of_wikis())
let norm_path = fnamemodify(vimwiki#vars#get_wikilocal('path', idx), ':h:t')
let norm_path = escape(norm_path, '\ \.')
let norm_path = vimwiki#path#to_string(vimwiki#vars#get_wikilocal('path', idx))
let norm_path = escape(norm_path, '\ .')
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
\ ' :call vimwiki#base#goto_index('.(idx+1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
+1 -1
View File
@@ -297,7 +297,7 @@ execute 'syntax match VimwikiItalicBoldT /'.vimwiki#vars#get_syntaxlocal('rxItal
execute 'syntax match VimwikiDelText /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /'.vimwiki#vars#get_syntaxlocal('rxDelText').
\ '/ contained contains=VimwikiDelTextCharT,@Spell'
\ '/ contained contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiSuperScript /'.vimwiki#vars#get_syntaxlocal('rxSuperScript').
\ '/ contains=VimwikiSuperScriptChar,@Spell'