[DEBUG] correction of the output bb code
This commit is contained in:
parent
4caa15d422
commit
47b884d9b2
@ -16,11 +16,13 @@ import re
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
#value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*))?\](.*?)\[/code\]',
|
||||
value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*?))?\](.*?)\[/code\]',
|
||||
r'<pre>\4</pre>',
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[code=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]',
|
||||
r'<span style="color: \1;">\2</span>',
|
||||
value)
|
||||
|
||||
# TODO : remove the basic indentation of the element (to have a better display in the text tutorial ...
|
||||
return value
|
||||
|
||||
|
||||
|
@ -47,13 +47,15 @@ def transcode(value):
|
||||
value = re.sub(r'\n:',
|
||||
r'\n:INDENT:',
|
||||
value)
|
||||
p = re.compile('((\:INDENT\:(.*?)\n)*)')
|
||||
p = re.compile('((\:INDENT\:(.*?)\n)*)',
|
||||
flags=re.DOTALL)
|
||||
value = p.sub(replace_wiki_identation,
|
||||
value)
|
||||
|
||||
value = re.sub(r'\*\*(.*?)\n',
|
||||
r'<li>\1</li>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
return value
|
||||
|
||||
@ -61,7 +63,7 @@ def transcode(value):
|
||||
def replace_wiki_identation(match):
|
||||
if match.group() == "":
|
||||
return ""
|
||||
debug.info("plop: " + str(match.group()))
|
||||
#debug.verbose("plop: " + str(match.group()))
|
||||
value = "<ul>"
|
||||
value += re.sub(r':INDENT:',
|
||||
r'',
|
||||
|
@ -8,14 +8,46 @@ import re
|
||||
##
|
||||
## @brief Transcode:
|
||||
## [http://votre_site.con] => http://votre_site.con
|
||||
## [http://votre_site.con | texte affiché] => texte affiché
|
||||
## [http://votre_site.con texte affiché] => texte affiché.
|
||||
## [http://votre_site.con | text displayed] => text displayed
|
||||
## [http://votre_site.con text displayed] => text displayed.
|
||||
##
|
||||
## @param[in] value String to transform.
|
||||
## @return Transformed string.
|
||||
##
|
||||
def transcode(value):
|
||||
|
||||
|
||||
# named link : [[http://plop.html | link name]]
|
||||
value = re.sub(r'\[\[http://(.*?) \| (.*?)\]\]',
|
||||
r'<a href="http://\1">\2</a>',
|
||||
value)
|
||||
|
||||
# direct link : [[http://plop.html]]
|
||||
value = re.sub(r'\[\[http://(.*?)\]\]',
|
||||
r'<a href="http://\1">http://\1</a>',
|
||||
value)
|
||||
|
||||
# direct lib link : [lib[libname]]
|
||||
value = re.sub(r'\[lib\[(.*?) \| (.*?)\]\]',
|
||||
r'<a href="../\1">\2</a>',
|
||||
value)
|
||||
"""
|
||||
p = re.compile('\[\[(.*?)(|(.*?))\]\])',
|
||||
flags=re.DOTALL)
|
||||
value = p.sub(replace_link,
|
||||
value)
|
||||
"""
|
||||
return value
|
||||
|
||||
|
||||
"""
|
||||
def replace_link(match):
|
||||
if match.group() == "":
|
||||
return ""
|
||||
#debug.verbose("plop: " + str(match.group()))
|
||||
value = "<ul>"
|
||||
value += re.sub(r':INDENT:',
|
||||
r'',
|
||||
match.group())
|
||||
value += "</ul>"
|
||||
return transcode(value)
|
||||
"""
|
||||
|
@ -24,55 +24,67 @@ import re
|
||||
def transcode(value):
|
||||
value = re.sub(r'\[b\](.*?)\[/b\]',
|
||||
r'<span style="font-weight: bold;">\1</span>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[i\](.*?)\[/i\]',
|
||||
r'<span style="font-style: italic;">\1</span>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[u\](.*?)\[/u\]',
|
||||
r'<span style="text-decoration: underline;">\1</span>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[sup\](.*?)\[/sup\]',
|
||||
r'<sup>\1</sup>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[sub\](.*?)\[/sub\]',
|
||||
r'<sub>\1</sub>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]',
|
||||
r'<span style="color: \1;">\2</span>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[center\](.*?)\[/center\]',
|
||||
value = re.sub(r'\[center\](.*)\[/center\]',
|
||||
r'<div align="center">\1</div>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[right\](.*?)\[/right\]',
|
||||
r'<div align="right">\1</div>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[left\](.*?)\[/left\]',
|
||||
r'<div align="left">\1</div>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[strike\](.*?)\[/strike\]',
|
||||
r'<span><strike>\1</strike></span>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[size=(.*?)\](.*?)\[/size\]',
|
||||
r'<span style="font-size: \1px; line-height: normal;">\2</span>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'\[cadre\](.*?)\[/cadre\]',
|
||||
r'<table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td class="quote">\1</td></tr></tbody></table>',
|
||||
value)
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
value = re.sub(r'____(.*?)\n',
|
||||
r'<hr>',
|
||||
value)
|
||||
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
|
||||
return value
|
||||
|
@ -18,23 +18,23 @@ import re
|
||||
def transcode(value):
|
||||
|
||||
value = re.sub(r'\n======(.*?)======',
|
||||
r'<h5>\1</h5>',
|
||||
r'\n<h5>\1</h5>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n=====(.*?)=====',
|
||||
r'<h4>\1</h4>',
|
||||
r'\n<h4>\1</h4>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n====(.*?)====',
|
||||
r'<h3>\1</h3>',
|
||||
r'\n<h3>\1</h3>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n===(.*?)===',
|
||||
r'<h2>\1</h2>',
|
||||
r'\n<h2>\1</h2>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n==(.*?)==',
|
||||
r'<h1>\1</h1>',
|
||||
r'\n<h1>\1</h1>',
|
||||
'\n' + value)
|
||||
# todo : remove \n at the start of the file ...
|
||||
|
||||
|
@ -15,12 +15,13 @@ def transcode(value):
|
||||
|
||||
value = re.sub(r'\/\*(.*?)\*\/',
|
||||
r'',
|
||||
value)
|
||||
|
||||
value,
|
||||
flags=re.DOTALL)
|
||||
"""
|
||||
value = re.sub(r'\/\/(.*?)\n',
|
||||
r'',
|
||||
value)
|
||||
|
||||
"""
|
||||
return value
|
||||
|
||||
|
||||
|
@ -17,10 +17,6 @@ def transcode(value):
|
||||
r'\n',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n\n\n',
|
||||
r'<br/><br/>',
|
||||
value)
|
||||
|
||||
value = re.sub(r'\n\n',
|
||||
r'<br/>',
|
||||
value)
|
||||
|
@ -24,7 +24,7 @@ def transcode(value):
|
||||
value = BB_Title.transcode(value)
|
||||
value = BB_Text.transcode(value)
|
||||
value = BB_IndentAndDot.transcode(value)
|
||||
#value = BB_Link.transcode(value)
|
||||
value = BB_Link.transcode(value)
|
||||
value = BB_Image.transcode(value)
|
||||
value = BB_Table.transcode(value)
|
||||
value = BB_Code.transcode(value)
|
||||
|
25
lutinDoc.py
25
lutinDoc.py
@ -20,6 +20,7 @@ class doc:
|
||||
def __init__(self, moduleName):
|
||||
self.moduleName = moduleName
|
||||
self.listDocFile = []
|
||||
self.listTutorialFile = []
|
||||
self.listClass = dict()
|
||||
self.listEnum = dict()
|
||||
self.listVariable = dict()
|
||||
@ -94,17 +95,33 @@ class doc:
|
||||
# Import the module :
|
||||
for filename in tmpList:
|
||||
fileCompleteName = os.path.join(root, filename)
|
||||
debug.debug(" Find a doc file : '" + fileCompleteName + "'")
|
||||
self.add_file_doc(fileCompleteName)
|
||||
tutorialPath = os.path.join(self.pathGlobalDoc, "tutorial/")
|
||||
debug.verbose(" Find a doc file : '" + fileCompleteName + "'")
|
||||
pathBase = fileCompleteName[len(self.pathGlobalDoc):len(fileCompleteName)-3]
|
||||
if fileCompleteName[:len(tutorialPath)] == tutorialPath:
|
||||
self.add_file_doc(fileCompleteName, pathBase)
|
||||
else:
|
||||
self.add_tutorial_doc(fileCompleteName, pathBase)
|
||||
|
||||
##
|
||||
## @brief Add a documentation file at the parsing system
|
||||
## @param[in] filename File To add at the parsing element system.
|
||||
## @param[in] outPath output system file.
|
||||
## @return True if no error occured, False otherwise
|
||||
##
|
||||
def add_file_doc(self, filename):
|
||||
def add_file_doc(self, filename, outPath):
|
||||
debug.debug("adding file in documantation : '" + filename + "'");
|
||||
self.listDocFile.append(filename)
|
||||
self.listDocFile.append([filename, outPath])
|
||||
|
||||
##
|
||||
## @brief Add a documentation file at the parsing system
|
||||
## @param[in] filename File To add at the parsing element system.
|
||||
## @param[in] outPath output system file.
|
||||
## @return True if no error occured, False otherwise
|
||||
##
|
||||
def add_tutorial_doc(self, filename, outPath):
|
||||
debug.debug("adding file in documantation : '" + filename + "'");
|
||||
self.listTutorialFile.append([filename, outPath])
|
||||
|
||||
##
|
||||
## @brief Add a file at the parsing system
|
||||
|
@ -443,8 +443,27 @@ def generate(myDoc, outFolder) :
|
||||
|
||||
file.close()
|
||||
|
||||
for docInputName in myDoc.listDocFile :
|
||||
codeBB.transcode_file(docInputName, docInputName+".html")
|
||||
for docInputName,outpath in myDoc.listDocFile :
|
||||
debug.printElement("doc", myDoc.moduleName, "<==", docInputName)
|
||||
outputFileName = outFolder + "/" + outpath.replace('/','_') +".html"
|
||||
debug.debug("output file : " + outputFileName)
|
||||
lutinTools.CreateDirectoryOfFile(outputFileName)
|
||||
inData = lutinTools.FileReadData(docInputName)
|
||||
if inData == "":
|
||||
continue
|
||||
outData = genericHeader + codeBB.transcode(inData) + genericFooter
|
||||
lutinTools.FileWriteData(outputFileName, outData)
|
||||
|
||||
for docInputName,outpath in myDoc.listTutorialFile :
|
||||
debug.printElement("tutorial", myDoc.moduleName, "<==", docInputName)
|
||||
outputFileName = outFolder + "/" + outpath+".html"
|
||||
debug.debug("output file : " + outputFileName)
|
||||
lutinTools.CreateDirectoryOfFile(outputFileName)
|
||||
inData = lutinTools.FileReadData(docInputName)
|
||||
if inData == "":
|
||||
continue
|
||||
outData = genericHeader + codeBB.transcode(inData) + genericFooter
|
||||
lutinTools.FileWriteData(outputFileName, outData)
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user