Skip to content

Commit 85e111c

Browse files
authored
Merge pull request #12 from decaf-dev/dev
1.1.1
2 parents ec6bb0d + f2e2050 commit 85e111c

File tree

7 files changed

+43
-36
lines changed

7 files changed

+43
-36
lines changed

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Obsidian Downloads](https://img.shields.io/badge/dynamic/json?logo=obsidian&color=%23483699&label=downloads&query=%24%5B%22note-splitter%22%5D.downloads&url=https%3A%2F%2Fraw.githubusercontent.com%2Fobsidianmd%2Fobsidian-releases%2Fmaster%2Fcommunity-plugin-stats.json)
44

5-
Note splitter is an [Obsidian.md](https://obsidian.md) plugin for desktop only. It allows you to split a single Obsidian note into many notes based on a specified sequence of characters (a delimiter). The default delimiter is a new line.
5+
Note splitter is an [Obsidian.md](https://obsidian.md) plugin for desktop only. It allows you to split a single note into many notes based on a specified sequence of characters (a delimiter).
66

77
## Table of contents
88

@@ -15,13 +15,13 @@ Note splitter is an [Obsidian.md](https://obsidian.md) plugin for desktop only.
1515

1616
## Videos
1717

18-
Splitting a note without changing any settings
18+
Split a note with default settings.
1919

2020
<video src="https://github.com/decaf-dev/obsidian-note-splitter/assets/40307803/b15117e8-a297-4353-b705-13e7713872ef" controls="controls" style="max-width: 100%;">
2121
Your browser does not support the video tag.
2222
</video>
2323

24-
Splitting a note with [Use content as title](#use-content-as-title) enabled
24+
Split a note with [use first line as title](#use-first-line-as-title) enabled.
2525

2626
<video src="https://github.com/decaf-dev/obsidian-note-splitter/assets/40307803/fe4edb7c-4f4d-4f3e-b1a8-a42cd2a23706" controls="controls" style="max-width: 100%;">
2727
Your browser does not support the video tag.
@@ -39,49 +39,55 @@ Splitting a note with [Use content as title](#use-content-as-title) enabled
3939

4040
## Usage
4141

42-
1. Open a note that you want to split
42+
1. Open the note that you want to split
4343
2. Switch to editing mode
4444
3. Open the Obsidian command palette
4545
4. Type **Split by delimiter**
4646
5. Press enter
47-
6. Your note is now split
47+
6. See split notes in the [output folder](#output-folder)
4848

4949
>[!NOTE]
50-
> Splitting a note will not modify the original note, unless the [delete original](#delete-original) setting is enabled. It will create new notes in an output folder that you specify.
50+
> Splitting a note does not modify the original note.
5151
5252
### Frontmatter
5353

54-
When splitting a note, this plugin will ignore frontmatter. Only the content after the frontmatter block will be split.
54+
When splitting a note, frontmater is ignored. Only content after the frontmatter block is split.
5555

5656
## Settings
5757

58-
### Folder path
58+
### Output folder
5959

60-
Folder to save the split notes to. The default is `note-splitter`.
60+
The folder to save split notes in. If empty, the folder of the original note will be used.
6161

62-
Setting this field to an empty string will save split notes to the same folder as the original note.
62+
> [!NOTE]
63+
> Default value is `note-splitter`
6364
6465
### Delimiter
6566

66-
The delimiter to split by can be configured in the plugin settings. The default delimiter is a new line `\n`.
67+
The sequence of characters to split by. When you split a note, the content before and after each delimiter will become new notes.
68+
69+
> [!NOTE]
70+
> Default value is a newline character `\n`
71+
72+
### Use first line as title
6773

68-
### Use content as title
74+
If enabled, the first line of split content will be used as the title of the split note. If the title already exists, the conflict will be indicated by naming the note as `Split conflict <random-uuid>`.
6975

70-
If enabled, use the first line of the split section as the name for new notes, handling any name collisions automatically. If disabled, a timestamp is used.
76+
If disabled, a timestamp will be used as the title e.g. `note-splitter-1702591910`.
7177

7278
> [!NOTE]
7379
> Disabled by default.
7480
7581
### Delete original
7682

77-
If enabled, the original note will be deleted after the split.
83+
If enabled, the original note will be deleted after a successful split.
7884

7985
> [!NOTE]
8086
> Disabled by default.
8187
8288
## Contributing
8389

84-
Contributions are welcome. Please include a brief description of the changes you are making in your pull request.
90+
Issues and pull requests are welcome.
8591

8692
## License
8793

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "note-splitter",
33
"name": "Note Splitter",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"minAppVersion": "0.15.0",
66
"description": "Split a note into individual notes based on a delimiter.",
77
"author": "DecafDev",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-note-splitter",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Split notes based on a delimiter",
55
"main": "main.js",
66
"scripts": {

src/main.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ export default class NoteSplitterPlugin extends Plugin {
6969
return;
7070
}
7171

72-
const splitLines = dataWithoutFrontmatter
72+
const splitContent = dataWithoutFrontmatter
7373
.split(delimiter)
74-
.map((line) => line.trim())
75-
.filter((line) => line !== "");
74+
.map((content) => content.trim())
75+
.filter((content) => content !== "");
7676

77-
if (splitLines.length === 0) {
77+
if (splitContent.length === 0) {
7878
new Notice("No content to split.");
7979
return;
8080
}
8181

82-
if (splitLines.length === 1) {
83-
new Notice("Only one line found. Nothing to split.");
82+
if (splitContent.length === 1) {
83+
new Notice("Only one piece of content found. Nothing to split.");
8484
return;
8585
}
8686

@@ -96,8 +96,8 @@ export default class NoteSplitterPlugin extends Plugin {
9696
}
9797

9898
let filesCreated = 0;
99-
for (const [i, line] of splitLines.entries()) {
100-
let fileName = line;
99+
for (const [i, content] of splitContent.entries()) {
100+
let fileName = content.split("\n")[0];
101101
if (this.settings.useContentAsTitle) {
102102
fileName = escapeInvalidFileNameChars(fileName);
103103
fileName = trimForFileName(fileName, ".md");
@@ -108,13 +108,13 @@ export default class NoteSplitterPlugin extends Plugin {
108108
const filePath = normalizePath(`${folderPath}/${fileName}.md`);
109109

110110
try {
111-
await this.app.vault.create(filePath, line);
111+
await this.app.vault.create(filePath, content);
112112
filesCreated++;
113113
} catch (err) {
114114
if (err.message.includes("already exists")) {
115115
const newFilePath = `${folderPath}/Split conflict ${crypto.randomUUID()}.md`;
116116
try {
117-
await this.app.vault.create(newFilePath, line);
117+
await this.app.vault.create(newFilePath, content);
118118
filesCreated++;
119119
} catch (err) {
120120
console.error(err);
@@ -127,7 +127,7 @@ export default class NoteSplitterPlugin extends Plugin {
127127
}
128128
}
129129

130-
if (filesCreated === splitLines.length && this.settings.deleteOriginalNote) {
130+
if (filesCreated === splitContent.length && this.settings.deleteOriginalNote) {
131131
await this.app.vault.delete(file);
132132
}
133133

src/obsidian/note-splitter-settings-tab.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export default class NoteSplitterSettingsTab extends PluginSettingTab {
1515
containerEl.empty();
1616

1717
new Setting(containerEl)
18-
.setName("Folder path")
18+
.setName("Output folder")
1919
.setDesc(
20-
"The path to the folder that split notes will be placed in. If left empty, the folder of the original note will be used.",
20+
"The folder to save split notes in. If empty, the folder of the original note will be used.",
2121
)
2222
.addText((text) =>
2323
text.setValue(this.plugin.settings.saveFolderPath).onChange(async (value) => {
@@ -28,7 +28,7 @@ export default class NoteSplitterSettingsTab extends PluginSettingTab {
2828

2929
new Setting(containerEl)
3030
.setName("Delimiter")
31-
.setDesc("The delimiter to split by.")
31+
.setDesc("The sequence of characters to split by.")
3232
.addText((text) =>
3333
text.setValue(this.plugin.settings.delimiter).onChange(async (value) => {
3434
this.plugin.settings.delimiter = value;
@@ -37,9 +37,9 @@ export default class NoteSplitterSettingsTab extends PluginSettingTab {
3737
);
3838

3939
new Setting(containerEl)
40-
.setName("Use content as title")
40+
.setName("Use first line as title")
4141
.setDesc(
42-
"If true, the first sentence will be used as the title of the note, otherwise a timestamp will be used e.g. note-splitter-1702591910.",
42+
"If enabled, the first line of split content will be used as the title of the split note. If disabled, a timestamp will be used. e.g. note-splitter-1702591910",
4343
)
4444
.addToggle((text) =>
4545
text.setValue(this.plugin.settings.useContentAsTitle).onChange(async (value) => {

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export const escapeInvalidFileNameChars = (value: string) => {
3232
* Trims the string to the maximum length allowed for a file name
3333
*/
3434
export const trimForFileName = (value: string, extension: string) => {
35-
const MAX_LENGTH_MAC_OS = 255;
36-
return value.substring(0, MAX_LENGTH_MAC_OS - extension.length - 1);
35+
const MAX_LENGTH = 255;
36+
return value.substring(0, MAX_LENGTH - extension.length - 1);
3737
};

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"0.5.1": "0.15.0",
1111
"0.6.0": "0.15.0",
1212
"1.0.0": "0.15.0",
13-
"1.1.0": "0.15.0"
13+
"1.1.0": "0.15.0",
14+
"1.1.1": "0.15.0"
1415
}

0 commit comments

Comments
 (0)