pylixm / django-mdeditor

Django-mdeditor is Markdown Editor plugin application for django base on Editor.md.
https://pypi.org/project/django-mdeditor/
GNU General Public License v3.0
481 stars 103 forks source link

Remove line numbers in Code #93

Closed sjay05 closed 4 years ago

sjay05 commented 4 years ago

I would like to remove the line numbers that appear on code like the image below. Is there a quick way I can do this?

image

jaradc commented 4 years ago

I am a new user as well and am wondering the same. I thought this would do it but I still see line numbers:

MDEDITOR_CONFIGS = {
    'default': {
        'language': 'en',
        'lineNumbers': False,
    }
}
jaradc commented 4 years ago

Kind of got it with some custom css, but not sure this is the best approach:

posts/static/posts/css/posts_custom.css

ol.linenums {
    padding-left: 0 !important;
}

ol.linenums li {
    list-style-type: none !important;
}

posts/admin.py

from django.contrib import admin
from posts.models import Post

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ('id', 'title', 'user')
    list_display_links = ('title',)

    class Meta:
        model = Post

    class Media:
        css = {'all': ('posts/css/posts_custom.css',)}
        js = ()

Still, why doesn't lineNumbers work? I came across several posts experiencing the same thing.

pylixm commented 4 years ago

The 'lineNumbers' in the configuration is the global edit box line number control, not the code block. The line number of the code block does not support configuration now, it can only be retained. You can also modify the CSS style to achieve it yourself, or have a more elegant solution, please leave a message or submit a PR.