barraq / django-epiceditor

A django app that allows the easy addition of EpicEditor markdown editor to a django form field, whether in a custom app or the Django Admin.
Other
38 stars 12 forks source link

New line always added on save #8

Open adi- opened 10 years ago

adi- commented 10 years ago

I have noticed some issues while saving/opening documents written in EpicEditor. Editor is always adding break tag to each line of text on open.

Do you know any workarounds? Can it be fixed in Django or is it EpicEditor's issue that you can't fix in django-epiceditor?

CapnKernel commented 9 years ago

I'm also having this problem. My markdown gets longer and longer every time it's saved.

For example, here's the markdown (see the last field):

(env)[mjd@green hv]$ mysqldump --skip-extended-insert -t --compact --where 'id = 3' -u root -p$PP db notes_note
INSERT INTO `notes_note` VALUES (3,'f7vFniFaQcm+BiPxWQ0jKQ','foo1','foo1','abc\ndef\n');

On the admin page, it looks like this, in the black edit field:

abc
def

If I click "Save and continue editing", the text in the black field doesn't change, but it changes in the DB:

(env)[mjd@green hv]$ mysqldump --skip-extended-insert -t --compact --where 'id = 3' -u root -p$PP db notes_note
INSERT INTO `notes_note` VALUES (3,'f7vFniFaQcm+BiPxWQ0jKQ','foo1','foo1','abc\r\ndef\r\n');

The \n was replaced with \r\n.

If I click "Save and continue editing", the DB has changed again:

(env)[mjd@green hv]$ mysqldump --skip-extended-insert -t --compact --where 'id = 3' -u root -p$PP db notes_note
INSERT INTO `notes_note` VALUES (3,'f7vFniFaQcm+BiPxWQ0jKQ','foo1','foo1','abc\r\n\r\ndef\r\n\r\n');

Then if I reload the admin page, the black edit field looks like this:

abc

def

I'd really like to see a fix for this bug please! (Platform: Fedora 20 Linux, mysql) (suggestion: Check the POST data when the page is saved. The RFC for POST data may require that newlines be sent as \r\n)

adi-: Is this the same bug you're seeing?

adi- commented 9 years ago

Yeap, the same. I haven't found a workaround for EpicEditor, so I wrote my own. If you are interested check https://github.com/adi-/django-markdownx

barraq commented 9 years ago

Hi @adi- and @CapnKernel thanks for reporting this. I am no longer using Django.... I've migrated most of my stuff to Rails (when I needed server side dynamics) or static generator like Nanoc for all the rest.

Is your issue related to https://github.com/OscarGodson/EpicEditor/issues/171 or https://github.com/OscarGodson/EpicEditor/issues/363 ? If the bug is coming from EpicEditor then this issue must be reported there; otherwise a patch can be provided, as @CapnKernel propose, by checking the post data e.g. providing a clean_YOURFIELD method which would handle those bad carriage return lines....

@CapnKernel a patch is welcome then :)