Skip to content

Commit

Permalink
Added support for multi-line dialogs, #4
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikmayer committed May 13, 2024
1 parent 65b4f7d commit 79b3a72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "yesterday",
"name": "Yesterday",
"version": "1.0.11",
"version": "1.1.0",
"minAppVersion": "0.12.0",
"description": "Transform your notes into a visually stunning diary, integrating dialogs, chat logs, and media content blocks for a seamless journaling experience.",
"author": "Dominik Mayer",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-yesterday",
"version": "1.0.11",
"version": "1.1.0",
"description": "Plugin that provides Yesterday journaling support to Obsidian",
"main": "main.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export class YesterdayDialog extends MarkdownRenderChild {
onload() {
this.speakersMap.clear();
this.allSpeakers.clear();
const lines = this.text.split("\n");
let lines = this.text.split("\n.");
lines = lines.map((entry, index) => (index === 0 ? entry : '.' + entry));

const dialogContainer = this.containerEl.createEl("ul");
dialogContainer.addClass("yesterday-dialog");
Expand Down Expand Up @@ -110,7 +111,6 @@ export class YesterdayDialog extends MarkdownRenderChild {
metaElement.addClass("dialog-meta");
line.appendChild(metaElement);

// Construct the line content. Implementation depends on your format
if (showSpeaker) {
speakerElement.textContent = `${speaker}`;
metaElement.appendChild(speakerElement);
Expand All @@ -127,7 +127,7 @@ export class YesterdayDialog extends MarkdownRenderChild {
line.classList.add("emoji-only");
}

statementElement.textContent = `${statement}`;
statementElement.innerHTML = statement.replace(/\n/g, "<br>");
line.appendChild(statementElement);
this.spokenYet.add(speaker.toLowerCase());

Expand All @@ -144,7 +144,7 @@ export class YesterdayDialog extends MarkdownRenderChild {
}

dissectDialogLine(line: string): { speaker: string; comment: string; statement: string } {
const regex = /\.?(.*?)(?:\s?\((.*?)\))?:\s?(.*)/;
const regex = /^\.([^:(]+)(?:\s?\((.*?)\))?:\s?((?:.|\n)*)/;
const match = line.match(regex);
if (match) {
const [_, speaker, comment = '', statement] = match;
Expand Down

0 comments on commit 79b3a72

Please sign in to comment.