+10
-2
atproto/blog.rb
+10
-2
atproto/blog.rb
···
37
37
"/post/#{rkey}"
38
38
end
39
39
40
-
def get_type(lex)
41
-
if lex.start_with?(MainBlog.config.richtext_lex)
40
+
def get_formatting_type(lex)
41
+
if lex.start_with?(MainBlog.config.formatting_lex)
42
42
lex.split("#")[1]
43
43
else
44
44
raise "Formatting lexicon not recognized: #{lex}"
45
+
end
46
+
end
47
+
48
+
def get_block_type(lex)
49
+
if lex.start_with?(MainBlog.config.block_lex)
50
+
lex.split("#")[1]
51
+
else
52
+
raise "Block lexicon not recognized: #{lex}"
45
53
end
46
54
end
47
55
+2
-1
config.lua
+2
-1
config.lua
···
3
3
repo = "did:plc:bnqkww7bjxaacajzvu5gswdf",
4
4
post_collection = "net.shreyanjain.blog.post",
5
5
homepage_record = "net.shreyanjain.blog.homepage",
6
-
richtext_lex = "net.shreyanjain.blog.richtext"
6
+
formatting_lex = "net.shreyanjain.richtext.formatting",
7
+
block_lex = "net.shreyanjain.richtext.block",
7
8
}
+10
-10
public/converter.html
public/editor.html
+10
-10
public/converter.html
public/editor.html
···
3
3
<html lang="en">
4
4
<head>
5
5
<meta charset="UTF-8">
6
-
<title>Markdown Editor to ATProto JSON</title>
6
+
<title>Blog Post Editor</title>
7
7
<!-- Toast UI Editor CSS -->
8
8
<link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />
9
9
<style>
···
149
149
const block = {
150
150
"text": textContent,
151
151
"$type": level === 1
152
-
? "net.shreyanjain.blog.richtext#heading"
153
-
: "net.shreyanjain.blog.richtext#subheading"
152
+
? "net.shreyanjain.richtext.block#heading"
153
+
: "net.shreyanjain.richtext.block#subheading"
154
154
};
155
155
blocks.push(block);
156
156
i += 3; // skip heading_open, inline, heading_close
···
163
163
const textBlocks = processInline(inlineToken.children);
164
164
const block = {
165
165
"text": textBlocks,
166
-
"$type": "net.shreyanjain.blog.richtext#paragraph"
166
+
"$type": "net.shreyanjain.richtext.block#paragraph"
167
167
};
168
168
blocks.push(block);
169
169
i += 3; // skip paragraph_open, inline, paragraph_close
···
174
174
if(token.type === 'fence') {
175
175
const block = {
176
176
"text": token.content,
177
-
"$type": "net.shreyanjain.blog.richtext#code"
177
+
"$type": "net.shreyanjain.richtext.block#code"
178
178
};
179
179
blocks.push(block);
180
180
i++;
···
205
205
// Wrap list items in a list block.
206
206
const block = {
207
207
"text": listItems,
208
-
"$type": "net.shreyanjain.blog.richtext#list"
208
+
"$type": "net.shreyanjain.richtext.block#list"
209
209
};
210
210
blocks.push(block);
211
211
i++; // skip list_close
···
234
234
segments.push({
235
235
"content": token.content,
236
236
"formatting": [
237
-
{ "$type": "net.shreyanjain.blog.richtext#code-inline" }
237
+
{ "$type": "net.shreyanjain.richtext.formatting#code" }
238
238
]
239
239
});
240
240
i++;
···
249
249
segments.push({
250
250
"content": content,
251
251
"formatting": [
252
-
{ "$type": "net.shreyanjain.blog.richtext#italic" }
252
+
{ "$type": "net.shreyanjain.richtext.formatting#italic" }
253
253
]
254
254
});
255
255
} else if (token.type === 'strong_open') {
···
263
263
segments.push({
264
264
"content": content,
265
265
"formatting": [
266
-
{ "$type": "net.shreyanjain.blog.richtext#bold" }
266
+
{ "$type": "net.shreyanjain.richtext.formatting#bold" }
267
267
]
268
268
});
269
269
} else if (token.type === 'link_open') {
···
282
282
segments.push({
283
283
"content": content,
284
284
"formatting": [
285
-
{ "$type": "net.shreyanjain.blog.richtext#link", "href": href }
285
+
{ "$type": "net.shreyanjain.richtext.formatting#link", "href": href }
286
286
]
287
287
});
288
288
} else {
+1
-1
views/block.haml
+1
-1
views/block.haml
+2
-2
views/paragraph.haml
+2
-2
views/paragraph.haml
···
14
14
but for now we're not even doing that, just 1 piece of formatting.
15
15
16
16
Also, it has slight trouble with characters coming right after differently formatted ones.
17
-
- type = get_type(formatting.first["$type"])
17
+
- type = get_formatting_type(formatting.first["$type"])
18
18
- case type
19
19
- when "bold"
20
20
%strong>= content
···
24
24
%u>= content
25
25
- when "link"
26
26
%a{ href: formatting.first["href"] }>= content
27
-
- when "code-inline"
27
+
- when "code"
28
28
%code>= content
29
29
- else
30
30
= content