-
-
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.
- Loading branch information
Showing
21 changed files
with
286 additions
and
107 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
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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
export type { Diagnostic } from './diagnostic'; | ||
export { DiagnosticSeverity } from './diagnostic'; | ||
export type { DiagnosticFix } from './diagnostic-fix'; | ||
export type { | ||
DiagnosticProvider, | ||
DiagnosticProviderConstructor, | ||
DiagnosticProviderFactory, | ||
DiagnosticsChanged, | ||
} from './diagnostic-provider'; | ||
export type { DiagnosticProvider, DiagnosticsChanged } from './diagnostic-provider'; |
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
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
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
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,5 @@ | ||
import { ScriptureNode } from './scripture-node'; | ||
|
||
export interface ScriptureSerializer { | ||
serialize(nodes: ScriptureNode[] | ScriptureNode): string; | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1 @@ | ||
export type { | ||
OnTypeFormattingProvider, | ||
OnTypeFormattingProviderConstructor, | ||
OnTypeFormattingProviderFactory, | ||
} from './on-type-formatting-provider'; | ||
export type { OnTypeFormattingProvider } from './on-type-formatting-provider'; |
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { UsfmDocument } from './usfm-document'; | ||
export { UsfmDocumentFactory } from './usfm-document-factory'; | ||
export { UsfmScriptureSerializer } from './usfm-scripture-serializer'; |
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,68 @@ | ||
import { UsfmStylesheet } from '@sillsdev/machine/corpora'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { UsfmDocument } from './usfm-document'; | ||
import { UsfmScriptureSerializer } from './usfm-scripture-serializer'; | ||
|
||
describe('UsfmScriptureSerializer', () => { | ||
it('single paragraph', () => { | ||
const usfm = normalize(`\\p This is a paragraph.`); | ||
const result = serialize(usfm); | ||
expect(result).toEqual(usfm); | ||
}); | ||
|
||
it('multiple paragraphs', () => { | ||
const usfm = normalize(`\\p This is a paragraph. | ||
\\p This is another paragraph.`); | ||
const result = serialize(usfm); | ||
expect(result).toEqual(usfm); | ||
}); | ||
|
||
it('nested character style', () => { | ||
const usfm = normalize(`\\add an addition containing the word \\+nd Lord\\+nd*\\add*`); | ||
const result = serialize(usfm); | ||
expect(result).toEqual(usfm); | ||
}); | ||
|
||
it('attributes', () => { | ||
const usfm = normalize(`\\fig At once they left their nets.|src="avnt016.jpg" size="span" ref="1.18"\\fig*`); | ||
const result = serialize(usfm); | ||
expect(result).toEqual(usfm); | ||
}); | ||
|
||
it('default attribute', () => { | ||
const usfm = normalize(`\\w gracious|grace\\w*`); | ||
const result = serialize(usfm); | ||
expect(result).toEqual(usfm); | ||
}); | ||
|
||
it('chapter and verse', () => { | ||
const usfm = normalize(`\\c 1 | ||
\\p | ||
\\v 1 This is a verse.`); | ||
const result = serialize(usfm); | ||
expect(result).toEqual(usfm); | ||
}); | ||
|
||
it('table', () => { | ||
const usfm = normalize(`\\tr \\th1 Tribe \\th2 Leader \\thr3 Number | ||
\\tr \\tc1 Reuben \\tc2 Elizur son of Shedeur \\tcr3 46,500 | ||
\\tr \\tc1 Simeon \\tc2 Shelumiel son of Zurishaddai \\tcr3 59,300 | ||
\\tr \\tc1 Gad \\tc2 Eliasaph son of Deuel \\tcr3 45,650 | ||
\\tr \\tcr1-2 Total: \\tcr3 151,450`); | ||
const result = serialize(usfm); | ||
expect(result).toEqual(usfm); | ||
}); | ||
}); | ||
|
||
function serialize(usfm: string): string { | ||
const stylesheet = new UsfmStylesheet('usfm.sty'); | ||
const document = new UsfmDocument('uri', 1, usfm, stylesheet); | ||
const serializer = new UsfmScriptureSerializer(stylesheet); | ||
|
||
return normalize(serializer.serialize(document)); | ||
} | ||
|
||
function normalize(text: string): string { | ||
return text.replace(/\r?\n/g, '\n').trim(); | ||
} |
Oops, something went wrong.