-
Notifications
You must be signed in to change notification settings - Fork 2
Create parsing for texvc.sty using texutil.js #46
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
Conversation
@notjagan please fix the failing tests |
@HowardCohl @notjagan what is the progess here? |
@physikerwelt It turns out that this was a pull request made by Claude, not @notjagan . Also, it has to do with the texvcjs repo, @notjagan is working on the texer repo. |
While I was getting the code to pass the tests, I noticed two possible inconsistencies between texvc.sty and the preexisting test cases. The first is that the test cases look for |
lib/npm-debug.log
Outdated
@@ -0,0 +1,18 @@ | |||
0 info it worked if it ends with ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the log file, please.
lib/parseSty.js
Outdated
} | ||
sections = sections.slice(0, sections.length - 1); | ||
return sections; | ||
return string.match(/\{[^\{\}]*?(([^\}]*)\}+)*?[^\{\}]*?\}|\[[^\[\]]*?(([^\]]*)\]+)*?[^\[\]]*?\]/g).map(function(s) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Germany one calls that "to reinvent the wheel".
How about using a well tested library for that like
https://www.npmjs.com/package/balanced-match
?
lib/parseSty.js
Outdated
"\\DeclareRobustCommand", | ||
"\\defSpecFun"]; | ||
|
||
// Returns a two dimensional array, where each element contains the body of a bracket section and the type of bracket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use multiline comments here as in https://github.com/wikimedia/service-template-node/blob/master/routes/ex.js#L44-L49
I wrote tests for a majority of the methods within |
lib/parseSty.js
Outdated
cmds[commands[0]] = commands[1]; | ||
break; | ||
case 1: | ||
var cmd = definition.replace(new RegExp(sections[0][0].replace(/\\/g, "\\\\"), 'g'), "").match(/\\[a-zA-Z]+/)[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still not clear to me, what this line does. @HowardCohl do you understand that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would make sense to introduce a a variable for sections[0] ?
Would that be \command1,'{' int the example below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@physikerwelt @notjagan says he fixed this in the latest pull request
Well done! The comments help to understand your code. However, there are some things that still are not clear to me. |
@notjagan each function should have at least one test case. But you can create different ways of testing your methods. |
test/parseSty.js
Outdated
parseSty.newCommand("\\newcommand\\test\\test\\test", "\\newcommand", {}); | ||
}, function(err) { return err instanceof Error; }); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline at the end of the file please
.gitignore
Outdated
lib/optionalFunctions.csv | ||
|
||
# Node log | ||
lib/npm-debug.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a newline at the end of the file, please.
only one more newline and you are done ;-) |
It currently puts the parsed array into other_literals3.