Skip to content

Commit

Permalink
Update allowed characters and add conversion for single quotation mar…
Browse files Browse the repository at this point in the history
…ks to RTF format.
  • Loading branch information
ioanlucut committed Sep 29, 2023
1 parent 5925b7e commit ee76f72
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 78 deletions.
128 changes: 64 additions & 64 deletions src/__snapshots__/proPresenter7SongConverter.spec.ts.snap

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/__snapshots__/txtToRtfConverter.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ exports[`txtToRtfConverter should convert to expected \`rtf\` correctly 1`] = `
\\pard\\tx560\\tx1120\\tx1680\\tx2240\\tx2800\\tx3360\\tx3920\\tx4480\\tx5040\\tx5600\\tx6160\\tx6720\\pardirnatural\\qc\\partightenfactor0
\\f0\\b\\fs120 \\cf2 \\cb3 Row 1-1\\
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\\]abcdefghijklmnopqrstuvwxyz\\uc0\\u206\\uc0\\u226\\uc0\\u238\\uc0\\u259\\uc0\\u194\\uc0\\u536\\uc0\\u537\\uc0\\u258\\uc0\\u538\\uc0\\u539\\uc0\\u8217\\uc0\\u8221\\uc0\\u8222\\
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\\]abcdefghijklmnopqrstuvwxyz\\uc0\\u206\\uc0\\u226\\uc0\\u238\\uc0\\u259\\uc0\\u194\\uc0\\u536\\uc0\\u537\\uc0\\u258\\uc0\\u538\\uc0\\u539\\uc0\\u8217\\uc0\\u8216\\uc0\\u8221\\uc0\\u8222\\
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\\]abcdefghijklmnopqrstuvwxyz\\uc0\\u206\\uc0\\u226\\uc0\\u238\\uc0\\u259\\uc0\\u194\\uc0\\u536\\uc0\\u537\\uc0\\u258\\uc0\\u538\\uc0\\u539\\uc0\\u8217\\uc0\\u8216\\uc0\\u8221\\uc0\\u8222\\
Row 1-3}
"
`;
Expand All @@ -34,6 +35,7 @@ space-not-expected-before \\uc0\\u538text\\
space-not-expected-before \\uc0\\u539text\\
space-not-expected-before -text\\
space-not-expected-before \\uc0\\u8217text\\
space-not-expected-before \\uc0\\u8216text\\
space-not-expected-before \\uc0\\u8221text\\
space-not-expected-before \\uc0\\u8222text\\
\\
Expand All @@ -49,6 +51,7 @@ text\\uc0\\u538 single-space-expected-after-this\\
text\\uc0\\u539 single-space-expected-after-this\\
text- single-space-expected-after-this\\
text\\uc0\\u8217 single-space-expected-after-this\\
text\\uc0\\u8216 single-space-expected-after-this\\
text\\uc0\\u8221 single-space-expected-after-this\\
text\\uc0\\u8222 single-space-expected-after-this\\
\\
Expand All @@ -64,6 +67,7 @@ end-of-line-works-without-extra-space-text\\uc0\\u538\\
end-of-line-works-without-extra-space-text\\uc0\\u539\\
end-of-line-works-without-extra-space-text-\\
end-of-line-works-without-extra-space-text\\uc0\\u8217\\
end-of-line-works-without-extra-space-text\\uc0\\u8216\\
end-of-line-works-without-extra-space-text\\uc0\\u8221\\
end-of-line-works-without-extra-space-text\\uc0\\u8222}
"
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const TXT_EXTENSION = '.txt';
export const TEST_FILE = 'TEMPLATE.txt';

export const ALLOWED_CHARS =
` {}&#!(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZYQ[\\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’”„\n`.split(
` *_{}&!(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZYQ[\\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’”„\n`.split(
EMPTY_STRING,
);

Expand Down
18 changes: 9 additions & 9 deletions src/proPresenter7SongConverter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ jest.mock('crypto', () => {
const ANY_CONFIG = {
arrangementName: 'BES',
ccliSettings: {
publisher: 'Biserica Emanuel Sibiu',
author: 'Ioan Lucuț',
copyrightYear: new Date().getFullYear(),
album: `Biserica Emanuel Sibiu ${new Date().getFullYear()}`,
publisher: 'ANY_PUBLISHER',
author: 'ANY_AUTHOR',
copyrightYear: 2023,
album: `Biserica Emanuel Sibiu 2023`,
songNumber: 0,
} as Presentation_CCLI,
fontConfig: {
name: 'CMGSans-Regular',
name: 'CMGSans-BoldCnCAPS',
size: 58,
family: 'CMGSans',
family: 'CMG Sans Cn CAPS',
bold: true,
} as Graphics_Text_Attributes_Font,
graphicSize: {
width: 1920,
height: 1080,
},
presentationCategory: `Worship Songs ~ BES ${new Date().getFullYear()}`,
refMacroId: '3ffd01b7-104f-499f-aac9-a13135006d0e',
refMacroName: 'Songs',
presentationCategory: `Worship Songs ~ BES 2023`,
refMacroId: 'ANY_REF_MACRO_ID',
refMacroName: 'ANY_REF_MACRO_NAME',
};

describe('proPresenter7SongConverter', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/txtToRtfConverter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { convertToRtf } from './txtToRtfConverter';
describe('txtToRtfConverter', () => {
it('should convert to expected `rtf` correctly', () => {
const rtfContent = convertToRtf(`Row 1-1
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’”„
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’‘”„
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’‘”„
Row 1-3`);

expect(rtfContent).toMatchSnapshot();
Expand All @@ -25,6 +26,7 @@ space-not-expected-before Țtext
space-not-expected-before țtext
space-not-expected-before -text
space-not-expected-before ’text
space-not-expected-before ‘text
space-not-expected-before ”text
space-not-expected-before „text
Expand All @@ -40,6 +42,7 @@ textȚ single-space-expected-after-this
textț single-space-expected-after-this
text- single-space-expected-after-this
text’ single-space-expected-after-this
text‘ single-space-expected-after-this
text” single-space-expected-after-this
text„ single-space-expected-after-this
Expand All @@ -55,6 +58,7 @@ end-of-line-works-without-extra-space-textȚ
end-of-line-works-without-extra-space-textț
end-of-line-works-without-extra-space-text-
end-of-line-works-without-extra-space-text’
end-of-line-works-without-extra-space-text‘
end-of-line-works-without-extra-space-text”
end-of-line-works-without-extra-space-text„`);

Expand Down
4 changes: 3 additions & 1 deletion src/txtToRtfConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const encodeVerseContentToUnicodeRTFFormat = (verseContent: string) =>
.replaceAll('” ', '\\uc0\\u8221 ')
.replaceAll('„ ', '\\uc0\\u8222 ')
.replaceAll('’ ', '\\uc0\\u8217 ')
.replaceAll('‘ ', '\\uc0\\u8216 ')
// Remaining chars
.replaceAll('Â', '\\uc0\\u194')
.replaceAll('â', '\\uc0\\u226')
Expand All @@ -36,7 +37,8 @@ const encodeVerseContentToUnicodeRTFFormat = (verseContent: string) =>
.replaceAll('Ț', '\\uc0\\u538')
.replaceAll('”', '\\uc0\\u8221')
.replaceAll('„', '\\uc0\\u8222')
.replaceAll('’', '\\uc0\\u8217');
.replaceAll('’', '\\uc0\\u8217')
.replaceAll('‘', '\\uc0\\u8216');

export const convertToRtf = (multiLineVerseContent: string) => {
if (!rtfTemplate) {
Expand Down
3 changes: 2 additions & 1 deletion txtToRtfConverterGeneratedRtf.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc\partightenfactor0

\f0\b\fs120 \cf2 \cb3 Row 1-1\
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\]abcdefghijklmnopqrstuvwxyz\uc0\u206\uc0\u226\uc0\u238\uc0\u259\uc0\u194\uc0\u536\uc0\u537\uc0\u258\uc0\u538\uc0\u539\uc0\u8217\uc0\u8221\uc0\u8222\
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\]abcdefghijklmnopqrstuvwxyz\uc0\u206\uc0\u226\uc0\u238\uc0\u259\uc0\u194\uc0\u536\uc0\u537\uc0\u258\uc0\u538\uc0\u539\uc0\u8217\uc0\u8216\uc0\u8221\uc0\u8222\
Row 1-2 !(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\]abcdefghijklmnopqrstuvwxyz\uc0\u206\uc0\u226\uc0\u238\uc0\u259\uc0\u194\uc0\u536\uc0\u537\uc0\u258\uc0\u538\uc0\u539\uc0\u8217\uc0\u8216\uc0\u8221\uc0\u8222\
Row 1-3}
3 changes: 3 additions & 0 deletions txtToRtfConverterGeneratedRtf_II.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ space-not-expected-before \uc0\u538text\
space-not-expected-before \uc0\u539text\
space-not-expected-before -text\
space-not-expected-before \uc0\u8217text\
space-not-expected-before \uc0\u8216text\
space-not-expected-before \uc0\u8221text\
space-not-expected-before \uc0\u8222text\
\
Expand All @@ -32,6 +33,7 @@ text\uc0\u538 single-space-expected-after-this\
text\uc0\u539 single-space-expected-after-this\
text- single-space-expected-after-this\
text\uc0\u8217 single-space-expected-after-this\
text\uc0\u8216 single-space-expected-after-this\
text\uc0\u8221 single-space-expected-after-this\
text\uc0\u8222 single-space-expected-after-this\
\
Expand All @@ -47,5 +49,6 @@ end-of-line-works-without-extra-space-text\uc0\u538\
end-of-line-works-without-extra-space-text\uc0\u539\
end-of-line-works-without-extra-space-text-\
end-of-line-works-without-extra-space-text\uc0\u8217\
end-of-line-works-without-extra-space-text\uc0\u8216\
end-of-line-works-without-extra-space-text\uc0\u8221\
end-of-line-works-without-extra-space-text\uc0\u8222}

0 comments on commit ee76f72

Please sign in to comment.