Skip to content

Disable parts of Markdown #179

Closed
Closed

Description

@daGrevis

Are there any way to disable, lets say, image adding for Markdown?

I'm using Markdown markup for my blog — for articles and comments. Articles should have full support for Markdown including HTML, but comments should allow only minimal markup w/o images and HTML.

Activity

  1. waylan commented on Jan 15, 2013

    @waylan
    Member

    You can do this with Python-Markdown's Extension API (see the built-in safe_mode to disallow html). In fact, the Extension API should allow you to change any part of the parser you want to do pretty much anything you want. Of course, you'll need to create your own extension (unless a third party extension already meets your needs).

    However, I think a better tool would be to use something like Bleach after running markdown for something like this. In fact, I recommend Bleach over our own so-called 'safe_mode`.

    import bleach
    import markdown
    bleach.clean(markdown.markdown(some_comment))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions