# HG changeset patch # User constantine@gmail.com # Date 1381165363 -25200 # Node ID 5a8c3dda25ee136355fd54ea959fbb6350ee160f # Parent ade5266185db547798cc32d380ea6f17ec5cac4a Fix relative links rebase diff -r ade5266185db -r 5a8c3dda25ee ReadMe.markdown --- a/ReadMe.markdown Sun Oct 06 17:36:21 2013 +0700 +++ b/ReadMe.markdown Tue Oct 08 00:02:43 2013 +0700 @@ -13,6 +13,14 @@ [WikiLinks](http://packages.python.org/Markdown/extensions/wikilinks.html) extension to support documentation split across several pages. +You can add relative links to [nested](relative/doca.md) pages, or to current [headers](#config), +or even to images +_(actually at BitBucket relative links are +[broken](https://bitbucket.org/site/master/issue/6315/relative-urls-in-readmemd-files-only-work) +and you don't see logo, but hgext.markdown can do it :)_ + +![logo](relative/logo.png) + ##Install## 1. Install Python-Markdown (http://packages.python.org/Markdown/install.html) diff -r ade5266185db -r 5a8c3dda25ee __init__.py --- a/__init__.py Sun Oct 06 17:36:21 2013 +0700 +++ b/__init__.py Tue Oct 08 00:02:43 2013 +0700 @@ -80,7 +80,6 @@ f = req.form.get('file', [''])[0] parts = os.path.splitext(f) - if 'file' not in req.form: return webcommands.manifest(web, req, tmpl) @@ -100,8 +99,9 @@ if util.binary(text): return webcommands.rawfile(web, req, tmpl) - base_url = tmpl.defaults['url'] + 'file/' + changeid + "/" - base_raw_url = tmpl.defaults['url'] + 'rawfile/' + changeid + "/" + relative_path = os.path.split(f)[0] + base_url = tmpl.defaults['url'] + 'file/' + changeid + "/" + relative_path + base_raw_url = tmpl.defaults['url'] + 'rawfile/' + changeid + "/" + relative_path def rebase(proc, e, attr): uri = e.get(attr, '') @@ -113,7 +113,7 @@ e.set(attr, proc.rebase(base, uri)) ext = mdx_urlrebase.UrlRebaseExtension(configs=[('rebase', rebase)]) - md = markdown.Markdown( + md = Markdown( extensions=[ext, 'wikilinks','toc','headerid','attr_list'], extension_configs={ 'wikilinks' : [('base_url', ""), ('end_url', parts[-1])]}) diff -r ade5266185db -r 5a8c3dda25ee relative/doca.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relative/doca.md Tue Oct 08 00:02:43 2013 +0700 @@ -0,0 +1,4 @@ +#Relative links demo + +- [Sibling page B](docb.md) +- [Parent page](../ReadMe.markdown) \ No newline at end of file diff -r ade5266185db -r 5a8c3dda25ee relative/docb.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relative/docb.md Tue Oct 08 00:02:43 2013 +0700 @@ -0,0 +1,4 @@ +#Relative links demo + +- [Sibling page A](doca.md) +- [Parent page](../ReadMe.markdown) \ No newline at end of file diff -r ade5266185db -r 5a8c3dda25ee relative/logo.png Binary file relative/logo.png has changed