Giter VIP home page Giter VIP logo

agusmakmun / django-markdown-editor Goto Github PK

View Code? Open in Web Editor NEW
775.0 11.0 1.3K 7.45 MB

Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI

License: GNU General Public License v3.0

Python 26.75% JavaScript 43.79% CSS 9.16% HTML 19.04% Shell 1.05% Dockerfile 0.21%
markdown markdown-editor semantic-ui django ace wysiwyg content-editor python-markdown django-markdown-editor martor

django-markdown-editor's People

Contributors

0p3r4t0r avatar agusmakmun avatar aleksac avatar baseplate-admin avatar bhemmer avatar cristopherh95 avatar dependabot[bot] avatar enjoy-software avatar jafnhaar avatar jsenecal avatar junwenwaynepeng avatar kayleethemech avatar kvadimas avatar mvbrn avatar naincykumariknoldus avatar nezhar avatar oasismystre avatar olymk2 avatar pcraig3 avatar peppar avatar pizzapanther avatar quantum5 avatar rgammans avatar soomy avatar tim-schilling avatar tomaszn avatar tsvwd avatar xero7689 avatar xyene avatar yolcruz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-markdown-editor's Issues

Syntax highlighting doesn't work in page view with template tags?

It seems that the syntax highlighting doesn't work with template tages. For example, with:

{% load dractags %}
{{ content | safe_makrdown }}

where content is:

```python

import numpy as np

import matplotlib.pyplot as plt

x = np.random.randn(100)

y = np.random.randn(100)

plt.plot(x, y) 

\```

only surrounds the string wiht , but doesn't really render any of the hljs tags.

I wonder if I'm doing something wrong or simply this feature is not available (I copied the default settings from front page, using django 1.11 final).

Thanks!

Italics, Heading, and "Pre" add double characters

Similar to the issue I raised about bold adding double the amount of asterisks, I've found that the same is true for italics, headings, and selecting the "pre" option when you want to highlight code. Please see the following screenshot, which was generated by typing text, selecting it, and then choosing on of the options from the bar. Note: I did not press the button twice, just once. The issue persists in both chrome and safari.

It only happens when you click on the buttons in the toolbar. Using the keyboard shortcuts works as expected.

image

Emojiis dont work when using storage engines

When running fetch_emojii the images are fetched and uploaded to a bucket.

How ever on display the domain and hash's are missing so the used emojiis do not work when displayed if you dont use a bucket and have a localfile system store everything works fine.

Usually {% static %} fixes this but because the path's are worked out before the template is rendered they are incorrect.

Incoming PR which should fix this.

custom css

How can I override the css for the widget?

Rendering forms via Javascript

Hi. Currently the template I've written will generate one editor at the top which serves its purpose, however, when I click on a "Reply" button on the page I want another markdown editor form to be appended below.

I've currently tried cloning the form above and changing the ids to avoid conflicts however this renders the form unusable altogether (cannot type, button clicks on the editor do nothing). If I include two forms in the template (so not generated by Javascript) any buttons I click on the second editor will only ever make changes to the 1st editor.

I currently suspect most of these issues are due to the handlers on the Javascript files provided and was wondering if there was a potential workaround without having to change the JS files?

Below is the code in the HTML template which renders the current editor at the top of the page (works correctly)

<form method="POST" id="comment-post-form" class="comment-post-form">
    {% csrf_token %}
    {% for field in comment_form %}
        <p class="{{field.name}}-container">
            {{ field }}
        </p>
    {% endfor %}
    <button name="comment_submit" type="submit">Post Comment</button>
</form>

Below is the JS function which when the reply button is pressed is called. It should append the editor to div tag provided, whilst adding a user mention preloaded into the editor. The code below was from my attempt of cloning the editor already on the page using jQuery.

function generateReplyForm(commentIdAppendTo) {
    const userReplyTo = $(`#${commentIdAppendTo}`).children('.comment-author-username').html();

    let newForm = $('#comment-post-form').clone().removeAttr('id');
    newForm.find('.ace_content').text(`@${userReplyTo}`);
    newForm.find('#martor-content').attr('id', `#martor-content${commentIdAppendTo}`);
    newForm.find('#id_content').attr('id', `#id_content${commentIdAppendTo}`);
    $(`#${commentIdAppendTo}`).append(newForm);
}

Does id on h* tags are supported ?

Hi,

I have multiples titles which are translates as h1, h2 ... But when I try to render, it doesn't add an id attribute on the html tag, which leads me to not having table of content.

