mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
doc: use raw strings for regular expressions in python
This commit is contained in:
parent
de13ba803a
commit
47f34e0cff
@ -18,20 +18,20 @@ figures = {
|
|||||||
|
|
||||||
|
|
||||||
def fix_empty_href(line):
|
def fix_empty_href(line):
|
||||||
corr = re.match('.*(href{}).*',line)
|
corr = re.match(r'.*(href{}).*',line)
|
||||||
if corr:
|
if corr:
|
||||||
line = line.replace(corr.group(1), "path")
|
line = line.replace(corr.group(1), "path")
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
def fix_listing_after_section(line):
|
def fix_listing_after_section(line):
|
||||||
corr = re.match('.*begin{lstlisting}',line)
|
corr = re.match(r'.*begin{lstlisting}',line)
|
||||||
if corr:
|
if corr:
|
||||||
line = "\leavevmode" + line
|
line = "\leavevmode" + line
|
||||||
return line
|
return line
|
||||||
|
|
||||||
def fix_listing_hyperref_into_ref(line):
|
def fix_listing_hyperref_into_ref(line):
|
||||||
corr = re.match('(.*\\\\)hyperref\[(lst:.*)\]{.*}(.*)',line)
|
corr = re.match(r'.*\\)hyperref\[(lst:.*)\]{.*}(.*)',line)
|
||||||
if corr:
|
if corr:
|
||||||
line = corr.group(1)+"ref{" + corr.group(2) +"} " + corr.group(3)
|
line = corr.group(1)+"ref{" + corr.group(2) +"} " + corr.group(3)
|
||||||
return line
|
return line
|
||||||
@ -40,14 +40,14 @@ def fix_listing_hyperref_into_ref(line):
|
|||||||
def fix_figure_width_and_type(line):
|
def fix_figure_width_and_type(line):
|
||||||
global figures
|
global figures
|
||||||
for name, width in figures.items():
|
for name, width in figures.items():
|
||||||
corr = re.match('(.*includegraphics)(.*'+name+'.*)',line)
|
corr = re.match(r'(.*includegraphics)(.*'+name+'.*)',line)
|
||||||
if corr:
|
if corr:
|
||||||
line = corr.group(1) + '[width='+width+'\\textwidth]' + corr.group(2).replace('png','pdf')
|
line = corr.group(1) + '[width='+width+'\\textwidth]' + corr.group(2).replace('png','pdf')
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
def fix_appendix_pagebreak(line):
|
def fix_appendix_pagebreak(line):
|
||||||
corr = re.match('.*section{APIs}.*',line)
|
corr = re.match(r'.*section{APIs}.*',line)
|
||||||
if corr:
|
if corr:
|
||||||
line = "\leavevmode\pagebreak\n" + line
|
line = "\leavevmode\pagebreak\n" + line
|
||||||
return line
|
return line
|
||||||
@ -67,7 +67,7 @@ def postprocess_file(markdown_filepath, fout, title):
|
|||||||
# remove path from section reference
|
# remove path from section reference
|
||||||
# e.g. [the SPP Counter example](examples/generated/#sec:sppcounterExample)
|
# e.g. [the SPP Counter example](examples/generated/#sec:sppcounterExample)
|
||||||
# replace with [the SPP Counter example](#sec:sppcounterExample)
|
# replace with [the SPP Counter example](#sec:sppcounterExample)
|
||||||
section_ref = re.match('.*\(((.*)(#sec:.*))\).*',line)
|
section_ref = re.match(r'.*\(((.*)(#sec:.*))\).*',line)
|
||||||
if section_ref:
|
if section_ref:
|
||||||
line = line.replace(section_ref.group(2),"")
|
line = line.replace(section_ref.group(2),"")
|
||||||
fout.write(line)
|
fout.write(line)
|
||||||
|
@ -38,13 +38,13 @@ api_description = """
|
|||||||
code_ref = """GITHUB/FPATH#LLINENR"""
|
code_ref = """GITHUB/FPATH#LLINENR"""
|
||||||
|
|
||||||
def isEndOfComment(line):
|
def isEndOfComment(line):
|
||||||
return re.match('\s*\*/.*', line)
|
return re.match(r'\s*\*/.*', line)
|
||||||
|
|
||||||
def isStartOfComment(line):
|
def isStartOfComment(line):
|
||||||
return re.match('\s*\/\*/.*', line)
|
return re.match(r'\s*\/\*/.*', line)
|
||||||
|
|
||||||
def isTypedefStart(line):
|
def isTypedefStart(line):
|
||||||
return re.match('.*typedef\s+struct.*', line)
|
return re.match(r'.*typedef\s+struct.*', line)
|
||||||
|
|
||||||
def codeReference(fname, githuburl, filename_without_extension, filepath, linenr):
|
def codeReference(fname, githuburl, filename_without_extension, filepath, linenr):
|
||||||
global code_ref
|
global code_ref
|
||||||
@ -54,11 +54,11 @@ def codeReference(fname, githuburl, filename_without_extension, filepath, linenr
|
|||||||
return ref
|
return ref
|
||||||
|
|
||||||
def isTagAPI(line):
|
def isTagAPI(line):
|
||||||
return re.match('(.*)(-\s*\')(APIs).*',line)
|
return re.match(r'(.*)(-\s*\')(APIs).*',line)
|
||||||
|
|
||||||
def getSecondLevelIdentation(line):
|
def getSecondLevelIdentation(line):
|
||||||
indentation = ""
|
indentation = ""
|
||||||
parts = re.match('(.*)(-\s*\')(APIs).*',line)
|
parts = re.match(r'(.*)(-\s*\')(APIs).*',line)
|
||||||
if parts:
|
if parts:
|
||||||
# return double identation for the submenu
|
# return double identation for the submenu
|
||||||
indentation = parts.group(1) + parts.group(1) + "- "
|
indentation = parts.group(1) + parts.group(1) + "- "
|
||||||
@ -132,19 +132,19 @@ def createIndex(fin, filename, api_filepath, api_title, api_label, githuburl):
|
|||||||
|
|
||||||
# search typedef struct end
|
# search typedef struct end
|
||||||
if typedefFound:
|
if typedefFound:
|
||||||
typedef = re.match('}\s*(.*);\n', line)
|
typedef = re.match(r'}\s*(.*);\n', line)
|
||||||
if typedef:
|
if typedef:
|
||||||
typedefFound = 0
|
typedefFound = 0
|
||||||
typedefs[typedef.group(1)] = codeReference(typedef.group(1), githuburl, filename, api_filepath, linenr)
|
typedefs[typedef.group(1)] = codeReference(typedef.group(1), githuburl, filename, api_filepath, linenr)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ref_function = re.match('.*typedef\s+void\s+\(\s*\*\s*(.*?)\)\(.*', line)
|
ref_function = re.match(r'.*typedef\s+void\s+\(\s*\*\s*(.*?)\)\(.*', line)
|
||||||
if ref_function:
|
if ref_function:
|
||||||
functions[ref_function.group(1)] = codeReference(ref_function.group(1), githuburl, filename, api_filepath, linenr)
|
functions[ref_function.group(1)] = codeReference(ref_function.group(1), githuburl, filename, api_filepath, linenr)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
one_line_function_definition = re.match('(.*?)\s*\(.*\(*.*;\n', line)
|
one_line_function_definition = re.match(r'(.*?)\s*\(.*\(*.*;\n', line)
|
||||||
if one_line_function_definition:
|
if one_line_function_definition:
|
||||||
parts = one_line_function_definition.group(1).split(" ");
|
parts = one_line_function_definition.group(1).split(" ");
|
||||||
name = parts[len(parts)-1]
|
name = parts[len(parts)-1]
|
||||||
@ -154,7 +154,7 @@ def createIndex(fin, filename, api_filepath, api_title, api_label, githuburl):
|
|||||||
functions[name] = codeReference( name, githuburl, filename, api_filepath, linenr)
|
functions[name] = codeReference( name, githuburl, filename, api_filepath, linenr)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
multi_line_function_definition = re.match('.(.*?)\s*\(.*\(*.*', line)
|
multi_line_function_definition = re.match(r'.(.*?)\s*\(.*\(*.*', line)
|
||||||
if multi_line_function_definition:
|
if multi_line_function_definition:
|
||||||
parts = multi_line_function_definition.group(1).split(" ");
|
parts = multi_line_function_definition.group(1).split(" ");
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ def findTitle(fin):
|
|||||||
if isStartOfComment(line):
|
if isStartOfComment(line):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
parts = re.match('.*(@title)(.*)', line)
|
parts = re.match(r'.*(@title)(.*)', line)
|
||||||
if parts:
|
if parts:
|
||||||
title = parts.group(2).strip()
|
title = parts.group(2).strip()
|
||||||
state = State.SearchEndTitle
|
state = State.SearchEndTitle
|
||||||
@ -187,7 +187,7 @@ def findTitle(fin):
|
|||||||
state = State.DoneAPI
|
state = State.DoneAPI
|
||||||
break
|
break
|
||||||
|
|
||||||
parts = re.match('(\s*\*\s*)(.*\n)',line)
|
parts = re.match(r'(\s*\*\s*)(.*\n)',line)
|
||||||
if parts:
|
if parts:
|
||||||
desc = desc + parts.group(2)
|
desc = desc + parts.group(2)
|
||||||
return [title, desc]
|
return [title, desc]
|
||||||
|
@ -101,40 +101,40 @@ def latexText(text, ref_prefix):
|
|||||||
return ""
|
return ""
|
||||||
brief = text.replace(" in the BTstack manual","")
|
brief = text.replace(" in the BTstack manual","")
|
||||||
|
|
||||||
refs = re.match('.*(Listing\s+)(\w+).*',brief)
|
refs = re.match(r'.*(Listing\s+)(\w+).*',brief)
|
||||||
if refs:
|
if refs:
|
||||||
brief = brief.replace(refs.group(2), "[here](#lst:"+ref_prefix + refs.group(2)+")")
|
brief = brief.replace(refs.group(2), "[here](#lst:"+ref_prefix + refs.group(2)+")")
|
||||||
|
|
||||||
return brief
|
return brief
|
||||||
|
|
||||||
def isEmptyCommentLine(line):
|
def isEmptyCommentLine(line):
|
||||||
return re.match('(\s*\*\s*)\n',line)
|
return re.match(r'(\s*\*\s*)\n',line)
|
||||||
|
|
||||||
def isCommentLine(line):
|
def isCommentLine(line):
|
||||||
return re.match('(\s*\*\s*).*',line)
|
return re.match(r'(\s*\*\s*).*',line)
|
||||||
|
|
||||||
def isEndOfComment(line):
|
def isEndOfComment(line):
|
||||||
return re.match('\s*\*/.*', line)
|
return re.match(r'\s*\*/.*', line)
|
||||||
|
|
||||||
def isNewItem(line):
|
def isNewItem(line):
|
||||||
return re.match('(\s*\*\s*\-\s*)(.*)',line)
|
return re.match(r'(\s*\*\s*\-\s*)(.*)',line)
|
||||||
|
|
||||||
def isTextTag(line):
|
def isTextTag(line):
|
||||||
return re.match('.*(@text).*', line)
|
return re.match(r'.*(@text).*', line)
|
||||||
|
|
||||||
def isItemizeTag(line):
|
def isItemizeTag(line):
|
||||||
return re.match("(\s+\*\s+)(-\s)(.*)", line)
|
return re.match(r'(\s+\*\s+)(-\s)(.*)', line)
|
||||||
|
|
||||||
def processTextLine(line, ref_prefix):
|
def processTextLine(line, ref_prefix):
|
||||||
if isTextTag(line):
|
if isTextTag(line):
|
||||||
text_line_parts = re.match(".*(@text)(.*)", line)
|
text_line_parts = re.match(r'.*(@text)(.*)', line)
|
||||||
return " " + latexText(text_line_parts.group(2), ref_prefix)
|
return " " + latexText(text_line_parts.group(2), ref_prefix)
|
||||||
|
|
||||||
if isItemizeTag(line):
|
if isItemizeTag(line):
|
||||||
text_line_parts = re.match("(\s*\*\s*\-\s*)(.*)", line)
|
text_line_parts = re.match(r'(\s*\*\s*\-\s*)(.*)', line)
|
||||||
return "\n- " + latexText(text_line_parts.group(2), ref_prefix)
|
return "\n- " + latexText(text_line_parts.group(2), ref_prefix)
|
||||||
|
|
||||||
text_line_parts = re.match("(\s+\*\s+)(.*)", line)
|
text_line_parts = re.match(r'(\s+\*\s+)(.*)', line)
|
||||||
if text_line_parts:
|
if text_line_parts:
|
||||||
return " " + latexText(text_line_parts.group(2), ref_prefix)
|
return " " + latexText(text_line_parts.group(2), ref_prefix)
|
||||||
return ""
|
return ""
|
||||||
@ -143,9 +143,9 @@ def getExampleTitle(example_path):
|
|||||||
example_title = ''
|
example_title = ''
|
||||||
with open(example_path, 'r') as fin:
|
with open(example_path, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
parts = re.match(r'.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
||||||
if parts:
|
if parts:
|
||||||
example_title = parts.group(3).replace("_","\_")
|
example_title = parts.group(3).replace("_",r'\_')
|
||||||
continue
|
continue
|
||||||
return example_title
|
return example_title
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ def writeListings(aout, infile_name, ref_prefix, git_branch_name):
|
|||||||
with open(infile_name, 'r') as fin:
|
with open(infile_name, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
if state == State.SearchExampleStart:
|
if state == State.SearchExampleStart:
|
||||||
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
parts = re.match(r'.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
||||||
if parts:
|
if parts:
|
||||||
label = parts.group(2).replace("_","")
|
label = parts.group(2).replace("_","")
|
||||||
title = latexText(parts.group(2), ref_prefix)
|
title = latexText(parts.group(2), ref_prefix)
|
||||||
@ -194,13 +194,13 @@ def writeListings(aout, infile_name, ref_prefix, git_branch_name):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# detect @section
|
# detect @section
|
||||||
section_parts = re.match('.*(@section)\s*(.*)(:?\s*.?)\*?/?\n',line)
|
section_parts = re.match(r'.*(@section)\s*(.*)(:?\s*.?)\*?/?\n',line)
|
||||||
if section_parts:
|
if section_parts:
|
||||||
aout.write("\n" + example_subsection.replace("SECTION_TITLE", section_parts.group(2)))
|
aout.write("\n" + example_subsection.replace("SECTION_TITLE", section_parts.group(2)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# detect @subsection
|
# detect @subsection
|
||||||
subsection_parts = re.match('.*(@section)\s*(.*)(:?\s*.?)\*?/?\n',line)
|
subsection_parts = re.match(r'.*(@section)\s*(.*)(:?\s*.?)\*?/?\n',line)
|
||||||
if section_parts:
|
if section_parts:
|
||||||
subsubsection = example_subsection.replace("SECTION_TITLE", section_parts.group(2)).replace('section', 'subsection')
|
subsubsection = example_subsection.replace("SECTION_TITLE", section_parts.group(2)).replace('section', 'subsection')
|
||||||
aout.write("\n" + subsubsection)
|
aout.write("\n" + subsubsection)
|
||||||
@ -245,7 +245,7 @@ def writeListings(aout, infile_name, ref_prefix, git_branch_name):
|
|||||||
#continue
|
#continue
|
||||||
|
|
||||||
if state == State.SearchListingStart:
|
if state == State.SearchListingStart:
|
||||||
parts = re.match('.*(LISTING_START)\((.*)\):\s*(.*)(\s+\*/).*',line)
|
parts = re.match(r'.*(LISTING_START)\((.*)\):\s*(.*)(\s+\*/).*',line)
|
||||||
|
|
||||||
if parts:
|
if parts:
|
||||||
lst_label = parts.group(2).replace("_","")
|
lst_label = parts.group(2).replace("_","")
|
||||||
@ -257,9 +257,9 @@ def writeListings(aout, infile_name, ref_prefix, git_branch_name):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if state == State.SearchListingEnd:
|
if state == State.SearchListingEnd:
|
||||||
parts_end = re.match('.*(LISTING_END).*',line)
|
parts_end = re.match(r'.*(LISTING_END).*',line)
|
||||||
parts_pause = re.match('.*(LISTING_PAUSE).*',line)
|
parts_pause = re.match(r'.*(LISTING_PAUSE).*',line)
|
||||||
end_comment_parts = re.match('.*(\*/)\s*\n', line);
|
end_comment_parts = re.match(r'.*(\*/)\s*\n', line);
|
||||||
|
|
||||||
if parts_end:
|
if parts_end:
|
||||||
aout.write(code_in_listing)
|
aout.write(code_in_listing)
|
||||||
@ -278,12 +278,12 @@ def writeListings(aout, infile_name, ref_prefix, git_branch_name):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if state == State.SearchListingResume:
|
if state == State.SearchListingResume:
|
||||||
parts = re.match('.*(LISTING_RESUME).*',line)
|
parts = re.match(r'.*(LISTING_RESUME).*',line)
|
||||||
if parts:
|
if parts:
|
||||||
state = State.SearchListingEnd
|
state = State.SearchListingEnd
|
||||||
continue
|
continue
|
||||||
|
|
||||||
parts = re.match('.*(EXAMPLE_END).*',line)
|
parts = re.match(r'.*(EXAMPLE_END).*',line)
|
||||||
if parts:
|
if parts:
|
||||||
if state != State.SearchListingStart:
|
if state != State.SearchListingStart:
|
||||||
print("Formating error detected")
|
print("Formating error detected")
|
||||||
|
@ -33,22 +33,22 @@ See [NAME API](../appendix/apis/#REFERENCE).
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def isEmptyCommentLine(line):
|
def isEmptyCommentLine(line):
|
||||||
return re.match('(\s*\*\s*)\n',line)
|
return re.match(r'(\s*\*\s*)\n',line)
|
||||||
|
|
||||||
def isCommentLine(line):
|
def isCommentLine(line):
|
||||||
return re.match('(\s*\*\s*).*',line)
|
return re.match(r'(\s*\*\s*).*',line)
|
||||||
|
|
||||||
def isEndOfComment(line):
|
def isEndOfComment(line):
|
||||||
return re.match('\s*\*/.*', line)
|
return re.match(r'\s*\*/.*', line)
|
||||||
|
|
||||||
def isNewItem(line):
|
def isNewItem(line):
|
||||||
return re.match('(\s*\*\s*\-\s*)(.*)',line)
|
return re.match(r'(\s*\*\s*\-\s*)(.*)',line)
|
||||||
|
|
||||||
def isTextTag(line):
|
def isTextTag(line):
|
||||||
return re.match('.*(@text).*', line)
|
return re.match(r'.*(@text).*', line)
|
||||||
|
|
||||||
def isItemizeTag(line):
|
def isItemizeTag(line):
|
||||||
return re.match("(\s+\*\s+)(-\s)(.*)", line)
|
return re.match(r'(\s+\*\s+)(-\s)(.*)', line)
|
||||||
|
|
||||||
def processTextLine(line):
|
def processTextLine(line):
|
||||||
if isEmptyCommentLine(line):
|
if isEmptyCommentLine(line):
|
||||||
@ -57,17 +57,17 @@ def processTextLine(line):
|
|||||||
line.rstrip()
|
line.rstrip()
|
||||||
|
|
||||||
if isTextTag(line):
|
if isTextTag(line):
|
||||||
text_line_parts = re.match(".*(@text\s*)(.*)", line)
|
text_line_parts = re.match(r'.*(@text\s*)(.*)', line)
|
||||||
return text_line_parts.group(2).lstrip() + " "
|
return text_line_parts.group(2).lstrip() + " "
|
||||||
|
|
||||||
if isItemizeTag(line):
|
if isItemizeTag(line):
|
||||||
text_line_parts = re.match("(\s*\*\s*\-\s*)(.*)", line)
|
text_line_parts = re.match(r'(\s*\*\s*\-\s*)(.*)', line)
|
||||||
return "- " + text_line_parts.group(2)
|
return "- " + text_line_parts.group(2)
|
||||||
|
|
||||||
if isEmptyCommentLine(line):
|
if isEmptyCommentLine(line):
|
||||||
return "\n"
|
return "\n"
|
||||||
|
|
||||||
text_line_parts = re.match("(\s+\*\s+)(.*)", line)
|
text_line_parts = re.match(r'(\s+\*\s+)(.*)', line)
|
||||||
if text_line_parts:
|
if text_line_parts:
|
||||||
return text_line_parts.group(2) + " "
|
return text_line_parts.group(2) + " "
|
||||||
return ""
|
return ""
|
||||||
|
@ -11,7 +11,7 @@ def get_readme_title(example_path):
|
|||||||
title = ''
|
title = ''
|
||||||
with open(example_path, 'r') as fin:
|
with open(example_path, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
parts = re.match('(##\s)(.*)\n',line)
|
parts = re.match(r'(##\s)(.*)\n',line)
|
||||||
if parts:
|
if parts:
|
||||||
title = parts.group(2)
|
title = parts.group(2)
|
||||||
continue
|
continue
|
||||||
@ -43,7 +43,7 @@ def process_readmes(intro_file, port_folder, ports_file, ports_folder):
|
|||||||
with open(readme_file, 'r') as fin:
|
with open(readme_file, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
# find title, add reference
|
# find title, add reference
|
||||||
title_parts = re.match('(#\s+)(.*)\n',line)
|
title_parts = re.match(r'(#\s+)(.*)\n',line)
|
||||||
if title_parts:
|
if title_parts:
|
||||||
title = title_parts.group(2)
|
title = title_parts.group(2)
|
||||||
ports.write(port_item.replace("PORT_TITLE", title).replace("PORT_LABEL", readme_dir))
|
ports.write(port_item.replace("PORT_TITLE", title).replace("PORT_LABEL", readme_dir))
|
||||||
@ -55,10 +55,10 @@ def process_readmes(intro_file, port_folder, ports_file, ports_folder):
|
|||||||
with open(readme_file, 'r') as fin:
|
with open(readme_file, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
#increase level of indentation
|
#increase level of indentation
|
||||||
parts = re.match('#(.*)\n',line)
|
parts = re.match(r'#(.*)\n',line)
|
||||||
|
|
||||||
title_parts_level1 = re.match('(#\s+)(.*)\n',line)
|
title_parts_level1 = re.match(r'(#\s+)(.*)\n',line)
|
||||||
title_parts_level2 = re.match('(##\s+)(.*)\n',line)
|
title_parts_level2 = re.match(r'(##\s+)(.*)\n',line)
|
||||||
|
|
||||||
if parts and title_parts_level1:
|
if parts and title_parts_level1:
|
||||||
ports.write("## " + title_parts_level1.group(2) + " {" + "#sec:" + readme_dir + "Port}\n" )
|
ports.write("## " + title_parts_level1.group(2) + " {" + "#sec:" + readme_dir + "Port}\n" )
|
||||||
|
@ -16,7 +16,7 @@ def insert_reference(mdout, text, link):
|
|||||||
mdout.write("")
|
mdout.write("")
|
||||||
|
|
||||||
def process_source_file_link(mdin, mdout, githuburl, line):
|
def process_source_file_link(mdin, mdout, githuburl, line):
|
||||||
parts = re.match('.*(GITHUB_URL).*\n',line)
|
parts = re.match(r'.*(GITHUB_URL).*\n',line)
|
||||||
if parts:
|
if parts:
|
||||||
line_with_source_file_link = line.replace("GITHUB_URL", githuburl)
|
line_with_source_file_link = line.replace("GITHUB_URL", githuburl)
|
||||||
mdout.write(line_with_source_file_link)
|
mdout.write(line_with_source_file_link)
|
||||||
@ -25,7 +25,7 @@ def process_source_file_link(mdin, mdout, githuburl, line):
|
|||||||
|
|
||||||
# handlers for various elements
|
# handlers for various elements
|
||||||
def process_section(mdin, mdout, line):
|
def process_section(mdin, mdout, line):
|
||||||
section = re.match('(#+.*){#(sec:.*)}',line)
|
section = re.match(r'(#+.*){#(sec:.*)}',line)
|
||||||
if section:
|
if section:
|
||||||
insert_anchor(mdout, section.group(2))
|
insert_anchor(mdout, section.group(2))
|
||||||
mdout.write(section.group(1)+"\n")
|
mdout.write(section.group(1)+"\n")
|
||||||
@ -34,7 +34,7 @@ def process_section(mdin, mdout, line):
|
|||||||
|
|
||||||
def process_figure(mdin, mdout, line):
|
def process_figure(mdin, mdout, line):
|
||||||
# detect figure
|
# detect figure
|
||||||
figure = re.match('\s*(\!.*)({#(fig:.*)})',line)
|
figure = re.match(r'\s*(\!.*)({#(fig:.*)})',line)
|
||||||
if figure:
|
if figure:
|
||||||
insert_anchor(mdout, figure.group(3))
|
insert_anchor(mdout, figure.group(3))
|
||||||
mdout.write(figure.group(1)+"\n")
|
mdout.write(figure.group(1)+"\n")
|
||||||
@ -43,7 +43,7 @@ def process_figure(mdin, mdout, line):
|
|||||||
|
|
||||||
def process_fig_ref(mdin, mdout, line):
|
def process_fig_ref(mdin, mdout, line):
|
||||||
# detect figure reference
|
# detect figure reference
|
||||||
figure_ref = re.match('.*({@(fig:.*)})',line)
|
figure_ref = re.match(r'.*({@(fig:.*)})',line)
|
||||||
if figure_ref:
|
if figure_ref:
|
||||||
md_reference = "[below](#"+figure_ref.group(2)+")"
|
md_reference = "[below](#"+figure_ref.group(2)+")"
|
||||||
line = line.replace(figure_ref.group(1), md_reference)
|
line = line.replace(figure_ref.group(1), md_reference)
|
||||||
@ -53,7 +53,7 @@ def process_fig_ref(mdin, mdout, line):
|
|||||||
|
|
||||||
def process_table(mdin, mdout, line):
|
def process_table(mdin, mdout, line):
|
||||||
# detect table
|
# detect table
|
||||||
table = re.match('\s*(Table:.*)({#(tbl:.*)})',line)
|
table = re.match(r'\s*(Table:.*)({#(tbl:.*)})',line)
|
||||||
if table:
|
if table:
|
||||||
insert_anchor(mdout, table.group(3))
|
insert_anchor(mdout, table.group(3))
|
||||||
mdout.write(table.group(1)+"\n")
|
mdout.write(table.group(1)+"\n")
|
||||||
@ -61,7 +61,7 @@ def process_table(mdin, mdout, line):
|
|||||||
return line
|
return line
|
||||||
|
|
||||||
def process_tbl_ref(mdin, mdout, line):
|
def process_tbl_ref(mdin, mdout, line):
|
||||||
table_ref = re.match('.*({@(tbl:.*)})',line)
|
table_ref = re.match(r'.*({@(tbl:.*)})',line)
|
||||||
if table_ref:
|
if table_ref:
|
||||||
md_reference = "[below](#"+table_ref.group(2)+")"
|
md_reference = "[below](#"+table_ref.group(2)+")"
|
||||||
line = line.replace(table_ref.group(1), md_reference)
|
line = line.replace(table_ref.group(1), md_reference)
|
||||||
@ -70,8 +70,8 @@ def process_tbl_ref(mdin, mdout, line):
|
|||||||
return line
|
return line
|
||||||
|
|
||||||
def process_listing(mdin, mdout, line):
|
def process_listing(mdin, mdout, line):
|
||||||
listing_start = re.match('.*{#(lst:.*)\s+.c\s+.*',line)
|
listing_start = re.match(r'.*{#(lst:.*)\s+.c\s+.*',line)
|
||||||
listing_end = re.match('\s*~~~~\s*\n',line)
|
listing_end = re.match(r'\s*~~~~\s*\n',line)
|
||||||
if listing_start:
|
if listing_start:
|
||||||
insert_anchor(mdout, listing_start.group(1))
|
insert_anchor(mdout, listing_start.group(1))
|
||||||
line = ''
|
line = ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user