From cf29edcd7465e99bf123765d35a06afb463edd64 Mon Sep 17 00:00:00 2001 From: Jakob Kramer Date: Tue, 24 Apr 2012 17:16:31 +0200 Subject: [PATCH] allow pre+code tags in rendered HTML --- mediagoblin/static/css/base.css | 20 ++++++++++++++++++-- mediagoblin/tools/text.py | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index ed3f69a6..6909bf28 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -544,18 +544,34 @@ table.media_panel th { margin-left: 10px; } -/* ASCII art */ +/* ASCII art and code */ @font-face { font-family: Inconsolata; src: local('Inconsolata'), url('../fonts/Inconsolata.otf') format('opentype') } -.ascii-wrapper pre { +pre, code { font-family: Inconsolata, monospace; line-height: 1em; } +pre { + overflow: auto; + /* -10px, because it is usually preceded by

with margin-bottom: 20px */ + margin: -10px 0 10px 0; +} + +.comment_wrapper pre { + /* same as above, but with 2px */ + margin: 8px 0 10px 0; +} + +.ascii-wrapper pre { + /* but it should not affect the ASCII art */ + margin: 0; +} + /* Media queries and other responsivisivity */ @media screen and (max-width: 940px) { .media_pane { diff --git a/mediagoblin/tools/text.py b/mediagoblin/tools/text.py index 138d8ed7..ea231244 100644 --- a/mediagoblin/tools/text.py +++ b/mediagoblin/tools/text.py @@ -36,7 +36,8 @@ HTML_CLEANER = Cleaner( forms=True, annoying_tags=True, allow_tags=[ - 'div', 'b', 'i', 'em', 'strong', 'p', 'ul', 'ol', 'li', 'a', 'br'], + 'div', 'b', 'i', 'em', 'strong', 'p', 'ul', 'ol', 'li', 'a', 'br', + 'pre', 'code'], remove_unknown_tags=False, # can't be used with allow_tags safe_attrs_only=True, add_nofollow=True, # for now -- 2.25.1