Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F1526DFB3 for ; Thu, 29 Nov 2012 23:17:46 +0000 (UTC) Received: (qmail 3141 invoked by uid 500); 29 Nov 2012 23:17:46 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 3123 invoked by uid 500); 29 Nov 2012 23:17:46 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 3105 invoked by uid 99); 29 Nov 2012 23:17:46 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Nov 2012 23:17:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 91562813853; Thu, 29 Nov 2012 23:17:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brondsem@apache.org To: allura-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: [#5316] allow markdown within html tags, and document it Message-Id: <20121129231746.91562813853@tyr.zones.apache.org> Date: Thu, 29 Nov 2012 23:17:46 +0000 (UTC) Updated Branches: refs/heads/db/5316 [created] d49a66a09 [#5316] allow markdown within html tags, and document it Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d49a66a0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d49a66a0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d49a66a0 Branch: refs/heads/db/5316 Commit: d49a66a096a2388e5596cd5a8e62280b2695bbdf Parents: d460995 Author: Dave Brondsema Authored: Thu Nov 29 23:17:35 2012 +0000 Committer: Dave Brondsema Committed: Thu Nov 29 23:17:35 2012 +0000 ---------------------------------------------------------------------- Allura/allura/lib/markdown_extensions.py | 2 + Allura/allura/templates/jinja_master/lib.html | 32 ++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d49a66a0/Allura/allura/lib/markdown_extensions.py ---------------------------------------------------------------------- diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py index b34aa6a..0a5f75d 100644 --- a/Allura/allura/lib/markdown_extensions.py +++ b/Allura/allura/lib/markdown_extensions.py @@ -33,6 +33,8 @@ class ForgeExtension(markdown.Extension): def extendMarkdown(self, md, md_globals): md.registerExtension(self) + # allow markdown within e.g.
...
More info at: https://github.com/waylan/Python-Markdown/issues/52 + md.preprocessors['html_block'].markdown_in_raw = True md.preprocessors['fenced-code'] = FencedCodeProcessor() md.preprocessors.add('plain_text_block', PlainTextPreprocessor(md), "_begin") md.inlinePatterns['autolink_1'] = AutolinkPattern(r'(http(?:s?)://[a-zA-Z0-9./\-_0%?&=+#;~:]+)') http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d49a66a0/Allura/allura/templates/jinja_master/lib.html ---------------------------------------------------------------------- diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html index 7bfdddc..239f66f 100644 --- a/Allura/allura/templates/jinja_master/lib.html +++ b/Allura/allura/templates/jinja_master/lib.html @@ -120,7 +120,7 @@
  • Links
  • Reference Links
  • Artifact Links
  • -
  • Text
  • +
  • Basic Text Formatting
  • Blockquotes
  • Preformatted Text
  • Lists
  • @@ -128,7 +128,7 @@
  • Headers
  • Horizontal Rules
  • Images
  • -
  • Escapes
  • +
  • Escapes and HTML
  • More Headers
  • Table of Contents
  • Code Highlighting
  • @@ -226,7 +226,7 @@ You can even link to tickets in a subproject with `[subproject.tickets:#123]`.
    -

    Text

    +

    Basic Text Formatting

    Use * or _ to emphasize things:

    *this is in italic*  and _so is this_
     
    @@ -484,7 +484,7 @@ image.

    -

    Escapes

    +

    Escapes and HTML

    What if you want to just show asterisks, not italics?

    * this shows up in italics: *a happy day*
     * this shows the asterisks: \*a happy day\*
    @@ -494,22 +494,30 @@ image.

    {{g.markdown.convert('''* this shows up in italics: *a happy day* * this shows the asterisks: \*a happy day\*''')}} -

    The backslashes will disappear and leave the asterisks.

    -

    You can do the same with any of the characters that have a special meaning
    for Markdown.

    -

    HTML tags may need to be escaped. <b> will be interpreted as a bold tag. Entity codes will be used. -<foobar> isn't allowed and will be dropped, so you probably want to escape it:

    +

    The backslashes will disappear and leave the asterisks. You can do the same with any of the +characters that have a special meaning
    for Markdown.

    + +

    Many simple HTML tags are allowed, for example <b> And unknown tags will be dropped. +To show a literal <b> or an unknown tag like <foobar> you need escape it with +HTML entities: +:

     <b>this will be bold</b>
     you should escape &lt;unknown&gt; tags
    -&lt; special entities work
    -&amp;lt; if you want to escape it
    +&copy; special entities work
    +&amp;copy; if you want to escape it
     

    Output:

    {{g.markdown.convert('''this will be bold you should escape <unknown> tags -< special entities work -&lt; if you want to escape it''')}} +© special entities work +&copy; if you want to escape it''')}} + +

    HTML tags that are block-level like <div> can be used, but if there is markdown formatting +within it, you must add a "markdown" attribute: <div markdown> Some safe attributes are also +allowed, permitting basic styling and layout: <div markdown style="float:left">

    +

    Individual ampersands (&) and less-than signs (<) are fine, they will be shown as expected.