• Get Review Board
  • What's New
  • Products
  • Review Board Code review, image review, and document review
  • Documentation
  • Release Notes
  • Power Pack Enterprise integrations, reports, and enhanced document review
  • Try for 60 Days
  • Purchase
  • RBCommons Review Board as a Service, hosted by us
  • Pricing
  • RBTools Command line tools and Python API for Review Board
  • Documentation
  • Release Notes
  • Review Bot Automated code review, connecting tools you already use
  • Documentation
  • Release Notes
  • RB Gateway Manage Git and Mercurial repositories in your network
  • Documentation
  • Release Notes
  • Learn and Explore
  • What is Code Review?
  • Documentation
  • Frequently Asked Questions
  • Support Options
  • Third-Party Integrations
  • Demo
  • Review Board RBTools Power Pack Review Bot Djblets RB Gateway
    1. Djblets 0.9
    2. Version 5.x
    3. Version 4.x
    4. Version 3.x
    5. Version 2.x
    6. Version 2.0
    7. Version 1.0
    8. Version 0.9
    9. Djblets Documentation
    10. Module and Class References
    11. djblets.markdown.extensions.wysiwyg
  • Home
  • Guides
  • Extension Guides
  • Writing Extensions
  • Testing Extensions
  • Web API Guides
  • Writing Web API Resources
  • Module and Class References
  • djblets
  • djblets.auth.forms
  • djblets.auth.signals
  • djblets.auth.util
  • djblets.auth.views
  • djblets.cache.backend
  • djblets.cache.backend_compat
  • djblets.cache.context_processors
  • djblets.cache.errors
  • djblets.cache.forwarding_backend
  • djblets.cache.serials
  • djblets.configforms.forms
  • djblets.configforms.pages
  • djblets.configforms.views
  • djblets.datagrid.grids
  • djblets.db.backends.mysql.base
  • djblets.db.fields
  • djblets.db.managers
  • djblets.db.query
  • djblets.db.validators
  • djblets.extensions.errors
  • djblets.extensions.extension
  • djblets.extensions.forms
  • djblets.extensions.hooks
  • djblets.extensions.loaders
  • djblets.extensions.manager
  • djblets.extensions.middleware
  • djblets.extensions.models
  • djblets.extensions.packaging
  • djblets.extensions.resources
  • djblets.extensions.settings
  • djblets.extensions.signals
  • djblets.extensions.staticfiles
  • djblets.extensions.testing
  • djblets.extensions.testing.testcases
  • djblets.extensions.urls
  • djblets.extensions.views
  • djblets.extensions.templatetags.djblets_extensions
  • djblets.feedview.views
  • djblets.feedview.templatetags.feedtags
  • djblets.forms.fields
  • djblets.gravatars
  • djblets.gravatars.templatetags.gravatars
  • djblets.log
  • djblets.log.middleware
  • djblets.log.siteconfig
  • djblets.log.urls
  • djblets.log.views
  • djblets.mail.dmarc
  • djblets.mail.message
  • djblets.mail.testing
  • djblets.mail.utils
  • djblets.markdown
  • djblets.markdown.extensions.wysiwyg
  • djblets.markdown.extensions.wysiwyg_email
  • djblets.siteconfig.context_processors
  • djblets.siteconfig.django_settings
  • djblets.siteconfig.forms
  • djblets.siteconfig.managers
  • djblets.siteconfig.middleware
  • djblets.siteconfig.models
  • djblets.siteconfig.views
  • djblets.template.loaders.conditional_cached
  • djblets.template.loaders.namespaced_app_dirs
  • djblets.testing.decorators
  • djblets.testing.testcases
  • djblets.testing.testrunners
  • djblets.urls.context_processors
  • djblets.urls.decorators
  • djblets.urls.patterns
  • djblets.urls.resolvers
  • djblets.urls.root
  • djblets.urls.staticfiles
  • djblets.util.contextmanagers
  • djblets.util.dates
  • djblets.util.decorators
  • djblets.util.filesystem
  • djblets.util.http
  • djblets.util.humanize
  • djblets.util.serializers
  • djblets.util.views
  • djblets.util.templatetags.djblets_deco
  • djblets.util.templatetags.djblets_email
  • djblets.util.templatetags.djblets_forms
  • djblets.util.templatetags.djblets_images
  • djblets.util.templatetags.djblets_js
  • djblets.util.templatetags.djblets_utils
  • djblets.webapi.auth
  • djblets.webapi.auth.backends
  • djblets.webapi.auth.backends.api_tokens
  • djblets.webapi.auth.backends.base
  • djblets.webapi.auth.backends.basic
  • djblets.webapi.auth.views
  • djblets.webapi.decorators
  • djblets.webapi.encoders
  • djblets.webapi.errors
  • djblets.webapi.managers
  • djblets.webapi.models
  • djblets.webapi.resources
  • djblets.webapi.resources.base
  • djblets.webapi.resources.group
  • djblets.webapi.resources.registry
  • djblets.webapi.resources.root
  • djblets.webapi.resources.user
  • djblets.webapi.resources.mixins.api_tokens
  • djblets.webapi.resources.mixins.forms
  • djblets.webapi.resources.mixins.queries
  • djblets.webapi.responses
  • djblets.webapi.testing
  • djblets.webapi.testing.decorators
  • djblets.webapi.testing.testcases
  • djblets
  • djblets.auth.forms
  • djblets.auth.signals
  • djblets.auth.util
  • djblets.auth.views
  • djblets.cache.backend
  • djblets.cache.backend_compat
  • djblets.cache.context_processors
  • djblets.cache.errors
  • djblets.cache.forwarding_backend
  • djblets.cache.serials
  • djblets.configforms.forms
  • djblets.configforms.pages
  • djblets.configforms.views
  • djblets.datagrid.grids
  • djblets.db.backends.mysql.base
  • djblets.db.fields
  • djblets.db.managers
  • djblets.db.query
  • djblets.db.validators
  • djblets.extensions.errors
  • djblets.extensions.extension
  • djblets.extensions.forms
  • djblets.extensions.hooks
  • djblets.extensions.loaders
  • djblets.extensions.manager
  • djblets.extensions.middleware
  • djblets.extensions.models
  • djblets.extensions.packaging
  • djblets.extensions.resources
  • djblets.extensions.settings
  • djblets.extensions.signals
  • djblets.extensions.staticfiles
  • djblets.extensions.testing
  • djblets.extensions.testing.testcases
  • djblets.extensions.urls
  • djblets.extensions.views
  • djblets.extensions.templatetags.djblets_extensions
  • djblets.feedview.views
  • djblets.feedview.templatetags.feedtags
  • djblets.forms.fields
  • djblets.gravatars
  • djblets.gravatars.templatetags.gravatars
  • djblets.log
  • djblets.log.middleware
  • djblets.log.siteconfig
  • djblets.log.urls
  • djblets.log.views
  • djblets.mail.dmarc
  • djblets.mail.message
  • djblets.mail.testing
  • djblets.mail.utils
  • djblets.markdown
  • djblets.markdown.extensions.wysiwyg
  • djblets.markdown.extensions.wysiwyg_email
  • djblets.siteconfig.context_processors
  • djblets.siteconfig.django_settings
  • djblets.siteconfig.forms
  • djblets.siteconfig.managers
  • djblets.siteconfig.middleware
  • djblets.siteconfig.models
  • djblets.siteconfig.views
  • djblets.template.loaders.conditional_cached
  • djblets.template.loaders.namespaced_app_dirs
  • djblets.testing.decorators
  • djblets.testing.testcases
  • djblets.testing.testrunners
  • djblets.urls.context_processors
  • djblets.urls.decorators
  • djblets.urls.patterns
  • djblets.urls.resolvers
  • djblets.urls.root
  • djblets.urls.staticfiles
  • djblets.util.contextmanagers
  • djblets.util.dates
  • djblets.util.decorators
  • djblets.util.filesystem
  • djblets.util.http
  • djblets.util.humanize
  • djblets.util.serializers
  • djblets.util.views
  • djblets.util.templatetags.djblets_deco
  • djblets.util.templatetags.djblets_email
  • djblets.util.templatetags.djblets_forms
  • djblets.util.templatetags.djblets_images
  • djblets.util.templatetags.djblets_js
  • djblets.util.templatetags.djblets_utils
  • djblets.webapi.auth
  • djblets.webapi.auth.backends
  • djblets.webapi.auth.backends.api_tokens
  • djblets.webapi.auth.backends.base
  • djblets.webapi.auth.backends.basic
  • djblets.webapi.auth.views
  • djblets.webapi.decorators
  • djblets.webapi.encoders
  • djblets.webapi.errors
  • djblets.webapi.managers
  • djblets.webapi.models
  • djblets.webapi.resources
  • djblets.webapi.resources.base
  • djblets.webapi.resources.group
  • djblets.webapi.resources.registry
  • djblets.webapi.resources.root
  • djblets.webapi.resources.user
  • djblets.webapi.resources.mixins.api_tokens
  • djblets.webapi.resources.mixins.forms
  • djblets.webapi.resources.mixins.queries
  • djblets.webapi.responses
  • djblets.webapi.testing
  • djblets.webapi.testing.decorators
  • djblets.webapi.testing.testcases
  • General Index
  • Python Module Index
  • Release Notes
  • This documentation covers Djblets 0.9. You can select a version above or view the latest documentation.

    djblets.markdown.extensions.wysiwyg¶

    class SmartEmptyBlockProcessor(parser)[source]¶

    Bases: markdown.blockprocessors.BlockProcessor

    Handles empty blocks in a more specialized way.

    By default, Python-Markdown will trim away excess empty blocks, with the idea being that it doesn’t matter how much whitespace exists between tags when rendered to HTML. However, in our case, we need to preserve whitespace in order to better match the resulting render to the input text.

    We replace any empty lines with paragraph tags, which will safely stick around.

    This is invoked before EmptyBlockProcessor.

    test(parent, block)[source]¶

    Test that the processor should apply to the given block.

    run(parent, blocks)[source]¶

    Run the processor on the given blocks.

    class PreserveStartOListBlockProcessor(parser)[source]¶

    Bases: markdown.blockprocessors.OListProcessor

    Applies CSS styles to any <ol> with a start= attribute.

    This allows for CSS tricks to be performed that ensure that ordered list item numbers and item contents line up between source text and rendered text. It basically turns off the <li>’s native counter value and instead creates its own using :before and CSS counters. These tricks end up causing the start= attribute on the <ol> to be ignored.

    This block processor extends the standard OListProcessor to also apply a CSS style to set the displayed counter value to the intended start value.

    This replaces OListProcessor.

    run(parent, blocks)[source]¶

    Run the processor on the given blocks.

    class TrimTrailingEmptyParagraphs(markdown_instance=None)[source]¶

    Bases: markdown.treeprocessors.Treeprocessor

    Removes empty paragraphs from the end of the tree.

    This will remove any trailing empty paragraphs formerly added by SmartEmptyBlockProcessor. This step must be done after all the blocks are processed, so that we have a complete picture of the state of the tree. It’s therefore performed right before we prettify the tree.

    run(root)[source]¶

    Run the processor on the root of the tree.

    class RTrimmedString[source]¶

    Bases: unicode

    Keeps a string free of trailing whitespace when replacing.

    This is used in TrimmedRawHtmlPostprocessor to prevent the base RawHtmlPostprocessor code from adding an extra unnecessary newline when replacing raw HTML placeholders.

    When that code calls replace(), the replaced contents will be rstrip’d, removing the newline. The result of that call is another RTrimmedString.

    Note that other functions may result in a standard string being returned, but in the case of RawHtmlPostprocessor, this isn’t really a concern.

    replace(src, dest)[source]¶

    Replace the contents of the string.

    This wraps the string’s replace method to return another RTrimmedString instead of a standard string, rstripping any newlines in the process.

    class TrimmedRawHtmlPostprocessor(markdown_instance=None)[source]¶

    Bases: markdown.postprocessors.RawHtmlPostprocessor

    Post-processes raw HTML placeholders, without adding extra newlines.

    Python Markdown’s RawHtmlPostprocessor had a nasty habit of adding an extra newline after replacing a placeholder with stored raw HTML. That would cause extra newlines to appear in our output.

    This version first converts the string to a RTrimmedString, preventing these newlines from being added. It then converts back to a standard string.

    run(text)[source]¶

    Run the processor on the HTML.

    class WysiwygFormattingExtension(configs={})[source]¶

    Bases: markdown.extensions.Extension

    Provides a series of WYSIWYG formatting rules for Markdown rendering.

    We have a lot of specific rendering concerns that Python Markdown doesn’t really address, or generally need to care about. We try very hard to match up newlines around various code blocks, and we have special ways we do ordered lists. The resulting rendered output is meant to look identical to the input text, as much as possible.

    This extension renders a series of processors that ensures that the HTML output is in the format required for our rendering.

    This is meant to be used with the following Markdown configuration and extensions:

    {
        'lazy_ol': False,
        'extensions': [
            'sane_lists', 'nl2br', 'djblets.markdown.extentions.wysiwyg',
        ],
    }
    
    extendMarkdown(md, md_globals)[source]¶

    Extend the list of Markdown processors.

    Each processor in this file will be registered in the order necessary for the smarter formatting.

    makeExtension(configs={})[source]¶

    Create a Markdown extension instance for this file.

    Keep up with the latest Review Board releases, security updates, and helpful information.

    About
    News
    Demo
    RBCommons Hosting
    Integrations
    Happy Users
    Support Options
    Documentation
    FAQ
    User Manual
    RBTools
    Administration Guide
    Power Pack
    Release Notes
    Downloads
    Review Board
    RBTools
    Djblets
    Power Pack
    Package Store
    PGP Signatures
    Contributing
    Bug Tracker
    Submit Patches
    Development Setup
    Wiki
    Follow Us
    Mailing Lists
    Reddit
    Twitter
    Mastodon
    Facebook
    YouTube

    Copyright © 2006-2025 Beanbag, Inc. All rights reserved.

    Terms of Service — Privacy Policy — AI Ethics Policy — Branding

    On this page

    • [Top]