Typeset integration

Typeset is an HTML pre-proces­sor for better web ty­pog­ra­phy. The library runs on the server using Node.js. How would you integrate this with Kirby?

You would need to create a simple Typeset CLI (a command line tool that gets passed the HTML code, calls typeset() on it and outputs the generated code back.
In Kirby, you can then use $html = System::execute('path_to_typeset_cli', array($html), 'output') to pass the code to the tool and get the pre-processed code back.

Thanks @lukasbestle!

Should I use it in a post filter? Something like:

kirbytext::$post[] = function($kirbytext, $value) {
  $html = System::execute('typeset_cli', array($value), 'output');
  return $html;
};

Or is there a better way to handle this?

Yes, that’s exactly how I would implement it.

1 Like