Expand delimiters if code contains backticks#416
Open
mtkraai wants to merge 3 commits into
Open
Conversation
Collaborator
|
@mtkraai could you share an example how it looked in the past VS how it looks now? |
Author
|
I have updated the PR top post with an example of the inline case. However, when trying to contrive a reasonable example of a block case, I found that the template does not call this function for the location of my example. I tried updating the templates to call I'd like to finish expanding the improvements, but it will take some time to troubleshoot (working around my regular work). |
Author
|
@bastelfreak I made additional changes, did more testing, and updated the PR top comment. |
d56529f to
b8a38be
Compare
Use the `code_maybe_block()` function for all code strings that could possibly contain backticks.
b8a38be to
9e7d403
Compare
Author
|
Apologies for the force pushes, I accidentally used my work profile for the update commits. |
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.
Summary
Generated markdown was incorrect when an inline code block contained backticks.
Additional Context
Markdown inline code or fenced code blocks do not allow for the closing delimiter to be escaped. Instead, the length of the delimiter can be changed to accommodate any reasonable content.
I have also made the stylistic change of making single-line code strings longer than 70 characters into fenced blocks, so that the code displays in its original horizontal format, instead of being wrapped by the browser.
Examples
1. Backtick in data type:
The original case that prompted me to do this was a Pattern type that included a backtick in a character class.
type My_module::My_type = Pattern[/\A[- \w~`<>.,?\/"#]+\z/]Which produced this:
And looks like this:
After the change, it produces this:
Which looks like this:
2. Fenced code in example:
This is the case I contrived to test the change as it applies to fenced blocks.
Which produced:
And is broken like this:
After the change we get:
Which displays correctly:
3. Long value:
To demonstrate the advantage of using block style for long values, I'll borrow a data type from the
stdlibmodule.Old:
Which renders:
New:
And that looks like this, which I think is more code-like and a little easier to read, even though the whole thing can't be seen at once:
Related Issues (if any)
I did not find anything related. The original code comments do mention the omission.
Tests
I did not find any test that directly tests the
code_maybe_block()function, or I would have added a couple of test cases. Additionally, the the test that might apply is very simplistic, and additions that would properly test this function and change would, I think, substantially change the existing test in ways I don't know if they would be acceptable.In addition to testing with my own modules, I ran the puppetlabs/stdlib and puppetlabs/apache modules through this. When I
diffed the results, the only changes were as expected.