Skip to content

Commit

Permalink
Fix invisible links pasted on multiple lines
Browse files Browse the repository at this point in the history
  • Loading branch information
kuchejak committed Oct 21, 2024
1 parent 388dfbe commit 4c29f27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/logic/copy-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { App, HeadingCache, Notice, TFile } from "obsidian";
import { PluginSettings } from "../main";
import {bookAndChapterRegEx, escapeForRegex, isOBSKFileRegEx} from "../utils/regexes";
import { capitalize, getFileByFilename as getTFileByFilename, parseUserVerseInput } from "./common";
import {getConstrainedTypeAtLocation} from "@typescript-eslint/type-utils";

/**
* Converts biblical reference to text of given verses
Expand Down Expand Up @@ -211,15 +212,15 @@ async function createCopyOutput(app: App, tFile: TFile, fileName: string, beginV
if ((beginVerse == maxVerse || (settings.linkEndVerse && beginVerse == maxVerse - 1)) // No need to add another link, when only one verse is being linked
&& (!settings.enableMultipleTranslations
|| settings.translationLinkingType === "main"
|| settings.translationLinkingType === "used")) // Only linking one translation - already linked
|| settings.translationLinkingType === "used"
|| (settings.translationLinkingType === "usedAndMain" && translationPath === settings.parsedTranslationPaths.first())))
return res;


res += `\n${settings.prefix}`;
const lastVerseToLink = settings.linkEndVerse ? maxVerse - 1 : maxVerse;
for (let i = beginVerse; i <= lastVerseToLink; i++) { // beginVerse + 1 because link to first verse is already inserted before the text
if (!settings.enableMultipleTranslations) {
if (i == beginVerse) continue; // already linked in the first link before text
res += `\n${settings.prefix}`;
res += `[[${fileName}#${headings[i].heading}|]]`
}
else { // multiple translations
Expand Down Expand Up @@ -249,7 +250,6 @@ async function createCopyOutput(app: App, tFile: TFile, fileName: string, beginV
}
if (translationPathsToUse.length === 0) return;

res += `\n${settings.prefix}`;
translationPathsToUse.forEach((translationPath) => {
res += `[[${translationPath}/${fileName}#${headings[i].heading}|]]`
})
Expand Down

0 comments on commit 4c29f27

Please sign in to comment.