My LinkedIn-ify Scripts
Sometimes I post my thoughts on LinkedIn, but I'm writing them in org-mode
, in
the comfort of my emacs configuration, honed over many years of twiddling
various options and adopting new packages.
org-mode
has many advantages, among which the ability to link to my other
notes, to link to external resources, to embed code snippets, etc.
Formatting on LinkedIn is very time consuming. As LinkedIn does not support rich
text, one must resort to using unicode tricks, such as using mathematical
monospace symbols to typeset code (codepoints 0x1D670
and above), or
mathematical bold symbols for headings (codepoints 0x1D400
and above).
This is not without issues, as the code is not copy-pastable, and it may cause issue with accessibility (but LinkedIn does not strike me as particularly accesible website anyway).
Then there's the issue of emojis, without which one can't write a proper LinkedIn post.
To solve both issues, I've written two scripts that I can chain in a pipeline.
The first is an example of what I alluded to when I wrote about using natural languages in UNIX pipelines: it concatenates its standard input with a prompt instructing the LLM to add emojis and preserve the org syntax, and prints the LLM's answer on standard output:
cat $PROMPTS/linkedin.org /dev/stdin <(echo '---EOF---'; echo) | \ ./llamafile-0.8.16 --model $MODELS/Qwen2.5-Coder-14B-Instruct-Q6_K_L.gguf \ -ngl 999 --temp 0 -f /dev/stdin --silent-prompt 2>/dev/null \ | grep -Ev '^---EOF---$'
The second script I wrote is a slow, buggy Python implementation of a
state-machine based parser for a subset of org-mode
. It parses links, code
blocks, and headings. Its output uses the unicode tricks mentioned above, and
regroup the links at the end, so that I can paste them in a comment.
So when I want to publish a note on LinkedIn, I go:
./Emojify.sh < my-file.org | ./LinkedInIfy.py | xclip -selection clipboard
And paste the result into a LinkedIn post, with very minimal tweaking required.
1. Changelog
Initial version