mirror of
https://github.com/lebr0nli/slader-extension.git
synced 2025-05-10 21:12:19 +00:00
handle hasInvalidKatex
This commit is contained in:
parent
38b6b93388
commit
c258ad0777
|
@ -70,7 +70,7 @@ function processData(data){
|
||||||
if (column.text)
|
if (column.text)
|
||||||
{
|
{
|
||||||
var textDiv = document.createElement('div');
|
var textDiv = document.createElement('div');
|
||||||
textDiv.classList.add('sladerBypassKatexTextArea')
|
textDiv.classList.add('sladerBypassKatexTextArea');
|
||||||
textDiv.textContent = column.text.replaceAll('\n\n\n', '\n\n'); // The replace call is a bit funky but it works.
|
textDiv.textContent = column.text.replaceAll('\n\n\n', '\n\n'); // The replace call is a bit funky but it works.
|
||||||
columnDiv.appendChild(textDiv);
|
columnDiv.appendChild(textDiv);
|
||||||
}
|
}
|
||||||
|
@ -81,13 +81,16 @@ function processData(data){
|
||||||
image.setAttribute('src', column.images.additional.regular.srcUrl);
|
image.setAttribute('src', column.images.additional.regular.srcUrl);
|
||||||
columnDiv.appendChild(image);
|
columnDiv.appendChild(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append server-rendered image src url. Used in errorhandling. (See: handleKatexError())
|
// Append server-rendered image src url. Used in errorhandling. (See: handleKatexError())
|
||||||
if (column.images.latex && column.images.latex.large)
|
if (column.images.latex && column.images.latex.large)
|
||||||
{
|
{
|
||||||
div.querySelector('.sladerBypassKatex').setAttribute('katexsrc', column.images.latex.large.srcUrl);
|
div.querySelector('.sladerBypassKatex').setAttribute('katexsrc', column.images.latex.large.srcUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle hasInvalidKatex
|
||||||
|
if(column.hasInvalidKatex)
|
||||||
|
div.querySelector('.sladerBypassKatex').setAttribute('InvalidKatex', "true");
|
||||||
|
|
||||||
div.querySelector('.sladerBypassKatex').appendChild(columnDiv);
|
div.querySelector('.sladerBypassKatex').appendChild(columnDiv);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,21 +102,27 @@ function processData(data){
|
||||||
// Render Katex for each card
|
// Render Katex for each card
|
||||||
expArea.querySelectorAll('.sladerBypassKatex').forEach(textArea => {
|
expArea.querySelectorAll('.sladerBypassKatex').forEach(textArea => {
|
||||||
try {
|
try {
|
||||||
renderMathInElement(textArea, {
|
if(!textArea.hasAttribute("InvalidKatex")){
|
||||||
delimiters: [
|
renderMathInElement(textArea, {
|
||||||
{left: "$$", right: "$$", display: true},
|
delimiters: [
|
||||||
{left: "$", right: "$", display: false},
|
{left: "$$", right: "$$", display: true},
|
||||||
{left: "\\(", right: "\\)", display: false},
|
{left: "$", right: "$", display: false},
|
||||||
{left: "\\begin{equation}", right: "\\end{equation}", display: true},
|
{left: "\\(", right: "\\)", display: false},
|
||||||
{left: "\\begin{align}", right: "\\end{align}", display: true},
|
{left: "\\begin{equation}", right: "\\end{equation}", display: true},
|
||||||
{left: "\\begin{alignat}", right: "\\end{alignat}", display: true},
|
{left: "\\begin{align}", right: "\\end{align}", display: true},
|
||||||
{left: "\\begin{gather}", right: "\\end{gather}", display: true},
|
{left: "\\begin{alignat}", right: "\\end{alignat}", display: true},
|
||||||
{left: "\\begin{CD}", right: "\\end{CD}", display: true},
|
{left: "\\begin{gather}", right: "\\end{gather}", display: true},
|
||||||
{left: "\\[", right: "\\]", display: true}
|
{left: "\\begin{CD}", right: "\\end{CD}", display: true},
|
||||||
],
|
{left: "\\[", right: "\\]", display: true}
|
||||||
throwOnError : true,
|
],
|
||||||
errorCallback : function(a, b){ handleKatexError(a, b, textArea); }
|
throwOnError : true,
|
||||||
});
|
errorCallback : function(a, b){ handleKatexError(a, b, textArea); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// sometimes even hasInvalidKatex, textArea still can render without error
|
||||||
|
handleKatexError("hasInvalidKatex","hasInvalidKatex", textArea);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Katex experienced an error. Attempting to load image replacement.');
|
console.error('Katex experienced an error. Attempting to load image replacement.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "slader bypass",
|
"name": "slader bypass",
|
||||||
"version": "0.7",
|
"version": "0.8",
|
||||||
"author":"Alan Li & Ethan Harvey",
|
"author":"Alan Li & Ethan Harvey",
|
||||||
"description": "Slader/Quizlet 5 solutions limit bypass",
|
"description": "Slader/Quizlet 5 solutions limit bypass",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
|
Loading…
Reference in a new issue