diff --git a/codeBB/BB_Code.py b/codeBB/BB_Code.py index 49c311e..8c0d337 100644 --- a/codeBB/BB_Code.py +++ b/codeBB/BB_Code.py @@ -2,6 +2,7 @@ import lutinDebug as debug import sys import lutinTools +import codeHL import re @@ -18,7 +19,7 @@ import re def transcode(value): #value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*))?\](.*?)\[/code\]', value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*?))?\](.*?)\[/code\]', - r'
\4
', + replace_code, #r'
\4
', value, flags=re.DOTALL) @@ -26,3 +27,11 @@ def transcode(value): return value + +def replace_code(match): + if match.group() == "": + return "" + #debug.info("plop: " + str(match.groups())) + value = codeHL.transcode(match.groups()[2], match.groups()[3]) + return '
' + value + '
' + diff --git a/codeBB/BB_Link.py b/codeBB/BB_Link.py index d3a8bc8..a8dc88b 100644 --- a/codeBB/BB_Link.py +++ b/codeBB/BB_Link.py @@ -31,6 +31,19 @@ def transcode(value): value = re.sub(r'\[lib\[(.*?) \| (.*?)\]\]', r'\2', value) + + value = re.sub(r'\[doc\[(.*?) \| (.*?)\]\]', + r'\2', + value) + + value = re.sub(r'\[tutorial\[(.*?) \| (.*?)\]\]', + r'\2', + value) + + value = re.sub(r'\[class\[(.*?)\]\]', + replace_link_class, + value) + """ p = re.compile('\[\[(.*?)(|(.*?))\]\])', flags=re.DOTALL) @@ -51,3 +64,14 @@ def replace_link(match): value += "" return transcode(value) """ + +def replace_link_class(match): + if match.group() == "": + return "" + #debug.info("plop: " + str(match.group())) + className = match.groups()[0] + value = re.sub(':', '_', className) + return '' + className + '' + + + diff --git a/codeBB/BB_Text.py b/codeBB/BB_Text.py index fe0365a..c7a8c0d 100644 --- a/codeBB/BB_Text.py +++ b/codeBB/BB_Text.py @@ -22,6 +22,7 @@ import re ## @return Transformed string. ## def transcode(value): + value = re.sub(r'\[b\](.*?)\[/b\]', r'\1', value, diff --git a/codeBB/BB_Title.py b/codeBB/BB_Title.py index b52362e..7c68199 100644 --- a/codeBB/BB_Title.py +++ b/codeBB/BB_Title.py @@ -7,6 +7,7 @@ import re ## ## @brief Transcode . +## =?=Page Title=?= ## ==Title 1== ## ===Title 2=== ## ====Title 3==== @@ -17,6 +18,10 @@ import re ## def transcode(value): + value = re.sub(r'=\?=(.*?)=\?=', + r'

\1

', + value) + value = re.sub(r'\n======(.*?)======', r'\n
\1
', value) @@ -36,7 +41,8 @@ def transcode(value): value = re.sub(r'\n==(.*?)==', r'\n

\1

', '\n' + value) - # todo : remove \n at the start of the file ... + + value = value[1:] return value diff --git a/codeBB/codeBB.py b/codeBB/codeBB.py index 2ea0834..00231f2 100644 --- a/codeBB/codeBB.py +++ b/codeBB/codeBB.py @@ -2,6 +2,7 @@ import lutinDebug as debug import sys import lutinTools +import re import BB_Title import BB_Text import BB_IndentAndDot @@ -20,6 +21,9 @@ import BB_Specification ## @return Transformed string. ## def transcode(value): + # remove html property + value = re.sub(r'<', r'<', value) + value = re.sub(r'>', r'>', value) value = BB_comment.transcode(value) value = BB_Title.transcode(value) value = BB_Text.transcode(value) diff --git a/codeHL/codeHL.py b/codeHL/codeHL.py index 6184971..30a8a42 100644 --- a/codeHL/codeHL.py +++ b/codeHL/codeHL.py @@ -1,4 +1,31 @@ #!/usr/bin/python import lutinDebug as debug import sys -import lutinTools \ No newline at end of file +import lutinTools +import codeHLcpp +import codeHLBBcode +import codeHLJava +import codeHLjson +import codeHLPython +import codeHLXML +import codeHLshell + + +def transcode(type, value): + if type == "c++": + value = codeHLcpp.transcode(value) + elif type == "java": + value = codeHLJava.transcode(value) + elif type == "bbcode": + value = codeHLBBcode.transcode(value) + elif type == "python": + value = codeHLPython.transcode(value) + elif type == "json": + value = codeHLjson.transcode(value) + elif type == "xml": + value = codeHLXML.transcode(value) + elif type == "shell": + value = codeHLshell.transcode(value) + + return value + diff --git a/codeHL/codeHLBBcode.py b/codeHL/codeHLBBcode.py index 6184971..d91f2d0 100644 --- a/codeHL/codeHLBBcode.py +++ b/codeHL/codeHLBBcode.py @@ -1,4 +1,9 @@ #!/usr/bin/python import lutinDebug as debug import sys -import lutinTools \ No newline at end of file +import lutinTools +import re + + +def transcode(value): + return value diff --git a/codeHL/codeHLJava.py b/codeHL/codeHLJava.py index 6184971..d91f2d0 100644 --- a/codeHL/codeHLJava.py +++ b/codeHL/codeHLJava.py @@ -1,4 +1,9 @@ #!/usr/bin/python import lutinDebug as debug import sys -import lutinTools \ No newline at end of file +import lutinTools +import re + + +def transcode(value): + return value diff --git a/codeHL/codeHLPython.py b/codeHL/codeHLPython.py index 6184971..d91f2d0 100644 --- a/codeHL/codeHLPython.py +++ b/codeHL/codeHLPython.py @@ -1,4 +1,9 @@ #!/usr/bin/python import lutinDebug as debug import sys -import lutinTools \ No newline at end of file +import lutinTools +import re + + +def transcode(value): + return value diff --git a/codeHL/codeHLXML.py b/codeHL/codeHLXML.py index 6184971..d91f2d0 100644 --- a/codeHL/codeHLXML.py +++ b/codeHL/codeHLXML.py @@ -1,4 +1,9 @@ #!/usr/bin/python import lutinDebug as debug import sys -import lutinTools \ No newline at end of file +import lutinTools +import re + + +def transcode(value): + return value diff --git a/codeHL/codeHLcpp.py b/codeHL/codeHLcpp.py index 6184971..ab2f79f 100644 --- a/codeHL/codeHLcpp.py +++ b/codeHL/codeHLcpp.py @@ -1,4 +1,63 @@ #!/usr/bin/python import lutinDebug as debug import sys -import lutinTools \ No newline at end of file +import lutinTools +import re + +listRegExp = [ + [ r'/\*\*(.*?)\*/', 'code-doxygen'], + [ r'/\*(.*?)\*/', 'code-comment'], + [ r'//!(.*?)\n', 'code-doxygen'], + [ r'//(.*?)\n', 'code-comment'], + [ r'#(.*?)\n', 'code-preproc'], + [ r'"((\\"|.)*?)"', 'code-text-quote'], + [ r"'(('|.)*?)'", 'code-text-quote'], + [ r'(inline|const|class|virtual|private|public|protected|friend|const|extern|auto|register|static|volatile|typedef|struct|union|enum)', + 'code-storage-keyword'], + [ r'(bool|BOOL|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128))', + 'code-type'], + [ r'(((0(x|X)[0-9a-fA-F]*)|(\d+\.?\d*|\.\d+)((e|E)(\+|\-)?\d+)?)(L|l|UL|ul|u|U|F|f)?)', + 'code-number'], + [ r'(m_[A-Za-z_0-9])', + 'code-member'], + [ r'(( |\t)_[A-Za-z_0-9]*)', + 'code-input-function'], + [ r'(return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof)( |\t|\(|\{)', + 'code-keyword'], + [ r'((new|delete|try|catch|memset|fopen|fread|fwrite|fgets|fclose|printf|(f|s|diag_)printf|calloc|malloc|realloc|(cyg|sup)_([a-z]|[A-Z]|[0-9]|_)+)( |\t|\())', + 'code-function-system'], + [ r'((\w|_)+[ \t]*\()', + 'code-function-name'], + [ r'(NULL|MAX|MIN|__LINE__|__DATA__|__FILE__|__func__|__TIME__|__STDC__)', + 'code-generic-define'], + [ r'([A-Z_][A-Z_0-9]{3,500})', + 'code-macro"'], + [ r'(==|>=|<=|!=|>{1,2}|<{1,2}|&&|\{|\})', + 'code-operator'], + [ r'(true|TRUE|false|FALSE)', + '' + outValue += result.group() + outValue += '' + + # change the input value + inValue = inValue[result.end():] + # Search again ... + result = re.search(reg1, inValue, re.DOTALL) + outValue += inValue + return outValue diff --git a/codeHL/codeHLjson.py b/codeHL/codeHLjson.py index 6184971..acfafb2 100644 --- a/codeHL/codeHLjson.py +++ b/codeHL/codeHLjson.py @@ -1,4 +1,10 @@ #!/usr/bin/python import lutinDebug as debug import sys -import lutinTools \ No newline at end of file +import lutinTools +import re + + +def transcode(value): + return value + diff --git a/codeHL/codeHLshell.py b/codeHL/codeHLshell.py new file mode 100644 index 0000000..67ccb0b --- /dev/null +++ b/codeHL/codeHLshell.py @@ -0,0 +1,14 @@ +#!/usr/bin/python +import lutinDebug as debug +import sys +import lutinTools +import re + +listRegExp = [ + [ r'#(.*?)\n', r'#\1\n'] +] + +def transcode(value): + for reg1, reg2 in listRegExp: + value = re.sub(reg1, reg2, value, flags=re.DOTALL) + return value diff --git a/lutinDoc.py b/lutinDoc.py index 5efa5ec..b642dca 100644 --- a/lutinDoc.py +++ b/lutinDoc.py @@ -6,6 +6,7 @@ import lutinTools sys.path.append(lutinTools.GetCurrentPath(__file__) + "/ply/ply/") sys.path.append(lutinTools.GetCurrentPath(__file__) + "/cppParser/CppHeaderParser/") sys.path.append(lutinTools.GetCurrentPath(__file__) + "/codeBB/") +sys.path.append(lutinTools.GetCurrentPath(__file__) + "/codeHL/") import CppHeaderParser import lutinDocHtml import lutinDocMd diff --git a/theme/base.css b/theme/base.css index aa94d74..502c71e 100644 --- a/theme/base.css +++ b/theme/base.css @@ -128,4 +128,67 @@ pre { .code-storage-keyword { text-decoration:none; color:#466cb4; -} \ No newline at end of file +} + +.code-doxygen { + text-decoration:none; + color:#bf3e00; + font-weight:bold; +} + +.code-comment { + text-decoration:none; + color:#b704b5; +} + +.code-preproc { + text-decoration:none; + color:#ac0000; +} + +.code-text-quote { + text-decoration:none; + color:#008e00; +} +.code-number { + text-decoration:none; + color:#007b00; +} +.code-member { + text-decoration:none; + color:#7c5406; +} +.code-input-function { + text-decoration:none; + color:#B80000; + font-weight:bold; +} +.code-function-name { + text-decoration:none; + color:#09857e; + font-weight:bold; +} +.code-function-system { + text-decoration:none; + color:#acaa00; +} +.code-generic-define { + text-decoration:none; + color:#3c850b; +} +.code-macro { + text-decoration:none; + color:#3c850b; +} +.code-operator { + text-decoration:none; + color:#1633a3; +} +.code-keyword { + text-decoration:none; + color:#466cb4; +} +.code-class { + text-decoration:none; + color:#006cb4; +}