Match only verse identifies at start of string.

This commit is contained in:
Benjamin A. Shelton 2026-06-29 22:29:56 -06:00
commit a83f1cabe6
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01

View file

@ -6,11 +6,11 @@ function scriptureLink(node, args, meta) {
const value = node.children?.[0]?.value?.trim() || '';
let passage = (args && args.length > 0 && args[0] != '') ? args[0] : value;
if (value.match(/[Vv][Vv]?(erses?)?\s*/)) {
if (value.match(/^[Vv][Vv]?(erses?)?\s*/)) {
const book = meta.data.astro.frontmatter.book;
const chapter = meta.data.astro.frontmatter.chapter;
if ((args.length == 0 || args[0] == '') && (book && chapter)) {
passage = `${book} ${chapter}:${value.replace(/[Vv][Vv]?(erses?)?\s*/, '')}`;
passage = `${book} ${chapter}:${value.replace(/^[Vv][Vv]?(erses?)?\s*/, '')}`;
} else if (args.length == 0 || args[0] == '') {
node.properties.href = null;
return;