Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Can I exclude the extension when rendering links? (Read 886 times)
Pat Maddox
Full Member
*
Offline



Posts: 66

Can I exclude the extension when rendering links?
Feb 04th, 2016, 1:45pm
 
I'm trying to incrementally convert a jekyll site to use Tinderbox. For the time being, I want Tinderbox to generate the markdown files that jekyll uses.

I've managed to do it simply enough by making a prototype and HTML template combo that export the note text exactly as is. So far so good.

Now I want to use Tinderbox to link between notes, rather than my hard-coded links in the markdown.

I make a note...
I select some text in it...
I link it to another note...
I export the document as HTML...

And the link is "wrong" Tinderbox works as expected, but the link doesn't match what I need for it to work with jekyll.

The note that I'm linking to exports as mypage.md and Tinderbox naturally creates a link using <a href="mypage.md">. But I've got jekyll configured to use "pretty URLs", so when jekyll builds the markdown files it will produce mypage/index.html and so the link that I want Tinderbox to produce is <a href="mypage/"> (the web server will automatically pick up the index.html)

Is there a Tinderbox-native way to override the generated link to end in a "/" instead of the .md extension?

or do I have to process it using HTMLExportCommand?
Back to top
 
 
  IP Logged
Pat Maddox
Full Member
*
Offline



Posts: 66

Re: Can I exclude the extension when rendering links?
Reply #1 - Feb 4th, 2016, 2:24pm
 
I'm still curious to know if there's a Tinderbox-native way of doing this, but here's a Ruby script that does the trick:

Code:
require "nokogiri"

doc = Nokogiri::HTML::DocumentFragment.parse($stdin.read)

(doc / 'a')
 .each { |l| l[:href] = l[:href].gsub(/\.md$/, '/') }

puts doc.to_html
 

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Can I exclude the extension when rendering links?
Reply #2 - Feb 4th, 2016, 3:05pm
 
The extension of the exported file is stored in [http://www.acrobatfaq.com/atbref6/index/Attributes/SystemAttributeList/HTMLExportExtension.html]$HTMLExportExtension[/url]. The app default is '.html' but you can set it to '.md' (for all notes or just those affected) and it should fix the linkage problem.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pat Maddox
Full Member
*
Offline



Posts: 66

Re: Can I exclude the extension when rendering links?
Reply #3 - Feb 4th, 2016, 3:15pm
 
Yep I've done that. And it correctly produces a .md file on disk.

The problem that I want to address is that any generated links are now "wrong" because they link to the .md file - which ends up not existing once I run it through jekyll.

I want Tinderbox to export a .md file, but when it generates links it should drop the extension entirely.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Can I exclude the extension when rendering links?
Reply #4 - Feb 4th, 2016, 3:32pm
 
Tinderbox doesn't allow access into the link creation code. You'll need to process the extensions post export.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pat Maddox
Full Member
*
Offline



Posts: 66

Re: Can I exclude the extension when rendering links?
Reply #5 - Feb 4th, 2016, 3:33pm
 
Okie dokie Smiley
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print