llinfeng / Vim

0 stars 0 forks source link

冒昧问一下,vimviki中的“file”和“local”生成html时一直出问题,不知是何原因?可有解决方法? #2

Closed unix2012 closed 4 years ago

unix2012 commented 7 years ago

我是作图像链接,但是生成的图像路径总是不对。 ‘{{local:image/aa.jpg|aaa.jpg}} {{file:as.jpg|bbb.jpg}}‘ 生成的却是: ’aaa.jpg‘ ’bbb.jpg’‘ 我用的是vimwiki 2.3,它对vimrc和语法上有何特殊要求吗? 冒昧请教。谢谢。

llinfeng commented 7 years ago

啊,插入圖片的話 我不大會啊(輸入法變不回來了……)

你去問問 作者? @ https://github.com/vimwiki/vimwiki

llinfeng commented 7 years ago

你試試用絕對目錄(absolute path)試試? [[file:/home/somebody/a/b/c/music.mp3]] [[file:C:/Users/somebody/d/e/f/music.mp3]] [[file:~/a/b/c/music.mp3]] [[file:../assets/data.csv|Important Data]] [[local:C:/Users/somebody/d/e/f/music.mp3]] [[file:/home/user/documents/|Link to a directory]]

unix2012 commented 7 years ago

嗯,因为我一直用VIMVIKI做网页(用的是1.2),一切正常。但升级到2.3则图像出问题,一切都很好,唯独是这个local转换出问题。绝对路径对网站来说是无法使用的,因此焦点仍然是使用local转换成相对路径。折腾了好长时间,转换过来的图像路径中始终插入没有道理的路径参路。郁闷…… 问作者么,嘿嘿,我的英语不太好。没法儿去问…… 再次感谢您的回复。

llinfeng commented 7 years ago

啊,那你寫好我有空給你翻譯過去?

unix2012 commented 7 years ago

非常感谢!已写好如下(太长了,抱歉。我不是程序员,连菜鸟都不是,只是个爱好者……) `我的VIM配置是win10+VIM8.0+vimwiki2.3。 原来一直使用vimwiki 1.2版,链接和图像使用一切正常。 这次全新升级到vimwiki2.3。

我的目录结构是这样的: e: - web - hill - wiki (WIKI源文件)

图像路径:e:/web/hill/html/image/aa.jpg

问题:将wiki文件转换成网页时,其它一切皆正常,唯独本地图像显示不正确。

我的vimwiki配置如下(这是从1.2版留下的配置):

let g:vimwiki_list = [{'path': 'E:/web/hill/wiki', \ 'path_html': 'E:/web/hill/html/', \ 'template_path': 'E:/web/hill/template/', \ 'template_default': 'template', \ 'template_ext': '.html' \ 'diary_link_count': 12}]

set encoding=utf-8 " WIKI使用utf-8,模板中编码也要改 let g:vimwiki_w32_dir_enc = 'utf-8' set fenc=utf-8 "当设置下面一行时无论所打开文件是否为utf-8编码,保存时都会强制保存为utf-8格式 let g:vimwiki_camel_case = 0 " 对中文用户来说,我们并不怎么需要驼峰英文成为维基词条 let g:vimwiki_use_mouse = 1 " 启用鼠标 let g:vimwiki_hl_cb_checked = 0 " 标记为完成的 checklist 项目会有特别的颜色 let g:vimwiki_folding = 1 "是否开启按语法折叠 会让文件比较慢 let g:vimwiki_CJK_length = 1 "是否在计算字串长度时用特别考虑中文字符 let g:vimwiki_valid_html_tags='b,i,s,u,sub,sup,kbd,br,hr,div,del,code,red,center,left,right,h4,h5,h6,pre' map wd VimwikiDeleteLink "删除当前页 map wr VimwikiRenameLink "更改当前页的名称 map wq VimwikiToggleListItem "对[ ]中的选中切换 map :Calendar "WIKI日记 map :Vimwiki2HTML "单页生成html网页 map :VimwikiAll2HTML "全部生成html网页

我在wiki文件中输入的源码: {{file:e:/web/hill/html/image/aa.jpg|aaa.jpg}} {{local:image/aa.jpg|aaa.jpg}} 生成的html网页源码: aaa.jpg(file:正确) aaa.jpg(local:错误) 以file:使用的绝对目录图像显示正确,但是这个方法对做网站来说没有实际用处。应该是以local做的相对路径才对。 也就是说,以local:生成的图像路径多了「../E:/web/hill/wiki/」这一段,实在难以理解。 我设定的html路径是「'path_html': 'E:/web/hill/html/',」,而它却使用了wiki文件路径「'path': 'E:/web/hill/wiki',」。

后来又试着使用新的配置如下:

let wiki = {}
let g:vimwiki_list = [wiki]
let wiki.path = 'e:/web/hussar/wiki'
let wiki.nested_syntaxes = {'python': 'python', 'lisp': 'lisp'}

let g:vimwiki_list = [{'path': 'e:/web/hussar/wiki', \ 'path_html': 'E:/web/hussar/html/', \ 'template_path': 'E:/web/hussar/template/', \ 'template_default': 'template', \ 'template_ext': '.html'}]

结果效果更差,连file:的使用都出现错误,全部插入了“e:/web/hussar/wiki”的错误路径。 aaa.jpg(file:错误) aaa.jpg(local:错误)

个人猜想问题所在: 1、我的路径配置错误,路径可能设错了参数。 2、我使用的wiki语法错误。 3、再就是vimwiki转换时出现BUG。 ` 感谢朋友的热心。

