Skip to content

Commit

Permalink
extra line break for #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Jan 13, 2022
1 parent c1c61d5 commit 011d76b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class TextFormat extends Plugin {
this.addCommand({
id: "text-format-remove-blank-line",
name: "Remove blank line(s)",
callback: () => this.textFormat("blank-line"),
callback: () => this.textFormat("remove-blank-line"),
});
this.addCommand({
id: "text-format-merge-line",
Expand Down Expand Up @@ -89,13 +89,18 @@ export default class TextFormat extends Plugin {
callback: () => this.textFormat("decodeURI"),
});
this.addCommand({
id: "text-format-extra-line-break",
name: "Add extra line break to paragraph for whole file (beta)",
callback: () => this.extraLineBreak(),
id: "text-format-paragraph-double-spaces",
name: "Add extra double spaces per paragraph for whole file (beta)",
callback: () => this.extraDoubleSpaces(),
});
this.addCommand({
id: "text-format-add-line-break",
name: "Add extra line break to paragraph",
callback: () => this.textFormat("add-line-break"),
});
}

extraLineBreak(): void {
extraDoubleSpaces(): void {
let markdownView = this.app.workspace.getActiveViewOfType(MarkdownView);
if (!markdownView) {
return;
Expand Down Expand Up @@ -209,9 +214,12 @@ export default class TextFormat extends Plugin {
replacedText = replacedText.replace(/ +/g, " ");
}
break;
case "blank-line":
case "remove-blank-line":
replacedText = selectedText.replace(/\n+/g, "\n");
break;
case "add-line-break":
replacedText = selectedText.replace(/\n/g, "\n\n");
break;
case "bullet":
replacedText = selectedText
.replace(/(^|(?<=[\s])) *• */g, "\n- ")
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-text-format",
"name": "Text Format",
"version": "1.5.1",
"version": "1.5.2",
"minAppVersion": "0.9.7",
"description": "Format selected text lowercase/uppercase/capitalize/titlecase or remove redundant spaces/newline characters.",
"author": "Benature",
Expand Down

0 comments on commit 011d76b

Please sign in to comment.