annotate src/lib/Bbcode.luan @ 35:1ce75c5ab0f7

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 03 Aug 2022 14:13:12 -0600
parents 8ff35379cc89
children 298c71e0c854
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local type = Luan.type or error()
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local ipairs = Luan.ipairs or error()
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
5 local pairs = Luan.pairs or error()
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local stringify = Luan.stringify or error()
13
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
7 local Io = require "luan:Io.luan"
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
8 local output_of = Io.output_of or error()
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Parsers = require "luan:Parsers.luan"
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local bbcode_parse = Parsers.bbcode_parse or error()
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local Html = require "luan:Html.luan"
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local html_encode = Html.encode or error()
21
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
13 local html_parse = Html.parse or error()
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 local Table = require "luan:Table.luan"
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 local is_list = Table.is_list or error()
21
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
16 local concat = Table.concat or error()
13
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
17 local String = require "luan:String.luan"
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
18 local regex = String.regex or error()
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
19 local ends_with = String.ends_with or error()
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 local User = require "site:/lib/User.luan"
13
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
21 local Shared = require "site:/lib/Shared.luan"
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
22 local list_to_set = Shared.list_to_set or error()
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
23 local to_list = Shared.to_list or error()
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 local Logging = require "luan:logging/Logging.luan"
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 local logger = Logging.logger "Bbcode"
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 local Bbcode = {}
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
30 local starting_cr_regex = regex[[^\n]]
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
31
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 local to_html
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 local html = {}
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
35 function html.b(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
36 %><b><% to_html(bbcode.contents,options) %></b><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
37 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
38
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
39 function html.i(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
40 %><i><% to_html(bbcode.contents,options) %></i><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
41 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
42
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
43 function html.u(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
44 %><u><% to_html(bbcode.contents,options) %></u><%
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
47 function html.s(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
48 %><s><% to_html(bbcode.contents,options) %></s><%
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
51 function html.sup(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
52 %><sup><% to_html(bbcode.contents,options) %></sup><%
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
55 function html.brackets(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
56 %>[<% to_html(bbcode.contents,options) %>]<%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
57 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
58
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
59 function html.url(bbcode,options)
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
60 local url = bbcode.param
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61 if url == nil then
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
62 url = html_encode(bbcode.contents)
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
63 %><a href="<%=url%>"><%=url%></a><%
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
64 else
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
65 url = html_encode(url)
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
66 %><a href="<%=url%>"><% to_html(bbcode.contents,options) %></a><%
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
67 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
68 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
69
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
70 function html.code(bbcode,options)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
71 local s = starting_cr_regex.gsub(bbcode.contents,"")
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
72 %><code><%= html_encode(s) %></code><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
73 options.strip_newline = true
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
74 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
75
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
76 function html.img(bbcode,options)
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
77 %><img src="<%= html_encode(bbcode.contents) %>"><%
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
78 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
79
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
80 function html.color(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
81 %><span style="color:<%=bbcode.param%>"><% to_html(bbcode.contents,options) %></span><%
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
82 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
83
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
84 function html.size(bbcode,options)
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
85 %><span style="font-size:<%=bbcode.param%>"><% to_html(bbcode.contents,options) %></span><%
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
86 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
87
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
88 function html.quote(bbcode,options)
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
89 %><blockquote><%
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
90 local user_name = bbcode.param
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
91 if user_name ~= nil then
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
92 local user = User.get_by_name(user_name)
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
93 if user == nil then
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
94 %><%= user_name %> wrote:<%
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
95 else
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
96 %><a href="/user_something"><%= user_name %></a> wrote:<%
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
97 end
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
98 else
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
99 options.strip_newline = true
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
100 end
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
101 to_html(bbcode.contents,options)
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
102 %></blockquote><%
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
103 options.strip_newline = true
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
104 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
105
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
106 local function video_iframe(url)
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
107 %><iframe width="560" height="315" frameborder="0" allowfullscreen src="<%=url%>"></iframe><%
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
108 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
109
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
110 local video_handlers = {}
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
111 do
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 29
diff changeset
112 local ptn1 = regex[[^\Qhttps://youtu.be/\E([a-zA-Z0-9_-]+)(?:\?t=([0-9]+))?]]
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 29
diff changeset
113 local ptn2 = regex[[^\Qhttps://www.youtube.com/watch?v=\E([a-zA-Z0-9_-]+)(?:&t=([0-9]+)s)?]]
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
114 function video_handlers.youtube(url)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
115 local id, start = ptn1.match(url)
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
116 if id == nil then
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
117 id, start = ptn2.match(url)
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
118 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
119 if id == nil then
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
120 return false
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
121 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
122 url = "https://www.youtube.com/embed/"..id
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
123 if start ~= nil then
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
124 url = url.."?start="..start
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
125 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
126 video_iframe(url)
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
127 return true
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
128 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
129 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
130 do
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 29
diff changeset
131 local ptn = regex[[^\Qhttps://rumble.com/embed/\E[a-z0-9]+/\?pub=[a-z0-9]+]]
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
132 function video_handlers.rumble(url)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
133 if not ptn.matches(url) then
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
134 return false
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
135 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
136 video_iframe(url)
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
137 return true
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
138 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
139 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
140 do
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 29
diff changeset
141 local ptn = regex[[^\Qhttps://www.bitchute.com/video/\E([a-zA-Z0-9]+)/]]
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
142 function video_handlers.bitchute(url)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
143 local id = ptn.match(url)
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
144 if id == nil then
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
145 return false
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
146 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
147 url = "https://www.bitchute.com/embed/"..id.."/"
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
148 video_iframe(url)
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
149 return true
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
150 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
151 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
152 do
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 29
diff changeset
153 local ptn = regex[[^\Qhttps://vimeo.com/\E([0-9]+)]]
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
154 function video_handlers.vimeo(url)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
155 local id = ptn.match(url)
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
156 if id == nil then
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
157 return false
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
158 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
159 url = "https://player.vimeo.com/video/"..id
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
160 video_iframe(url)
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
161 return true
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
162 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
163 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
164 do
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 29
diff changeset
165 local ptn = regex[[^\Qhttps://dai.ly/\E([a-z0-9]+)]]
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
166 function video_handlers.dailymotion(url)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
167 local id = ptn.match(url)
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
168 if id == nil then
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
169 return false
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
170 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
171 url = "https://www.dailymotion.com/embed/video/"..id
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
172 video_iframe(url)
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
173 return true
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
174 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
175 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
176 do
30
8ff35379cc89 regex cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 29
diff changeset
177 local ptn = regex[[^\Qhttps://www.tiktok.com/\E[^/]+/video/([0-9]+)]]
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
178 function video_handlers.tiktok(url)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
179 local id = ptn.match(url)
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
180 if id == nil then
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
181 return false
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
182 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
183 %><blockquote class="tiktok-embed" data-video-id="<%=id%>" style="max-width: 560px; margin-left: 0;"><section></section></blockquote><%
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
184 %><script async src="https://www.tiktok.com/embed.js"></script><%
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
185 return true
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
186 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
187 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
188 do
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
189 local ptn = regex[[\.[a-zA-Z0-9]+$]]
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
190 function video_handlers.file(url)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
191 if not ptn.matches(url) then
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
192 return false
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
193 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
194 %><video controls width="560"><source src="<%=html_encode(url)%>"></video><%
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
195 return true
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
196 end
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
197 end
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
198
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
199 function html.video(bbcode,options)
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
200 local url = bbcode.contents
28
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
201 for _, handle in pairs(video_handlers) do
d9d7aa2a79db more video types
Franklin Schmidt <fschmidt@gmail.com>
parents: 27
diff changeset
202 if handle(url) then return end
27
6871eec2cf4c add rumble
Franklin Schmidt <fschmidt@gmail.com>
parents: 23
diff changeset
203 end
23
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
204 url = html_encode(url)
cdcd1b70c15e tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
205 %><a href="<%=url%>"><%=url%></a><%
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
206 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
207
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
208 local function list_to_html(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
209 local list = to_list(bbcode.contents)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
210 for _, item in ipairs(list) do
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
211 if type(item) == "table" and item.name == "li" then
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
212 %><li><% to_html(item.contents,options) %></li><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
213 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
214 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
215 options.strip_newline = true
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
216 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
217
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
218 function html.ul(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
219 %><ul><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
220 list_to_html(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
221 %></ul><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
222 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
223
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
224 function html.ol(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
225 %><ol><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
226 list_to_html(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
227 %></ol><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
228 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
229
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
230 function to_html(bbcode,options)
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
231 if options.strip_newline then
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
232 if type(bbcode) == "string" then
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
233 bbcode = starting_cr_regex.gsub(bbcode,"")
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
234 end
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
235 options.strip_newline = false
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
236 end
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
237 if type(bbcode) == "string" then
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
238 %><%= html_encode(bbcode) %><%
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
239 else
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
240 type(bbcode) == "table" or error()
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
241 if is_list(bbcode) then
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
242 for _, v in ipairs(bbcode) do
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
243 to_html(v,options)
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
244 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
245 else
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
246 local fn = html[bbcode.name] or error(bbcode.name.." not handled")
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
247 fn(bbcode,options)
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
248 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
249 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
250 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
251
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
252 function Bbcode.to_html(bbcode)
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
253 bbcode = bbcode_parse(bbcode)
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
254 %><div message><%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
255 to_html(bbcode,{strip_newline=false})
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
256 %></div><%
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
257 end
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
258
13
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
259
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
260 local doesnt_nest = list_to_set{
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
261 "url"
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
262 "code"
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
263 "img"
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
264 "video"
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
265 }
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
266
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
267 local url_regex = regex[[(^|\s)(https?://\S+)]]
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
268
13
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
269 local function preprocess(bbcode)
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
270 if type(bbcode) == "string" then
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
271 bbcode = url_regex.gsub( bbcode, "$1[url]$2[/url]" )
13
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
272 %><%= bbcode %><%
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
273 else
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
274 type(bbcode) == "table" or error()
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
275 if is_list(bbcode) then
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
276 for _, v in ipairs(bbcode) do
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
277 preprocess(v)
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
278 end
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
279 else
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
280 local name = bbcode.name
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
281 local param = bbcode.param
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
282 %>[<%=name%><%
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
283 if param ~= nil then
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
284 %>=<%=param%><%
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
285 end
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
286 %>]<%
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
287 if doesnt_nest[name] then
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
288 %><%=bbcode.contents%><%
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
289 else
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
290 preprocess(bbcode.contents)
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
291 end
20
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
292 if name == "code" and param ~= nil then
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
293 %>[/<%=name%>=<%=param%>]<%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
294 else
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
295 %>[/<%=name%>]<%
3ea49246d6a7 bbcode work
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
296 end
13
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
297 end
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
298 end
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
299 end
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
300
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
301 function Bbcode.preprocess(bbcode)
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
302 bbcode = bbcode_parse(bbcode)
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
303 return output_of(function()
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
304 preprocess(bbcode)
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
305 end)
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
306 end
24668255cede preprocess urls
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
307
21
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
308 function Bbcode.remove_html(text)
29
a1db5223ced1 luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 28
diff changeset
309 local ends_with_newline = ends_with(text,"\n")
21
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
310 local t = {}
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
311 local html = html_parse(text)
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
312 local is_first = true
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
313 for _, v in ipairs(html) do
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
314 if type(v) == "string" then
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
315 t[#t+1] = v
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
316 else
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
317 local name = v.name
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
318 if name == "div" then
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
319 if not is_first then
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
320 t[#t+1] = "\n"
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
321 end
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
322 elseif name == "/div" or name == "br" then
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
323 -- ignore
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
324 else
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
325 error("unexpected tag: "..name)
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
326 end
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
327 end
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
328 is_first = false
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
329 end
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
330 if not ends_with_newline then
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
331 t[#t+1] = "\n"
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
332 end
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
333 return concat(t)
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
334 end
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
335
33731231093a fix bbcode editing
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
336
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
337 return Bbcode