mirror of
https://github.com/rabirabirara/obsidian-jelly-snippets.git
synced 2026-07-22 07:30:22 +00:00
feat: added newline as snippet divider
This commit is contained in:
parent
553b946db8
commit
f3d5309f44
1 changed files with 10 additions and 5 deletions
15
main.ts
15
main.ts
|
|
@ -142,13 +142,18 @@ export default class JellySnippets extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
parseSearchSnippets(): void {
|
parseSearchSnippets(): void {
|
||||||
|
// If they specified newline control character, split snippets by newline
|
||||||
|
let snippetDivider =
|
||||||
|
this.settings.snippetDivider == "\\n"
|
||||||
|
? "\n"
|
||||||
|
: this.settings.snippetDivider;
|
||||||
|
|
||||||
// go through the search snippets file, split by the snippet divider, split by the part divider, put in map
|
// go through the search snippets file, split by the snippet divider, split by the part divider, put in map
|
||||||
let snippetLines = this.settings.searchSnippetsFile.split(
|
let snippetLines =
|
||||||
this.settings.snippetDivider
|
this.settings.searchSnippetsFile.split(snippetDivider);
|
||||||
);
|
|
||||||
for (let snippet of snippetLines) {
|
for (let snippet of snippetLines) {
|
||||||
// trim() is used so that each snippet line does not retain newlines.
|
// trim() is used so that each snippet line does not retain newlines.
|
||||||
// TODO: Add the newline symbol for dividers.
|
// TODO: Again, control characters or semantic symbols in lhs.
|
||||||
let snippetParts = snippet
|
let snippetParts = snippet
|
||||||
.trim()
|
.trim()
|
||||||
.split(this.settings.snippetPartDivider);
|
.split(this.settings.snippetPartDivider);
|
||||||
|
|
@ -335,7 +340,7 @@ class JellySnippetsSettingTab extends PluginSettingTab {
|
||||||
new Setting(childEl)
|
new Setting(childEl)
|
||||||
.setName("Snippet line divider")
|
.setName("Snippet line divider")
|
||||||
.setDesc(
|
.setDesc(
|
||||||
"This string will divide each separate snippet definition."
|
"This string will divide each separate snippet definition. (Enter the two characters '\\n' to use newlines as your separator.)"
|
||||||
)
|
)
|
||||||
.addText((text) =>
|
.addText((text) =>
|
||||||
text
|
text
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue