Opened 6 years ago

Closed 3 years ago

#10146 closed New feature (wontfix)

Support for contrib/markdown extension_configs in settings.py

Reported by: bdejong Owned by: nobody
Component: contrib.markup Version: master
Severity: Normal Keywords: markdown config extensions extension_configs
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Markdown has support for "extension configs". For example: the "wikilink" extension normally turns [[link]] into <a href="/link/" class="wikilink">link</a>, but if you want to change the link class or the prefix of the URL you need to do this through configuration of the extension.

This patch allows you to add the configuration in the settings.py file as such:

MARKDOWN_EXTENSION_CONFIGS = {
    'wikilink': [
                ('base_url', '/help/'),
                ('end_url', ''),
                ('html_class', 'wikilink')
                ]
}

It's a very small patch but helps a lot when using markdown extensions. Almost all extensions have some form of configuration available.

Attachments (2)

markup_extension_configs.diff (1.2 KB) - added by bdejong 6 years ago.
markdown extension_configs patch, svn revision 9791 version
markup_extension_configs_docs.diff (2.1 KB) - added by bdejong 6 years ago.
documentation for additional (and django 1.0) markup parameters and settings

Download all attachments as: .zip

Change History (17)

Changed 6 years ago by bdejong

markdown extension_configs patch, svn revision 9791 version

comment:1 Changed 6 years ago by bdejong

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Ah, saw that the restrucured text markup template used a different name (and method of getting the config) for the config value. Changed the code to match that example:

MARKDOWN_FILTER_SETTINGS = {'wikilink': [('base_url', '/help/'), ('end_url', '/'), ('html_class', 'wikilink')]}

Now using:

extension_configs = getattr(settings, "MARKDOWN_FILTER_SETTINGS", {})
md = markdown.Markdown(extensions=extensions, extension_configs=extension_configs, safe_mode=safe_mode)

Changed 6 years ago by bdejong

documentation for additional (and django 1.0) markup parameters and settings

comment:2 Changed 6 years ago by bdejong

The documentation diff also includes documentation for features which were already in django 1.0, but were not documented.

I.e. the usage of RESTRUCTUREDTEXT_FILTER_SETTINGS and markdown extensions.

comment:3 Changed 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:4 Changed 6 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 6 years ago by dc

Maybe MarkupField (#10317) will solve this in more generic and elegant way?

comment:6 Changed 6 years ago by jacob

  • milestone changed from 1.1 to 1.2

This is a feature add -- bump to 1.2.

comment:7 Changed 5 years ago by jkocherhans

  • milestone changed from 1.2 to 1.3

Feature. Bumping to 1.3.

comment:8 Changed 5 years ago by ubernostrum

The request for documentation for reST filter support has been split off to #13310; this ticket is now solely for the feature of supporting Markdown extensions.

comment:9 Changed 4 years ago by ubernostrum

  • milestone 1.3 deleted

1.3 is feature-frozen now.

comment:10 Changed 4 years ago by gabrielhurley

  • Component changed from Contrib apps to contrib.markup

comment:11 Changed 4 years ago by SmileyChris

  • Severity set to Normal
  • Type set to New feature

comment:12 Changed 4 years ago by julien

  • Needs tests set

Could someone write tests for this? Also, all changes would need to be combined in one single diff patch.

comment:13 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:14 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:15 Changed 3 years ago by claudep

  • Resolution set to wontfix
  • Status changed from new to closed

contrib.markup has been deprecated (#18504) and will be removed in Django 1.6. Closing as obsolete.

Note: See TracTickets for help on using tickets.
Back to Top