Skip to content

Add fuller DITA task element support to MDITA task topic type - #249

Open
aireilly wants to merge 2 commits into
jelovirt:masterfrom
aireilly:gtask
Open

Add fuller DITA task element support to MDITA task topic type#249
aireilly wants to merge 2 commits into
jelovirt:masterfrom
aireilly:gtask

Conversation

@aireilly

@aireilly aireilly commented Apr 16, 2026

Copy link
Copy Markdown

Extend the SpecializeFilter to support additional task elements through positional inference and heading-based section annotation:

Layer 1 - Positional inference:

  • result: content after steps auto-wraps in <result>
  • substeps/substep: nested ordered list in step becomes <substeps>
  • choices/choice: nested unordered list in step becomes <choices>
  • choicetable: simpletable in step becomes <choicetable> with chhead/chrow/choption/chdesc elements

Layer 2 - Heading-based sections:

  • Add prereq, context, result, postreq, tasktroubleshooting as recognized section classes in TopicRenderer so {.prereq} etc. on H2 headings create sections (not nested topics)
  • Preserve task section names in outputclass (only strip generic "section" and "example") so SpecializeFilter can rename them
  • Add section handler in SpecializeFilter to rename sections with matching outputclass to task-specific elements

Also adds useJUnitPlatform() to build.gradle for JUnit 5 test execution.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@jelovirt jelovirt added enhancement llm Issue or pull request authored by or with assistance of an LLM labels Jul 27, 2026
@jelovirt

Copy link
Copy Markdown
Owner

This is a good idea. Haven't looked carefully enough into the implementation, but there are some things that would need to be fixed.

@aireilly

Copy link
Copy Markdown
Author

Hi @jelovirt 😃

This is quite out of date now I've spent some time playing with this stuff and landed here:

https://github.com/aireilly/redhat.mdita.extended

This is all heavily LLM-based work so I am not sure how useful this is to you or org.lwdita generally.

We can close this PR, or spend some time to make this work properly.

I think an MDITA implementation with a wider compatibility with DITA features generally would be very useful.

@jelovirt

Copy link
Copy Markdown
Owner

@aireilly, I just rebased this PR on the latest code. This PR needs some additional work to be merged, because the task section detection based on header text content needs to be configurable. But this is good start and parts of it can be cherry picked.

Comment on lines +11 to +15
<ol class="- topic/ol ">
<li class="- topic/li ">
<p class="- topic/p ">Command</p>
</li>
</ol>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, this cannot be written in Markdown. Markdown doesn't offer any way to end a section, thus the ordered list would be parsed to be inside the prereq section. So this is a redundant test.

Comment on lines +7 to +8
<section class="- topic/section " outputclass="prereq">
<title class="- topic/title ">Prerequisites</title>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having both @outputclass and a predefined title text is redundant. For this test, the @outputclass should be removed, but then the tests break.

@jelovirt

Copy link
Copy Markdown
Owner

#252 cherry-picks substeps from this PR with manual refactoring and fixes.

@jelovirt

jelovirt commented Aug 2, 2026

Copy link
Copy Markdown
Owner

#254 implements support for choices using explicit choices class.

@jelovirt

jelovirt commented Aug 3, 2026

Copy link
Copy Markdown
Owner

#255 adds configuration for implicit choices and substebs

Extend the SpecializeFilter to support additional task elements through
positional inference and heading-based section annotation:

Layer 1 - Positional inference:
- result: content after steps auto-wraps in <result>
- substeps/substep: nested ordered list in step becomes <substeps>
- choices/choice: nested unordered list in step becomes <choices>
- choicetable: simpletable in step becomes <choicetable> with
  chhead/chrow/choption/chdesc elements

Layer 2 - Heading-based sections:
- Add prereq, context, result, postreq, tasktroubleshooting as
  recognized section classes in TopicRenderer so {.prereq} etc. on
  H2 headings create sections (not nested topics)
- Preserve task section names in outputclass (only strip generic
  "section" and "example") so SpecializeFilter can rename them
- Add section handler in SpecializeFilter to rename sections with
  matching outputclass to task-specific elements

Also adds useJUnitPlatform() to build.gradle for JUnit 5 test execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED

# Conflicts:
#	src/main/java/com/elovirta/dita/markdown/SpecializeFilter.java

# Conflicts:
#	src/main/java/com/elovirta/dita/markdown/SpecializeFilter.java
#	src/test/java/com/elovirta/dita/markdown/SpecializeFilterTest.java

# Conflicts:
#	src/main/java/com/elovirta/dita/markdown/SpecializeFilter.java
#	src/test/resources/specialize/src/task_choices.dita
Map common heading titles to task section elements without requiring
explicit class attributes:

- "Prerequisites" → <prereq>
- "About this task" → <context>
- "Verification" → <result>
- "Next steps" → <postreq>

Title matching is case-insensitive. Explicit class attributes (e.g.
{.prereq}) still work and take precedence, allowing custom titles
like "## Before you begin {.prereq}".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@aireilly

aireilly commented Aug 3, 2026

Copy link
Copy Markdown
Author

@jelovirt I've split the remaining features from this PR into focused, standalone PRs:

  • Choicetable: Add choicetable support in task steps #256 — simpletable in a step → <choicetable> with chhead/chrow/choption/chdesc
  • Default title mapping: coming next — will be configurable via a SAX feature (implicit-task-sections), addressing your review feedback

Once the individual PRs are submitted, this PR can be closed.

@aireilly

aireilly commented Aug 3, 2026

Copy link
Copy Markdown
Author

Default title mapping is now submitted as #257 — configurable via SAX feature http://lwdita.org/sax/features/implicit-task-sections (default: false), addressing the review feedback about configurability.

Both PRs from this split are now open:

This PR can be closed once those are reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement llm Issue or pull request authored by or with assistance of an LLM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants