How do I convert bold markdown formatting to bold text INSIDE Spreadsheet Cells?

I have a spreadsheet with a bunch of text formatted like ** example ** (without the spaces). I want it to look like this ‘example’.

How do I convert it?

Regarding the specific problem of doing this for text portions inside Calc cells there is a “solution” followed by some comments here.
There I attached also some demos based on an example provided by the original questioner.
If you are familiar with macro programming, you can easily adapt one of the examples to your needs. If not: There isn’t a way by ready-made tools.
If you attach a realistic example, I may find (sooner or later) the time to adapt my solution to the use-case.

1 Like

The quote above is a very realistic example of Markdown markup. :smile:

2 Likes

Once in a while you are right. :laughing:

But whilst you just joked, I did the work. :angry: The few lines of code contained in the attached example did for me as requested. My feeling told me the run-time for all of Sheet2 was about 10 ms. (With the stopwatch it was then 7 s.)

disask92778applyMarkdowCommandsToCellContents.ods (114.4 KB)
Sorry! Above attachment contained erroneous code that was tinkered too hastily. I hope the new version is correct now.
disask92778applyMarkdowCommandsToCellContentsRectified.ods (120.1 KB)

:people_hugging:

1 Like

Hey thanks. I tried this and your previous one in your linked post, and it doesn’t really do it exactly. Words that are not bold get bolded with words that are bold. That’s ok though, I found a way to do it in Excel (even though I hate Microsoft).

Please upload your example with problematic words and we’ll look together. The ability to work with “rich” text in LO Calc is much higher than in Excel.

Very strange to me. Can you (@Frederico2) please do as always is recommended in such cases and eventually attach an example sheet showing the actual situation. Otherwise this gets stabbing in the dark.
You may have noticed that I took the time to create a relevant example. That’s also expected from questioners.

wlx **this** emohuhx **is** tcvrjofcdvftuh wixtffut kmkv sezpmru **test** lwmjgxgycwjjmvmu **another test** hgjghjj test**

After running the macro:

wlx this emohuhx is tcvrjofcdvftuhwixtffutkmkvsezpmru test lwmjgxgycwjjmvmu another test hgjghjj test**

Please see my response below.

I couldn’t see the “response below”, but I have to apologize.
The claimed solution above (contained in the attachment to my comment) was created too hastily as an adaptation of older code, and the necessary care was not taken.
I will now edit the comment containing the bad attachment, and replace it with a hopefully correct one.

Works fine, now!

Thanks!

Wrong solution (see comment below). My bad (I’ll need to go back to school to learn to read :slight_smile:). Thanks @ajlittoz.
Find All instances of \*\*(.+)\*\* (don’t close the Find and Replace dialog)
Style as Bold (
Strong Emphasis if do you work with styles)
~~Replace All with $1
imagen

If there are spaces and punctuation marks between the **, see the List of Regular Expressions~~

Unless I am wrong, this won’t work in Calc (see question tagging and explicit mention of a “spreadsheet”). In Calc, styles apply to an entire cell. You can’t apply variations (bold, italic, …) while the Find & Replace dialog is open and, anyway, the variation will be applied to the cell as a whole. I’m afraid the only solution is manual.

The questioner didn’t tell clearly if the markdown ranges are assured to always cover the complete cell content.
I’ve taken the liberty of assuming that’s not the case and adjusting the headline accordingly.
Unfortunately the otherwise correct answer by @LeroyG looks a bit displaced now. Sorry.

1 Like