Skip to content

feat(jtk): add wiki markup detection and conversion#49

Merged
rianjs merged 1 commit intomainfrom
feat/37-jtk-wiki-markup
Jan 31, 2026
Merged

feat(jtk): add wiki markup detection and conversion#49
rianjs merged 1 commit intomainfrom
feat/37-jtk-wiki-markup

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Jan 31, 2026

Summary

  • Add IsWikiMarkup() function to detect Jira wiki markup patterns
  • Add WikiToMarkdown() function to convert wiki markup to markdown
  • Update MarkdownToADF() to auto-detect and convert wiki markup first

Supported patterns:

  • Headings: h1. through h6.
  • Code blocks: {code}...{code} and {code:lang}...{code}
  • Monospace: {{text}}
  • Links: [text|url]
  • Images: !image.png! and !image.png|alt=text!
  • Blockquotes: bq. and {quote}...{quote}
  • Bullet lists: * item, ** nested
  • Noformat: {noformat}...{noformat}
  • Horizontal rules: ----

Ports wiki markup handling from jira-ticket-cli PR #63.

Closes #37

Test plan

  • make build passes
  • make test passes
  • make lint passes
  • Unit tests for IsWikiMarkup() with wiki and non-wiki content
  • Unit tests for WikiToMarkdown() with various patterns
  • Integration test with MarkdownToADF()

🤖 Generated with Claude Code

Port wiki markup handling from jira-ticket-cli PR #63:
- IsWikiMarkup() detects Jira wiki patterns (h1., {{code}}, etc.)
- WikiToMarkdown() converts wiki to markdown format
- Auto-detect wiki in MarkdownToADF() and convert first

Supported patterns: headings, code blocks, monospace, links, images,
blockquotes, bullet lists, horizontal rules, and more.

Closes #37

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rianjs
Copy link
Copy Markdown
Contributor Author

rianjs commented Jan 31, 2026

TDD Quality Assessment for PR #49

Overall Assessment: Good (with room for improvement)

The PR demonstrates solid TDD practices with comprehensive test coverage for the core functionality. The tests are well-structured and follow the codebase's established patterns.


1. Test Comprehensiveness

Strengths:

  • IsWikiMarkup() covers 12 test cases including positive matches (h1, h2, monospace, code blocks, links, images, blockquotes, noformat, quote blocks) and negative cases (plain markdown, plain text, empty string)
  • WikiToMarkdown() covers 19 test cases including all documented patterns
  • Integration test with MarkdownToADF() verifies the auto-detect flow works end-to-end
  • TestWikiToMarkdownPreservesMarkdown() ensures markdown passthrough works correctly

Coverage of documented patterns:

Pattern Detection Test Conversion Test
h1. - h6. Yes Yes (h1, h2, h3, multiple)
{code}...{code} Yes Yes (with/without lang)
{{monospace}} Yes Yes
[text|url] Yes Yes
!image.png! Yes Yes (with/without alt)
bq. Yes Yes
{quote}...{quote} Yes Yes
{noformat}...{noformat} Yes Yes
---- No Yes
Bullet lists (*, **) Partial Yes (single, nested)

2. Edge Cases Analysis

Covered:

  • Empty string input
  • Plain text (no formatting)
  • Markdown passthrough (headings, bold, code, links, lists)
  • Multi-line quote blocks
  • Nested bullet lists (2 levels)
  • Complex documents with mixed formatting

Missing edge cases:

  1. Detection edge cases:

    • ---- horizontal rule (not tested for detection, only conversion)
    • Mixed wiki + markdown content (e.g., h1. Title with **bold**)
    • Wiki patterns inside code blocks (should not trigger detection)
  2. Conversion edge cases:

    • h4., h5., h6. headings (only h1-h3 tested)
    • Triple-nested bullet lists (*** item)
    • Code blocks with special characters or empty content
    • Monospace with special characters ({{foo|bar}})
    • Links with special characters in URL or text
    • Images with other attributes besides alt=
    • Text formatting: underline (+text+), subscript (~text~), superscript (^text^), citation (??text??), strikethrough (-text-)
    • Consecutive horizontal rules
    • Unicode content in various patterns
  3. Boundary conditions:

    • Very long input strings
    • Input with only whitespace
    • Wiki patterns at EOF without trailing newline
    • Malformed wiki syntax (unclosed {code}, unmatched {{)

3. Test Pattern Consistency

Consistent with codebase:

  • Uses testify/assert for assertions (matches markdown_test.go, errors_test.go)
  • Table-driven tests with name, input, expected fields
  • Follows t.Run() pattern for subtests
  • Uses require.NotNil before accessing struct fields

Minor inconsistencies:

  • markdown_test.go uses require more liberally for preconditions; this PR uses mostly assert
  • Some tests in codebase have more descriptive test names (e.g., TestMarkdownToADF_CodeBlockNoLanguage)

4. What's Missing

High priority:

  1. Text formatting conversion tests - The implementation handles underline, subscript, superscript, citation, and strikethrough, but none are tested
  2. h4-h6 heading tests - Only h1-h3 are tested despite supporting h1-h6
  3. Error resilience tests - Malformed input handling

Medium priority:
4. Detection for horizontal rules - ---- is converted but not tested in detection
5. Deeply nested lists - Only 2 levels tested, code handles 3
6. Code block edge cases - Empty blocks, blocks with regex special chars

Nice to have:
7. Benchmark tests - The regex-heavy implementation could benefit from performance validation
8. Fuzz testing - For robust input handling


Recommendations

  1. Add tests for the text formatting conversions (lines 228-272 in wiki.go are untested)
  2. Extend heading tests to cover h4-h6
  3. Add a test for *** item (triple-nested bullet)
  4. Consider adding a few malformed input tests to ensure graceful handling

Example test to add:

{
    name:     "text formatting strikethrough",
    input:    "This is -struck- text",
    expected: "This is ~~struck~~ text",
},
{
    name:     "text formatting underline",
    input:    "This is +underlined+ text",
    expected: "This is <u>underlined</u> text",
},

Summary

The tests are well-written and cover the primary use cases effectively. The table-driven approach and integration testing are excellent. The main gap is the complete lack of tests for the text formatting conversions (strikethrough, underline, subscript, superscript, citation) which represent ~45 lines of untested implementation code. Adding these tests would bring the PR to an excellent TDD standard.

Score: 7.5/10 - Good coverage of core functionality, but text formatting and some edge cases need attention.

@rianjs rianjs merged commit bcc6f46 into main Jan 31, 2026
7 checks passed
@rianjs rianjs deleted the feat/37-jtk-wiki-markup branch January 31, 2026 11:09
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.

feat(jtk): port wiki markup detection

1 participant