diff --git a/tetras_extraction/script/src/transform.py b/tetras_extraction/script/src/transform.py index 10ae8ffb6802d3d7cf36da49cf4d5a0ec45ff391..bb0d8df9d7c37f733d682f9434e1790692fefdae 100644 --- a/tetras_extraction/script/src/transform.py +++ b/tetras_extraction/script/src/transform.py @@ -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) diff --git a/tetras_extraction/script/templates/activite.rq b/tetras_extraction/script/templates/activite.rq index ad2284f0addeeba47be42c3dcdc5bf84db49c105..c1382546b76baa42fc6357be791797da473f222c 100644 --- a/tetras_extraction/script/templates/activite.rq +++ b/tetras_extraction/script/templates/activite.rq @@ -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()