feat: Allow users to override comment delimiters #900
Merged
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.
Allow users to specify the comment delimiters they are using in their documentation. vale replaces these with HTML comment tags before linting, making it possible to control style rules for specific passages of prose in file formats that use non-HTML comment syntax. This is critical for controlling style rules within a page in MDX, and potentially other formats as well.
This example configures the
CommentDelimiters
field for*.md
files, indicating that{/*
and*/}
are the custom comment delimiters:Internally, custom delimiters are represented as a
[2]string
, and it is only possible to configure one set of custom comment delimiters for a given format block.More specific changes:
applyPatterns
. Remove the method receiver and take only the necessary fields of*core.Config
as parameters. This makes it easier to testapplyPatterns
without mocking an entire*core.Config
. Also extract functions forapplyInlinePatterns
andapplyBlockPatterns
so we can use fewer arguments in a single function.applyCommentPatterns
, which works similarly toapplyInlinePatterns
andapplyBlockPatterns
, but for substituting comments.https//github.com/stretchr/testify/assert
, a popular testing library, to get richer test output.Closes #762