Skip to content

Commit

Permalink
deploy: 1836fd2
Browse files Browse the repository at this point in the history
  • Loading branch information
Routhleck committed Aug 28, 2023
1 parent 9f2bc06 commit 29dab1d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ pre .k, pre .kd, pre .kn, pre .kp, pre .kr, pre .kt, pre .javascript .function {
.links-of-author { margin-top: 20px; }

.links-of-author a { display: inline-block; vertical-align: middle; margin-right: 10px; margin-bottom: 10px; border-bottom-color: #555; font-size: 13px; }
.links-of-author a:before { display: inline-block; vertical-align: middle; margin-right: 3px; content: " "; width: 4px; height: 4px; border-radius: 50%; background: magenta; }
.links-of-author a:before { display: inline-block; vertical-align: middle; margin-right: 3px; content: " "; width: 4px; height: 4px; border-radius: 50%; background: #47ffff; }

.links-of-blogroll { font-size: 13px; }

Expand Down
2 changes: 1 addition & 1 deletion atom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="routhleck.github.io/BrainPy-course-notes/atom.xml" rel="self" type="application/atom+xml" /><link href="routhleck.github.io/BrainPy-course-notes/" rel="alternate" type="text/html" /><updated>2023-08-28T05:19:28+00:00</updated><id>routhleck.github.io/BrainPy-course-notes/atom.xml</id><title type="html">BrainPy course notes</title><subtitle>Notes from the first training course on Neural Computational Modeling</subtitle><author><name>Sichao He</name></author><entry><title type="html">BrainPy course notes</title><link href="routhleck.github.io/BrainPy-course-notes/2023/08/27/BrainPy-course-notes/" rel="alternate" type="text/html" title="BrainPy course notes" /><published>2023-08-27T00:00:00+00:00</published><updated>2023-08-27T00:00:00+00:00</updated><id>routhleck.github.io/BrainPy-course-notes/2023/08/27/BrainPy-course-notes</id><content type="html" xml:base="routhleck.github.io/BrainPy-course-notes/2023/08/27/BrainPy-course-notes/">&lt;script src=&quot;https://polyfill.io/v3/polyfill.min.js?features=es6&quot;&gt;&lt;/script&gt;
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="routhleck.github.io/BrainPy-course-notes/atom.xml" rel="self" type="application/atom+xml" /><link href="routhleck.github.io/BrainPy-course-notes/" rel="alternate" type="text/html" /><updated>2023-08-28T06:56:50+00:00</updated><id>routhleck.github.io/BrainPy-course-notes/atom.xml</id><title type="html">BrainPy course notes</title><subtitle>Notes from the first training course on Neural Computational Modeling</subtitle><author><name>Sichao He</name></author><entry><title type="html">BrainPy course notes</title><link href="routhleck.github.io/BrainPy-course-notes/2023/08/27/BrainPy-course-notes/" rel="alternate" type="text/html" title="BrainPy course notes" /><published>2023-08-27T00:00:00+00:00</published><updated>2023-08-27T00:00:00+00:00</updated><id>routhleck.github.io/BrainPy-course-notes/2023/08/27/BrainPy-course-notes</id><content type="html" xml:base="routhleck.github.io/BrainPy-course-notes/2023/08/27/BrainPy-course-notes/">&lt;script src=&quot;https://polyfill.io/v3/polyfill.min.js?features=es6&quot;&gt;&lt;/script&gt;

&lt;script id=&quot;MathJax-script&quot; async=&quot;&quot; src=&quot;https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js&quot;&gt;&lt;/script&gt;

Expand Down
50 changes: 31 additions & 19 deletions image_url_process.py → markdown_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import os


def replace_img_url_1(input_path, out_path):
# 读取文件内容
with open(input_path, "r", encoding="utf-8") as file:
content = file.read()

def replace_img_url_1(content):
# 对于 ![image name](Notes.assets/image-000.png) 格式的替换
pattern1 = r'!\[.*?\]\((Notes\.assets/.*?\.(png|jpg|jpeg|gif|bmp))\)'
replacement1 = r'!\[.*?\](/assets/images/\1)'
Expand All @@ -17,16 +13,10 @@ def replace_img_url_1(input_path, out_path):
replacement2 = r'<img src="/assets/images/\1"'
content = re.sub(pattern2, replacement2, content)

# 将修改后的内容写入新文件
with open(out_path, "w", encoding="utf-8") as file:
file.write(content)

return content

def replace_img_url_2(input_path, out_path):
# 读取文件内容
with open(input_path, "r", encoding="utf-8") as file:
content = file.read()

def replace_img_url_2(content):
# 对于 ![image name](Notes.assets/image-000.png) 格式的替换
pattern1 = r'(!\[.*?\])\((/assets/images/Notes\.assets/.*?\.(png|jpg|jpeg|gif|bmp))\)'
replacement1 = r'\1(/BrainPy-course-notes\2)'
Expand All @@ -37,14 +27,36 @@ def replace_img_url_2(input_path, out_path):
replacement2 = r'<img src="/BrainPy-course-notes\1"'
content = re.sub(pattern2, replacement2, content)

# 将修改后的内容写入新文件
with open(out_path, "w", encoding="utf-8") as file:
file.write(content)
return content


def add_newlines_around_formula(content):
# 在 $$ 前后添加空行,确保不重复添加空行,并且公式块内部的内容不发生改变
pattern_start = r'(?<!\n)\n\$\$'
replacement_start = r'\n\n$$'
content = re.sub(pattern_start, replacement_start, content)

pattern_end = r'\$\$(?!\n)'
replacement_end = r'$$\n'
content = re.sub(pattern_end, replacement_end, content)

return content


if __name__ == "__main__":
# 打印当前工作目录
# print(os.getcwd())
input = "_posts/2023-08-27-BrainPy-course-notes.md"
out = "_posts/2023-08-27-BrainPy-course-notes_replace.md"
replace_img_url_2(input, out)
input_path = "_posts/2023-08-27-BrainPy-course-notes.md"
out_path = "_posts/2023-08-27-BrainPy-course-notes_replace.md"

with open(input_path, "r", encoding="utf-8") as file:
md_content = file.read()

md_content = replace_img_url_1(content)
md_content = replace_img_url_2(content)
md_content = add_newlines_around_formula(content)

# 将修改后的内容写入新文件
with open(out_path, "w", encoding="utf-8") as file:
file.write(md_content)

0 comments on commit 29dab1d

Please sign in to comment.