Back

Copy Markdown to Teams

I write all my notes at work and also my private notes in Obsidian. I find that it works perfect for my personal workflow and helps me be more organized. When I work on a new project, I like to write out a detailed proposal that highlights a possible plan, any issues that might occur, and any open questions.

I find myself copying that text over to Teams so that my colleagues also have access to these notes. But when I copy the markdown that I have written in Obsidian, the formatting is not correctly copied over.

While Teams does support some markdown (you can use **something** to make some text bold) it does not work well when pasting markdown.

Other people have noticed this issue as well and there are some workarounds but none that really work for me. I just want to copy the markdown and paste it into Teams.

The best workaround I found was pasting the markdown into an editor that supports a rich text preview and the copying the rich text preview. This is quite annoying and I do not want to use any online tool because I do not want to paste possibly sensitive text into a website.

The Plan: Markdown to HTML to Teams

After some research, I found the following workflow that seems to work rather consistently and produce well formatted text:

  1. Copy the markdown from Obsidian.
  2. Translate the markdown into HTML using the markdown package in Python.
  3. Copying and pasting the HTML into Teams.

Teams knows how turn HTML into formatted text.

Nushell

To make this more convenient, I turned this into some shell script that takes the current clipboard content and converts it into html.

I use uv to invoke the CLI of the markdown package in Python. I then copy the output back into the clipboard.

Just put the following function into your nu config (config nu)

# convert markdown to html for Teams / other Microsoft products
def md2html [] {
    let markdown = (powershell -c "Get-Clipboard -Raw")
    let html = ($markdown | uvx --from markdown --with markdown python -m markdown -e utf8)
    $html | powershell -c "Set-Clipboard -AsHtml -Value $input"
}

Powershell

You can do the same thing in Powershell. Just put the following function into your powershell profile Microsoft.PowerShell_profile.ps1.

Function md2html {
    $OutputEncoding = [System.Text.Encoding]::UTF8
    $markdown = Get-Clipboard -Raw
    $html = $markdown | uvx --from markdown --with markdown python -m markdown -e utf8
    $html | Set-Clipboard -AsHtml
}

Creating a Shortcut (on Windows)

Right now, you will have to open a terminal and run md2html whenever you want to convert something, which is not the best UX.

On Windows, you can create a shortcut and assign a keyboard shortcut to it:

  1. Create a new Shortcut: Right-click on your Desktop (or in any other folder) and select New > Shortcut.

  2. Set the Target: In the “Type the location of the item” field, paste the following command. This command tells Windows to run PowerShell, hide its window, and then execute the function (which has to be in your powershell profile): powershell.exe -WindowStyle Hidden md2html.

  3. Name the Shortcut: Give it a clear name, like “Convert Markdown to HTML”, and click Finish.

  4. Assign a Hotkey:

    • Right-click on your newly created shortcut and select Properties.
    • Look for the Shortcut field. Click into the field.
    • Press the key combination you want to use, for example, Ctrl + Alt + M. Windows will automatically register it.
    • Click OK to save.

Your hotkey is now active system-wide. You can try it out and for a short moment, a Powershell console should open.

The New and Improved Usage

With the hotkey is active, the process is more user friendly:

  1. Copy the Markdown notes from Obsidian (Ctrl + C).
  2. Press your new global hotkey (Ctrl + Alt + M or whatever you chose).
  3. Click into the Teams message box and paste (Ctrl + V). The result should be perfectly formatted text in your Teams chat or channel post, without ever having to manually open a terminal or break your focus.