markedKatexExtension.ts ×5

Frontier kind: Code frontier

unlabeled · c_34e708bedd0d

38 tests · 5079 LOC · 28 files · introduces 0 tests · 77 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
7 ranges77 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
734 ranges5079 lines · 28 files · Browse complete extent
All tests (intent)
38 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 77 introduced LOC across 7 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/model/chatWordCounter.ts 47 introduced LOC · 2 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- chatWordCounter.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import * as markedKatexExtension from '../../../markdown/common/markedKatexExtension.js';
7 >
8 > export interface IWordCountResult {
9 > value: string;
10 > returnedWordCount: number;
11 > totalWordCount: number;
12 > isFullString: boolean;
13 > }
14 >
15 > const r = String.raw;
16 >
17 > /**
18 > * Matches `[text](link title?)` or `[text](<link> title?)`
19 > *
20 > * Taken from vscode-markdown-languageservice
21 > */
22 > const linkPattern =
23 > r`(?<!\\)` + // Must not start with escape
24 >
25 > // text
26 > r`(!?\[` + // open prefix match -->
27 > /**/r`(?:` +
28 > /*****/r`[^\[\]\\]|` + // Non-bracket chars, or...
29 > /*****/r`\\.|` + // Escaped char, or...
30 > /*****/r`\[[^\[\]]*\]` + // Matched bracket pair
31 > /**/r`)*` +
32 > r`\])` + // <-- close prefix match
33 >
34 > // Destination
35 > r`(\(\s*)` + // Pre href
36 > /**/r`(` +
37 > /*****/r`[^\s\(\)<](?:[^\s\(\)]|\([^\s\(\)]*?\))*|` + // Link without whitespace, or...
38 > /*****/r`<(?:\\[<>]|[^<>])+>` + // In angle brackets
39 > /**/r`)` +
40 >
41 > // Title
42 > /**/r`\s*(?:"[^"]*"|'[^']*'|\([^\(\)]*\))?\s*` +
43 > r`\)`;
44 >
45 > export function getNWords(str: string, numWordsToCount: number): IWordCountResult {
46 // This regex matches each word and skips over whitespace and separators. A word is:
47 // A markdown link
69 };
70 }
72 > export function countWords(str: string): number {
73 const result = getNWords(str, Number.MAX_SAFE_INTEGER);
74 return result.returnedWordCount;
src/vs/workbench/contrib/markdown/common/markedKatexExtension.ts 30 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- markedKatexExtension.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 > import type * as marked from '../../../../base/common/marked/marked.js';
6 > import { htmlAttributeEncodeValue } from '../../../../base/common/strings.js';
7 >
8 > export const mathInlineRegExp = /(?<![a-zA-Z0-9])(?<dollars>\${1,2})(?!\.|\(["'])((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\k<dollars>(?![a-zA-Z0-9])/; // Non-standard, but ensure opening $ is not preceded and closing $ is not followed by word/number characters, opening $ not followed by ., (", ('
9 > export const katexContainerClassName = 'vscode-katex-container';
10 > export const katexContainerLatexAttributeName = 'data-latex';
11 >
12 > const inlineRule = new RegExp('^' + mathInlineRegExp.source);
13 >
14 > export namespace MarkedKatexExtension {
15 > type KatexOptions = import('katex').KatexOptions;
16 >
17 > // From https://github.com/UziTech/marked-katex-extension/blob/main/src/index.js
18 > // From https://github.com/UziTech/marked-katex-extension/blob/main/src/index.js
19 > export interface MarkedKatexOptions extends KatexOptions { }
20 >
21 > const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
22 >
23 > export function extension(katex: typeof import('katex').default, options: MarkedKatexOptions = {}): marked.MarkedExtension {
24 return {
25 extensions: [
29 };
30 }
32 > function createRenderer(katex: typeof import('katex').default, options: MarkedKatexOptions, isBlock: boolean): marked.RendererExtensionFunction {
33 return (token: marked.Tokens.Generic) => {
34 let out: string;
50 };
51 }
53 > function inlineKatex(options: MarkedKatexOptions, renderer: marked.RendererExtensionFunction): marked.TokenizerAndRendererExtension {
54 const ruleReg = inlineRule;
55 return {
90 };
91 }
93 > function blockKatex(options: MarkedKatexOptions, renderer: marked.RendererExtensionFunction): marked.TokenizerAndRendererExtension {
94 return {
95 name: 'blockKatex',