Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a712ca12da | |||
| 8700bda104 | |||
| 3160e02d41 | |||
| cfa61c2066 | |||
| 27faea1823 | |||
| df76e34c71 |
@@ -12,6 +12,7 @@ const DANGEROUS_TAGS = ['svg', 'math'];
|
|||||||
const latexDelimiters = [
|
const latexDelimiters = [
|
||||||
{ left: '$$', right: '$$', display: true },
|
{ left: '$$', right: '$$', display: true },
|
||||||
{ left: '\\[', right: '\\]', display: true },
|
{ left: '\\[', right: '\\]', display: true },
|
||||||
|
{ left: '$', right: '$', display: false },
|
||||||
{ left: '\\(', right: '\\)', display: false }
|
{ left: '\\(', right: '\\)', display: false }
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ function Article({ cache }) {
|
|||||||
|
|
||||||
if (v.nodeName === '#text') {
|
if (v.nodeName === '#text') {
|
||||||
const text = v.data;
|
const text = v.data;
|
||||||
if (text.includes('\\[') || text.includes('\\(') || text.includes('$$')) {
|
if (text.includes('\\[') || text.includes('\\(') || text.includes('$$') || text.includes('$')) {
|
||||||
return <Latex key={key} delimiters={latexDelimiters}>{text}</Latex>;
|
return <Latex key={key} delimiters={latexDelimiters}>{text}</Latex>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +138,8 @@ function Article({ cache }) {
|
|||||||
const textContent = v.textContent.trim();
|
const textContent = v.textContent.trim();
|
||||||
const isMath = (textContent.startsWith('\\(') && textContent.endsWith('\\)')) ||
|
const isMath = (textContent.startsWith('\\(') && textContent.endsWith('\\)')) ||
|
||||||
(textContent.startsWith('\\[') && textContent.endsWith('\\]')) ||
|
(textContent.startsWith('\\[') && textContent.endsWith('\\]')) ||
|
||||||
(textContent.startsWith('$$') && textContent.endsWith('$$'));
|
(textContent.startsWith('$$') && textContent.endsWith('$$')) ||
|
||||||
|
(textContent.startsWith('$') && textContent.endsWith('$') && textContent.indexOf('$') !== textContent.lastIndexOf('$') && !/\s/.test(textContent.charAt(textContent.length - 2)));
|
||||||
|
|
||||||
const props = { key: key };
|
const props = { key: key };
|
||||||
if (v.hasAttributes()) {
|
if (v.hasAttributes()) {
|
||||||
@@ -157,6 +159,13 @@ function Article({ cache }) {
|
|||||||
const firstParen = mathContent.indexOf('\\(');
|
const firstParen = mathContent.indexOf('\\(');
|
||||||
const lastParen = mathContent.lastIndexOf('\\)');
|
const lastParen = mathContent.lastIndexOf('\\)');
|
||||||
mathContent = mathContent.substring(0, firstParen) + '\\[' + mathContent.substring(firstParen + 2, lastParen) + '\\]' + mathContent.substring(lastParen + 2);
|
mathContent = mathContent.substring(0, firstParen) + '\\[' + mathContent.substring(firstParen + 2, lastParen) + '\\]' + mathContent.substring(lastParen + 2);
|
||||||
|
} else if (trimmed.startsWith('$') && !trimmed.startsWith('$$')) {
|
||||||
|
// Replace $ with $$
|
||||||
|
const firstDollar = mathContent.indexOf('$');
|
||||||
|
const lastDollar = mathContent.lastIndexOf('$');
|
||||||
|
if (firstDollar !== lastDollar) {
|
||||||
|
mathContent = mathContent.substring(0, firstDollar) + '$$' + mathContent.substring(firstDollar + 1, lastDollar) + '$$' + mathContent.substring(lastDollar + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <Tag {...props}><Latex delimiters={latexDelimiters}>{mathContent}</Latex></Tag>;
|
return <Tag {...props}><Latex delimiters={latexDelimiters}>{mathContent}</Latex></Tag>;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.black .checkbox:checked + label::after {
|
.black .checkbox:checked + label::after {
|
||||||
border-color: #ddd;
|
border-color: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.black .copy-button {
|
.black .copy-button {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dark .checkbox:checked + label::after {
|
.dark .checkbox:checked + label::after {
|
||||||
border-color: #ddd;
|
border-color: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark .copy-button {
|
.dark .copy-button {
|
||||||
|
|||||||
@@ -355,7 +355,8 @@ button.comment {
|
|||||||
top: 0.2em;
|
top: 0.2em;
|
||||||
width: 0.3rem;
|
width: 0.3rem;
|
||||||
height: 0.6rem;
|
height: 0.6rem;
|
||||||
border: solid #000;
|
border-style: solid;
|
||||||
|
border-color: #000;
|
||||||
border-width: 0 2px 2px 0;
|
border-width: 0 2px 2px 0;
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.red .checkbox:checked + label::after {
|
.red .checkbox:checked + label::after {
|
||||||
border-color: #aa0000;
|
border-color: #dd0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.red .copy-button {
|
.red .copy-button {
|
||||||
|
|||||||
Reference in New Issue
Block a user