lyrics-structure 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: 20
20
+ registry-url: https://registry.npmjs.org
21
+
22
+ - run: npm ci
23
+
24
+ - run: npm run build
25
+
26
+ - run: npm test
27
+
28
+ - run: npm publish --provenance --access public
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.prettierrc CHANGED
@@ -1,10 +1,10 @@
1
- {
2
- "semi": true,
3
- "trailingComma": "es5",
4
- "singleQuote": true,
5
- "printWidth": 100,
6
- "tabWidth": 2,
7
- "useTabs": false,
8
- "bracketSpacing": true,
9
- "arrowParens": "always"
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "bracketSpacing": true,
9
+ "arrowParens": "always"
10
10
  }
@@ -1,19 +1,19 @@
1
- {
2
- "editor.formatOnSave": true,
3
- "editor.defaultFormatter": "esbenp.prettier-vscode",
4
- "editor.codeActionsOnSave": {
5
- "source.fixAll": "explicit"
6
- },
7
- "[typescript]": {
8
- "editor.defaultFormatter": "esbenp.prettier-vscode"
9
- },
10
- "[javascript]": {
11
- "editor.defaultFormatter": "esbenp.prettier-vscode"
12
- },
13
- "[json]": {
14
- "editor.defaultFormatter": "esbenp.prettier-vscode"
15
- },
16
- "[markdown]": {
17
- "editor.defaultFormatter": "esbenp.prettier-vscode"
18
- }
19
- }
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
4
+ "editor.codeActionsOnSave": {
5
+ "source.fixAll": "explicit"
6
+ },
7
+ "[typescript]": {
8
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
9
+ },
10
+ "[javascript]": {
11
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
12
+ },
13
+ "[json]": {
14
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
15
+ },
16
+ "[markdown]": {
17
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
18
+ }
19
+ }
package/CHANGELOG.md CHANGED
@@ -1,56 +1,56 @@
1
- # Changelog
2
-
3
- ## [1.2.2] - 2024-04-06
4
-
5
- ### Fixed
6
-
7
- - Fixed issue where consecutive lines without part containers were incorrectly split into separate parts
8
- - Improved handling of regular text lines to maintain proper grouping
9
-
10
- ## [1.2.0] - 2024-03-XX
11
-
12
- ### Changed
13
-
14
- - Simplified the lyrics format to use clear section markers
15
- - Updated documentation with clearer examples
16
- - Improved type definitions for better TypeScript support
17
-
18
- ### Added
19
-
20
- - Support for section indications in parentheses
21
- - Better handling of repeated sections
22
- - More intuitive content structure
23
-
24
- ### Removed
25
-
26
- - Slide-based content splitting
27
- - Special command tags
28
- - Complex formatting options
29
-
30
- ## [1.1.0] - 2024-03-XX
31
-
32
- ### Added
33
-
34
- - Initial release
35
- - `getParts` function for basic content extraction
36
- - `getSlideParts` function for slide-based content splitting
37
- - Support for special command tags
38
- - Comprehensive test suite
39
- - TypeScript types and documentation
40
-
41
- ### Features
42
-
43
- - Bracketed section parsing
44
- - Special command tag handling
45
- - Slide splitting based on content length
46
- - Empty line separation
47
- - Long line handling (>40 characters)
48
- - Whitespace preservation
49
- - Unicode support in tags
50
-
51
- ### Test Coverage
52
-
53
- - Basic functionality tests
54
- - Slide splitting tests
55
- - Special command tests
56
- - Edge case handling
1
+ # Changelog
2
+
3
+ ## [1.2.2] - 2024-04-06
4
+
5
+ ### Fixed
6
+
7
+ - Fixed issue where consecutive lines without part containers were incorrectly split into separate parts
8
+ - Improved handling of regular text lines to maintain proper grouping
9
+
10
+ ## [1.2.0] - 2024-03-XX
11
+
12
+ ### Changed
13
+
14
+ - Simplified the lyrics format to use clear section markers
15
+ - Updated documentation with clearer examples
16
+ - Improved type definitions for better TypeScript support
17
+
18
+ ### Added
19
+
20
+ - Support for section indications in parentheses
21
+ - Better handling of repeated sections
22
+ - More intuitive content structure
23
+
24
+ ### Removed
25
+
26
+ - Slide-based content splitting
27
+ - Special command tags
28
+ - Complex formatting options
29
+
30
+ ## [1.1.0] - 2024-03-XX
31
+
32
+ ### Added
33
+
34
+ - Initial release
35
+ - `getParts` function for basic content extraction
36
+ - `getSlideParts` function for slide-based content splitting
37
+ - Support for special command tags
38
+ - Comprehensive test suite
39
+ - TypeScript types and documentation
40
+
41
+ ### Features
42
+
43
+ - Bracketed section parsing
44
+ - Special command tag handling
45
+ - Slide splitting based on content length
46
+ - Empty line separation
47
+ - Long line handling (>40 characters)
48
+ - Whitespace preservation
49
+ - Unicode support in tags
50
+
51
+ ### Test Coverage
52
+
53
+ - Basic functionality tests
54
+ - Slide splitting tests
55
+ - Special command tests
56
+ - Edge case handling
package/README.md CHANGED
@@ -1,54 +1,54 @@
1
- # Lyrics Parser
2
-
3
- A TypeScript library for parsing lyrics with bracketed sections and special commands. Supports splitting text into structured parts with names and indications.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install lyrics-parser
9
- ```
10
-
11
- ## Usage
12
-
13
- ```typescript
14
- import { getLyricsParts } from 'lyrics-parser';
15
-
16
- const lyrics = `[verse 1] (first time)
17
- This is the first verse content
18
- [/verse 1]
19
-
20
- [chorus]
21
- This is the chorus content
22
- [/chorus]
23
-
24
- [verse 2]
25
- This is the second verse content
26
- [/verse 2]`;
27
-
28
- const parts = getLyricsParts(lyrics);
29
- // Result: Array of LyricPart objects with name, repetition, indication, and content
30
- ```
31
-
32
- ## Features
33
-
34
- - Extracts content from bracketed sections
35
- - Handles section names and indications
36
- - Supports repeated sections
37
- - Preserves non-bracketed content
38
- - TypeScript support
39
-
40
- ## Example Format
41
-
42
- ```text
43
- [partname] (indication)
44
- content
45
- [/partname]
46
-
47
- [another part]
48
- more content
49
- [/another part]
50
- ```
51
-
52
- ## License
53
-
1
+ # Lyrics Parser
2
+
3
+ A TypeScript library for parsing lyrics with bracketed sections and special commands. Supports splitting text into structured parts with names and indications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install lyrics-parser
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { getLyricsParts } from 'lyrics-parser';
15
+
16
+ const lyrics = `[verse 1] (first time)
17
+ This is the first verse content
18
+ [/verse 1]
19
+
20
+ [chorus]
21
+ This is the chorus content
22
+ [/chorus]
23
+
24
+ [verse 2]
25
+ This is the second verse content
26
+ [/verse 2]`;
27
+
28
+ const parts = getLyricsParts(lyrics);
29
+ // Result: Array of LyricPart objects with name, repetition, indication, and content
30
+ ```
31
+
32
+ ## Features
33
+
34
+ - Extracts content from bracketed sections
35
+ - Handles section names and indications
36
+ - Supports repeated sections
37
+ - Preserves non-bracketed content
38
+ - TypeScript support
39
+
40
+ ## Example Format
41
+
42
+ ```text
43
+ [partname] (indication)
44
+ content
45
+ [/partname]
46
+
47
+ [another part]
48
+ more content
49
+ [/another part]
50
+ ```
51
+
52
+ ## License
53
+
54
54
  MIT
