def display_data(instance): if not instance.data: return '' style = '<style>code,pre {font-size:1.13em;}</style><p></p>' try: data = json.dumps(json.loads(instance.data), indent=4, ensure_ascii=False) except ValueError: # data is not a valid json string data = instance.data data = break_lines(data) data = highlight(data, JsonLexer(), HtmlFormatter()) return mark_safe(style + urlize(data))
def display_metadata(instance): style = '<style>code,pre {font-size:1.13em;}</style><p></p>' metadata = break_headers(instance.metadata) metadata = highlight(metadata, JsonLexer(), HtmlFormatter()) return mark_safe(style + urlize(metadata))