2525 * @apiParam (Post Body) {String} body.mainheadword.lang ISO language code for the head word
2626 * @apiParam (Post Body) {String} body.mainheadword.value ISO head word
2727 * @apiParam (Post Body) {Object} body.audio Audio associated with the entry
28- * @apiParam (Post Body) {String} body.audio.fileClass Css class for the audio
28+ * @apiParam (Post Body) {String} body.audio.fileClass CSS class for the audio
2929 * @apiParam (Post Body) {String} body.audio.id Unique id for audio file
3030 * @apiParam (Post Body) {String} body.audio.src Relative file path to the audio
3131 * @apiParam (Post Body) {Object[]} body.pictures Images associated with the entry
9999 * HTTP/1.1 500 Internal Server Error
100100 * {
101101 * "errorType": "SyntaxError",
102- * "errorMessage": "Unexpected token } in JSON at position 243"
102+ * "errorMessage": "Unexpected token { in JSON at position 243"
103103 * }
104104 */
105105
@@ -247,7 +247,7 @@ const getLangTexts = (xhtml: string) => {
247247 const searchTexts : string [ ] = [ ] ;
248248
249249 // eslint-disable-next-line array-callback-return
250- $ ( 'span[lang]' ) . each ( ( index , elem ) => {
250+ $ ( 'span[lang]' ) . each ( ( _index , elem ) => {
251251 const lang = $ ( elem ) . attr ( 'lang' ) ;
252252 const text = $ ( elem ) . text ( ) ;
253253 if ( ! lang || ! text ) {
@@ -330,6 +330,22 @@ export const transformToEntry = ({
330330 } ;
331331} ;
332332
333+ /**
334+ * This is to remove the version numbers FLEx is now appending to the class name of some span tags.
335+ *
336+ * @param postedEntry
337+ */
338+ const fixSpanClassVersions = ( postedEntry : any ) => {
339+
340+ if ( ! postedEntry . displayXhtml )
341+ return ;
342+
343+ // remove the version numbers from the span classes before processing
344+ const regex = / < s p a n c l a s s = " ( [ ^ " \s ] + ?) - \d + " / g;
345+ const subst = `<span class="$1"` ;
346+ postedEntry . displayXhtml = postedEntry . displayXhtml . replace ( regex , subst ) ;
347+ } ;
348+
333349export async function upsertEntries (
334350 postedEntries : Array < any > ,
335351 isReversal : boolean ,
@@ -338,7 +354,11 @@ export async function upsertEntries(
338354) {
339355 const updatedAt = new Date ( ) ;
340356 const transformEntryFunction = isReversal ? transformToReversalEntry : transformToEntry ;
357+
341358 const entries = postedEntries . map ( ( postedEntry ) => {
359+
360+ fixSpanClassVersions ( postedEntry ) ;
361+
342362 const entry = transformEntryFunction ( { postedEntry, dictionaryId } ) ;
343363 entry . updatedAt = updatedAt ;
344364 entry . updatedBy = username ;
0 commit comments