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

comments and anchors

parent 5f723d6c
No related branches found
No related tags found
1 merge request!5Resolve "Parseur par type d'activité"
......@@ -41,6 +41,16 @@ def prepareHTMLforMD(str):
# Identify image content and add markups to identify them in the MD
regexIMG = re.compile(r"<img.*?src=\"\.\./media/(.*?)\".*?>")
str = regexIMG.sub(r"@IMAGESTART\1@IMAGEEND", str)
# Identify words supporting comments and add markups to identify them in the MD
regexANCHOR= re.compile(r"<a class=\"STY_lienComt\" href=\"javascript:CRS_afficherDetail\('(.)'\)\" onclick=\"enrPosClic\(event,'.'\)\">(.*?)</a>")
str = regexANCHOR.sub(r"@ANCHORSTART@\1@\2@ANCHOREND", str)
# Identify anchor words with related comment id and add markups to identify them in the MD
regexANCHOR= re.compile(r"<a class=\"STY_lienComt\" href=\"javascript:CRS_afficherDetail\('(.)'\)\" onclick=\"enrPosClic\(event,'.'\)\">(.*?)</a>")
str = regexANCHOR.sub(r"@ANCHORSTART@\1@\2@ANCHOREND", str)
# Identify comments ids and add markups to identify them in the MD
regexCOMMENTID= re.compile(r"<div id=\"divCmt(.)\" onclick=\"SPE_clicDansBulle\(event,'.'\)\">")#(.*)</div>", re.MULTILINE)
str = regexCOMMENTID.sub(r"@COMMENTIDSTART@\1@COMMENTIDEND", str)
return(str)
......@@ -70,6 +80,17 @@ def postEditMD(str):
str = str.replace(imageElt, imgHtml)
###################################################
###################################################
# Add html code to MD for comment anchors
###################################################
# First for the words supporting the comments
regexANCHOR = re.compile(r"@ANCHORSTART@(.)@(.*?)@ANCHOREND")
str = regexANCHOR.sub(r"<span commentaireInfoId='\1'>\2</span>", str)
# For the comments themselves it is done in activite.rq
###################################################
# Add html for images and fix media paths
regexIMG = re.compile(r"!\[\]\(\.\./media/(.*?)\)")
str = regexIMG.sub(r"<img src='/macao-hugo/media/\1'>", str)
......
......@@ -15,10 +15,9 @@ template mt:activite(?act) {
?desc st:nl()
'<div class="commentaireInfoGroup">' st:nl()
'<div class="commentaireInfoGroup" hidden="True">' st:nl()
group {
'<div class="commentaireInfo">' st:nl()
?info_comment
concat(replace(replace(?info_comment,'@COMMENTIDSTART@','<div class="commentaireInfo" id="'),'@COMMENTIDEND','">'),'</div>')
'</div>' st:nl()
}
'</div>' st:nl()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment