Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: markdown.highlightLanguages config does not take effect #1026

Closed
Timeless0911 opened this issue Apr 26, 2024 · 0 comments · Fixed by #1041
Closed

[Bug]: markdown.highlightLanguages config does not take effect #1026

Timeless0911 opened this issue Apr 26, 2024 · 0 comments · Fixed by #1041
Labels
🐞 bug Something isn't working 👏 PR welcome

Comments

@Timeless0911
Copy link
Collaborator

Timeless0911 commented Apr 26, 2024

Version

-

Details

In Rspress doc https://rspress.dev/api/config/config-build#markdownhighlightlanguages

Each language config supports both string and [string, string] formats. In the array format, the former is the alias of the language, and the latter is the full name of the language. You can go to the file list to view all supported language full names.

Here can be understood as we can configure aliases to map some unsupported languages to the languages supported by prism( etc ['mdx', 'tsx']), or we can also make an abbreviation for a certain language ( etc ['oc', 'objectivec'])

But now there should be some problems in existing implementation, below code block are not highlighted.

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSLog(@"Hello, Objective-C!");
    }
    return 0;
}
<Alert type="info">This is a info alert</Alert>

Reproduce link

https://github.com/web-infra-dev/rspress/tree/main/e2e/fixtures/basic

Reproduce Steps

  1. cd https://github.com/web-infra-dev/rspress/tree/main/e2e/fixtures/basic
  2. modify rspress.config.ts
import * as path from 'path';
import { defineConfig } from 'rspress/config';

export default defineConfig({
  root: path.join(__dirname, 'doc'),
  markdown: {
    highlightLanguages: [
      ['oc', 'objectivec'],
      ['mdx', 'tsx'],
    ],
  },
});

['mdx', 'tsx'] is the DEFAULT_HIGHLIGHT_LANGUAGES in

export const DEFAULT_HIGHLIGHT_LANGUAGES = [
['js', 'javascript'],
['ts', 'typescript'],
['jsx', 'tsx'],
'tsx',
'json',
'css',
'scss',
'less',
['xml', 'xml-doc'],
'diff',
'yaml',
['md', 'markdown'],
['mdx', 'tsx'],
'bash',
];

You can also try ['mdx', 'md'], may be also check whether there are any problems with the logic of merging and deduplication highlight languages.

  1. add some code blocks like below in index.mdx

image

(since github will transform the raw code, so screenshot here)

  1. run pnpm dev

  2. see if the code is highlighted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 👏 PR welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant