Skip to content
Snippets Groups Projects
Commit b50e798c authored by David Rouquet's avatar David Rouquet
Browse files

Insert directly html code for audio instead of shortcode. Hence it works in Surveyjs JSON

parent ff57efc7
No related branches found
No related tags found
1 merge request!4Main
......@@ -36,8 +36,13 @@ def construct_while(g: Graph, query: str):
def prepareHTMLforMD(str):
#regexJS = re.compile(r'<script type="text/javascript">(.*)</script>')
# Identify audio content and add markups to identify them in the MD
regexAV = re.compile(r".*?PF_clipAV\('.*?', '(.*?).swf',.*")
str = regexAV.sub(r"@AUDIOSTART\1@AUDIOEND", str)
# Fix media paths (especially for images)
str = str.replace("../media/", "/macao-hugo/media/")
return(str)
def postEditMD(str):
......@@ -48,7 +53,8 @@ def postEditMD(str):
audioStr = ''
for audioPath in audioPaths:
audioFile = audioPath.split('/')[-1]
audioStr += r'{{< audio id="'+audioFile+r'" src="media/'+audioFolder+r'/'+audioFile+r'" >}}'
#audioStr += r'{{< audio id="'+audioFile+r'" src="media/'+audioFolder+r'/'+audioFile+r'" >}}'
audioStr += '<div><audio id="'+audioFile+'" ><source src="/macao-hugo/media/'+audioFolder+r'/'+audioFile+'" type="audio/mpeg"></audio><button onclick="document.getElementById(\''+audioFile+'\').play()">Play</button></div>'
str = str.replace(audioElt, audioStr)
return(str)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment