Commit fe00cef
authored
[Java.Interop.Tools.JavaSource] Support html tags with attributes (#1286)
Context: dotnet/android#9647
dotnet/android#9647 attempted to import API docs for API 35, and
produced the following warning:
The following issues were found, review the build log for more details:
> ## Unable to translate remarks for android/app/admin/DevicePolicyManager:
> JavadocImport-Error (31:39): Syntax error, expected: </p>, </P>, #PCDATA, <tt>, <TT>, <i>, <I>, <a attr=, <code>, {@code, {@docroot}, {@inheritdoc}, {@link, {@linkplain, {@literal, {@see, {@value}, {@value, IgnorableDeclaration, {@param, UnknownHtmlElementStart, <p>, <P>, <pre , @author, @apiSince, @deprecated, @deprecatedSince, @exception, @inheritdoc, @hide, @param, @return, @see, @Serialdata, @serialField, @SInCE, @throws, @[unknown], @Version
<li>A <i id="deviceowner">Device Owner</i>, which only ever exists on the
^
Parsing logic fails here because the `<i>` tag has an `id` attribute
_and_ is present in an open `<p>` tag.
Turns Out™ that HTML allows attributes on nearly *everything*; e.g.
from [§3.2.3 Global attributes][0]:
> The following attributes are common to and may be specified on all
> [HTML elements](https://dev.w3.org/html5/spec-LC/infrastructure.html#html-elements)
> (even those not defined in this specification):
> * …
> * `id`
Given this, it doesn't make sense for `CreateStartElement()` to not
allow any attributes. Update `CreateStartElement()` so that *all*
elements *ignore* any specified attributes (by default), which
allows `<i id="deviceowner">Device Owner</i>` to work.
The regex used has also been improved to include word boundaries
around the tag name to make sure that it does not match unexpected
elements.
[0]: https://dev.w3.org/html5/spec-LC/elements.html#global-attributes1 parent 2c06b3c commit fe00cef
File tree
2 files changed
+9
-18
lines changed- src/Java.Interop.Tools.JavaSource/Java.Interop.Tools.JavaSource
- tests/Java.Interop.Tools.JavaSource-Tests
2 files changed
+9
-18
lines changedLines changed: 5 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 280 | + | |
289 | 281 | | |
290 | 282 | | |
291 | 283 | | |
292 | 284 | | |
293 | 285 | | |
294 | 286 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | 287 | | |
301 | 288 | | |
302 | 289 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
0 commit comments