llinfeng commented 7 years ago

却是好长,我期末之后 翻译?

unix2012 commented 7 years ago

嘿嘿,是呀是呀。 其实就是一句话,帮忙问问作者就行: 如何使用local?(配置如何?语法如何?)

llinfeng commented 7 years ago

你對圖像引用的話,不就該直接指向Wiki所在的目錄嗎?你想讓 圖片 從 另一個 HTML 的目錄 來 load,那就需要直接 把自己的 local 鏈接 指向過去?你做下面兩件事:

  1. 把 HTML的根目錄 跟 Wiki 的 根目錄 放在同一個 文件夾下面
  2. 用下面的例子定義 你的 local path: `[[local:../image/IMG_0252.JPG]]`

local_in_html

我感覺 local 的 用法就 是 相對於 你自己的 Wiki的根目錄來説的,但也説不準。

unix2012 commented 7 years ago

2.3版使用图像用的是{{}},不在用[[]]了,而且,不论我用何路径,生成的路径总是带着盘符: <img src="../E:/web/hill/wiki/image/aa.jpg" alt="aaa.jpg" /> 注意那个「../E:/web/hill/wiki」,这一小段路径全是错误的,而且是设定的wiki源文件路径而不是生成html的路径。 可能是很少有人使用图像,所以在网络上一直没有看到有人提。 原作者倒是一直在改BUG,只是外文太多看不懂。^-^ 我决定暂时还是用回原来的1.2吧,这个版就没有这个问题。 相比于1.2来说,2.3最好的地方是支持了锚点,令人割舍不下。啧。 —— 非常感谢,这几天让朋友你费心了。

llinfeng commented 7 years ago

啊,你自己的vim在Github上面 挂着吗? 我月底忙完期末之后可以再帮你看看?

2017-04-10 20:06 GMT-04:00 哥舒 notifications@github.com:

不论我用何路径,生成的路径总是带着盘符:

aaa.jpg

注意那个「../E:/web/hill/wiki」,这一小段路径全是错误的,而且是设定的wiki源文件路径而不是生成html的路径。 可能是很少有人使用图像,所以在网络上一直没有看到有人提。 原作者倒是一直在改BUG,只是外文太多看不懂。^-^ 我决定暂时还是用回原来的1.2吧,这个版就没有这个问题。 相比于1.2来说,2.3最好的地方是支持了锚点,令人割舍不下。啧。 —— 非常感谢,这几天让朋友你费心了。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/llinfeng/Vim/issues/2#issuecomment-293112802, or mute the thread https://github.com/notifications/unsubscribe-auth/AFnhZ7EGhyxv-NuFvNwRvb1A-ENqGz6qks5rusQUgaJpZM4M4Fzf .

-- Linfeng Li

Doctoral Student in the School of Information University of Michigan Phone: (+1)7346045530 Skype: llinfeng1900

llinfeng commented 7 years ago

啊,我Vimwiki的配置在這個repo的_vimrc裏面,從340行開始。然後我能看到 圖片 正常 載入啊。(上面是沒有任何 template的 HTML,下面的是對應的Wiki file) pic_good 你試試把我的settings 拿去?

unix2012 commented 7 years ago

郁闷之至!下载了你的配置文件,仍然如故。想不通问题出在哪里。 请问你的图片的绝对路径是多少??

llinfeng commented 7 years ago
unix2012 commented 7 years ago

我是用git下载下来的vimwiki文件覆盖安装的。可是我发现你的插件怎么只有一个在vimfiles\ftplugin下呢? 我的足有十三四个。

llinfeng commented 7 years ago

啊,我是用個“韓國人(?)”寫的 vim-plug來管理 plugin 的;有空我去update下這個repo的 installation guide。

