Skip to content

fix(prism): highlight scss, vue directives and vue typescript - #4873

Merged
thetaPC merged 3 commits into
chore/docusaurus-configfrom
chore/highlight-scss
Nov 20, 2026
Merged

thetaPC merged 3 commits into
chore/docusaurus-configfrom
chore/highlight-scss

Conversation

@thetaPC

@thetaPC thetaPC commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Issue URL: N/A

What is the current behavior?

  • Prism doesn't load scss, so the 6 pages with ```scss blocks show them as plain text: Theming Advanced, High Contrast Mode, and Angular Virtual Scroll, in docs and v8.
  • The Vue grammar's rule for directives (v-if, :prop, @click) never runs, because the tag rule consumes attributes first, so directives look like plain attributes.
  • <script setup lang="ts"> blocks are highlighted as JavaScript, so type annotations stay uncolored.

What is the new behavior?

  • scss is added to additionalLanguages.
  • Directives are matched inside the tag and colored as keywords.
  • <script lang="ts"> blocks use the TypeScript grammar. A plain <script> stays JavaScript.
  • html blocks share the Vue grammar, so Vue code written as ```html gets the directive colors too. So do Angular template refs: #content, #swiper and #input on Angular Quickstart, Angular Slides and Managing Focus, in docs and v8.

Does this introduce a breaking change?

  • Yes
  • No

Other information

How to test

  1. Open the preview's Modifying CSS Color Variables section. Its SCSS block is highlighted, while on production it's plain text.
  2. Open the preview's Navigating using router-link section and compare it with production. The :router-animation directive uses the keyword color, while router-link keeps the attribute color.
  3. Open the preview's URL Parameters section and compare it with production. In defineProps<{ id: string }>(), string is highlighted as a type.

Stacked on #4867.

@thetaPC
thetaPC added this pull request to stack #4861 November 19, 2026 03:10
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-docs Ready Ready Preview Nov 20, 2026 12:18am UTC

Request Review

@brandyscarney brandyscarney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Nice improvement!

'inside',
'attr-name',
{
directive: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the bottom of this file sets Prism.languages.html = Prism.languages.markup = Prism.languages.vue, this rule also runs on every ```html block, not just ```vue. In practice, Angular template refs will now be colored as keywords:

  • docs/developing/managing-focus.mdx:187: <ion-input #input>
  • docs/angular/quickstart.mdx:315: <ion-content [fullscreen]="true" #content>
  • docs/angular/zoneless.mdx:113: <ion-popover #popover>

That's arguably an improvement, since template refs are framework syntax, but it's a visible change on Angular pages. Could you mention it in the description? If it's unwanted, the rule could go on a separate grammar for vue that html doesn't alias.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, added to the description. I kept it shared: 7 of the 10 html blocks it matches are Vue code, including the Vue Navigation sample in How to test, so a Vue-only grammar would drop their directive colors until they're converted to vue blocks. The zoneless one is unaffected, since that template is a string inside a ts block.

@thetaPC
thetaPC force-pushed the chore/highlight-scss branch from 50e8294 to e4e58d9 Compare November 20, 2026 00:17
@thetaPC
thetaPC merged commit f8cf9fb into main Nov 20, 2026
7 of 12 checks passed
@thetaPC
thetaPC deleted the chore/highlight-scss branch November 20, 2026 00:21

This branch was successfully deployed

1 active deployment
Preview — e4e58d9a Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants