[DEBUG] correction of the output bb code

This commit is contained in:
Edouard DUPIN 2013-12-09 21:38:00 +01:00
parent 4caa15d422
commit 47b884d9b2
10 changed files with 125 additions and 44 deletions

View File

@ -16,11 +16,13 @@ import re
## @return Transformed string. ## @return Transformed string.
## ##
def transcode(value): 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\]', # TODO : remove the basic indentation of the element (to have a better display in the text tutorial ...
r'<span style="color: \1;">\2</span>',
value)
return value return value

View File

@ -47,13 +47,15 @@ def transcode(value):
value = re.sub(r'\n:', value = re.sub(r'\n:',
r'\n:INDENT:', r'\n:INDENT:',
value) value)
p = re.compile('((\:INDENT\:(.*?)\n)*)') p = re.compile('((\:INDENT\:(.*?)\n)*)',
flags=re.DOTALL)
value = p.sub(replace_wiki_identation, value = p.sub(replace_wiki_identation,
value) value)
value = re.sub(r'\*\*(.*?)\n', value = re.sub(r'\*\*(.*?)\n',
r'<li>\1</li>', r'<li>\1</li>',
value) value,
flags=re.DOTALL)
return value return value
@ -61,7 +63,7 @@ def transcode(value):
def replace_wiki_identation(match): def replace_wiki_identation(match):
if match.group() == "": if match.group() == "":
return "" return ""
debug.info("plop: " + str(match.group())) #debug.verbose("plop: " + str(match.group()))
value = "<ul>" value = "<ul>"
value += re.sub(r':INDENT:', value += re.sub(r':INDENT:',
r'', r'',

View File

@ -8,14 +8,46 @@ import re
## ##
## @brief Transcode: ## @brief Transcode:
## [http://votre_site.con] => http://votre_site.con ## [http://votre_site.con] => http://votre_site.con
## [http://votre_site.con | texte affiché] => texte affiché ## [http://votre_site.con | text displayed] => text displayed
## [http://votre_site.con texte affiché] => texte affiché. ## [http://votre_site.con text displayed] => text displayed.
## ##
## @param[in] value String to transform. ## @param[in] value String to transform.
## @return Transformed string. ## @return Transformed string.
## ##
def transcode(value): 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 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)
"""

View File

@ -24,55 +24,67 @@ import re
def transcode(value): def transcode(value):
value = re.sub(r'\[b\](.*?)\[/b\]', value = re.sub(r'\[b\](.*?)\[/b\]',
r'<span style="font-weight: bold;">\1</span>', r'<span style="font-weight: bold;">\1</span>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[i\](.*?)\[/i\]', value = re.sub(r'\[i\](.*?)\[/i\]',
r'<span style="font-style: italic;">\1</span>', r'<span style="font-style: italic;">\1</span>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[u\](.*?)\[/u\]', value = re.sub(r'\[u\](.*?)\[/u\]',
r'<span style="text-decoration: underline;">\1</span>', r'<span style="text-decoration: underline;">\1</span>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[sup\](.*?)\[/sup\]', value = re.sub(r'\[sup\](.*?)\[/sup\]',
r'<sup>\1</sup>', r'<sup>\1</sup>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[sub\](.*?)\[/sub\]', value = re.sub(r'\[sub\](.*?)\[/sub\]',
r'<sub>\1</sub>', r'<sub>\1</sub>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]', value = re.sub(r'\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]',
r'<span style="color: \1;">\2</span>', 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>', r'<div align="center">\1</div>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[right\](.*?)\[/right\]', value = re.sub(r'\[right\](.*?)\[/right\]',
r'<div align="right">\1</div>', r'<div align="right">\1</div>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[left\](.*?)\[/left\]', value = re.sub(r'\[left\](.*?)\[/left\]',
r'<div align="left">\1</div>', r'<div align="left">\1</div>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[strike\](.*?)\[/strike\]', value = re.sub(r'\[strike\](.*?)\[/strike\]',
r'<span><strike>\1</strike></span>', r'<span><strike>\1</strike></span>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[size=(.*?)\](.*?)\[/size\]', value = re.sub(r'\[size=(.*?)\](.*?)\[/size\]',
r'<span style="font-size: \1px; line-height: normal;">\2</span>', r'<span style="font-size: \1px; line-height: normal;">\2</span>',
value) value,
flags=re.DOTALL)
value = re.sub(r'\[cadre\](.*?)\[/cadre\]', 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>', 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', value = re.sub(r'____(.*?)\n',
r'<hr>', r'<hr>',
value) value,
flags=re.DOTALL)
return value return value

View File

@ -18,23 +18,23 @@ import re
def transcode(value): def transcode(value):
value = re.sub(r'\n======(.*?)======', value = re.sub(r'\n======(.*?)======',
r'<h5>\1</h5>', r'\n<h5>\1</h5>',
value) value)
value = re.sub(r'\n=====(.*?)=====', value = re.sub(r'\n=====(.*?)=====',
r'<h4>\1</h4>', r'\n<h4>\1</h4>',
value) value)
value = re.sub(r'\n====(.*?)====', value = re.sub(r'\n====(.*?)====',
r'<h3>\1</h3>', r'\n<h3>\1</h3>',
value) value)
value = re.sub(r'\n===(.*?)===', value = re.sub(r'\n===(.*?)===',
r'<h2>\1</h2>', r'\n<h2>\1</h2>',
value) value)
value = re.sub(r'\n==(.*?)==', value = re.sub(r'\n==(.*?)==',
r'<h1>\1</h1>', r'\n<h1>\1</h1>',
'\n' + value) '\n' + value)
# todo : remove \n at the start of the file ... # todo : remove \n at the start of the file ...

View File

@ -15,12 +15,13 @@ def transcode(value):
value = re.sub(r'\/\*(.*?)\*\/', value = re.sub(r'\/\*(.*?)\*\/',
r'', r'',
value) value,
flags=re.DOTALL)
"""
value = re.sub(r'\/\/(.*?)\n', value = re.sub(r'\/\/(.*?)\n',
r'', r'',
value) value)
"""
return value return value

View File

@ -17,10 +17,6 @@ def transcode(value):
r'\n', r'\n',
value) value)
value = re.sub(r'\n\n\n',
r'<br/><br/>',
value)
value = re.sub(r'\n\n', value = re.sub(r'\n\n',
r'<br/>', r'<br/>',
value) value)

View File

@ -24,7 +24,7 @@ def transcode(value):
value = BB_Title.transcode(value) value = BB_Title.transcode(value)
value = BB_Text.transcode(value) value = BB_Text.transcode(value)
value = BB_IndentAndDot.transcode(value) value = BB_IndentAndDot.transcode(value)
#value = BB_Link.transcode(value) value = BB_Link.transcode(value)
value = BB_Image.transcode(value) value = BB_Image.transcode(value)
value = BB_Table.transcode(value) value = BB_Table.transcode(value)
value = BB_Code.transcode(value) value = BB_Code.transcode(value)

View File

@ -20,6 +20,7 @@ class doc:
def __init__(self, moduleName): def __init__(self, moduleName):
self.moduleName = moduleName self.moduleName = moduleName
self.listDocFile = [] self.listDocFile = []
self.listTutorialFile = []
self.listClass = dict() self.listClass = dict()
self.listEnum = dict() self.listEnum = dict()
self.listVariable = dict() self.listVariable = dict()
@ -94,17 +95,33 @@ class doc:
# Import the module : # Import the module :
for filename in tmpList: for filename in tmpList:
fileCompleteName = os.path.join(root, filename) fileCompleteName = os.path.join(root, filename)
debug.debug(" Find a doc file : '" + fileCompleteName + "'") tutorialPath = os.path.join(self.pathGlobalDoc, "tutorial/")
self.add_file_doc(fileCompleteName) 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 ## @brief Add a documentation file at the parsing system
## @param[in] filename File To add at the parsing element 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 ## @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 + "'"); 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 ## @brief Add a file at the parsing system

View File

@ -443,8 +443,27 @@ def generate(myDoc, outFolder) :
file.close() file.close()
for docInputName in myDoc.listDocFile : for docInputName,outpath in myDoc.listDocFile :
codeBB.transcode_file(docInputName, docInputName+".html") 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)