agelessdummy / vimwiki

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

Default syntax always assumed when generating links #370

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create any link by pressing enter on a word or
2. ,w,i a diary
3. while vimwiki syntax is markdown

What is the expected output? What do you see instead?

I expect [TITLE](LINK), but I see [[LINK|TITLE]]. This is unrecognizable markup 
in markdown.

Original issue reported on code.google.com by vper...@gmail.com on 25 Aug 2012 at 10:04

GoogleCodeExporter commented 8 years ago
Yes, you're right.  Thanks for pointing this out.  I will look into a fix.

For the time being, you can type '+' when the cursor is on them.  I realize 
this is not a very practical solution, although it could get you started with a 
creative "hack" ...

- S.

Original comment by stu.andrews on 25 Aug 2012 at 4:53

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Here's my hack:

{{{
#!/usr/bin/python

# generate a markdown diary

import glob
import re
import os.path

files = glob.glob('*.md')
dates = []
diary_file_re = re.compile('(\d\d\d\d)\-(\d\d)\-(\d\d).md')

for f in sorted(files, reverse=True):
    m = diary_file_re.match(f)
    if m:
        date = dict( zip( ('file','year','month','day'), (f,)+m.groups() ) )
        dates.append( date )

pyear = 0
pmonth = 0
print "# Diary\n"
month_name=['bug','January','Febuary','March','April','May','June','July','Augus
t','September','October','November','December']

for date in dates:
    if date['year'] != pyear:
        print "##",date['year'],"\n"
        pyear = date['year']
        pmonth = 0
    if date['month'] != pmonth:
        print "###",month_name[ int(date['month']) ],"\n"
        pmonth = date['month']
    (basename,_) = os.path.splitext( date['file'] ) 
    print "[%s](%s)\n" % (basename,basename)

}}}

Original comment by 415...@gmail.com on 25 Nov 2012 at 6:11

GoogleCodeExporter commented 8 years ago
Here's one with a bit more noise which I guess would be a matter of taste.

{{{

#!/usr/bin/python

# generate a markdown diary

import glob
import re
import os.path

files = glob.glob('*.md')
dates = []
diary_file_re = re.compile('(\d\d\d\d)\-(\d\d)\-(\d\d).md')
markdown_heading_re = re.compile('^\s*\#+?\s+?(.*?)\#*?\s*?$',re.MULTILINE)

for f in sorted(files, reverse=True):
    m = diary_file_re.match(f)
    if m:
        date = dict( zip( ('file','year','month','day'), (f,)+m.groups() ) )
        dates.append( date )

pyear = 0
pmonth = 0
print "# Diary\n"
month_name=['bug','January','Febuary','March','April','May','June','July','Augus
t','September','October','November','December']

for date in dates:
    if date['year'] != pyear:
        print "##",date['year'],"\n"
        pyear = date['year']
        pmonth = 0
    if date['month'] != pmonth:
        print "###",month_name[ int(date['month']) ],"\n"
        pmonth = date['month']
    (basename,_) = os.path.splitext( date['file'] ) 
    print "#### [%s](%s)\n" % (basename,basename)

    f = open( date['file'] )
    s = f.read()
    f.close()
    for h in markdown_heading_re.findall( s ):
        print h,'\n'

}}}

Original comment by 415...@gmail.com on 25 Nov 2012 at 7:07