Skip to content

Commit

Permalink
Tweak directive regexp, force space after semicolon to separate direc…
Browse files Browse the repository at this point in the history
…tives in same line.

Should fix #57
  • Loading branch information
IvanSanchez committed Dec 20, 2020
1 parent bc65673 commit 5e4cdf9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions spec/leafdoc-e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('e2e tests', () => {

for (const i in dirs) {
const dirName = dirs[i];
// if (dirName !== 'leaflet-vml') { continue; }
const dir = `./spec/e2e/${ dirName }/`;

it(dirName, () => {
Expand Down
8 changes: 4 additions & 4 deletions spec/specRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
<script type="text/javascript" src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script type="text/javascript" src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>



<script>
window.module = {};
</script>
<script type="text/javascript" src="../src/parsers/multilang.js"></script>
<script type="text/javascript" src="../src/parsers/trivial.js"></script>
<script type="module" src="../src/parsers/multilang.mjs"></script>
<script type="module" src="../src/parsers/trivial.mjs"></script>
<!-- <script type="text/javascript" src="../src/parsers/multilang.mjs"></script> -->
<!-- <script type="text/javascript" src="../src/parsers/trivial.mjs"></script> -->

<script type="text/javascript" src="intel-hex-parse-spec.js"></script>
<script type="text/javascript" src="intel-hex-blocks-spec.js"></script>
Expand Down
11 changes: 8 additions & 3 deletions src/leafdoc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,21 @@ export default class Leafdoc {
let match;
// In "param foo, bar", directive is "param" and content is "foo, bar"
while (match = regexps.getLeafDirective().exec(line)) {
if (match[2]) { match[2] = match[2].trim(); }
directives.push([match[1], match[2]]); // [directive, content]
if (match.groups.content) {
match.groups.content = match.groups.content.trim();
}
directives.push([
match.groups.directive,
match.groups.content
]);
// console.log('directive match: ', match);
blockIsEmpty = false;
lineIsValid = true;
parsedCharacters = match.index + match[0].length;
}

if (lineIsValid) {
const trailing = line.substr(parsedCharacters + 1).trim();
const trailing = line.substr(parsedCharacters).trim();
if (trailing) {
directives.push(['comment', trailing]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/regexps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function getLeafDirective() {

// Re-builds the 🍂 directive based on a different leading character
export function redoLeafDirective(char) {
global.leafDirective = xRegExp(` \\s* ${ char } (?<directive> \\S+ ) (\\s+ (?<content> [^;\\n]+ )){0,1} `, 'gnx');
global.leafDirective = new RegExp(`\\s*${char}(?<directive>\\S+)(\\s+(?<content>.+?))?(?:; |$)`, 'g');
return global.leafDirective;
}

Expand Down

0 comments on commit 5e4cdf9

Please sign in to comment.