package/debug.ts CHANGED
@@ -1,47 +1,47 @@
1
- import { getSlideParts } from './slide';
2
-
3
- const comprehensiveInput = `
4
- [verse]
5
- First line of verse
6
- Second line of verse
7
- Third line of verse
8
- Fourth line of verse
9
- Fifth line of verse
10
- [/verse]
11
- [verse]
12
- (inside parentheses)
13
- Regular text line 1
14
- Regular text line 2
15
-
16
- [chorus]
17
- First chorus line
18
- Second chorus line
19
- [/chorus]
20
-
21
- [verse 1]
22
- This is a very long line that should be considered too long for the slide
23
- This is another very long line that should also be considered too long
24
- Short line 1
25
- Short line 2
26
- [/verse 1]
27
-
28
- Regular line 1
29
- Regular line 2
30
-
31
- More content
32
-
33
- This is a very long line that exceeds forty characters for testing purposes
34
- This is another very long line that also exceeds the forty character limit
35
- Another very long line that should be considered too long for the slide
36
- And yet another very long line that should be split into a new section
37
- Regular line
38
-
39
- [verse 2]
40
- First line with spaces
41
- Second line with spaces
42
- [/verse 2]
43
-
44
- [chorus]`;
45
-
46
- console.log('Output from getSlideParts:');
47
- console.log(JSON.stringify(getSlideParts(comprehensiveInput), null, 2));
1
+ import { getSlideParts } from './slide';
2
+
3
+ const comprehensiveInput = `
4
+ [verse]
5
+ First line of verse
6
+ Second line of verse
7
+ Third line of verse
8
+ Fourth line of verse
9
+ Fifth line of verse
10
+ [/verse]
11
+ [verse]
12
+ (inside parentheses)
13
+ Regular text line 1
14
+ Regular text line 2
15
+
16
+ [chorus]
17
+ First chorus line
18
+ Second chorus line
19
+ [/chorus]
20
+
21
+ [verse 1]
22
+ This is a very long line that should be considered too long for the slide
23
+ This is another very long line that should also be considered too long
24
+ Short line 1
25
+ Short line 2
26
+ [/verse 1]
27
+
28
+ Regular line 1
29
+ Regular line 2
30
+
31
+ More content
32
+
33
+ This is a very long line that exceeds forty characters for testing purposes
34
+ This is another very long line that also exceeds the forty character limit
35
+ Another very long line that should be considered too long for the slide
36
+ And yet another very long line that should be split into a new section
37
+ Regular line
38
+
39
+ [verse 2]
40
+ First line with spaces
41
+ Second line with spaces
42
+ [/verse 2]
43
+
44
+ [chorus]`;
45
+
46
+ console.log('Output from getSlideParts:');
47
+ console.log(JSON.stringify(getSlideParts(comprehensiveInput), null, 2));
package/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './slide.js';
1
+ export * from './slide.js';
2
2
  export * from './lyrics.js';
