rnote 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rnote/noun/note/converter.rb +21 -10
- data/lib/rnote/noun/note/edit.rb +1 -1
- data/lib/rnote/version.rb +1 -1
- metadata +2 -2
@@ -21,6 +21,14 @@ require 'evernote-thrift'
|
|
21
21
|
# the note attributes get its own class and thats where we stick the conversion routines.
|
22
22
|
|
23
23
|
class Evernote::EDAM::Type::Note
|
24
|
+
|
25
|
+
NON_BREAKING_SPACE = "\xc2\xa0".force_encoding("UTF-8")
|
26
|
+
|
27
|
+
ENML_PREAMBLE = <<EOF
|
28
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
29
|
+
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
|
30
|
+
<en-note style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
|
31
|
+
EOF
|
24
32
|
|
25
33
|
# simple xhtml to txt converter
|
26
34
|
# just tries to convert evernotes simple xhtml.
|
@@ -131,20 +139,24 @@ class Evernote::EDAM::Type::Note
|
|
131
139
|
# TODO create a proper DOM, with proper xml entity escapes and tag structure
|
132
140
|
|
133
141
|
# escape any entities
|
134
|
-
txt.gsub
|
135
|
-
txt.gsub
|
142
|
+
txt = txt.gsub('<','<')
|
143
|
+
txt = txt.gsub('>','>')
|
136
144
|
|
137
145
|
# replace todo items
|
138
|
-
txt.gsub
|
139
|
-
txt.gsub
|
146
|
+
txt = txt.gsub('[ ] ','<en-todo/>')
|
147
|
+
txt = txt.gsub('[X] ','<en-todo checked="true"/>')
|
140
148
|
|
141
149
|
# every newline becomes a <div></div>
|
142
150
|
# an empty line becomes a <div><br/></div>
|
151
|
+
txt = txt.gsub(' ',NON_BREAKING_SPACE + ' ')
|
143
152
|
|
144
153
|
lines = txt.split("\n",-1)
|
145
154
|
lines = [''] if txt == ''
|
146
155
|
raise if lines.length == 0
|
147
156
|
|
157
|
+
# every pair of spaces must be swaped to a nbsp
|
158
|
+
# don't have to use the identity though. the utf-8 char is fine
|
159
|
+
|
148
160
|
xhtml = lines.map { |string|
|
149
161
|
if string == ''
|
150
162
|
"<div><br/></div>\n"
|
@@ -153,12 +165,7 @@ class Evernote::EDAM::Type::Note
|
|
153
165
|
end
|
154
166
|
}.join('')
|
155
167
|
|
156
|
-
|
157
|
-
<?xml version='1.0' encoding='utf-8'?>
|
158
|
-
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
|
159
|
-
<en-note>
|
160
|
-
#{xhtml}</en-note>
|
161
|
-
EOF
|
168
|
+
"#{Evernote::EDAM::Type::Note::ENML_PREAMBLE}#{xhtml}</en-note>\n"
|
162
169
|
end
|
163
170
|
|
164
171
|
def self.enml_to_format(format,enml)
|
@@ -187,6 +194,10 @@ EOF
|
|
187
194
|
self.class.enml_to_format('txt',self.content)
|
188
195
|
end
|
189
196
|
|
197
|
+
def txt_content=(txt)
|
198
|
+
self.content = self.class.format_to_enml('txt', txt)
|
199
|
+
end
|
200
|
+
|
190
201
|
# The yaml stream is what we give to the user to edit in their editor
|
191
202
|
#
|
192
203
|
# Its just a string, but its composed of 2 parts. the note attributes and the note content.
|
data/lib/rnote/noun/note/edit.rb
CHANGED
data/lib/rnote/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rnote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|