feat: Allow users to override comment delimiters#900
Conversation
|
Hello @jdkato, it looks like a number of cucumber tests are failing in CI. When I set up a development environment per the instructions and run |
|
The tests pass on the v3 branch on GitHub and for me locally. So my guess is that the failures you're seeing locally on the v3 branch are related to your environment, but I would need to know which cases are failing to say more. The failures here are related to your changes, but I haven't looked closely enough to say exactly why. My advice would be to try running Vale in the relevant test directories, starting with |
9a7ac8b to
cfbeec1
Compare
|
@jdkato Thanks for your help! I realized why my changes were introducing failures and pushed a fix with a new unit test. |
|
The changes look good. Are you ready for this to be merged? |
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:
```ini
[*.md]
CommentDelimiters = "{/*,*/}"
```
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:
- Refactor `applyPatterns`. Remove the method receiver and take only the
necessary fields of `*core.Config` as parameters. This makes it easier
to test `applyPatterns` without mocking an entire `*core.Config`. Also
extract functions for `applyInlinePatterns` and `applyBlockPatterns`
so we can use fewer arguments in a single function.
- Add `applyCommentPatterns`, which works similarly to
`applyInlinePatterns` and `applyBlockPatterns`, but for substituting
comments.
- For tests, import `https//github.com/stretchr/testify/assert`, a
popular testing library, to get richer test output.
Closes vale-cli#762
cfbeec1 to
7ed02e6
Compare
Yes, thanks for taking a look and helping me through the process! |
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
CommentDelimitersfield for*.mdfiles, 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.Configas parameters. This makes it easier to testapplyPatternswithout mocking an entire*core.Config. Also extract functions forapplyInlinePatternsandapplyBlockPatternsso we can use fewer arguments in a single function.applyCommentPatterns, which works similarly toapplyInlinePatternsandapplyBlockPatterns, but for substituting comments.https//github.com/stretchr/testify/assert, a popular testing library, to get richer test output.Closes #762