mirror of
https://github.com/xlucn/PAT.git
synced 2026-10-03 00:23:15 +08:00
change katex spans in html into mathjax string
This commit is contained in:
@@ -5,12 +5,10 @@
|
||||
{%- seo -%}
|
||||
<link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
|
||||
<link rel="stylesheet" href="{{ "/assets/css/mystyle.css" | relative_url }}">
|
||||
<link rel="stylesheet" href="{{ "/assets/css/PATkatex.css" | relative_url }}">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{{ "favicon.ico" | relative_url }}">
|
||||
{%- feed_meta -%}
|
||||
{%- if jekyll.environment == 'production' and site.google_analytics -%}
|
||||
{%- include google-analytics.html -%}
|
||||
{%- endif -%}
|
||||
{%- include mathjax.html -%}
|
||||
{%- include katex.html -%}
|
||||
</head>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<!-- Katex files -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
|
||||
|
||||
<!-- The loading of KaTeX is deferred to speed up page rendering -->
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- To automatically render math in text elements, include the auto-render extension: -->
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"
|
||||
onload="renderMathInElement(document.body);"></script>
|
||||
@@ -11,5 +11,6 @@
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" async
|
||||
src="https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js">
|
||||
src="https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
|
||||
/* https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js */
|
||||
</script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+18
-2
@@ -7,6 +7,7 @@ import os
|
||||
import sys
|
||||
import re
|
||||
import argparse
|
||||
from bs4 import BeautifulSoup
|
||||
from subprocess import run, PIPE, CalledProcessError
|
||||
import config
|
||||
|
||||
@@ -55,7 +56,21 @@ class FileBuilder:
|
||||
frontmatter += "---\n\n"
|
||||
return frontmatter
|
||||
|
||||
def filename(self):
|
||||
def _processkatex(self, html):
|
||||
"""
|
||||
replace all the 'katex' class spans with simple latex string
|
||||
"""
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
katex_spans = soup.find_all("span", class_="katex")
|
||||
for katex_span in katex_spans:
|
||||
katex_span.mrow.decompose()
|
||||
mathstr = katex_span.find("math")
|
||||
mathjax = soup.new_tag("span")
|
||||
mathjax.string = "${}$".format(mathstr.string)
|
||||
katex_span.replace_with(mathjax)
|
||||
return str(soup)
|
||||
|
||||
def _filename(self):
|
||||
return os.path.join(config.md_dir, "{}{:04}.md".format(self.c, self.i))
|
||||
|
||||
def read_html(self):
|
||||
@@ -70,7 +85,8 @@ class FileBuilder:
|
||||
index=self.i,
|
||||
title=lines[0].rstrip(),
|
||||
lang="(C语言实现)")
|
||||
content = lines[1:]
|
||||
content = self._processkatex("".join(lines[1:]))
|
||||
|
||||
return title, content
|
||||
|
||||
def read_code(self):
|
||||
|
||||
Reference in New Issue
Block a user