-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW: Support Morphemic Analysis (#39)
closes #39
- Loading branch information
Showing
5 changed files
with
153 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Replaces regular hyphens (U+2010) with non-breaking hyphens (U+2011). | ||
* @param {String} data | ||
* @returns String | ||
*/ | ||
export default function replaceHyphens(data) { | ||
return data.replaceAll(`-`, `\u{2011}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import addEmphasis from '../utilities/addEmphasis.js' | ||
import replaceHyphens from '../utilities/replaceHyphens.js' | ||
|
||
export default function createMorphemes(data, { targetLang }) { | ||
|
||
const lang = targetLang ? `lang='${ targetLang }'` : `` | ||
let html = `` | ||
|
||
for (const ortho in data) { | ||
const morphemes = addEmphasis(replaceHyphens(data[ortho])) | ||
html += `<span class=w-m data-ortho='${ ortho }' ${ lang }>${ morphemes }</span>` | ||
} | ||
|
||
return html | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters