Ticket #21 (assigned enhancement)
Extend BlueCloth with URL resolver
| Reported by: | Anders Engström <aengstrom@…> | Owned by: | deveiant |
|---|---|---|---|
| Priority: | normal | Milestone: | Markdown 1.0.1 |
| Component: | API | Version: | 0.0.4b |
| Severity: | normal | Keywords: | rfe url resolver non-markdown |
| Cc: |
Description (last modified by deveiant) (diff)
Hi.
I'm using BlueCloth to automate the generation of a website. I have a bunch of Markdown files (such as INDEX, README, INSTALL etc.) that I process with BlueCloth into a website (containing index.html, readme.html, install.html etc.).
I've extended BlueCloth (0.0.4b) with some code that allows me to plug in an external URL resolver for links that can not be resolved in the current document. This makes it easy for me to reference pages in my website without cluttering the Markdown text with links like [this][readme.html].
Instead I can put the following in my document:
some text with an un-resolved [link][README] that should point to the README document.
The above is transformed to:
some text with an un-resolved <a href="readme.html" title="Readme">link</a> that should point to the README document.
My extension to BlueCloth allows me to code something like:
class Resolver def resolve(link_id) if link_id == "readme" ["readme.html", "Readme"] #URL and Title else nil end end end parser = BlueCloth.new(some_text) parser.url_resolver = Resolver.new puts parser.to_html
Allowing users to extend BlueCloth with custom url-resolvers would be a nice feature IMO.
My modification of BlueCloth is pretty trivial - but let me know if you want me to send in the code as a patch :)
Best Regards //Anders
