@@ -4,7 +4,8 @@ This library converts D-SI unit strings to Latex.
## Usage
Create a D-SI tree with the D-SI unit string as an argument: `tree = dsiParser.dsiTree("\mega\hertz")`.
Set up a parser (with optional arguments for default latex values): `parser = dsiParser(latexDefaultWrapper='$', latexDefaultPrefix=r'\mathrm{Prefix}', latexDefaultSuffix=r'\mathrm{Suffix}')`.
Create a D-SI tree with the D-SI unit string as an argument: `tree = parser.parse("\mega\hertz")`.
- To validate the D-SI unit string, inspect the `valid` property: `print(tree.valid)`
- To see any warning messages generated while parsing the string, inspect the `warnings` property: `print(tree.warnings)`
withpytest.warns(RuntimeWarning,match=r'The dsi string contains more than one \\per, does not match specs! Given string: \\metre\\per\\metre\\per\\metre'):
assertdsiTree(r'\metre').toLatex(wrapper='$',prefix=r'\mathrm{Unit: }',suffix=r'\mathrm{(generated from D-SI string)}')==r'$\mathrm{Unit: }\mathrm{m}\mathrm{(generated from D-SI string)}$'
assertp.parse(r'\metre').toLatex(wrapper='$',prefix=r'\mathrm{Unit: }',suffix=r'\mathrm{(generated from D-SI string)}')==r'$\mathrm{Unit: }\mathrm{m}\mathrm{(generated from D-SI string)}$'