Closed GoogleCodeExporter closed 9 years ago
Depending on the custom markdown converter, you might not need to do anything.
Otherwise, you can simulate `[[Wikilinks]]` using markdown reference-style
links. To accomplish this, you need to do 3 things.
1. Make sure that the `[[Wikilinks]]` are in a reference-style format recognized by your chosen markdown converter, for example, by transforming each occurance of a `[[Wikilink]]` into (a) `[Wikilink]`, (b) `[Wikilink][]`, or (c) `[Wikilink][Wikilink]`. With markdown as the chosen syntax, you can simply type "+" with the cursor above the link to cycle between syntaxes.
2. Create a reference-style index of all of your wiki files, with suitable html target, e.g. `[Wikilink]: file:///path_html/Wikilink.html`. The following "make-index.sh" script does this in the constrained setting where all my pages are located at the root level. The input directory is the same as the wiki's path, and the output directory is the same as path_html. You will likely need to adjust the filtering performed by the recurring "grep -v" commands.
3. Concatenate the index file to the end of each markdown source file that is passed to your custom_wiki2html wrapper. In this way, for each `Wikilink` encountered, the converter will be able to retrieve the target address from the index.
HTH,
- S.
``` bash
# usage: make-index.sh <input-directory> <output-directory>
INPUTDIR=$1
OUTPUTDIR=$2
INDEX=$OUTPUTDIR/MkdIndex.md
# create new blank index
echo "" >| "$INDEX"
echo "" >> "$INDEX"
# get note names and reformat as markdown reformat links
# n.b. fwd-slash after DIR in case it is a link
find "$INPUTDIR/" -name "*[^\~]" -type "f" | \
grep -v "\.DS_Store" | \
grep -v "\..*.swp" | \
grep -v ".hg\/" | \
grep -v ".hgignore" | \
perl -p -e 's#.md$##' | \
perl -p -e "s#^$INPUTDIR/*##" | \
perl -p -e 's#^(.*)$#\[${1}\]: XX-XX-XX/${1}.html#' | \
perl -p -e "s#XX-XX-XX#file://$OUTPUTDIR#" >> "$INDEX"
Original comment by `stu.andrews` on 20 Jul 2012 at 5:33
Thanks for the quick explanation, Stu!
I did not know about the cycling with "+" (for I had always pressed it only
once to generate the links :-) This is very handy, I think it should be pointed
out in the helpfile as well.
I'm converting with Pandoc, which defines links as `[Wikilink](Wikilink.html)`.
I'll modify my ´vimwiki_markdown.vim´ accordingly to have them included in
the "+ cycle".
However -- can you name any markdown converters that define wikilinks as
[[Wikilink]]?
I haven't googled out any so far. I did try Discount (which, I guess, you
proposed somewhere) but that did not do the trick for me, at least not in WinXP
+ MinGW.
Thanks again!
M.
Original comment by martzirn...@gmail.com
on 20 Jul 2012 at 12:11
Re: my own question about Markdown converters reading [[Wikilinks]]:
Great news, Markdown for Python can do this:
http://freewisdom.org/projects/python-markdown/
http://freewisdom.org/projects/python-markdown/WikiLinks
And, as for all the other plugins, it appears to be an awesome tool! Had it
Pandoc's `[@academic-references]` support as well, I'd be sold entirely.
Cheers,
M.
Original comment by martzirn...@gmail.com
on 20 Jul 2012 at 1:15
Original comment by stu.andrews
on 26 Jul 2012 at 9:39
Original issue reported on code.google.com by
martzirn...@gmail.com
on 19 Jul 2012 at 4:27