Any idea ?

Thanks you :)

Wrong request path to markdown.js

Hello,
Can someone help me with very weird bug? On production settings ace.js makes request to invalid path. Something like this: https://<domain>/en/patterns/snippets/markdown.js/ where correct path must be https://<domain>/static/plugins/js/snippets/markdown.js/. Development server on local machine doesn't produce such a behaviour. Maybe i miss some setting?

Imported or loaded extension modules message hiding

Hi!

I write a blog engine and the martor prints every page load "Successfully loaded extension" or "Successfuly imported extension module". How can I hide these messages?

web01 | Successfuly imported extension module "markdown.extensions.extra".
web01 | Successfuly imported extension module "markdown.extensions.smart_strong".  
web01 | Successfully loaded extension "markdown.extensions.smart_strong.SmartEmphasisExtension".  
web01 | Successfuly imported extension module "markdown.extensions.fenced_code".  
web01 | Successfully loaded extension "markdown.extensions.fenced_code.FencedCodeExtension".
web01 | Successfuly imported extension module "markdown.extensions.footnotes".
web01 | Successfully loaded extension "markdown.extensions.footnotes.FootnoteExtension".
web01 | Successfuly imported extension module "markdown.extensions.attr_list".
web01 | Successfully loaded extension "markdown.extensions.attr_list.AttrListExtension".
web01 | Successfuly imported extension module "markdown.extensions.def_list".
web01 | Successfully loaded extension "markdown.extensions.def_list.DefListExtension".
web01 | Successfuly imported extension module "markdown.extensions.tables".
web01 | Successfully loaded extension "markdown.extensions.tables.TableExtension".
web01 | Successfuly imported extension module "markdown.extensions.abbr".
web01 | Successfully loaded extension "markdown.extensions.abbr.AbbrExtension".
web01 | Successfully loaded extension "markdown.extensions.extra.ExtraExtension".
web01 | Successfuly imported extension module "markdown.extensions.nl2br".
web01 | Successfully loaded extension "markdown.extensions.nl2br.Nl2BrExtension".
web01 | Successfuly imported extension module "markdown.extensions.smarty".
web01 | Successfully loaded extension "markdown.extensions.smarty.SmartyExtension".
web01 | Successfuly imported extension module "markdown.extensions.fenced_code".
web01 | Successfully loaded extension "markdown.extensions.fenced_code.FencedCodeExtension".
web01 | Successfuly imported extension module "martor.extensions.urlize".
web01 | Successfully loaded extension "martor.extensions.urlize.UrlizeExtension".
web01 | Successfuly imported extension module "martor.extensions.del_ins".
web01 | Successfully loaded extension "martor.extensions.del_ins.DelInsExtension".
web01 | Successfuly imported extension module "martor.extensions.mention".
web01 | Successfully loaded extension "martor.extensions.mention.MentionExtension".
web01 | Successfuly imported extension module "martor.extensions.emoji".
web01 | Successfully loaded extension "martor.extensions.emoji.EmojiExtension".
web01 | Successfuly imported extension module "martor.extensions.mdx_video".
web01 | Successfully loaded extension "martor.extensions.mdx_video.VideoExtension".

`

I'm use docker so the web01 is my container name.

Thanks,
Greg

License for emojis

Hello,

I have a simple question about the emojis used in your markdown extension.
Does the assets-cdn used for rendering emojis is under a license ? Can we use it has free ?

Sincerely.

bug with order list

When I use list, it can not automatically complete the number after pressing the Enter key.

Synthax highlighting does not work.

Synthax highlighting is not working.
I am getting this (code block is not highlighted in my case though)

def foo():
    print("Hi")

Instead of this

def foo():
    print("Hi")

Also preview in admin page is not working. The result of the preview is always
"Nothing to preview"

However I can display the markdown content on the page (without synthax highlighting).

Django version 2.1.2.
Markdown version 2.6.11

Bug while rendering more than one editor

Hi, there is this bug when there are 2 or more martor fields on the same page.

The first one is rendered well, but the others are incompletes, and miss this part of the code:

<div id="martor-content" class="martor-field martor-field-content ace_editor resizable ace-github" draggable="false">
    <div style="position: absolute;"></div>
	<textarea class="ace_text-input" autocorrect="off" autocapitalize="off" spellcheck="false" style="opacity: 0; font-size: 1px; height: 1px; width: 1px; top: 24px; left: 86px;" wrap="off">
	</textarea>
	<div class="ace_gutter" aria-hidden="true" style="left: 0px; width: 40px;">
	  <div class="ace_layer ace_gutter-layer ace_folding-enabled" style="height: 1000000px; top: 10px; left: 0px; width: 40px;">
	    <div class="ace_gutter-cell ace_gutter-active-line " style="height: 14px; top: 0px;">
		  1
		  <span class="ace_fold-widget ace_start ace_open" style="height: 14px; display: inline-block;"></span>
		</div>
	  </div>
	</div>
	<div class="ace_scroller" style="left: 40px; right: 0px; bottom: 0px;">
	  <div class="ace_content" style="top: 10px; left: 0px; width: 795px; height: 128px;">
	    <div class="ace_layer ace_print-margin-layer">
		  <div class="ace_print-margin" style="left: 564px; visibility: visible;"></div>
		</div>
		<div class="ace_layer ace_marker-layer">
		  <div style="height: 14px; top: 0px; left: 0px; right: 0px;" class="ace_active-line"></div>
		</div>
		<div class="ace_layer ace_text-layer" style="height: 1000000px; margin: 0px 4px; top: 0px; left: 0px;">
		  <div style="height: 14px; top: 0px;" class="ace_line_group">
		    <div class="ace_line" style="height: 14px;">
			  <span class="ace_markup ace_heading ace_1">#</span>
			  <span class="ace_heading">my awesome markdown</span>
			</div>
	      </div>
		</div>
		<div class="ace_layer ace_marker-layer"></div>
		<div class="ace_layer ace_cursor-layer ace_hidden-cursors">
		  <div class="ace_cursor" style="display: block; top: 0px; left: 46px; width: 7px; height: 14px; animation-duration: 1000ms;"></div>
		</div>
      </div>
	</div>
	<div class="ace_scrollbar ace_scrollbar-v" style="display: none; width: 22px; bottom: 0px;">
	  <div class="ace_scrollbar-inner" style="width: 22px; height: 34px;"></div>
	</div>
	<div class="ace_scrollbar ace_scrollbar-h" style="display: none; height: 22px; left: 40px; right: 0px;">
	  <div class="ace_scrollbar-inner" style="height: 22px; width: 835px;"></div>
	</div>
	<div style="height: auto; width: auto; top: 0px; left: 0px; visibility: hidden; position: absolute; white-space: pre; font: inherit; overflow: hidden;">
	<div style="height: auto; width: auto; top: 0px; left: 0px; visibility: hidden; position: absolute; white-space: pre; font: inherit; overflow: visible;">הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה</div>
	<div style="height: auto; width: auto; top: 0px; left: 0px; visibility: hidden; position: absolute; white-space: pre; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; font-size-adjust: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-language-override: inherit; font-feature-settings: inherit; font-variation-settings: inherit; overflow: visible;">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</div>
	</div><div class="resizable-handle resizable-b"></div><div class="resizable-handle resizable-b"></div>
</div>

Newer markdown not compatible

requirements.txt just has "Markdown" (therefore pip installs the latest version), but the code only allows 2.6.9.

except Exception:
        raise VersionNotCompatible("The markdown isn't compatible, please reinstall "
                                   "your python markdown into Markdown==2.6.9")

Can this be updated for newer versions and specify the version required (if necessary) in the requirements.txt?

Also note that the error is displayed for any error I've encountered with martor even when 2.6.9 is installed.

Adding the widget toolbar into the post editing page

Hello, I followed your instruction to apply the changes to my models.py and expected to see the same toolbar in my frontend blog post editor as the one shown in Admin. However it doesn't work (it looks like this:

screenshot 2018-03-04 23 10 22

I also tried the suggestions in the post , still doesn't work.

Here is my code (model.py):

## models.py 

from django.db import models
from django.utils import timezone

from martor.models import MartorField

class Post(models.Model): 
    author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    #text = models.TextField()
    text = MartorField()
    created_date = models.DateTimeField(
                   default=timezone.now)
    published_date = models.DateTimeField(
                    blank=True, null=True)

And forms.py

## forms.py
from django.forms import ModelForm

from martor.fields import MartorFormField
from martor.widgets import AdminMartorWidget

from .models import Post, Comment

class PostForm(ModelForm):

    class Meta:
        model = Post
        fields = ('title', 'text',)
        widgets = { 
                    'text': AdminMartorWidget,
                } 

How can I add the markdown toolbar as in Django Admin (the figure1) into my blog editing page? Thanks in advance!

A way to display youtube videos while MARTOR_MARKDOWN_SAFE_MODE = True ?

Hi there, I recently downloaded 1.2.7 today. I noticed that the editor supports embedded videos, which is great! However, I can only display embedded video when MARTOR_MARKDOWN_SAFE_MODE = False. Is there a way to display video while that value is set to true?

For my use case, I am developing a blog where the editor is only present in my admin page. Would it be secure to set the safe mode value to False since I am the only one who has access to the markdown editor?

Change image

how can I change the size of an image using Markdown?

Preview in example not working

I followed the procedures for running the example project, but Preview doesn't work. I got the following errors:

Internal Server Error: /martor/markdownify/
Traceback (most recent call last):
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Django-2.1.1-py3.6.egg/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Django-2.1.1-py3.6.egg/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Django-2.1.1-py3.6.egg/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/martor-1.3.3-py3.6.egg/martor/views.py", line 17, in markdownfy_view
    return HttpResponse(markdownify(request.POST['content']))
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/martor-1.3.3-py3.6.egg/martor/utils.py", line 28, in markdownify
    extension_configs=MARTOR_MARKDOWN_EXTENSION_CONFIGS
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Markdown-3.0.1-py3.6.egg/markdown/core.py", line 390, in markdown
    md = Markdown(**kwargs)
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Markdown-3.0.1-py3.6.egg/markdown/core.py", line 100, in __init__
    configs=kwargs.get('extension_configs', {}))
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Markdown-3.0.1-py3.6.egg/markdown/core.py", line 126, in registerExtensions
    ext = self.build_extension(ext, configs.get(ext, {}))
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Markdown-3.0.1-py3.6.egg/markdown/core.py", line 181, in build_extension
    return module.makeExtension(**configs)
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/martor-1.3.3-py3.6.egg/martor/extensions/del_ins.py", line 48, in makeExtension
    return DelInsExtension(configs=dict(configs))
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Markdown-3.0.1-py3.6.egg/markdown/extensions/__init__.py", line 42, in __init__
    self.setConfigs(kwargs)
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Markdown-3.0.1-py3.6.egg/markdown/extensions/__init__.py", line 73, in setConfigs
    self.setConfig(key, value)
  File "/home/jdshueu/.local/share/virtualenvs/martor-pW1NQgAM/lib/python3.6/site-packages/Markdown-3.0.1-py3.6.egg/markdown/extensions/__init__.py", line 61, in setConfig
    if isinstance(self.config[key][0], bool):
KeyError: 'configs'

something wrong with Chinese

When I input Chinese, the Pinyin of Chinese characters is also input. Like this, when I input "你好", it got "ni hao你好".

I'm using Mac OS X.

Resize the Image

I am trying to save the images to be upload in the post in a local storage. Is it to change the display size of the image at the time of uploading ?

Martor crashes with Markdown 3

Log:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 158, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 156, in _get_response
    response = response.render()
  File "/usr/local/lib/python3.6/site-packages/django/template/response.py", line 106, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python3.6/site-packages/django/template/response.py", line 83, in rendered_content
    content = template.render(context, self._request)
  File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 175, in render
    return self._render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 943, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 910, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 155, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 943, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 910, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 155, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 943, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 910, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/defaulttags.py", line 517, in render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 943, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 910, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 67, in render
    result = block.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 943, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 910, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/loader_tags.py", line 67, in render
    result = block.nodelist.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 943, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 910, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 993, in render
    output = self.filter_expression.resolve(context)
  File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 703, in resolve
    new_obj = func(obj, *arg_vals)
  File "/usr/local/lib/python3.6/site-packages/martor/templatetags/martortags.py", line 21, in safe_markdown
    return mark_safe(markdownify(field_name))
  File "/usr/local/lib/python3.6/site-packages/martor/utils.py", line 28, in markdownify
    extension_configs=MARTOR_MARKDOWN_EXTENSION_CONFIGS
  File "/usr/local/lib/python3.6/site-packages/markdown/core.py", line 390, in markdown
    md = Markdown(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/markdown/core.py", line 100, in __init__
    configs=kwargs.get('extension_configs', {}))
  File "/usr/local/lib/python3.6/site-packages/markdown/core.py", line 126, in registerExtensions
    ext = self.build_extension(ext, configs.get(ext, {}))
  File "/usr/local/lib/python3.6/site-packages/markdown/core.py", line 181, in build_extension
    return module.makeExtension(**configs)
  File "/usr/local/lib/python3.6/site-packages/martor/extensions/del_ins.py", line 48, in makeExtension
    return DelInsExtension(configs=dict(configs))
  File "/usr/local/lib/python3.6/site-packages/markdown/extensions/__init__.py", line 42, in __init__
    self.setConfigs(kwargs)
  File "/usr/local/lib/python3.6/site-packages/markdown/extensions/__init__.py", line 73, in setConfigs
    self.setConfig(key, value)
  File "/usr/local/lib/python3.6/site-packages/markdown/extensions/__init__.py", line 61, in setConfig
    if isinstance(self.config[key][0], bool):
KeyError: 'configs'

Downgrading to Markdown 2.6.11 fixed the problem for me.

Semantic conflicts with bootstrap

This uses semantic.js if you install on a site with bootstrap it breaks dialog boxes becuase they have the same .dialog js methods and similar styles.

Is there a way to fix this with out changing an entire site to use bootstraps no conflict mode ?

currently i have had to remove semantic.js to make dialogs work on my site any better solution ?

I am currently trying to integrate this into django wiki i have a PR with my current progress if interested.

django-wiki/django-wiki#709

Preview not working

Instead of getting a preview, it just looks exactly like the raw text in the editor box.

models.py:

class Question(models.Model, HitCountMixin):
    title = models.CharField(max_length=200, blank=False)
    description = MartorField()

forms.py

class QuestionForm(forms.ModelForm):
    class Meta:
        model = Question
        fields = ['title', 'description']
        widgets = {
            'description': AdminMartorWidget,
        }
    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user')
        super(QuestionForm, self).__init__(*args, **kwargs)
        self.fields['description'] = MartorFormField()

EDIT
My new form looks like this:

class QuestionForm(forms.ModelForm):
    class Meta:
        model = Question
        fields = ['title', 'description']

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user')
        super(QuestionForm, self).__init__(*args, **kwargs)
        self.fields['description'] = MartorFormField()

image

Preview and X-Frame-Options

Can it be possible that Preview is not displaying (not even switching to preview tab) because X-Frame-Options is set to DENY ?

HTML Code getting removed.

Whenever any HTML Code is written inside the editor it is being removed as [HTML_REMOVED].
Ideally, this should not happen. Can you please have a look into it.

Markdown widget becomes unresponsive when a model has multiple DraceditorField

Hello,

I just found this plugin and it is just what I need -congratulations for the good work ;)-, after installing and setting up some fields to DraceditorField() I entered the django admin panel and found the following error.

While in a model if you have only just 1 DraceditorField, the widget works as expected

1field markdown

But in the moment that in a same model two DraceditorFields are added when entering admin panel one of the widgets become unresponsive and duplicated with information of the previous field, and of course it is impossible to edit its content also. Try it by yourself, declare a model with two DraceditorField.

See how 2nd Markdown editor looks weird in the following image:

2 fields

Do you have a guess on why this is happening? Could be easy for you to fix it?

Semantic css is missing its image assets

when trying to run collectstatic with the gzip storage engine, it errors when processing semantic.min.css.

because the flags.png file is not present so it fails to compress and stops the collect static process.

Its looking for a child path of the below in the css file.

themes/default/assets/images/flags.png

utils.markdownify --- TypeError: cannot serialize b'Contents'

Hello! Look at that, code from the docstring of markdownify. I cant get what's wrong

>>> from martor.utils import markdownify
>>> content = "![awesome](http://i.imgur.com/hvguiSn.jpg)"
>>> markdownify(content)
Traceback (most recent call last):
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/serializers.py", line 95, in _escape_cdata
    if "&" in text:
TypeError: a bytes-like object is required, not 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/martor/utils.py", line 28, in markdownify
    extension_configs=MARTOR_MARKDOWN_EXTENSION_CONFIGS
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/__init__.py", line 494, in markdown
    return md.convert(text)
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/__init__.py", line 375, in convert
    newRoot = treeprocessor.run(root)
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/extensions/toc.py", line 260, in run
    toc = self.markdown.serializer(div)
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/serializers.py", line 282, in to_xhtml_string
    return _write_html(ElementTree(element).getroot(), format="xhtml")
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/serializers.py", line 203, in _write_html
    _serialize_html(write, root, qnames, namespaces, format)
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/serializers.py", line 188, in _serialize_html
    _serialize_html(write, e, qnames, None, format)
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/serializers.py", line 186, in _serialize_html
    write(_escape_cdata(text))
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/serializers.py", line 103, in _escape_cdata
    _raise_serialization_error(text)
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/serializers.py", line 78, in _raise_serialization_error
    "cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize b'Contents' (type bytes)
>>> markdownify(content.encode('utf-8'))
Traceback (most recent call last):
  File "/home/vsyrov/Home/PycharmProjects/web-linux36/lib/python3.5/site-packages/markdown/serializers.py", line 95, in _escape_cdata
    if "&" in text:
TypeError: a bytes-like object is required, not 'str'

python 3.5.4

Form label empty in Django Admin

When having several MartorFormField in the same form (and thus Django Admin interface, otherwise I would have integrated it in my own template), it is difficult to identify what is the role of each field because the label is emptied at the field creation (see fields.py line 12) :

class MartorFormField(forms.CharField):

def __init__(self, *args, **kwargs):
    kwargs['label'] = ''  # To set without label.
    super(MartorFormField, self).__init__(*args, **kwargs)

    if not issubclass(self.widget.__class__, MartorWidget):
        self.widget = MartorWidget()

Is it possible to remove this instruction to let the choice to the user ? I patched the code in my project but for maintainability it would be better if this could be integrated in the main branch.

Anyway kudos for this helpful library !

Rendering Frontend with React

I would like to save the results of this editor in the database and render it as React as it is, what kind of method is there?
I would like to know if there is something good compatible package etc.

Automatic image orientation

If the uploaded photo has been taken in portrait mode, the preview shows the image in landscape mode. It ignores the EXIF data. Is it possible to fix it somehow?

Ordered list after Unordered list rendered wrong

Here is visualisation of problem.

screenshot 2018-10-03 at 11 21 15

There is resulted HTML code, which is obviously wrong (no <ol> at all):

<p>sdasdas</p>
<ul>
<li>
<p>asd<br />
asdasd</p>
</li>
<li>
<p>12312323</p>
</li>
<li>12312323</li>
<li></li>
</ul>

Custom user model

Hi.

Is it possible to specify a different user model for the mentions without forking the repository and manually changing it?

ModuleNotFoundError: No module named 'mdx_martor'

Getting the following trace, has anyone encountered this before?

 File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py", line 215, in _get_response
    response = response.render()
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/response.py", line 107, in render
    self.content = self.rendered_content
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/response.py", line 84, in rendered_content
    content = template.render(context, self._request)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/backends/django.py", line 66, in render
    return self.template.render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 207, in render
    return self._render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/loader_tags.py", line 177, in render
    return compiled_parent._render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/loader_tags.py", line 72, in render
    result = block.nodelist.render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 1040, in render
    output = self.filter_expression.resolve(context)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/django/template/base.py", line 736, in resolve
    new_obj = func(obj, *arg_vals)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/martor/templatetags/martortags.py", line 21, in safe_markdown
    return mark_safe(markdownify(field_name))
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/martor/utils.py", line 28, in markdownify
    extension_configs=MARTOR_MARKDOWN_EXTENSION_CONFIGS
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/markdown/__init__.py", line 493, in markdown
    md = Markdown(*args, **kwargs)
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/markdown/__init__.py", line 159, in __init__
    configs=kwargs.get('extension_configs', {}))
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/markdown/__init__.py", line 185, in registerExtensions
    ext = self.build_extension(ext, configs.get(ext, {}))
  File "/Users/Jonny/anaconda3/lib/python3.6/site-packages/markdown/__init__.py", line 264, in build_extension
    module = importlib.import_module(module_name_old_style)
  File "/Users/Jonny/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'mdx_martor'

Urls after bullet points

When posting a link after a bullet point the link seems to fail if : is present in this case thing:3121794 it seems fine when no bullet point is used.

This works

[A thingiverse post](https://www.thingiverse.com/thing:3118584)
[https://www.thingiverse.com/thing:3121794](https://www.thingiverse.com/thing:3121794)

vs this which results in a blank url when the page is rendered

+ [A thingiverse post](https://www.thingiverse.com/thing:3118584)
+ [https://www.thingiverse.com/thing:3121794](https://www.thingiverse.com/thing:3121794)

I believe it happening in urlize but have struggle to track down an exact source, running the above directly through markdown in the repl seems to produce the expected result.

imgur photo uploads not showing image

Created an imgur dev account with my keys and photo uploads worked at first (a couple weeks ago). Now I'm having an issue where the image will get uploaded to imgur and the url to the image will will work if I manually copy-paste it into the browser, but the markdown editor box will show something like the following rather than the image itself:

image

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.