-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow separate strong emphasis marker #103
base: main
Are you sure you want to change the base?
Allow separate strong emphasis marker #103
Conversation
@swift-ci please test |
b9f1384
to
7be8670
Compare
@Kyle-Ye @QuietMisdreavus I've just rebased this PR on master, and all the tests (at least the ones that I can see) now pass. Would it be possible to get this merged? |
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Markdown spec allows one to, and I prefer to, use different markers for emphasis as compared to strong emphasis.
Could you add the spec link which describe this feature? Thanks.
We are actually using GFM. So I believe we should refer into this spec |
I was just about to link that, yeah |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM. Leave it to @QuietMisdreavus for the final merge.
One more issue is for "___a___"
or "***a***"
input. If we specify emphasisMarker to be "_"
and strongEmphasisMarker to be "*"
.
The result would be "_**a**_"
.
The order is expected but I do not see spec covers such usage. Can you provide some insights on this?
What specifically is your question? The ordering or whether it is allowed to have two different types of delimiters next to each other? The ordering should be addressed by Example 476, and the fact that you are allowed to have different delimiters right next to each other is addressed by Example 472 |
different emphasis marker and strong emphasis right next to each other
I have no problem of the ordering as it has been explicitly stated in the spec "An interpretation
No. Example 472 does not address my issue. I have not seen any spec statement or example of |
Ah, I see what you are asking. I'll give two examples.
In this case, the first The second The first The second
In this case, the first The second The first The second |
@Kyle-Ye hopefully that addresses your question. I do wish that they had examples, though |
Got it. They are indeed grammatically correct. Just hoping we go a example in the spec though. LOL |
I think that latest commit should address your other concern — let me know if you'd like any other changes to be made |
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I feel like combined emphasis and strong emphasis should all be rendered with the strong emphasis marker, but that requires that That would look something like this: public mutating func visitEmphasis(_ emphasis: Emphasis) {
let emphasisMarker: String
if let parent = emphasis.parent as? Strong, parent.childCount == 1 {
emphasisMarker = formattingOptions.strongEmphasisMarker.rawValue
} else if emphasis.childCount == 1, emphasis.child(at: 0) is Strong {
emphasisMarker = formattingOptions.strongEmphasisMarker.rawValue
} else {
emphasisMarker = formattingOptions.emphasisMarker.rawValue
}
print(emphasisMarker, for: emphasis)
descendInto(emphasis)
print(emphasisMarker, for: emphasis)
} And then adding more tests to make sure that combination emphasis works as expected. This way, we don't have to worry about semantics surrounding mixed emphasis markers. Even though we correctly parse the mixed result, it will look better in the rendered output to have these mixed emphasis spans use the same marker, even if we've been given separate emphasis markers. |
I think this would be unexpected behavior. When the strong emphasis marker and normal emphasis marker are both set, the former should be used for strong emphasis, and the latter should be used for normal emphasis.
Personally, I would still prefer my output to use different strong and normal emphasis markers even when they are both in use. I think this PR shouldn't include special cases where it diverges from the behavior one would expect when specifying two different emphasis markers |
Unless there are any other concerns, would it be possible to merge this? |
+1. cc @QuietMisdreavus |
Bug/issue #, if applicable: N/A
Summary
As it stands, the selection of an
emphasisMarker
inMarkupFormatter.Options
determines the marker used for both emphasis and strong emphasis. However, the Markdown spec allows one to, and I prefer to, use different markers for emphasis as compared to strong emphasis. For example:_emphasis_
and**strong emphasis**
.This PR adds an
Optional
parameter toMarkupFormatter.Options
that allows one to specify the marker used for strong emphasis. If omitted, it takes on the value of the marker used for normal emphasis.Dependencies
None
Testing
I've updated the bundled
markdown-tool
as well, so you can simply run:which will replicate the input as output. But if one runs:
the output is
Here's some __strong emphasis__ and some _normal emphasis_
— i.e., the previous behavior is honored.Steps:
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeededThe
./bin/test
script already fails for me onmain
, but I haven't introduced any new issues.