Skip to content

Commit a44a227

Browse files
author
Utsav Krishnan
committed
clean latex equations, $
Eg ≤ n ≤ 10^6$ -> 1 ≤ n ≤ 10^6
1 parent 690560e commit a44a227

File tree

10 files changed

+30
-21
lines changed

10 files changed

+30
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ Github: cses-solutions ✔
152152
* Supports only C++ currently, will add support for other languages on request. **UPDATE: Done**
153153
* A modifiable template code file. **UPDATE: Done**
154154
* Auto commit to Github repository **UPDATE: Done**
155-
* Clean LaTex based $equation$ from problem statement. Eg $1 ≤ n ≤ 10^6$
155+
* Clean LaTex based $equation$ from problem statement. Eg $1 ≤ n ≤ 10^6$ **UPDATE: Done**

cmd/helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func cacheGet(filename string, ret interface{}, root string) bool {
8181
return true
8282
}
8383

84-
func writeTask(filename string, text string, root string){
84+
func writeTask(filename string, text string, root string) {
8585
f, err := os.Create(filepath.Join(root, filename))
8686
defer f.Close()
8787
check(err)
@@ -116,7 +116,7 @@ func getTaskFromCache(task string, root string) (string, string) {
116116
output, err := exec.Command("bash", "-c", "lynx -dump "+path).Output()
117117
check(err)
118118
data := string(output)
119-
119+
120120
for k, v := range unicodeMap {
121121
data = strings.Replace(data, k, v, -1)
122122
}

cmd/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import (
2222

2323
// listCmd represents the list command
2424
var listCmd = &cobra.Command{
25-
Use: "list",
25+
Use: "list",
2626
Example: "cses-cli list, cses-cli list -r",
27-
Short: "list all problem statements along with status",
27+
Short: "list all problem statements along with status",
2828
Long: `Without any flag it lists all the problems from the cache.
2929
To invalidate/refresh/reload the problem list cache use flag '-r'
3030
If you are authenticated it will display the submission status along with the list.

cmd/login.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import (
2828

2929
// loginCmd represents the login command
3030
var loginCmd = &cobra.Command{
31-
Use: "login",
31+
Use: "login",
3232
Example: "cses-cli login",
33-
Short: "authenticate to cses.fi server by username and password",
33+
Short: "authenticate to cses.fi server by username and password",
3434
Long: `This command retrieves the csrf token and signs it to the server,
3535
reads the cookies and saves it in the config file along with the username
3636
Note: password is not saved in the config file and is only used to sign the csrf token

cmd/problems.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"os/exec"
88
"path/filepath"
9+
"regexp"
910
"strings"
1011
"time"
1112
)
@@ -139,5 +140,13 @@ func getTask(task string) (string, string, bool) {
139140
writeTask(filename, text, rootPath)
140141
}
141142
title, text := getTaskFromCache(task, rootPath)
143+
144+
text = cleanMathSyntax(text)
145+
142146
return title, text, true
143-
}
147+
}
148+
149+
func cleanMathSyntax(text string) string {
150+
re := regexp.MustCompile("\\$([^$]*)\\$")
151+
return re.ReplaceAllString(text, "${bold}$1${normal}")
152+
}

cmd/requests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func ListRequest(cookie string) []*Problem {
128128
check(err)
129129
defer resp.Body.Close()
130130

131-
var arr []*Problem
131+
var arr []*Problem
132132
doc, err := goquery.NewDocumentFromReader(resp.Body)
133133
check(err)
134134

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
)
2525

2626
var (
27-
cfgFile string
27+
cfgFile string
2828
rootPath string
2929
)
3030

3131
// rootCmd represents the base command when called without any subcommands
3232
var rootCmd = &cobra.Command{
3333
Use: "cses-cli",
3434
Short: "command line to solve probmens from https://cses.fi/problemset/",
35-
Long: `command line to solve probmens from https://cses.fi/problemset/`,
35+
Long: `command line to solve probmens from https://cses.fi/problemset/`,
3636
}
3737

3838
// Execute adds all child commands to the root command and sets flags appropriately.

cmd/show.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import (
2121

2222
// showCmd represents the show command
2323
var showCmd = &cobra.Command{
24-
Use: "show",
25-
Args: cobra.ExactArgs(1),
26-
Short: "show a problem statement by number",
24+
Use: "show",
25+
Args: cobra.ExactArgs(1),
26+
Short: "show a problem statement by number",
2727
Example: "cses-cli show 1068",
28-
Long: `Print the problem statement identified by the task number to stdout`,
28+
Long: `Print the problem statement identified by the task number to stdout`,
2929
Run: func(cmd *cobra.Command, args []string) {
3030
ShowProblem(args[0])
3131
},

cmd/solve.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424

2525
// solveCmd represents the solve command
2626
var solveCmd = &cobra.Command{
27-
Use: "solve",
28-
Args: cobra.ExactArgs(1),
27+
Use: "solve",
28+
Args: cobra.ExactArgs(1),
2929
Example: "cses-cli solve 1068",
30-
Short: "solve any problem identified by the task number",
30+
Short: "solve any problem identified by the task number",
3131
Long: `This command will print the problem statement by default (use '-s' to disable it)
3232
By default the editor name is read from the config file to overwrite use like '-e subl', where subl is binary for sublime-text editor.
3333
The language preference is also read form the config file`,

cmd/submit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323

2424
// submitCmd represents the submit command
2525
var submitCmd = &cobra.Command{
26-
Use: "submit",
27-
Args: cobra.ExactArgs(1),
26+
Use: "submit",
27+
Args: cobra.ExactArgs(1),
2828
Example: "cses-cli submit 1068.Weird-Algorithm.cpp",
29-
Short: "submit the solution file and fetch the status",
29+
Short: "submit the solution file and fetch the status",
3030
Long: `If the solution is ACCEPTED and github is configured, then it will push the solution to github,
3131
with limitation that the repo has to be public, since it uses github generated token`,
3232

0 commit comments

Comments
 (0)