neilagabriel / vim-geeknote

Vim plugin for Geeknote
233 stars 16 forks source link

Saved note not converted, unwanted 4-spaces indent added #28

Open fpytloun opened 9 years ago

fpytloun commented 9 years ago

Hello,

thank you for this great Vim plugin :-)

I have an issue with converting/saving the note. Eg. with following text:

test

 ## Test
 line without any indent
     one tab indent

Saved with :GeeknoteSaveAsNote

When I load the note with geeknote or vim-geeknote, I see every line is indented by 4 spaces. In Evernote UI, I see plaintext markdown so it wasn't converted to html. Additional indenting is added every time I re-save the note with vim-geeknote.

################## TITLE ##################
test
=================== META ==================
Created: 17.01.1970     
Updated: 17.01.1970     
----------------- CONTENT -----------------

    ## Test
    line without any indent
        one tab indent

When I edit the note with geeknote edit in Vim, note is saved correctly without additional indenting. If I open fixed note in vim-geeknote, save without any changes, 4 spaces are added and therefore document is not converted and saved correctly.

Tested with latest vim-geeknote and geeknote from master branch. No special settings used.


Update

It happens somewhere during:

note.content = textToENML(content)

because when I explicitly call strip() on each line during content string creation, I remove my indents but these are still present.

Solution: Found that saved note is not converted to ENML by default so one has to explicitly define GeeknoteFormat:

let g:GeeknoteFormat="markdown"

otherwise following code is executed and indenting is broken somewhere inside (wrapENML maybe?):

    content = content.replace('<', '&lt;')
    content = content.replace('>', '&gt;')
    content = content.replace('&', '&amp;')
    content = unicode(content, "utf-8")
    contentHTML = u''.join(('<pre>', content, '</pre>')).encode("utf-8")

    enml = Editor.wrapENML(contentHTML)
    return enml

In my opinion GeeknoteFormat should be set to markdown by default, because current vim-default doesn't do what user expects.