Commit e33e052 1 parent 53f0d28 commit e33e052 Copy full SHA for e33e052
File tree 4 files changed +830
-0
lines changed
src/components/Editor/parsers
4 files changed +830
-0
lines changed Original file line number Diff line number Diff line change
1
+ // example url: https://atcoder.jp/contests/arc084/tasks/arc084_b
2
+ export default function parseAc ( url : string , html : string ) {
3
+ const titleRegex = / < s p a n c l a s s = " h 2 " > [ \r \n \t ] + ( .* ?) [ \r \n \t ] + / ;
4
+ const name = html . match ( titleRegex ) ?. [ 1 ] . split ( '-' , 2 ) [ 1 ] ?? 'Unknown' ;
5
+ const uniqueId = `ac-${ name . replace ( / / g, '' ) . toLowerCase ( ) } ` ;
6
+ return {
7
+ uniqueId,
8
+ name,
9
+ source : 'AC' ,
10
+ solutionMetadata : {
11
+ kind : 'CHANGE THIS' ,
12
+ } ,
13
+ } ;
14
+ }
Original file line number Diff line number Diff line change
1
+ // example url: https://cses.fi/problemset/task/1083
2
+ export default function parseCses ( url : string , html : string ) {
3
+ const urlSplit = url . split ( '/' ) ;
4
+ const problemId = urlSplit . at ( - 1 ) ;
5
+ const titleRegex = / < h 1 > ( .* ?) < \/ h 1 > / ;
6
+ return {
7
+ uniqueId : `cses-${ problemId } ` , // e.g. cses-1083
8
+ name : html . match ( titleRegex ) ?. [ 1 ] ?? 'Unknown' ,
9
+ source : 'CSES' ,
10
+ solutionMetadata : {
11
+ kind : 'CHANGE THIS' ,
12
+ } ,
13
+ } ;
14
+ }
Original file line number Diff line number Diff line change
1
+ import parseAc from './ac' ;
1
2
import parseCf from './cf' ;
3
+ import parseCses from './cses' ;
2
4
import parseUsaco from './usaco' ;
3
5
export const parsers = {
4
6
'codeforces.com' : parseCf ,
5
7
'usaco.org' : parseUsaco ,
8
+ 'cses.fi' : parseCses ,
9
+ 'atcoder.jp' : parseAc ,
6
10
} ;
7
11
export default function parse ( url : string , html : string ) {
8
12
for ( const [ domain , parser ] of Object . entries ( parsers ) ) {
You can’t perform that action at this time.
0 commit comments