-
Notifications
You must be signed in to change notification settings - Fork 2
Add support for multline #48
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
base: master
Are you sure you want to change the base?
Changes from 7 commits
078acb1
a22d3ba
c89e66c
aca22ea
37abb53
5c2b556
9c7b69c
4da141b
f2b9efc
8cbdb01
cefc532
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| node_modules | ||
| lib/parser.js | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,17 @@ ast.Tex.defineVisitor("contains_func", { | |
| match(target, '\\end{'+t+'}') || | ||
| matrix_has(m); | ||
| }, | ||
| MULTLINE: function(target, t, m) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the difference in the functions for multine and matrix. Can't you just create one functaion and assign it to both keys MATRIX and MULTILINE |
||
| // \begin{env} .. \\ .. \\ .. \\ .. \end{env} | ||
| // t is the environment name. | ||
| // m is a one-dimensional array. | ||
| var expr_has = function(e) { return arr_contains_func(e, target); }; | ||
| var line_has = function(l) { return some(l, expr_has); }; | ||
| var lines_have = function(m) { return some(m, line_has); }; | ||
| return match(target, '\\begin{'+t+'}') || | ||
| match(target, '\\end{'+t+'}') || | ||
| lines_have(m); | ||
| }, | ||
| LR: function(target, l, r, tl) { | ||
| // \left\l tl1 tl2 tl3 ... \right\r (a balanced pair of delimiters) | ||
| return match(target, '\\left') || match(target, '\\right') || | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,20 +8,20 @@ var buildParser = module.exports = function(inFile, outFile) { | |
| var PEG = require('pegjs'); | ||
| var fs = require('fs'); | ||
|
|
||
| var parserSource = PEG.buildParser(fs.readFileSync(inFile, 'utf8'), { | ||
| var parserSource = PEG.generate(fs.readFileSync(inFile, 'utf8'), { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you explain, what this change means
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the newest version of pegJS (0.10.0), |
||
| /* PEGJS options */ | ||
| output: "source", | ||
| cache: true,// makes repeated calls to generic_func production efficient | ||
| allowedStartTules: [ "start" ] | ||
| }); | ||
| // hack up the source to make it pass jshint | ||
| parserSource = parserSource | ||
| .replace(/(peg\$subclass\(child, parent\)|peg\$SyntaxError\(message, expected, found, location\)|peg\$parse\(input\)) {/g, | ||
| function (m) { | ||
| return m + "\n /*jshint validthis:true, newcap:false*/ "; | ||
| }).replace(/\n(\s+)([?:+]) (expectedDescs|" or "|peg)/g, ' $2\n$1$3'); | ||
| // parserSource = parserSource | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. old code will remain in the git history. You do not need to comment it out. |
||
| // .replace(/(peg\$subclass\(child, parent\)|peg\$SyntaxError\(message, expected, found, location\)|peg\$parse\(input\)) {/g, | ||
| // function (m) { | ||
| // return m + "\n /*jshint validthis:true, newcap:false*/ "; | ||
| // }).replace(/\n(\s+)([?:+]) (expectedDescs|" or "|peg)/g, ' $2\n$1$3'); | ||
| parserSource = | ||
| '/* jshint latedef: false */\n' + | ||
| // '/* jshint latedef: false */\n' + | ||
| 'module.exports = ' + parserSource + ';'; | ||
|
|
||
| fs.writeFileSync(outFile, parserSource, 'utf8'); | ||
|
|
||
Large diffs are not rendered by default.
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
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.
I added a newline so that the "no newline" mark is gone, but it seems GitHub still displays it as if there is no newline at the end. Should I add another?
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 another.