Skip to content

Fix ManFileParser to support asciidoctor == section syntax - #684

Open
tristantarrant wants to merge 1 commit into
aeshell:masterfrom
tristantarrant:fix-manfileparser-asciidoctor-spec
Open

tristantarrant wants to merge 1 commit into
aeshell:masterfrom
tristantarrant:fix-manfileparser-asciidoctor-spec

Conversation

@tristantarrant

Copy link
Copy Markdown
Contributor

Summary

This PR fixes ManFileParser to properly conform to the asciidoctor manpage specification, particularly for section heading formats.

Fixes #683

Problem

The current implementation only supports the underline section format:

SECTION
-------

According to the asciidoctor spec, manpage sections should use the standard AsciiDoc heading syntax:

== Section Title

This meant that all standard asciidoctor manpage files using == section syntax failed to parse.

Changes

ManSection.java

  • Added support for == Section syntax (standard asciidoctor format)
  • Maintains backward compatibility with underline format (Section\n-----)
  • Cleans up unused variables

ManFileParser.java

  • Fixed header validation to support both = title and title\n==== formats
  • Properly validates :doctype: manpage attribute
  • Provides clear error messages for invalid headers

Test Suite

  • Added comprehensive test suite ManFileParserTest.java with 19 test cases
  • Tests cover:
    • == section syntax parsing
    • Underline section syntax parsing
    • Mixed format support
    • Header validation (both title formats)
    • Doctype validation
    • Edge cases (empty sections, anchors, aliases)
    • Parser reuse and different column widths
  • All 19 tests pass ✅

Test Resources

  • asciitest3_with_equals.txt - Complete manpage using == SECTION syntax
  • asciitest4_minimal.txt - Minimal valid manpage header
  • asciitest5_mixed_format.txt - Mixed == and underline formats

Backward Compatibility

✅ Full backward compatibility maintained

  • Existing man page files using underline format continue to work
  • Both formats can coexist in the same file
  • All existing tests pass

Test Results

Tests run: 19, Failures: 0, Errors: 0, Skipped: 0
Full test suite: BUILD SUCCESS

🤖 Generated with Claude Code

This commit fixes ManFileParser to properly conform to the asciidoctor
manpage specification, particularly for section heading formats.

Changes:
- ManSection.java: Added support for "== Section" syntax (standard
  asciidoctor format) while maintaining backward compatibility with
  the underline format (Section\n-----)
- ManFileParser.java: Fixed header validation to support both
  "= title" and "title\n====" formats, and properly validate
  :doctype: manpage attribute
- Added comprehensive test suite (ManFileParserTest.java) with 19
  test cases covering both formats
- Added test resources for == syntax, minimal headers, and mixed
  formats

The parser now supports:
1. Standard == section syntax: == SECTION
2. Legacy underline syntax: SECTION\n-------
3. Both title formats: = title(1) and title(1)\n=======
4. Proper doctype validation

All 19 tests pass, maintaining full backward compatibility with
existing man page files.

Fixes aeshell#683

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ManFileParser does not conform to asciidoctor manpage specification

1 participant