Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds machinery to use (edit and display) markdown in text fields. This PR implements this on the
Source.selected_bibliography
andSource.description
fields, but the same machinery can be used for other fields (e.g., flat page fields, future landing page fields).The PR includes the following features:
MarkdownWidget
django widget that can be used in forms. This widget provides both atextarea
editing area and the ability to navigate via tabs to a "preview" area. This preview is generated client side (with themarked.js
dependencies included by way of the widget definition.render_markdown
template tag that converts the markdown to html and sanitizes the html on the server side for when fields containing markdown are displayed.MarkdownWidget
and a new classmarkdown-field-display
that styles the contents of markdown fields (note: in future, these stylings could be expanded to multiple classes that can be used to style fields generated from markdown differently in different contexts).Note: The
render_markdown
tag cleans the generated html to remove raw html included in the markdown. Thus, fields displayed with this template tag that have legacy raw html in them will need to be edited before they will display correctly. This editing should occur concurrently with the implementation of this PR on production. I realize that this limits the kinds of things we can do in these fields (we can't use markup alongside markdown), which may present a future problem; on the other hand, we may find that these limits are perfectly fine for our use of these fields.Once this is implemented and relevant fields are edited, we will be able to deal with #1239, #1221, and #1219.
Screenshot of edit tab:
Screenshot of detail view: