lines = f.read()
ma = re.findall(r'{(.*)data-background-size=', str(lines))
# print(ma)
mac = mac+ ma
return mac
# with open(md_fname) as f:
def rewrite_html(self):
with open(self.output_html) as f:
lines = f.readlines()
k = self.red_tempmd()
i = 0
list1 = []
for ii in lines:
if '><section data-background-size=' in ii:
new = '><section '+k[i]+'data-background-size='
ii = ii.replace('><section data-background-size=',new)
i = i+ 1
list1.append(ii)
# print(list1)
with open(self.temp_html,'w') as w:
for i in list1:
w.write(i)
`
These methods implement the reading of the image address in temp.md and write it to slide.html.
Finally, adding this code to revealjs_converter.py will solve this problem.
` def convert(self):
first, convert the self.md_content links to local
super().convert()
# convert markdown to slide markdown
self.change_md_to_slide_md()
# convert slide markdown to html with pandoc
self.pandoc_slide_md_to_revealjs()
# adjust several things in the html
self.html_adjust()
# output the html, along with revealjs and assets files
self.make_output()
# preview the revealjs html
self.rewrite_html()
self.preview_slide()`
` def red_tempmd(self): mac = [] with open(self.temp_md_fname) as f:
mach = """## {data-background-image="assets/2019-10-03-21-44-01-348111.jpg" data-background-size="contain"}"""
` These methods implement the reading of the image address in temp.md and write it to slide.html. Finally, adding this code to revealjs_converter.py will solve this problem.
` def convert(self):
first, convert the self.md_content links to local
最后,对py大佬表示膜拜。代码看了一下午。。。。。