Skip to content

Commit

Permalink
🚧 biome: processors
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Dec 20, 2024
1 parent 4630c32 commit 3eec80f
Show file tree
Hide file tree
Showing 22 changed files with 467 additions and 486 deletions.
13 changes: 11 additions & 2 deletions src/@types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { PaneType } from 'obsidian';

export interface EmbeddedSlideParameters {
slide: string;
page?: number;
Expand Down Expand Up @@ -33,6 +31,15 @@ export interface SlidesExtendedSettings {
center: boolean;
}

export type ChartJsOptions = {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
elements?: any;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
plugins?: any;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
scales?: any;
};

export type Options = {
bg: string;
center: boolean;
Expand All @@ -55,6 +62,8 @@ export type Options = {
width: number;
enableCustomControls: boolean;
transition: string;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
[key: string]: any;
};

export interface MediaCollector {
Expand Down
2 changes: 1 addition & 1 deletion src/obsidian/processors/autoClosingProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class AutoClosingProcessor {
}

transformBlock(markdown: string) {
markdown = markdown.replaceAll(this.regex, `<$1></$2>`);
markdown = markdown.replaceAll(this.regex, "<$1></$2>");
return markdown;
}
}
2 changes: 1 addition & 1 deletion src/obsidian/processors/blockProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class BlockProcessor {
/:::\sblock\s*/g,
'<div class="block">\n\n',
);
markdown = markdown.replaceAll(':::', '</div>\n\n');
markdown = markdown.replaceAll(":::", "</div>\n\n");
return markdown;
}
}
185 changes: 92 additions & 93 deletions src/obsidian/processors/calloutProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ export class CalloutProcessor {
private regex = />\s?\[!([^\]]+)\]-* *(.*)/;

process(markdown: string) {
const lineArray = markdown.split('\n');
const lineArray = markdown.split("\n");
const outArray = [];

let startIdx = -1;
let add = true;
for (let i = 0; i < lineArray.length; i++) {
const line = lineArray[i];

if (line.trim().startsWith('>') && startIdx == -1) {
if (line.trim().startsWith(">") && startIdx === -1) {
startIdx = i;
add = false;
} else if (!line.trim().startsWith('>') && startIdx > -1) {
} else if (!line.trim().startsWith(">") && startIdx > -1) {
const content = this.transformBlock(lineArray, startIdx, i - 1);

for (let index = 0; index < content.length; index++) {
Expand All @@ -28,7 +28,7 @@ export class CalloutProcessor {
outArray.push(lineArray[i]);
}
}
return outArray.join('\n');
return outArray.join("\n");
}

transformBlock(lines: string[], start: number, end: number) {
Expand All @@ -44,28 +44,28 @@ export class CalloutProcessor {
result.push(`<div class="callout ${color}">`);
result.push('<div class="callout-title">');
result.push('<div class="callout-icon">');
result.push('');
result.push("");
result.push(icon);
result.push('');
result.push('</div>');
result.push("");
result.push("</div>");
result.push('<div class="callout-title-inner">');
result.push('');
result.push("");
result.push(title);
result.push('');
result.push('</div>');
result.push('</div>');
result.push("");
result.push("</div>");
result.push("</div>");

if (start != end) {
if (start !== end) {
result.push('<div class="callout-content">');
for (let i = start + 1; i <= end; i++) {
result.push('');
result.push("");
const line = lines[i].trim().substring(1).trim();
result.push(line);
}
result.push('');
result.push('</div>');
result.push("");
result.push("</div>");
}
result.push('</div>');
result.push("</div>");
} else {
for (let i = start; i <= end; i++) {
const line = lines[i];
Expand All @@ -79,97 +79,96 @@ export class CalloutProcessor {
const input = type.toLowerCase();

switch (input) {
case 'abstract':
case 'summary':
case 'tldr':
case 'info':
return 'callout-color1';
case 'todo':
case 'tip':
case 'hint':
case 'important':
return 'callout-color2';
case 'success':
case 'check':
case 'done':
return 'callout-color3';
case 'question':
case 'help':
case 'faq':
return 'callout-color4';
case 'warning':
case 'caution':
case 'attention':
return 'callout-color5';
case 'failure':
case 'fail':
case 'missing':
return 'callout-color6';
case 'danger':
case 'error':
case 'bug':
return 'callout-color7';
case 'example':
return 'callout-color8';
case 'quote':
case 'cite':
return 'callout-color9';
case "abstract":
case "summary":
case "tldr":
case "info":
return "callout-color1";
case "todo":
case "tip":
case "hint":
case "important":
return "callout-color2";
case "success":
case "check":
case "done":
return "callout-color3";
case "question":
case "help":
case "faq":
return "callout-color4";
case "warning":
case "caution":
case "attention":
return "callout-color5";
case "failure":
case "fail":
case "missing":
return "callout-color6";
case "danger":
case "error":
case "bug":
return "callout-color7";
case "example":
return "callout-color8";
case "quote":
case "cite":
return "callout-color9";
default:
return 'callout-color-default';
return "callout-color-default";
}
}
titleFrom(icon: string, titleLine: string): string {
if (titleLine) {
return titleLine;
} else {
return icon[0].toUpperCase() + icon.substring(1).toLowerCase();
}
return icon[0].toUpperCase() + icon.substring(1).toLowerCase();
}

iconFrom(type: string): string {
const input = type.toLowerCase();

switch (input) {
case 'abstract':
case 'summary':
case 'tldr':
return ':fas_clipboard-list:';
case 'info':
return ':fas_info-circle:';
case 'todo':
return ':fas_check-circle:';
case 'tip':
case 'hint':
case 'important':
return ':fas_fire-alt:';
case 'success':
case 'check':
case 'done':
return ':fas_check:';
case 'question':
case 'help':
case 'faq':
return ':fas_question-circle:';
case 'warning':
case 'caution':
case 'attention':
return ':fas_exclamation-triangle:';
case 'failure':
case 'fail':
case 'missing':
return ':fas_times:';
case 'danger':
case 'error':
return ':fas_bolt:';
case 'bug':
return ':fas_bug:';
case 'example':
return ':fas_list:';
case 'quote':
case 'cite':
return ':fas_quote-left:';
case "abstract":
case "summary":
case "tldr":
return ":fas_clipboard-list:";
case "info":
return ":fas_info-circle:";
case "todo":
return ":fas_check-circle:";
case "tip":
case "hint":
case "important":
return ":fas_fire-alt:";
case "success":
case "check":
case "done":
return ":fas_check:";
case "question":
case "help":
case "faq":
return ":fas_question-circle:";
case "warning":
case "caution":
case "attention":
return ":fas_exclamation-triangle:";
case "failure":
case "fail":
case "missing":
return ":fas_times:";
case "danger":
case "error":
return ":fas_bolt:";
case "bug":
return ":fas_bug:";
case "example":
return ":fas_list:";
case "quote":
case "cite":
return ":fas_quote-left:";
default:
return ':fas_pencil-alt:';
return ":fas_pencil-alt:";
}
}
}
Loading

0 comments on commit 3eec80f

Please sign in to comment.