[TxMt] markdown_to_help.rb image problem + a suggestion
Hans-Joerg Bibiko
bibiko at eva.mpg.de
Thu Nov 16 11:51:51 UTC 2006
Hi,
in the list I mentioned the problem that if you want to put images in
a help file written in markdown and using 'markdown_to_help.rb' for
formatting you will loose the reference for these images.
Allan mentioned to echo the base href in beforehand but then the
internal links generated by 'markdown_to_help.rb' don't work.
To solve this problem here my suggestion for an easy solution:
In your markdown file you write e.g.
![Hypersearch dialog](images/getall.png)
It is a relative path, so you can see the image with 'Show Web
Preview' while writing your markdown
In your command to display the help you can write:
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "Hypersearch Bundle Help" "Hypersearch"
"$TM_SUPPORT_PATH/lib/markdown_to_help.rb"
"$TM_BUNDLE_SUPPORT/help.markdown" | perl -npe
's/(.*?<img.*?src=")(.*?)(".*)/$1file:\/\/$ENV{"TM_BUNDLE_SUPPORT"}\/$2$3/gi'
html_footer
What I'm done here is to pipe the output of 'markdown_to_help.rb' to a
perl command which puts at the beginning of each relative path in src
within a img tag the absolute path 'file:///$TM_BUNDLE_SUPPORT/'.
This perl command, of course, could be also implemented within
'markdown_to_help.rb' or as TM wide standalone command written in
Ruby, Perl, or whatever (which I would prefer for speed).
Cheers,
Hans
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
More information about the textmate
mailing list