vimwiki-backup / vimwiki

Automatically exported from code.google.com/p/vimwiki
1 stars 1 forks source link

Closing parenthesis at the end of weblink not a part of that link #275

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enter a weblink ending in a parenthesis into a vimwiki page, e.g. 
"`https://en.wikipedia.org/wiki/John_Smith_(mathematician)`".
2. As per issue 96, vimwiki excludes the closing parenthesis from the weblink. 
This is perfectly OK.
3. Edit the weblink to add a description, e.g. change it to 
"`[https://en.wikipedia.org/wiki/John_Smith_(mathematician) John Smith]`". 
Vimwiki still excludes the closing parenthesis from the weblink. This is 
consistent, but inconvenient.

What is the expected output? What do you see instead?
In weblinks with descriptions, vimwiki should include everything up the 
whitespace that separates the weblink from the description into the weblink. 
However, now that issue 274 ("Weblinks using percent encoding do not work") has 
been fixed (thanks!), one can replace the closing parenthesis by "%29" as a 
workaround, and the current behavior can probably be kept. In that case, 
however, it would be nice if the workaround were mentioned somewhere in the 
documentation?

What version of the product are you using? On what operating system?
I am using Vimwiki 1.2 with Vim 7.2.330 under Lubuntu 10.10. (Lubuntu is a 
Ubuntu-based Linux distribution.)

Original issue reported on code.google.com by jtbergem...@yahoo.de on 27 Jan 2012 at 8:21

GoogleCodeExporter commented 9 years ago
That is an exceedingly polite report. Your example is a clear demonstration 
that the "fix" to issue 96 was not the best, there are (or soon going to be) 
millions of links with disambiguation. Why to URL-encode these very common 
links, when the fix to issue 96 is obvious: pressing the space bar (before 
typing the parenthesis that is not a part of the link).

* http://en.wikipedia.org/wiki/Vim_(text_editor)
* http://en.wikipedia.org/wiki/Vim_(text_editor), 
* http://en.wikipedia.org/wiki/Vim_(text_editor); 
* http://en.wikipedia.org/wiki/Vim_(text_editor). 
* http://en.wikipedia.org/wiki/Vim_(text_editor)! 
* http://en.wikipedia.org/wiki/Vim_(text_editor)?
None of them convert to a working link in HTML. As you very kindly say, this is 
consistent, but inconvenient. 

# http://en.wikipedia.org/wiki/Vim,     http://en.wikipedia.org/wiki/Vim;    
http://en.wikipedia.org/wiki/Vim.     http://en.wikipedia.org/wiki/Vim?     
http://en.wikipedia.org/wiki/Vim! 
This one is less consistent, three of them work, two don't.

I second your suggestion to improve the documentation, the URL-encoding trick 
is going to be necessary in same cases. It may be more suitable to put a link 
in the vimwiki docs, since it would take too much space to say something useful 
about URL encoding.

Original comment by tpospi...@gmail.com on 30 Jan 2012 at 5:47

GoogleCodeExporter commented 9 years ago
It is useful to have a test file for these web links. It seems 1.2 and current 
development version behave identically on this file. And there is another very 
inconvenient consistency, the unordered and the ordered lists in the first part 
of the file both merge into a single unordered list in HTML. But that has 
nothing to do with this issue of web links.

Original comment by tpospi...@gmail.com on 30 Jan 2012 at 6:21

Attachments:

GoogleCodeExporter commented 9 years ago
One can (sort of) have both correct handling of sensible links such as those 
from Wikipedia, and also automatic exclusion of punctuation and parentheses 
that (probably) do not belong to the link, even if there is no intervening 
space (that was the non-issue 96). Of course, it is not going to work all the 
time, but in simple cases it is OK.

The syntax highlighting is not OK, though (it shows the punctuation as part of 
the link), it is only the conversion to HTML that happens correctly. This seems 
to be Vim issue, not Vimwiki. One can see it on those lines that have many 
links (from line 11 in the file attached above), it is strangely inconsistent.

Anyway, instead of practicing URL-escapes, one could just patch manually the 
file plugin/vimwiki.vim because it is more or less one-line change. The problem 
is the regular expression would probably not survive unharmed the trip through 
this comment system... I'll try anyway.

Version 1.2, plugin/vimwiki.vim about line 317-318 (end of definition of 
g:vimwiki_rxWeblink)
looks like
{{{
      \'\+\S\+'.
      \'[().,?\]]\@<!'
}}}
needs to be changed to
{{{
     \'\S\S\{-}\%(([^ \t()]*)\)\=\ze[),;.!?]\=\%([ \t\]]\|$\)'
}}}
for a marked improvement in handling the links. As I wrote, the syntax 
highlighting is not behaving when there are several links on the same line. But 
that is not too bad, it will make people press the spacebar to separate the 
link from the text that follows, that is a much more robust solution. Colon is 
not autoexcluded, that would be confusing.

The attached file shows the improvement (but I also added some protocols, that 
is why so many things at the bottom show as "links", but those are not handled 
in any special way, so that is just a gimmick at the moment).

Original comment by tpospi...@gmail.com on 30 Jan 2012 at 7:05

Attachments:

GoogleCodeExporter commented 9 years ago
Super! I should resetup test environment and add your testlinks to it.

Should we close this issue?

Original comment by habamax on 2 Feb 2012 at 6:51

GoogleCodeExporter commented 9 years ago

Original comment by tpospi...@gmail.com on 3 Feb 2012 at 4:36