-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5878a79
commit da1c97a
Showing
26 changed files
with
497 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import type { Element, ElementContent, Root, RootContent } from "hast"; | ||
import { isPlainObject } from "@fern-api/ui-core-utils"; | ||
import type { Element } from "hast"; | ||
|
||
export function isHastElement( | ||
value: ElementContent | Element | Root | RootContent | null | undefined | ||
): value is Element { | ||
return value ? value.type === "element" : false; | ||
export function isHastElement(value: unknown): value is Element { | ||
return ( | ||
isPlainObject(value) && | ||
value.type === "element" && | ||
typeof value.tagName === "string" && | ||
isPlainObject(value.properties) && | ||
Array.isArray(value.children) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import type { Element, ElementContent, Root, RootContent, Text } from "hast"; | ||
import { isPlainObject } from "@fern-api/ui-core-utils"; | ||
import type { Text } from "hast"; | ||
|
||
export function isHastText( | ||
value: ElementContent | Element | Root | RootContent | null | undefined | ||
): value is Text { | ||
return value ? value.type === "text" : false; | ||
export function isHastText(value: unknown): value is Text { | ||
return ( | ||
isPlainObject(value) && | ||
value.type === "text" && | ||
typeof value.value === "string" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import type * as Hast from "hast"; | ||
import type * as Mdast from "mdast"; | ||
import { isPlainObject } from "@fern-api/ui-core-utils"; | ||
import type { MdxJsxElement, MdxJsxElementHast } from "../declarations"; | ||
|
||
export function isMdxJsxElement(node: Mdast.Node): node is MdxJsxElement { | ||
return node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement"; | ||
export function isMdxJsxElement(node: unknown): node is MdxJsxElement { | ||
if (isPlainObject(node) && typeof node.type === "string") { | ||
return ( | ||
(node.type === "mdxJsxFlowElement" || | ||
node.type === "mdxJsxTextElement") && | ||
Array.isArray(node.children) && | ||
Array.isArray(node.attributes) | ||
); | ||
} | ||
return false; | ||
} | ||
|
||
export function isMdxJsxElementHast( | ||
node: Hast.Node | ||
): node is MdxJsxElementHast { | ||
return node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement"; | ||
export function isMdxJsxElementHast(node: unknown): node is MdxJsxElementHast { | ||
// return node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement"; | ||
if (isPlainObject(node) && typeof node.type === "string") { | ||
return ( | ||
(node.type === "mdxJsxFlowElement" || | ||
node.type === "mdxJsxTextElement") && | ||
Array.isArray(node.children) && | ||
Array.isArray(node.attributes) | ||
); | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.