mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-01 11:18:24 +02:00
* feat: lazy match classic theme code block title * feat: allow single quotes for classic theme code block title * refactor(v2): extract parseCodeBlockTitle function extract `parseCodeBlockTitle` function to add tests for title parsing * test(v2): add tests for parseCodeBlockTitle * move code block title parser to theme-common Co-authored-by: slorber <lorber.sebastien@gmail.com>
12 lines
371 B
TypeScript
12 lines
371 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
const codeBlockTitleRegex = /title=(["'])(.*?)\1/;
|
|
|
|
export function parseCodeBlockTitle(metastring?: string): string {
|
|
return metastring?.match(codeBlockTitleRegex)?.[2] ?? '';
|
|
}
|