@@ -4,7 +4,7 @@ import { Clue, CrosswordJSON, CursorDirection, Position } from "xd-crossword-too
44export type PositionInfo =
55 | { type : "noop" }
66 | { type : "grid" ; position : Position ; clues : { across : Clue | undefined ; down : Clue | undefined } }
7- | { type : "clue" ; direction : CursorDirection ; number : number }
7+ | { type : "clue" ; direction : CursorDirection ; number : number ; lineMeta ?: { type : string ; value : string } }
88 | { type : "metadata" ; key : string ; value : string }
99
1010export const editorInfoAtCursor =
@@ -44,15 +44,24 @@ export const editorInfoAtCursor =
4444
4545 case "clues" : {
4646 const content = data . editorInfo . lines [ line ]
47- const trimmed = content . toLowerCase ( ) . trim ( )
47+ const trimmed = content . trim ( )
48+ const trimmedLower = trimmed . toLowerCase ( )
4849
49- if ( ! trimmed . startsWith ( "a" ) && ! trimmed . startsWith ( "d" ) ) return noop
50+ if ( ! trimmedLower . startsWith ( "a" ) && ! trimmedLower . startsWith ( "d" ) ) return noop
5051 if ( ! trimmed . includes ( "." ) && ! trimmed . includes ( "^" ) ) return noop
5152 if ( trimmed === "" ) return noop
5253
53- const direction = trimmed . startsWith ( "a" ) ? "across" : "down"
54- const numStr = trimmed . slice ( 1 ) . split ( " " ) [ 0 ] . replace ( "." , "" )
54+ const direction = trimmedLower . startsWith ( "a" ) ? "across" : "down"
55+ const numStr = trimmedLower . slice ( 1 ) . split ( " " ) [ 0 ] . replace ( "." , "" ) . replace ( "^ ", "" )
5556 const number = parseInt ( numStr )
57+
58+ // Check for clue metadata line (e.g., "A5 ^hint: Cell phone company...")
59+ const metaMatch = trimmed . match ( / ^ [ A D ] \d + \s + \^ ( \w + ) : \s * ( .* ) $ / i)
60+ if ( metaMatch ) {
61+ const lineMeta = { type : metaMatch [ 1 ] . toLowerCase ( ) , value : metaMatch [ 2 ] }
62+ return { type : "clue" , direction, number, lineMeta }
63+ }
64+
5665 return { type : "clue" , direction, number }
5766 }
5867
0 commit comments