Leafdoc icon indicating copy to clipboard operation
Leafdoc copied to clipboard

HTML Notation is not parsed correct

Open Falke-Design opened this issue 5 years ago • 6 comments

There is a issue https://github.com/Leaflet/Leaflet/pull/6208 where the ' is not correct parsed, the regex have to be changed:

Doc

@option zoomOutText: String = '−'

Regex:

\s*(?:)@(?:)((?:)\S+)(?:)(?:\s+(?:)((?:)[^;\n]+)){0,1}

When the ; is removed it works.

I tried do change it and select until the exact match ;\n with or without ; but the regex is to complicated for me.

Falke-Design avatar Dec 19 '20 14:12 Falke-Design

I'm not seeing that regexp in src/regexps.mjs. Are you sure that's the regexp being used?

IvanSanchez avatar Dec 19 '20 15:12 IvanSanchez

It might be autogenerated from

	global.leafDirective = xRegExp(`  \\s* ${  char  } (?<directive> \\S+ ) (\\s+ (?<content> [^;\\n]+ )){0,1} `, 'gnx');

It might be possible to trick the regexp by adding another ; at the end, i.e.

@option zoomOutText: String = '&#x2212;';

IvanSanchez avatar Dec 19 '20 15:12 IvanSanchez

Yes sorry, it is autogenerated from there.

No your suggestion is not working,

It is working with the regex:

\s*(?:)@(?:)((?:)\S+)(?:)(?:\s+(?:)((?:).+[^;\n])){0,1}

I removed the + from the end added it before the negation [^;\n]

So it looks like:

global.leafDirective = xRegExp(`  \\s* ${  char  } (?<directive> \\S+ ) (\\s+ (?<content> .+[^;\\n])){0,1} `, 'gnx');

@IvanSanchez maybe you can test the regex on you projects, because the test suite are not working for me.

If it is working for you I will create a PR

Falke-Design avatar Dec 20 '20 10:12 Falke-Design

@Falke-Design It seems that I messed up the unit tests after tweaking the basic template a bit yesterday. Mea culpa.

Anyway, I tested your regexp, and unfortunately it breaks stuff, specifically:

    # 🍂property parent: TreeNode; Parent of this node.  Will be `nil` for a root node.
181,182c181,182
<               <td><code><a href='#treenode'>TreeNode</a></code></td>
<               <td>Parent of this node.  Will be <code>nil</code> for a root node.</td>
---
>               <td><code>TreeNode; Parent of this node.  Will be `nil` for a root node.</code></td>
>               <td></td>

That shorthand syntax (which is equivalent to writing two lines, one with the actual directive and another with the text) is used elsewhere, e.g. https://github.com/Leaflet/Leaflet/blob/7db94fd1ec23f0967dd8b07a5e2e2b1554b6d8db/src/layer/vector/Circle.js#L39

IvanSanchez avatar Dec 20 '20 13:12 IvanSanchez

@Falke-Design Can you please try with the code from 5e4cdf9276d0e44f55f0848a8481fc4050f4e51c ? That regexp should behave nicer (now stuff needs ; , space after a semicolon, to separate several directives in the same line).

It'd be nice to have a specific e2e test with the zoomControl stuff afterwards.

IvanSanchez avatar Dec 20 '20 14:12 IvanSanchez

I would like to create tests but it is hard for me to understand this, because the most things not working correct and I don't know jasmine.

Maybe you can create a explanation how to create and run tests.

My failures:

  • npm run test not working Could not resolve entry module (rollup.config.js;).. If I call npm run rollup it is working also when I call jasmine
  • If jasmine is running it has 8 failures, is something missing?
  • npm run prepublish, update-markdown-leafdoc, update-html-leafdoc --> "src" not found", what is need that this works?
  • specRunner.html --> Error during loading: TypeError ... "multilang-extract-comments"
  • A ton of eslint erros but I understand that they are not fixed

Falke-Design avatar Dec 21 '20 16:12 Falke-Design