Commit 155edbf5 authored by pierre.tremouilhac's avatar pierre.tremouilhac
Browse files

Merge branch 'spaces-H-format' into 'development'

Add new format for ",3 H" -> ", 3H"

See merge request ComPlat/chemotion_ELN!462
parents c31ead60 ed711b24
......@@ -47,6 +47,22 @@ const formatChemicalFormular = (formular) => {
const sampleAnalysesFormatPattern = {
_13cnmr: [
{
pattern: '(,{0,1}) (\\d+\\.){0,1}(\\d*) {0,1}H(,|\\))',
replace: {
ops: [
{ insert: '#{1}#{2}#{3}H#{4}' },
],
},
},
{
pattern: '(,{0,1})(\\d+\\.){0,1}(\\d*) {0,1}H(,|\\))',
replace: {
ops: [
{ insert: '#{1} #{2}#{3}H#{4}' },
],
},
},
{
pattern: '13C NMR',
replace: {
......@@ -143,6 +159,22 @@ const sampleAnalysesFormatPattern = {
},
],
_1hnmr: [
{
pattern: '(,{0,1}) (\\d+\\.){0,1}(\\d*) {0,1}H(,|\\))',
replace: {
ops: [
{ insert: '#{1}#{2}#{3}H#{4}' },
],
},
},
{
pattern: '(,{0,1})(\\d+\\.){0,1}(\\d*) {0,1}H(,|\\))',
replace: {
ops: [
{ insert: '#{1} #{2}#{3}H#{4}' },
],
},
},
{
pattern: '1H NMR',
replace: {
......
......@@ -30,7 +30,7 @@ const mapValueToGroupRegex = (content, matchedGroup) => {
const patt = `#{${idx + 1}}`;
const insertString = d.insert;
const dd = { ...d };
dd.insert = insertString.replace(patt, m);
dd.insert = insertString.replace(patt, m || '');
return dd;
});
});
......
import React from 'react'
import expect from 'expect'
import { searchAndReplace } from '../../../app/assets/javascripts/components/utils/quillFormat';
import { sampleAnalysesFormatPattern } from '../../../app/assets/javascripts/components/utils/ElementUtils'
describe('sampleAnalysesFormatPattern', () => {
describe('_1hnmr', () => {
const _1hnmr = sampleAnalysesFormatPattern['_1hnmr']
it('replaces "3 H" by "3H"', () => {
let content = { ops: [{ insert: 'Hello 3 Hi, 3 H byebye'}] }
const expected = 'Hello 3Hi, 3H byebye'
_1hnmr.forEach((patt) => {
content = searchAndReplace(content, patt.pattern, patt.replace);
});
expect(content.ops[0]['insert']).toEqual(expected)
})
})
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment