Conditional formatting in Writer, or how to automate a strikethrough

I’m writing a template document that has some fields from a database and the very common Mr./Mrs. text where one is supposed to strike the wrong one out. You may ask me why I don’t just add that as a field from the database too? Because the boss wants it that way. So the way I try to do it now is to print every document as a single document file and then edit them manually.

Is there a way to have a strikeout there applied if the field “gender” in the database is “f” or “m”?

I tried to trick it to do it with hidden texts and with conditional text, but in the conditional text I can’t seem to have the possibility to apply the formatting to only a portion of the text. It seems to be either all or nothing.

An approach to what you want would be using conditional text fields
https://books.libreoffice.org/en/WG252/WG2517-Fields.html#toc24

One possible solution is to somehow “mark” these fields (for example: {{m}}, {{f}}), and then run a macro that will make the necessary replacement.