Contributors to this thread:

one of the crystal programming language’s greatest strengths is the ease with which you can work with c apis and external libraries without leaving crystal. you can even implement callbacks in crystal!

in sqlite you can define new functions—callable from sql—with sqlite3_create_function by providing a name and a callback that implements the function. i created a new function called strip, entirely in crystal, that removes html markup and leaves text. it can be used in a sql query like so:

select * from objects
where strip(content) like "%term%"

it’s part of the recently released content filtering code.

#crystallang #ktistec

@toddsundsted This is incredible. I completely forgot we could pass procs to C functions that take function pointers, and then I remembered that the `XML` library does this, too, to talk to libxml2.

@jamie tbh honest, i didn't want to go this route because i thought it was going to be a huge pain, but it turned out to just work!