Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

GJF adds <p> tag prior to the <div> tag

Đang mở
#1,180 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
tooling

Hướng nghiên cứu

Báo cáo không nêu tên tệp nguồn hoặc bài kiểm thử nào. Hãy tái hiện hành vi bằng ví dụ Test.java được cung cấp và lệnh google-java-format 1.24.0, sau đó lần theo điểm vào của quá trình định dạng Javadoc dành cho các thẻ cấp khối. Được xem là hoàn tất khi quá trình định dạng không còn thêm

trước

và vẫn giữ cách xử lý như mong đợi đối với
    và các thẻ
  • đóng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Detected at: https://github.com/checkstyle/checkstyle/issues/15865, User's got his answer at: https://github.com/checkstyle/checkstyle/issues/15865#issuecomment-2462352189

GJF adds <p> prior to <div> tag, but the style guide says that block-level tags should not be preceded by <p> tag:

https://google.github.io/styleguide/javaguide.html#s7.1.2-javadoc-paragraphs

HTML tags for other block-level elements, such as <ul> or <table>, are not preceded with <p>.

Here's an example of it:

01: /**
02:  * Plugin to standardize all directions to their appropriate abbreviation.
03:  *
04:  * <div>Some javadoc here....</div>
05:  *
06:  * <ul>
07:  * <li>Item - 1 </li>
08:  * <li>Item - 2 </li>
09:  * <li>Item - 3 </li>
10:  * </ul>
11:  *
12:  * <p>This plugin assumes numbered streets have the correct suffix, when applicable.
13:  */
14: public class Test {
15:   /** Some javadoc. */
16:   public static void main(String[] args) {
17: 
18:   }
19: }
20: 
$ java -jar .\checkstyle-10.20.1-all.jar -c .\google_checks.xml  .\Test.java
Starting audit...
Audit done.
$ java -jar .\google-java-format-1.24.0-all-deps.jar .\Test.java > TestUpdated.java
01: /**
02:  * Plugin to standardize all directions to their appropriate abbreviation.
03:  *
04:  * <p><div>Some javadoc here....</div>
05:  *
06:  * <ul>
07:  *   <li>Item - 1
08:  *   <li>Item - 2
09:  *   <li>Item - 3
10:  * </ul>
11:  *
12:  * <p>This plugin assumes numbered streets have the correct suffix, when applicable.
13:  */
14: public class Test {
15:   /** Some javadoc. */
16:   public static void main(String[] args) {}
17: }
18: 
java -jar .\checkstyle-10.20.1-all.jar -c .\google_checks.xml .\TestUpdated.java
Starting audit...
[WARN] C:\checkstyle testing\.\TestUpdated.java:4:4: <p> tag should not precede HTML block-tag '<div>', <p> tag should be removed. [JavadocParagraph]
[WARN] C:\checkstyle testing\.\TestUpdated.java:14:1: The name of the outer type and the file do not match. [OuterTypeFilename]
Audit done.

Ignore the OuterTypeFilename violation.

The formatter added <p> tag preceding to <div> tag, Checkstyle was complaining about it. But this did not happened in case of <ul> tag, formatter didn't added preceding <p> tag to it.

Edit: After formatting, GJF also removes closing li tags ( </li> )

Ngôn ngữ chính
Java
Star
6.2k
Fork
936
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của google/google-java-format

Tất cả issue của google/google-java-format

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.