package/jest.config.js CHANGED
@@ -1,17 +1,17 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- export default {
3
- preset: 'ts-jest',
4
- testEnvironment: 'node',
5
- extensionsToTreatAsEsm: ['.ts'],
6
- moduleNameMapper: {
7
- '^(\\.{1,2}/.*)\\.js$': '$1',
8
- },
9
- transform: {
10
- '^.+\\.tsx?$': [
11
- 'ts-jest',
12
- {
13
- useESM: true,
14
- },
15
- ],
16
- },
17
- };
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ export default {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ extensionsToTreatAsEsm: ['.ts'],
6
+ moduleNameMapper: {
7
+ '^(\\.{1,2}/.*)\\.js$': '$1',
8
+ },
9
+ transform: {
10
+ '^.+\\.tsx?$': [
11
+ 'ts-jest',
12
+ {
13
+ useESM: true,
14
+ },
15
+ ],
16
+ },
17
+ };
package/lyrics.test.ts CHANGED
@@ -1,76 +1,76 @@
1
- import { getLyricsParts } from './lyrics';
2
-
3
- const testLyrics = `[partname 1] (indication 1)
4
-
5
- content 1
6
-
7
- [/partname 1]
8
-
9
- [partname 1] (indication 2)
10
-
11
- [partname 2]
12
-
13
- content 2
14
-
15
- [/partname 2]
16
-
17
- [interlude 1]
18
-
19
- [partname 3]
20
-
21
- content without partname container
22
-
23
- content standalone 1
24
- content standalone 2
25
- `;
26
-
27
- describe('getLyricsParts', () => {
28
- it('should correctly parse lyrics into parts', () => {
29
- const result = getLyricsParts(testLyrics);
30
-
31
- expect(result).toEqual([
32
- {
33
- name: 'partname 1',
34
- repetition: false,
35
- indication: 'indication 1',
36
- content: 'content 1',
37
- },
38
- {
39
- name: 'partname 1',
40
- repetition: true,
41
- indication: 'indication 2',
42
- content: 'content 1',
43
- },
44
- {
45
- name: 'partname 2',
46
- repetition: false,
47
- indication: null,
48
- content: 'content 2',
49
- },
50
- {
51
- name: 'interlude 1',
52
- repetition: false,
53
- indication: null,
54
- content: undefined,
55
- },
56
- {
57
- name: 'partname 3',
58
- repetition: false,
59
- indication: null,
60
- content: undefined,
61
- },
62
- {
63
- name: undefined,
64
- repetition: false,
65
- indication: null,
66
- content: 'content without partname container',
67
- },
68
- {
69
- name: undefined,
70
- repetition: false,
71
- indication: null,
72
- content: 'content standalone 1\ncontent standalone 2',
73
- },
74
- ]);
75
- });
76
- });
1
+ import { getLyricsParts } from './lyrics';
2
+
3
+ const testLyrics = `[partname 1] (indication 1)
4
+
5
+ content 1
6
+
7
+ [/partname 1]
8
+
9
+ [partname 1] (indication 2)
10
+
11
+ [partname 2]
12
+
13
+ content 2
14
+
15
+ [/partname 2]
16
+
17
+ [interlude 1]
18
+
19
+ [partname 3]
20
+
21
+ content without partname container
22
+
23
+ content standalone 1
24
+ content standalone 2
25
+ `;
26
+
27
+ describe('getLyricsParts', () => {
28
+ it('should correctly parse lyrics into parts', () => {
29
+ const result = getLyricsParts(testLyrics);
30
+
31
+ expect(result).toEqual([
32
+ {
33
+ name: 'partname 1',
34
+ repetition: false,
35
+ indication: 'indication 1',
36
+ content: 'content 1',
37
+ },
38
+ {
39
+ name: 'partname 1',
40
+ repetition: true,
41
+ indication: 'indication 2',
42
+ content: 'content 1',
43
+ },
44
+ {
45
+ name: 'partname 2',
46
+ repetition: false,
47
+ indication: null,
48
+ content: 'content 2',
49
+ },
50
+ {
51
+ name: 'interlude 1',
52
+ repetition: false,
53
+ indication: null,
54
+ content: undefined,
55
+ },
56
+ {
57
+ name: 'partname 3',
58
+ repetition: false,
59
+ indication: null,
60
+ content: undefined,
61
+ },
62
+ {
63
+ name: undefined,
64
+ repetition: false,
65
+ indication: null,
66
+ content: 'content without partname container',
67
+ },
68
+ {
69
+ name: undefined,
70
+ repetition: false,
71
+ indication: null,
72
+ content: 'content standalone 1\ncontent standalone 2',
73
+ },
74
+ ]);
75
+ });
76
+ });