"""Glyphs: ADS core icons, drawn from the page's sprite at 16px in currentColor. CSS: glyphs.css. The paths are copied from @atlaskit/icon 38.0.2 svgs/core/ (Apache-2.0), and the tones are @atlaskit/object 2.3.5's accent colours. """ import re from .page import e GLYPHS = { 'page': '', 'task': '', 'epic': '', 'lightbulb': '', 'whiteboard': '', 'pull-request': '', 'incident': '', 'goal': '', 'project': '', 'folder-closed': '', 'calendar': '', 'video': '', 'comment': '', 'hashtag': '', 'person': '', 'teams': '', 'search': '', 'globe': '', 'angle-brackets': '', 'check-circle': '', 'question-circle': '', 'information-circle': '', 'cross-circle': '', 'chevron-right': '', 'copy': '', 'clock': '', } def glyph(name, tone=''): """A glyph from the set, 16px, in the text's colour or a tone: blue, teal, purple, yellow, green or red. An unknown name draws globe. glyph('task', 'blue') """ name = name if name in GLYPHS else 'globe' cls = f'glyph glyph--{e(tone)}' if tone else 'glyph' return f'' def symbols(body): """The sprite symbols for the glyphs the body uses. symbols('') """ used = set(re.findall(r'href="#g-([\w-]+)"', body)) return ''.join(f'{v}' for k, v in GLYPHS.items() if k in used)