Skip to content

Commit

Permalink
FIX: Glossing algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Mar 17, 2024
1 parent c166f31 commit 2797395
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utilities/createGlossLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import addEmphasis from '../utilities/addEmphasis.js'
import replaceHyphens from '../utilities/replaceHyphens.js'

const glossRegExp = /(?<gloss>[1-4]|[A-Z]+)/gv
const numberRegExp = /\b(?<number>sg|du|pl)\b/gv
const numberRegExp = /(?<=[1-4])(?<number>sg|du|pl)\b/giv

export default function createGlossLine(
data,
Expand All @@ -19,8 +19,9 @@ export default function createGlossLine(
}

if (glossesOption === true) {
// These replacements are sensitive to ordering.
data = data
.replaceAll(numberRegExp, wrapGloss) // This replacement should come first, in order to avoid double-wrapping of number glosses.
.replaceAll(numberRegExp, wrapGloss)
.replaceAll(glossRegExp, wrapGloss)
}

Expand Down

0 comments on commit 2797395

Please sign in to comment.