Skip to content

Commit 9e8af3d

Browse files
authored
Merge pull request #1814 from cuthbertLab/braille-quote
Braille translate smart quotes
2 parents 501e13d + a88a7d3 commit 9e8af3d

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

music21/common/stringTools.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,27 @@ def stripAccents(inputString: str) -> str:
304304
>>> common.stripAccents(s)
305305
'tres vite'
306306
307-
Also handles the German Eszett
307+
Also handles the German Eszett and smart quotes
308308
309309
>>> common.stripAccents('Muß')
310310
'Muss'
311+
>>> common.stripAccents('Süss, “êtré”')
312+
'Suss, "etre"'
313+
314+
Note -- is is still possible to have non-Ascii characters after this,
315+
like in this Japanese expression for music:
316+
317+
>>> common.stripAccents('音楽')
318+
'音楽'
311319
'''
312-
nfkd_form = unicodedata.normalize('NFKD', inputString).replace('ß', 'ss')
320+
nfkd_form = (
321+
unicodedata.normalize('NFKD', inputString)
322+
.replace('ß', 'ss')
323+
.replace('“', '"')
324+
.replace('”', '"')
325+
.replace('‘', "'")
326+
.replace('’', "'")
327+
)
313328
return ''.join([c for c in nfkd_form if not unicodedata.combining(c)])
314329

315330

@@ -324,7 +339,7 @@ def normalizeFilename(name: str) -> str:
324339
without any accented characters.
325340
326341
>>> common.normalizeFilename('03-Niccolò all’lessandra.not really.xml')
327-
'03-Niccolo_alllessandra_not_really.xml'
342+
'03-Niccolo_all_lessandra_not_really.xml'
328343
'''
329344
extension = None
330345
lenName = len(name)

music21/metadata/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,16 @@
175175

176176
class Metadata(base.Music21Object):
177177
r'''
178-
Metadata represent data for a work or fragment, including title, composer,
179-
dates, and other relevant information.
178+
Metadata objects contain information about a work, including title, composer,
179+
dates, and other relevant information. Metadata objects can also cover a fragment
180+
of a Score such as individual parts or a range of measures.
180181
181182
Metadata is a :class:`~music21.base.Music21Object` subclass, meaning that it
182183
can be positioned on a Stream by offset and have a
183184
:class:`~music21.duration.Duration`.
184185
185-
In many cases, each Stream will have a single Metadata object at the zero
186-
offset position.
186+
In many cases, each Stream will have a single Metadata object at the zero-offset
187+
position.
187188
188189
To get a simple string, use attribute-style access by unique name.
189190
Some workIds from music21 v7 have been renamed (e.g. 'date' has been renamed

0 commit comments

Comments
 (0)