1

I tried to use the lang attribute on an element in a documentation comment. Doclint (as part of the javadoc command) rejects that. I know I could suppress HTML errors in general, but I want to be told actual HTML errors.

This answer from 2015 lists allowed HTML tags, but I couldn’t even find a list of allowed attributes on tags.

Currently, for my specific problem, I added a custom taglet that transforms {@foreignterm de Hallo Welt} into <i lang="de">Hallo Welt</i>, but that’s not really close to optimal.

So I wonder how I could use <i lang="de">Hallo Welt</i> in a documentation comment. If it’s just not possible, which HTML attributes are allowed in Javadoc?

0

1 Answer 1

2

Not sure this is documented anywhere, but the source code is easy enough to understand:

e.g.

A(BlockType.INLINE, EndKind.REQUIRED,
        attrs(AttrKind.OK, HREF, TARGET, ID),
        attrs(AttrKind.HTML4, REV, CHARSET, SHAPE, COORDS, NAME))

The first argument (AttrKind) represents the validity. Possible values are: OK, INVALID, OBSOLETE, HTML4.

So for an anchor element, the 'href', 'target' and 'id' attributes are always okay. The 'rev', 'charset', etc. attributes are not supported in HTML5 (and you'll get this error)

Italic tags, like you tried to add an attribute to, do not accept any attributes.

 I(BlockType.INLINE, EndKind.REQUIRED,
     EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.