DEV Community

Alexey Melezhik
Alexey Melezhik

Posted on

Sparrow plugin to convert markdown to pdf

Hi! Sparrow is a wonderful framework allows you to do all sorts of automation. Recently I've released a couple of new plugins to convert markdown text to pdf.

This could be quite handy if you keep your CV in markdown format as me, and then want to convert it into pdf for recruiters.


Here is a simple example of Raku code:

.tom/markdown-to-pdf.pl6:

my %state =  task-run "readme html", "text-markdown", %(
  file => "README.md"
);

"README.html".IO.spurt(%state<html>);

say "<README.html> updated";

task-run "html-to-pdf", "weasyprint", %(
  in => "README.html",
  out => "Aleksei Melezhik CV.pdf"
);

say "<Aleksei Melezhik CV.pdf> updated";
Enter fullscreen mode Exit fullscreen mode

And how to run it:

[root@bdcaf22ac901 cv]# tom  markdown-to-pdf
[repository] :: index updated from file:///root/repo/api/v1/index
[readme html] :: convert README.md, write to /root/.sparrow6/tmp/698215/out.html
<README.html> updated
[html-to-pdf] :: stderr: ++ weasyprint README.html 'Aleksei Melezhik CV.pdf'
[html-to-pdf] :: <empty stdout>
<Aleksei Melezhik CV.pdf> updated
Enter fullscreen mode Exit fullscreen mode

The plugins require some CPAN and pip modules under the hood ( if one reads about Sparrow - it's super good in gluing things ), but an end user should not worry about that, the mentioned code should work as is, Sparrow will take care about dependencies.

I'd like users would tell me what they think about this tool.

Thanks

Alexey

Latest comments (0)