platform-bible-utils
    Preparing search index...

    Function collectUsjMarkers

    • Collects the distinct markers actually present in a USJ document.

      The scripture editor warns "Unexpected marker" for any marker in the USJ it doesn't recognize as a built-in USFM marker. Handbook/commentary resources use extra markers (e.g. pn, jmp, xtSee) that aren't built-ins, so a consumer can pass this document-derived set to the editor as options.nodes.extraValidMarkers to suppress those warnings — scoped to the resource actually being displayed, never a global list.

      The editor's isValidMarker is additive (a marker is valid if it is built-in OR listed in extraValidMarkers), so returning markers that are already built-in valid is a harmless no-op; callers therefore don't need the editor's internal built-in list (which it doesn't export) to compute a "delta". z-prefixed markers are omitted because the editor already treats every z... custom marker as unconditionally valid.

      Because this returns every marker the document uses, the editor will not warn about any marker in these panels — including genuine typos or bad data in the resource. That is an accepted trade-off: the warning is a logger.warn diagnostic (warn-and-continue; rendering is identical whether or not it fires), and these consumers are read-only resource viewers (isReadonly: true), not the editable authoring editor — so typo-catching still works where authors actually edit. Do not narrow this to an "extra-only" delta: that would require the editor's internal built-in marker lists, which it deliberately doesn't export, forcing either a re-coupling to the editor package or a duplicated list that drifts. Passing everything the document uses is the correct consequence of core not owning the editor's marker definitions.

      Parameters

      • usj: undefined | Usj

        The USJ document being displayed (e.g. the chapter USJ handed to the editor).

      Returns string[]

      The distinct non-z markers found anywhere in the document, in first-seen order. Empty when usj is undefined or contains no markers, so callers can omit the option (opt-in, no behavior change) for content that needs nothing extra.