Skip to content

Commit

Permalink
Tests and more supported elements
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Oct 28, 2024
1 parent 07ce0a0 commit 375b299
Show file tree
Hide file tree
Showing 16 changed files with 3,547 additions and 80 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test

on: [push]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20, 22]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
env:
CI: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ test/data/output/*
cache/*
!.gitkeep
*.log
instruments.xml
.mscbackup
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ musicxml-mscx

MusicXML to MuseScore converter and back.

![GitHub Build Status](https://github.com/infojunkie/musicxml-mscx/workflows/Test/badge.svg)

# Usage
- `npm run --silent convert:mscx /path/to/score.musicxml instrumentsFile=/path/to/MuseScore/share/instruments/instruments.xml`
- `npm install && npm test`
- `npm run --silent convert:mscx /path/to/score.musicxml instrumentsFile=/path/to/MuseScore/share/instruments/instruments.xml styleFile=/path/to/MuseScore/stylesheet.mss`
1 change: 1 addition & 0 deletions build/lib-musicxml.sef.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/mscx.sef.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
"xslt3": "^2.6.0"
},
"scripts": {
"build:sef": "for xsl in src/*.xsl; do sef=$(basename \"$xsl\"); xslt3 -relocate:on -xsl:$xsl -export:build/${sef/.xsl/.sef.json} -nogo:1 -t -ns:##html5; done",
"build": "npm run build:sef",
"build:sef": "for xsl in src/*.xsl; do sef=$(basename \"$xsl\"); xslt3 -relocate:off -xsl:$xsl -export:build/${sef/.xsl/.sef.json} -nogo:1 -t -ns:##html5; done",
"convert:mscx": "run() { xslt3 -xsl:src/mscx.xsl -s:\"$1\" ${@:2}; printf \"\n\"; }; run",
"debug:xpath": "run() { xslt3 -s:\"$1\" -xp:\"$2\"; printf \"\n\"; }; run"
"debug:xpath": "run() { xslt3 -s:\"$1\" -xp:\"$2\"; printf \"\n\"; }; run",
"test:spec": "node --test --test-name-pattern=\"${TEST:-.*}\"",
"test": "npm run build && npm run test:spec"
}
}
1 change: 1 addition & 0 deletions src/instruments.xml
17 changes: 17 additions & 0 deletions src/lib-musicxml.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
exclude-result-prefixes="#all"
>

<!--
Global: Parameters.
-->
<xsl:param name="defaultScalingMillimeters" select="7.0"/>
<xsl:param name="defaultScalingTenths" select="40"/>

<!--
Template: Get accumulator value at node.
Function: Get accumulator value at node.
Expand Down Expand Up @@ -176,6 +183,16 @@
</xsl:accumulator-rule>
</xsl:accumulator>

<!--
State: Defaults.
-->
<xsl:accumulator name="scalingMillimeters" as="xs:double" initial-value="$defaultScalingMillimeters">
<xsl:accumulator-rule match="//defaults/scaling" select="number(millimeters)"/>
</xsl:accumulator>
<xsl:accumulator name="scalingTenths" as="xs:double" initial-value="$defaultScalingTenths">
<xsl:accumulator-rule match="//defaults/scaling" select="number(tenths)"/>
</xsl:accumulator>

<!--
Function: Measure duration (as per current time signature).
-->
Expand Down
Loading

0 comments on commit 375b299

Please sign in to comment.