def loadFormats(self):
        self.formats = {}

        stylesCSS = pkg_resources.resource_string(data.__name__, 'styles.css')
        print("styles.css file: {}".format(stylesCSS))
        styleSheet = cssutils.parseString(stylesCSS)

        blockFormats = ['title[level="1"]', 
                        'title[level="2"]', 
                        'title[level="3"]', 
                        'para',
                        'tip',
                        'warning',
                        'blockquote',
                        'programlisting[language="java"]',
                        'programlisting[language="cpp"]',
                        'programlisting[language="xml"]',
                        'programlisting[language="sql"]',
                        'programlisting[language="python"]',
                        'programlisting[language="bash"]',
                        'screen']

        for cssKey in blockFormats:
            cssRule = self.simpleLookup(styleSheet, cssKey)

            # get the selector as a tuple of class and one attribute selector
            # (Can be extended later, but currently sufficient)
            m = re.match(r'^(\S*?)(?:\[(.*)="(.*)"])?$', cssKey)
            selector = m.groups()

            blockFmt = QTextBlockFormat()
            blockFmt.setProperty(QTextFormat.UserProperty, selector)

            value = self.getIntValue(cssRule, 'margin-top')
            if value:
                blockFmt.setTopMargin(value)
            value = self.getIntValue(cssRule, 'margin-right')
            if value:
                blockFmt.setRightMargin(value)
            value = self.getIntValue(cssRule, 'margin-bottom')
            if value:
                blockFmt.setBottomMargin(value)
            value = self.getIntValue(cssRule, 'margin-left')
            if value:
                blockFmt.setLeftMargin(value)
            value = self.getColorValue(cssRule, 'background-color')
            if value:
                blockFmt.setBackground(value)

            charFmt = QTextCharFormat()
            self.setCharFormatAttributes(cssRule, charFmt)

            fmt = Format(blockFmt, charFmt)
            value = self.getStringValue(cssRule, 'white-space')
            if value and value == 'pre':
                fmt.isPre = True
            self.formats[selector] = fmt

### List formats

        listFormats = ['itemizedlist[level="1"]',
                       'itemizedlist[level="2"]',
                       'itemizedlist[level="3"]', 
                       'itemizedlist[level="4"]',
                       'orderedlist[level="1"]',
                       'orderedlist[level="2"]' ,
                       'orderedlist[level="3"]',
                       'orderedlist[level="4"]'] 
        for cssKey in listFormats:
            cssRule = self.simpleLookup(styleSheet, cssKey)

            indent = 0
            m = re.match(r'^(\S*?)(?:\[(.*)="(.*)"])?$', cssKey)
            selector = m.groups()
            if selector[1] == 'level':
                indent = int(selector[2])

            listFmt = QTextListFormat()
            listFmt.setProperty(QTextFormat.UserProperty, selector)
            listFmt.setIndent(indent)

            value = self.getStringValue(cssRule, 'list-style-type')
            if value:
                if value == 'disc':
                    listFmt.setStyle(QTextListFormat.ListDisc)
                elif value == 'circle':
                    listFmt.setStyle(QTextListFormat.ListCircle)
                elif value == 'square':
                    listFmt.setStyle(QTextListFormat.ListSquare)
                elif value == 'decimal':
                    listFmt.setStyle(QTextListFormat.ListDecimal)

            self.formats[selector] = Format(None, None, listFmt)

### Inline formats

        # Base format (?????)
        pcharFmt = QTextCharFormat()
        pcharFmt.setFontPointSize(10)
        pcharFmt.setFontFamily("Sans")

        inlineFormats = ['emphasis[role="highlight"]', 
                         'emphasis',
                         'code',
                         'link',
                         'olink']

        for cssKey in inlineFormats:
            cssRule = self.simpleLookup(styleSheet, cssKey)

            m = re.match(r'^(\S*?)(?:\[(.*)="(.*)"])?$', cssKey)
            selector = m.groups()

            charFmt = QTextCharFormat(pcharFmt)
            charFmt.setProperty(QTextFormat.UserProperty, selector)

            # TODO: better approach?
            if cssKey in ['link', 'olink']:
                charFmt.setAnchor(True)
            self.setCharFormatAttributes(cssRule, charFmt)

            self.formats[selector] = Format(None, charFmt)

### special formats
        charFmt = QTextCharFormat()
        cssRule = self.simpleLookup(styleSheet, 'searchMarker')
        self.setCharFormatAttributes(cssRule, charFmt)
        self.formats[('searchMarker', None, None)] = Format(None, charFmt)