Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution中的图片显示出错, 代码样式出错 #16

Open
guxiyuesi opened this issue Jun 10, 2024 · 1 comment
Open

solution中的图片显示出错, 代码样式出错 #16

guxiyuesi opened this issue Jun 10, 2024 · 1 comment

Comments

@guxiyuesi
Copy link

os: win10
python: 3.8
chromedriver: 125
anki: QT5

工程为默认位置:
[DB_CN]
path = ./data_cn
debug = False

[Anki_CN]
front = ./templates/front-side.html
back = ./templates/back-side.html
css = ./templates/style.css
output = ./data_cn/LeetCode.apkg


问题描述如下:

导入anki后, 在问题页中, 图片可以正常显示:
image

但回答页中, 图片不显示, 行内公式不渲染, 代码格式化不正确:
image

image

@windli93
Copy link

windli93 commented Sep 16, 2024

`
def markdown_to_html(content: str):
# replace the math symbol "$x$" to "[$]x[/$]" to make it compatible with mathjax
content = re.sub(
pattern=r"$(.*?)$",
repl=r"[$]\1[/$]",
string=content
)

# Only matches the contents of the Markdown image format ![]() enclosed by angle brackets < and >, without affecting other contents
content = re.sub(
    pattern=r'<(!\[.*?\]\(.*?\))>',
    repl=r'\1',
    string=content
)

#Add line breaks before and after code blocks
content = re.sub(
    pattern=r'(```\w*)',
    repl=r'\n\1',
    string=content
)
content = re.sub(
    pattern=r'(\w*```)',
    repl=r'\1\n',
    string=content
)

# also need to load the mathjax and toc extensions
return markdown(content, extensions=['mdx_math', 'toc', 'fenced_code', 'tables'])

`
试一下下载源码,然后替换这个方法的内容,只能解决你的部分问题,不能解决全部问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants