Flexmark arbitrary formatter options in maven/gradle config#2968
Merged
nedtwigg merged 7 commits intoJun 9, 2026
Conversation
…ns map
Adds a flexmarkOptions map to FlexmarkConfig and the Maven plugin's
Flexmark class. Each camelCase key (e.g. rightMargin) is converted to
SCREAMING_SNAKE_CASE and resolved to a static DataKey field on the
flexmark Formatter class via reflection. Integer, Boolean, and String
option types are supported; an unknown key or unsupported type fails
the build with a clear error message.
Example Maven configuration:
<flexmark>
<flexmarkOptions>
<rightMargin>100</rightMargin>
</flexmarkOptions>
</flexmark>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds unit tests in FlexmarkStepTest verifying: - rightMargin option wraps long paragraphs at the configured column - an unknown option key fails with a clear IllegalArgumentException Adds a Maven integration test in FlexmarkMavenTest verifying the flexmarkOptions XML map configuration round-trips correctly through the plugin. Adds the corresponding test resource fixtures FlexmarkOptionsUnformatted.md / FlexmarkOptionsFormatted.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…camelCase conversion to Maven plugin - FlexmarkConfig stores SCREAMING_SNAKE_CASE keys directly; camelCase→SCREAMING_SNAKE_CASE conversion now lives in the Maven plugin (Flexmark.java) where XML element name convention originates - Renamed flexmarkOptions→formatterOptions throughout (config field, getter/setter, @parameter, Gradle DSL method, README, tests) - Added formatterOptions(Map) to Gradle FlexmarkExtension with a corresponding integration test - Added emulationProfile javadoc noting it can also be set via formatterOptions as FORMATTER_EMULATION_PROFILE - Updated plugin-maven/README.md with formatterOptions documentation and example Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
nedtwigg
reviewed
Jun 9, 2026
nedtwigg
left a comment
Member
There was a problem hiding this comment.
Assuming CI passes this LGTM, though I've got one nit:
| private String emulationProfile = "COMMONMARK"; | ||
| private List<String> pegdownExtensions = List.of("ALL"); | ||
| private List<String> extensions = new ArrayList<>(); | ||
| private Map<String, String> formatterOptions = new LinkedHashMap<>(); |
Member
There was a problem hiding this comment.
the serialized value of these options is used for up-to-date checks, so if there's any order instability we'll get lots of unnecessary rebuilds. How about swapping for TreeMap
Contributor
Author
|
@nedtwigg I pushed fixed that should fix CI, but it looks like you need to approve the workflow for CI to re-run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for arbitrary
formatterOptionsin the flexmark step for Maven and Gradle plugins.The Flexmark Markdown formatter step previously exposed only a small set of formatting options (emulationProfile, pegdownExtensions, extensions). This PR adds a formatterOptions map that lets users pass any option supported by the flexmark-java Markdown Formatter without requiring Spotless to add per-option DSL methods.
Options are specified as SCREAMING_SNAKE_CASE keys matching the static DataKey fields on
com.vladsch.flexmark.formatter.Formatter(e.g. RIGHT_MARGIN). The value is always a String and is coerced to the correct type (Integer, Boolean, or String) based on the key's default value. An unrecognised key or unsupported type fails the build with a descriptive error.Gradle:
Maven: