MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / parseTex

Function parseTex

packages/alphatab/test/importer/AlphaTexImporter.test.ts:78–96  ·  view source on GitHub ↗

* @static

(tex: string)

Source from the content-addressed store, hash-verified

76 * @static
77 */
78 function parseTex(tex: string): Score {
79 const importer: AlphaTexImporter = new AlphaTexImporter();
80 importer.logErrors = true;
81 importer.initFromString(tex, new Settings());
82 try {
83 return importer.readScore();
84 } catch (e) {
85 const x = (e as Error).cause instanceof AlphaTexErrorWithDiagnostics ? (e as Error).cause : e;
86 if (x instanceof AlphaTexErrorWithDiagnostics) {
87 const withDiag = x as AlphaTexErrorWithDiagnostics;
88 if (e instanceof UnsupportedFormatError) {
89 throw new UnsupportedFormatError(withDiag.toString());
90 } else {
91 throw new Error(`${withDiag.toString()}`);
92 }
93 }
94 throw e;
95 }
96 }
97
98 // as we often add tests here for new alphaTex features, this helper
99 // directly allows testing the exporter via a roundtrip comparison

Callers 4

testExportRoundtripFunction · 0.70
runSectionNoteSymbolTestFunction · 0.70
testFunction · 0.70

Calls 3

initFromStringMethod · 0.95
readScoreMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected