Ticket #47 (new enhancement)

Opened 23 months ago

Patch to allow postprocessing of links

Reported by: maxm Owned by: deveiant
Priority: normal Milestone: Bugfixes
Component: API Version:
Severity: normal Keywords:
Cc:

Description

Hi, first up thanks a lot for BlueCloth, I always end up sneaking it into my projects somehow.

The attached patch allows passing a block to to_html which gets called for each url (references, inline links and inline images) to allow for easy postprocessing.

The main reason is that I don't want users to have to remember some obscure prefix path for creating links or images - I want to be able to say [Foo](SomeWikiPage?) in my markdown and turn that into /wiki/pages/some/other/stuff/SomeWikiPage.

Example usage:

BlueCloth.new(some_text) do |url|
  if !url=~/(https?|ftp|/.*)/
    '/wiki/'+url
  else
    url
  end
end

Attachments

link_callback_patch.diff (0.7 kB) - added by maxm 23 months ago.

Change History

Changed 23 months ago by maxm

Note: See TracTickets for help on using tickets.