generated from obsidian-community/obsidian-preact-template
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug 18 and update mainfest (#20)
- Loading branch information
Showing
7 changed files
with
274 additions
and
48 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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import parse from "remark-parse"; | ||
import unified from "unified"; | ||
import { visit } from "unist-util-visit"; | ||
import { Node } from "unist"; | ||
import { Arguments } from "./types"; | ||
|
||
const parser = unified().use(parse); | ||
|
||
interface ButtonNode extends Node { | ||
lang: string; | ||
value: string; | ||
} | ||
|
||
interface Position { | ||
lineStart: number; | ||
lineEnd: number; | ||
} | ||
|
||
export const getButtonPosition = ( | ||
content: string, | ||
args: Arguments | ||
): Position => { | ||
const tree = parser.parse(content); | ||
const position = { lineStart: 0, lineEnd: 0 }; | ||
visit(tree, "code", (node: ButtonNode) => { | ||
if (node.lang === "button") { | ||
if (args && node.value.includes(args.name)) { | ||
position.lineStart = node.position.start.line - 1; | ||
position.lineEnd = node.position.end.line - 1; | ||
} | ||
} | ||
}); | ||
return position; | ||
}; |
Oops, something went wrong.