Git Product home page Git Product logo

Comments (7)

wckd avatar wckd commented on June 5, 2024 11

@will-emmerson You can install the django-markdown-deux package, add 'markdown_deux' to INSTALLED_APPS and put {% load markdown_deux_tags %} in the head of your template.
You can then apply the markdown-filter on the variable that holds the markdown-content.

Heres an example:

{% extends 'base.html' %}
{% load markdown_deux_tags %}

{% block content %}
    <div class="blog-post">
        <h2 class="blog-post-title">{{ entry.title }}</h2>
        <p class="blog-post-meta">{{ entry.created }} by {{ entry.author.first_name }}</p>
        {{ entry.body|markdown }}
    </div>
    {% if user.is_superuser %}
        <a href="{% url 'entry_update' slug=entry.slug %}" role="button" class="btn btn-primary"> Edit</a>
    {% endif %}
{% endblock %

from django-pagedown.

timmyomahony avatar timmyomahony commented on June 5, 2024 2

I've added a section at the bottom of the README addressing this, so hopefully it is clearer now:

https://github.com/timmyomahony/django-pagedown/blob/master/README.md#rendering-markdown-in-your-template

from django-pagedown.

timmyomahony avatar timmyomahony commented on June 5, 2024 1

I presume you mean you don't want to see the preview when writing your markdown in the django admin or elsewhere? You could simply hide the preview via css:

.wmd-preview{
    display: none;
}

but there is no built in way to ommit the preview div

from django-pagedown.

will-emmerson avatar will-emmerson commented on June 5, 2024

No, I want to see the preview in the admin and allow editing via the admin, but on other pages I just want the rendered html without the preview. Django 1.5 had a markdown template tag but 1.6 doesn't, I'm just wondering if pagedown includes any.

from django-pagedown.

timmyomahony avatar timmyomahony commented on June 5, 2024

I will add this to the README

from django-pagedown.

hitarths avatar hitarths commented on June 5, 2024

There is a difference between the django-pagedown preview and the html generated by the django-markdown-deux. Specifically the preview from pagedown shows line breaks when I press enter, but when I render it using the deux tag, the line breaks are gone. BUT, it I put two line breaks, then deux DOES puts
tags.
I am not sure if its a bug in pagedown, or its just the fact that I am silly!

from django-pagedown.

timmyomahony avatar timmyomahony commented on June 5, 2024

@hitarths that's interesting, I haven't noticed that before. The django-markdown-deux library uses python-markdown2 behind the scenes. python-markdown2 allows configuration via "Extras". I notice a break-on-newline option there. Something like this might work (I haven't tested it though):

MARKDOWN_DEUX_STYLES = {
    "default": {
        "extras": {
            "break-on-newline": None,
        },
        # ...
    },
}

from django-pagedown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.