Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook to process links #12

Closed
evert opened this issue Nov 11, 2013 · 3 comments
Closed

Hook to process links #12

evert opened this issue Nov 11, 2013 · 3 comments

Comments

@evert
Copy link
Contributor

evert commented Nov 11, 2013

Hi!

I'm working on a static site generator with Ciconia.

I would like to automatically be able to process all the links in the markdown source, and prepend the link with a base url (if they are relative).

Ideally, I would also be able to automatically add .md to the resulting like.

To do this effectively, it would be awesome if it were somehow possible to add a callback that allows me to process and rewrite links... For example something like this:

$ciconia->setLinkHandler(function($in) {

   return $in . '.md';

});

But I would also settle with a simple baseUrl and let Ciconia do the heavy lifting :)

@kzykhys
Copy link
Owner

kzykhys commented Nov 12, 2013

Just pushed v0.1.5. Please see this gist.
This example shows how to use RendererInterface to control urls.


I'm planning to extend event system like this:

$ciconia->on('event_name', function () {});

For example

// find "@username" and turn it into url
$ciconia->addExtension(new UsernameMentionExtension());

// called from extension
$ciconia->on('username', function ($username) use ($ciconia) {
    // fetch user's url from twitter api (or github)
   $user = [];
   return $user['url'];
});
$ciconia->render('****');

i'm looking forward to your site generator, because I'm just looking for a jekyll alternative written in PHP!

@evert
Copy link
Contributor Author

evert commented Nov 12, 2013

Cool :) consider using https://github.com/fruux/sabre-event (my project) or https://github.com/igorw/evenement ;)

@kzykhys
Copy link
Owner

kzykhys commented Nov 27, 2013

Great projects :) Looks like more powerful than ciconia's event classes.

I'm going to create a new ticket for events. so closing it.

@kzykhys kzykhys closed this as completed Nov 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants