mirror of
				https://github.com/lxsang/antd-web-apps
				synced 2025-10-31 18:35:35 +01:00 
			
		
		
		
	Merge pull request #13 from lxsang/master
add Youtube support on doc front end
This commit is contained in:
		| @@ -9,7 +9,7 @@ local pre_process_md = function(str, obj) | |||||||
|     local content = str |     local content = str | ||||||
|     for capture in str:gmatch("(%[%[@book:image:[^\n%]]*%]%])") do |     for capture in str:gmatch("(%[%[@book:image:[^\n%]]*%]%])") do | ||||||
|         local apath = capture:match("%[%[@book:image:([^\n%]]*)%]%]") |         local apath = capture:match("%[%[@book:image:([^\n%]]*)%]%]") | ||||||
|         local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]") |         local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]"):gsub("%-", "%%-") | ||||||
|         if apath then |         if apath then | ||||||
|             apath = apath:gsub(" ", "%%%%20") |             apath = apath:gsub(" ", "%%%%20") | ||||||
|             print(apath) |             print(apath) | ||||||
| @@ -27,7 +27,7 @@ local post_process_md = function(str, obj) | |||||||
|     -- 3D model |     -- 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("%]", "%%]"):gsub("%-", "%%-") | ||||||
|         if apath then |         if apath then | ||||||
|             --apath = utils.urlencode(apath):gsub("%%", "%%%%") |             --apath = utils.urlencode(apath):gsub("%%", "%%%%") | ||||||
|             apath = apath:gsub(" ", "%%20") |             apath = apath:gsub(" ", "%%20") | ||||||
| @@ -41,13 +41,12 @@ local post_process_md = function(str, obj) | |||||||
|     -- Youtube video |     -- Youtube video | ||||||
|     for capture in str:gmatch("(%[%[youtube:[^\n%]]*%]%])") do |     for capture in str:gmatch("(%[%[youtube:[^\n%]]*%]%])") do | ||||||
|         local apath = capture:match("%[%[youtube:([^\n%]]*)%]%]") |         local apath = capture:match("%[%[youtube:([^\n%]]*)%]%]") | ||||||
|         local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]") |         local pattern = capture:gsub("%[", "%%["):gsub("%]", "%%]"):gsub("%-", "%%-") | ||||||
|         if apath then |         if apath then | ||||||
|             --apath = utils.urlencode(apath):gsub("%%", "%%%%") |  | ||||||
|             content = content:gsub(pattern, |             content = content:gsub(pattern, | ||||||
|                 "<iframe width=\"100%\" src=\"https://www.youtube.com/embed/"..apath.."\"> </iframe>") |                 "<iframe style='width:100%%;height: auto;min-height: 400px;' src=\"https://www.youtube.com/embed/"..apath.."\"> </iframe>") | ||||||
|         end |         end | ||||||
|     end | end | ||||||
|  |  | ||||||
|     return content, has_model |     return content, has_model | ||||||
| end | end | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user