SharePoint Markdown: Syntax Highlighting for Authors & Devs

In a world where AI prompts and automation snippets are becoming part of everyday work, dumping them as plain text on a SharePoint page just doesn’t cut it. You end up with messy, hard to read, and to scan. The changes that your well-crafted’recipes’ get lost on the pages are great.

SharePoint page with ai prompt as a block quote without syntax highlighting
One way to create standout ai prompt highlighting Using a block quite is the closest you can get

Syntax highlighting nowadays is not only something for developers. It can help everyone to highlight an AI prompt without any effort and apply extensive formatting in the rich text editor.

SharePoint Page with markdown code block
This visualisation creates a one of a kind standout content for an ai prompt

The good news. SharePoint syntax highlighting is an out-of-the-box feature. Ready to use. The SharePoint Markdown web part lets you write Markdown on modern pages and display code blocks with syntax highlighting (ideal for Copilot prompts, runbooks, and dev snippets). Let me explain how.

The better option than using a text web part

You can achieve the same goal with the rich text editor, but you’ll have to reformat the content again. Yes, there are options such as copying a web part instance multiple times on the page and just changing the content for each instance.

The overall process would be time-consuming because modern SharePoint has many authoring gaps. In the old days, I wrote a blog post on how to extend the functionality of the rich text editor, with features such as syntax highlighting.

As mentioned, there is one web part that provides syntax highlighting out of the box: the Markdown web part.

SharePoint Markdown web part with some content
The markdown web part in action with some basic functionalities

Once added to the page, you see a split view. The left side is your editor, the right side is the preview.

SharePoint Markdown fatures
Sharepoint markdown web part in action with usage tips in the web part properties

If you are not familiar with Markdown, it is a lightweight markup language for writing formatted documents, such as HTML pages. The example above shows some of the syntax Markdown provides.

To name a few syntax features:

  • #, ##, ## followed by text is for Heading 1 to Heading 3
  • [content](https://n8d.at) – For links

You will find the complete syntax in the web part properties, too.

Markdown web part is the right tool for the job
Search for markdown web part and add this web part instead

So it is basically a quick-to-type content editor of SharePoint.

How to Highlight Copilot and AI Prompts on SharePoint Pages

This web part also supports syntax highlighting for any code. To document a copilot prompt, for example, I can use this feature.

A code block is always encapsulated between ``` your text ```. These triple backticks mark the beginning of a code block.

code block added to the markdown content
Basic example of a code block showing the wrong highlights

When you use only those, you will end up with code highlighting, as in the text above. The colored text is there because the markdown editor tried to identify a programming language in the content I added.

To turn this off, I added a simple programming language. I like this code block rendered as HTML. Every content inside the code block will be rendered as text this way.

Ai prompt in a markdown web part
Triple backticks followed by html force to render the content as pure text

Now we have an easy-to-read prompt, and the dark background makes your AI prompt stand out. The final result will be a clean SharePoint page.

The content I pasted inside the code block was simply the following:


Create a high-quality image of [subject] in [environment], [action/pose]. Style: [photorealistic / illustration / anime / 3D / watercolor]. Lighting: [soft daylight / cinematic / neon]. Camera: [close-up / wide shot / 35mm]. Mood: [calm / dramatic / joyful]. Colors: [warm / cool / pastel]. Highly detailed, sharp focus.

The overall result looks like the example I highlighted in the beginning of this blog post.

SharePoint Page with markdown code block
This visualisation creates a on of a kind standout content for an ai prompt

Real code highlighting for developers

I know this scenario focuses more on the site authors and the owner, but rest assured. It can also highlight your regular code.

The developer focus Highlighted SPFx web part
There are a variety of options for devlopers available too

As in the example above, you can highlight the SharePoint Framework web part code.

Verdict

To overcome many of the limitations in SharePoint, sometimes you have to use the right tool for the job. Instead of spending hours creating a reusable, standout content block, sometimes the Markdown web part does a better job.

Sometimes I miss the days when organisations could extend SharePoint’s capabilities with simple tricks. Now we have to find new tricks to get the job done.

SharePoint help & how-tos

Markdown & formatting

Find more posts in the following categories

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.