mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-11-20 02:18:20 +01:00
add Youtube support on doc front end
This commit is contained in:
parent
3ffd170f45
commit
4d55b64436
@ -24,6 +24,7 @@ end
|
|||||||
local post_process_md = function(str, obj)
|
local post_process_md = function(str, obj)
|
||||||
local content = str
|
local content = str
|
||||||
local has_model = false
|
local has_model = false
|
||||||
|
-- 3D model
|
||||||
for capture in str:gmatch("(%[%[@book:3dmodel:[^\n%]]*%]%])") do
|
for capture in str:gmatch("(%[%[@book:3dmodel:[^\n%]]*%]%])") do
|
||||||
local apath = capture:match("%[%[@book:3dmodel:([^\n%]]*)%]%]")
|
local apath = capture:match("%[%[@book:3dmodel:([^\n%]]*)%]%]")
|
||||||
local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]")
|
local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]")
|
||||||
@ -37,6 +38,17 @@ local post_process_md = function(str, obj)
|
|||||||
has_model = true
|
has_model = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Youtube video
|
||||||
|
for capture in str:gmatch("(%[%[youtube:[^\n%]]*%]%])") do
|
||||||
|
local apath = capture:match("%[%[youtube:([^\n%]]*)%]%]")
|
||||||
|
local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]")
|
||||||
|
if apath then
|
||||||
|
--apath = utils.urlencode(apath):gsub("%%", "%%%%")
|
||||||
|
content = str:gsub(pattern,
|
||||||
|
"<iframe width=\"100%\" src=\"https://www.youtube.com/embed/"..apath.."\"> </iframe>")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return content, has_model
|
return content, has_model
|
||||||
end
|
end
|
||||||
function DocController:loadTOC()
|
function DocController:loadTOC()
|
||||||
|
Loading…
Reference in New Issue
Block a user