unix2012 commented 7 years ago

面对这局面,嗯,很头疼——真是百思不得其解。

unix2012 commented 7 years ago

真快疯了,我将vimrc文件精简到只有这几条了,居然还不行。 " Vimwiki配置。 set encoding=utf-8 set fenc=utf-8 let g:vimwiki_w32_dir_enc = 'utf-8' let g:vimwiki_list = [{'path': 'E:/web/hussar/wiki', 'path_html': 'E:/web/hussar/html/'}] map :Vimwiki2HTML "单页生成html网页 map :VimwikiAll2HTML "全部生成html网页 始终是不变(包括使用你的配置) 源码:{{local:../html/image/aa.jpg|aa.jpg}} 结果:<img src="../E:/web/hussar/html/image/aa.jpg" alt="aa.jpg"/>` 始终多出来那个html文件路径。e:/web/hussar/ 唉,真想放弃2.3了,只是实在舍不得那个锚点功能。

llinfeng commented 7 years ago

你是说你整个_vimrc就剩这几行了?你机器的系统是啥?Windows?试试只留跟Vimwki相关的内容?

或者,你试着做一个 最简单的 能重复的 例子?然后我们去抱 作者 大腿?【作者大腿还是挺靠谱的,比我这儿回复都快……】

unix2012 commented 7 years ago

路径就是这些。 let g:vimwiki_list = [{'path': 'E:/web/hussar/wiki/', \ 'path_html': 'E:/web/hussar/html/', \ 'template_path': 'E:/web/hussar/template/', \ 'template_default': 'template', \ 'template_ext': '.html'}] 我怀疑local转换的地方出bug了。——但是你的转换却正常。 我估计是2.3的配置与1.2有不兼容的地方,但是我找不出来。 2.3版还有一个地方我很不舒服,就是在中文句子上一回车,整行就会生成一个wiki链接。也是难以理解的地方。

llinfeng commented 7 years ago

wiki链接是因为你在 normal mode里面 按回车的;insert mode 不会加 链接的;

现在看来 你可能需要从头安装个干净的Vim。

2017-04-17 10:46 GMT-04:00 哥舒 notifications@github.com:

路径就是这些。 let g:vimwiki_list = [{'path': 'E:/web/hussar/wiki/', \ 'path_html': 'E:/web/hussar/html/', \ 'template_path': 'E:/web/hussar/template/', \ 'template_default': 'template', \ 'template_ext': '.html'}] 我怀疑local转换的地方出bug了。——但是你的转换却正常。 我估计是2.3的配置与1.2有不兼容的地方,但是我找不出来。 2.3版还有一个地方我很不舒服,就是在中文句子上一回车,整行就会生成一个wiki链接。也是难以理解的地方。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/llinfeng/Vim/issues/2#issuecomment-294500440, or mute the thread https://github.com/notifications/unsubscribe-auth/AFnhZ4hghPpOZ4rBwBJ3YEFv4elss5ywks5rw3tggaJpZM4M4Fzf .

-- Linfeng Li

Doctoral Student in the School of Information University of Michigan Phone: (+1)7346045530 Skype: llinfeng1900

llinfeng commented 7 years ago

你这个 弄好了不/

2017-04-17 11:05 GMT-04:00 Linfeng Li llinfeng@umich.edu:

wiki链接是因为你在 normal mode里面 按回车的;insert mode 不会加 链接的;

现在看来 你可能需要从头安装个干净的Vim。

2017-04-17 10:46 GMT-04:00 哥舒 notifications@github.com:

路径就是这些。 let g:vimwiki_list = [{'path': 'E:/web/hussar/wiki/', \ 'path_html': 'E:/web/hussar/html/', \ 'template_path': 'E:/web/hussar/template/', \ 'template_default': 'template', \ 'template_ext': '.html'}] 我怀疑local转换的地方出bug了。——但是你的转换却正常。 我估计是2.3的配置与1.2有不兼容的地方,但是我找不出来。 2.3版还有一个地方我很不舒服,就是在中文句子上一回车,整行就会生成一个wiki链接。也是难以理解的地方。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/llinfeng/Vim/issues/2#issuecomment-294500440, or mute the thread https://github.com/notifications/unsubscribe-auth/AFnhZ4hghPpOZ4rBwBJ3YEFv4elss5ywks5rw3tggaJpZM4M4Fzf .

-- Linfeng Li

Doctoral Student in the School of Information University of Michigan Phone: (+1)7346045530 <(734)%20604-5530> Skype: llinfeng1900

-- Linfeng Li

Doctoral Student in the School of Information University of Michigan Phone: (+1)7346045530 Skype: llinfeng1900