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

cses problem url support added #55

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/component/QuestionsPane/ProblemList/ProblemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { TabsContext } from "service/TabsContext";
import Url from "url-parse";
import { useParams } from "react-router-dom";



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to remove unwanted spaces

interface AppProps {
companies: LabelType[];
tags: LabelType[];
Expand Down Expand Up @@ -75,16 +77,32 @@ const ProblemList: React.FC<AppProps> = ({
.then((res: AxiosResponse<QuestionListResponse[]>) => setResponse(res.data));
}, []);

(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cses.fi/lib/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; // use the location of your MathJax

var config = 'MathJax.Hub.Config({' +
'extensions: ["tex2jax.js"],' +
'jax: ["input/TeX","output/HTML-CSS"]' +
'});' +
'MathJax.Hub.Startup.onload();';

script.text = config;

document.getElementsByTagName("head")[0].appendChild(script);
})();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this function, because it will create a new script with every render,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I just forgot to remove my earlier code that was not working

const { filterResponseData, handleScrappedData } = useContext(TabsContext) as TabsContextTypes;
const { id } = useParams<Record<string, string>>();

const NextButton = () => {
const getQuestionData = async () => {
const { hostname } = new Url(url);
if (hostname !== "codeforces.com" && hostname !== "atcoder.jp") {
if (hostname !== "codeforces.com" && hostname !== "atcoder.jp" && hostname !== "cses.fi") {
setErrorText({
error: true,
comment: "Domain should either be codeforces or atcoder",
comment: "Domain should either be codeforces/atcoder/CSES problem set",
});
} else {
const { data }: AxiosResponse<{ error: boolean; htmlString: string }> = await axios({
Expand Down Expand Up @@ -162,7 +180,7 @@ const ProblemList: React.FC<AppProps> = ({
<>
<Grid container className={styles.root}>
<Grid item className={styles["request-field"]}>
<label>Enter Codeforces Or Atcoder Question URL:</label>
<label>Enter Codeforces/ Atcoder/ CSES Problem Set Question URL:</label>
<CssTextField
onChange={(e) => {
setUrl(e.target.value as string);
Expand Down
2 changes: 2 additions & 0 deletions src/component/QuestionsPane/ProblemPage/CodeForces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const LeetCode = ({ scrappedData }: { scrappedData: ScrappedDataType }) => {
{ left: "\\[", right: "\\]", display: true },
{ left: "%%", right: "%%", display: true },
{ left: "\\(", right: "\\)", display: false },
{ left: "$", right: "$", display: true },

],
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface QuestionDataSS {
}
export interface ScrappedDataType {
htmlString: string;
hostname: "codeforces.com" | "atcoder.jp";
hostname: "codeforces.com" | "atcoder.jp" | "cses.fi";
}

export interface TabsContextTypes {
Expand Down