Skip to content

Commit

Permalink
add support for citatation template placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Akop Kesheshyan committed Feb 19, 2024
1 parent e24b1db commit ca7bc7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export default class BibTeXManager extends Plugin {
const generator = new CitationGenerator(this.settings.cslStyle, false);
await generator.createEngine();

// @ts-ignore
const text = parse(source)
// @ts-ignore
text.entries.forEach(async (entry: Entry) => {
generator.addCitation(entry);
})
Expand Down
12 changes: 9 additions & 3 deletions src/suggest/csl.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { TextInputSuggest } from "./suggest";
import { cslList, CSLItem } from "../utils";

export class CSLSuggest extends TextInputSuggest<string> {
export class CSLSuggest extends TextInputSuggest<CSLItem> {
getSuggestions(inputStr: string): CSLItem[] {
const lowerCaseInputStr = inputStr.toLowerCase();
const listItem = cslList.filter((item: CSLItem) => item.label.toLowerCase().contains(lowerCaseInputStr))
return listItem
const items: Array<CSLItem> = [];
const listItem = cslList.forEach((item: CSLItem) => {
if (item.label.toLowerCase().contains(lowerCaseInputStr)) {
items.push(item);
}
});

return items
}

renderSuggestion(item: CSLItem, el: HTMLElement): void {
Expand Down

0 comments on commit ca7bc7e

Please sign in to comment.