File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 44 extractLighterAnnotations ,
55 parseLighterAnnotations ,
66} from "./lighter"
7+ import { annotationsMap } from "../mdx-client/annotations"
8+
9+ const annotationNames = Object . keys ( annotationsMap )
710
811export async function splitCodeAndAnnotations (
912 rawCode : string ,
@@ -15,7 +18,11 @@ export async function splitCodeAndAnnotations(
1518 focus : string
1619} > {
1720 let { code, annotations } =
18- await extractLighterAnnotations ( rawCode , lang )
21+ await extractLighterAnnotations ( rawCode , lang , [
22+ ...annotationNames ,
23+ "from" ,
24+ "focus" ,
25+ ] )
1926
2027 // import external code if needed and re-run annotations extraction
2128 const fromAnnotations = annotations . filter (
@@ -29,10 +36,11 @@ export async function splitCodeAndAnnotations(
2936 config . filepath ,
3037 range
3138 )
32- // TODO remove 'from' annotation from the annotation names to avoid loops
39+
3340 const result = await extractLighterAnnotations (
3441 externalFileContent ,
35- lang
42+ lang ,
43+ [ ...annotationNames , "focus" ]
3644 )
3745 code = result . code
3846 annotations = result . annotations
Original file line number Diff line number Diff line change @@ -4,21 +4,16 @@ import {
44 Annotation ,
55 LANG_NAMES ,
66} from "@code-hike/lighter"
7- import { Code } from "utils"
8- import { annotationsMap } from "../mdx-client/annotations"
7+ import { Code } from "../utils"
98import { CodeAnnotation } from "../smooth-code"
9+ import { annotationsMap } from "../mdx-client/annotations"
1010
1111export type LighterAnnotation = Annotation
1212
13- const annotationNames = [
14- "focus" ,
15- "from" ,
16- ...Object . keys ( annotationsMap ) ,
17- ]
18-
1913export async function extractLighterAnnotations (
2014 codeWithAnnotations : string ,
21- lang : string
15+ lang : string ,
16+ annotationNames : string [ ]
2217) {
2318 return await extractAnnotations (
2419 codeWithAnnotations ,
You can’t perform that action at this time.
0 commit comments