DEV Community

Cover image for Script for converting Markdown with bold text to Unicode, retaining the bold text.
Le Vuong
Le Vuong

Posted on • Edited on

1

Script for converting Markdown with bold text to Unicode, retaining the bold text.

Hello developers,

Have you ever needed to convert Markdown text to a bold/italic text that you can post to Facebook, Instagram ?

Here’s how it works:

  1. It looks through text for any parts that are wrapped in **bold text**.
  2. Using regex, it breaks up each segment into "normal" and "bold" parts.
  3. Each letter in the bold section gets replaced with its corresponding Unicode "bold" version. For example, A becomes a Unicode-bold 𝐀, and a becomes 𝐚.
  4. Finally, it puts everything back together and gives you the bolded version of the whole text.

This script is perfect for converting text so that it looks bold across platforms that don’t directly support rich text formatting, like some messaging apps. Simple and effective!

Code snippet

Side Notes:

  • If you need to get the Html output of some formatted text, use CopyQ. Windows have similar "buffer" tools like Free Clipboard Viewer

  • VSCode have "Paste" extension that allows you to paste different format of the Clipboard content.

  • Also, for VSCode, you have extensions for converting Markdown to Html and vice verse.

  • Take a look at the code comment if you want to extent the script to process Italic or Bold and Italic text.

Sentry image

Make it make sense

Make sense of fixing your code with straight-forward application monitoring.

Start debugging →

Top comments (0)

Image of Datadog

Keep your GPUs in check

This cheatsheet shows how to use Datadog’s NVIDIA DCGM and Triton integrations to track GPU health, resource usage, and model performance—helping you optimize AI workloads and avoid hardware bottlenecks.

Get the Cheatsheet

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay