-
-
Notifications
You must be signed in to change notification settings - Fork 503
Add CJK-friendly Emphasis Extension #921
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
Open
tats-u
wants to merge
10
commits into
xoofx:master
Choose a base branch
from
tats-u:cjk-friendly
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
48394a1
Add CJK-friendly Emphasis Extension
tats-u 0357650
Add auto-generated test file
tats-u 5aad3d9
Add name for configuration
tats-u 79f3d69
Remove useless default value assignments
tats-u 0ba3eaf
Make `CheckOpenCloseDelimiterCjkFriendly` internal only
tats-u 9fc6972
Remove `CjkFriendlyEmphasisExtension` class
tats-u b254c68
Add some comments including links
tats-u cf57652
Add direct tests on `CharHelper.CheckOpenCloseDelimiterCjkFriendly`
tats-u fdefca0
Fix generated tests
tats-u 5b75192
Add `#if NET`
tats-u File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
|
|
||
| // -------------------------------- | ||
| // CJK-friendly Emphasis | ||
| // -------------------------------- | ||
|
|
||
| using System; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Markdig.Tests.Specs.CJKFriendlyEmphasis | ||
| { | ||
| [TestFixture] | ||
| public class TestCJKFriendlyEmphasisExtension | ||
| { | ||
| // ## CJK-friendly Emphasis Extension | ||
| // | ||
| // See https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md for details about the spec of this extension. | ||
| // | ||
| // This extension drastically mitigates [the long-standing issue (specification flaw)](https://github.com/commonmark/commonmark-spec/issues/650) in CommonMark that emphasis in CJK languages is often not parsed as expected. | ||
| // | ||
| // The plain CommonMark cannot recognize even the following emphasis in CJK languages: | ||
| [Test] | ||
| public void CJKFriendlyEmphasisExtension_Example001() | ||
| { | ||
| // Example 1 | ||
| // Section: CJK-friendly Emphasis Extension | ||
| // | ||
| // The following Markdown: | ||
| // **この文を強調できますか(Can I emphasize this sentence)?**残念ながらこの文のせいでできません(Unfortunately not possible due to this sentence)。 | ||
| // | ||
| // Should be rendered as: | ||
| // <p><strong>この文を強調できますか(Can I emphasize this sentence)?</strong>残念ながらこの文のせいでできません(Unfortunately not possible due to this sentence)。</p> | ||
|
|
||
| TestParser.TestSpec("**この文を強調できますか(Can I emphasize this sentence)?**残念ながらこの文のせいでできません(Unfortunately not possible due to this sentence)。", "<p><strong>この文を強調できますか(Can I emphasize this sentence)?</strong>残念ながらこの文のせいでできません(Unfortunately not possible due to this sentence)。</p>", "cjk-friendly-emphasis", context: "Example 1\nSection CJK-friendly Emphasis Extension\n"); | ||
| } | ||
|
|
||
| // ````````````````````````````````` example | ||
| // 我可以强调**这个`code`**吗(Can I emphasize **this `code`**)? | ||
| // . | ||
| // <p>我可以强调<code>这个`code`</code>吗(Can I emphasize <strong>this <code>code</code></strong>)?</p> | ||
| // ````````````````````````````````` | ||
| [Test] | ||
| public void CJKFriendlyEmphasisExtension_Example002() | ||
| { | ||
| // Example 2 | ||
| // Section: CJK-friendly Emphasis Extension | ||
| // | ||
| // The following Markdown: | ||
| // **이 용어(This term)**를 강조해 주세요. (Please emphasize **this term**.) | ||
| // | ||
| // Should be rendered as: | ||
| // <p><strong>이 용어(This term)</strong>를 강조해 주세요. (Please emphasize <strong>this term</strong>.)</p> | ||
|
|
||
| TestParser.TestSpec("**이 용어(This term)**를 강조해 주세요. (Please emphasize **this term**.)", "<p><strong>이 용어(This term)</strong>를 강조해 주세요. (Please emphasize <strong>this term</strong>.)</p>", "cjk-friendly-emphasis", context: "Example 2\nSection CJK-friendly Emphasis Extension\n"); | ||
| } | ||
| // You can compare the results with and without this extension: https://tats-u.github.io/markdown-cjk-friendly/?sc8=KirjgZPjga7mlofjgpLlvLfoqr_jgafjgY3jgb7jgZnjgYvvvIhDYW4gSSBlbXBoYXNpemUgdGhpcyBzZW50ZW5jZe-8ie-8nyoq5q6L5b-144Gq44GM44KJ44GT44Gu5paH44Gu44Gb44GE44Gn44Gn44GN44G-44Gb44KT77yIVW5mb3J0dW5hdGVseSBub3QgcG9zc2libGUgZHVlIHRvIHRoaXMgc2VudGVuY2XvvInjgIIKCuaIkeWPr-S7peW8uuiwgyoq6L-Z5LiqYGNvZGVgKirlkJfvvIhDYW4gSSBlbXBoYXNpemUgKip0aGlzIGBjb2RlYCoq77yJ77yfCgoqKuydtCDsmqnslrQoVGhpcyB0ZXJtKSoq66W8IOqwleyhsO2VtCDso7zshLjsmpQuIChQbGVhc2UgZW1waGFzaXplICoqdGhpcyB0ZXJtKiouKQo&gfm=1&engine=markdown-it | ||
| // | ||
| // You will find how poor the plain CommonMark is for CJK languages. | ||
| // | ||
| // To use this extension, configure the pipeline as follows: | ||
| // | ||
| // ```csharp | ||
| // var pipeline = new MarkdownPipelineBuilder() | ||
| // .UseCJKFriendlyEmphasis() // Add this | ||
| // .Build(); | ||
| // ``` | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| ## CJK-friendly Emphasis Extension | ||
|
|
||
| See https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md for details about the spec of this extension. | ||
|
|
||
| This extension drastically mitigates [the long-standing issue (specification flaw)](https://github.com/commonmark/commonmark-spec/issues/650) in CommonMark that emphasis in CJK languages is often not parsed as expected. | ||
|
|
||
| The plain CommonMark cannot recognize even the following emphasis in CJK languages: | ||
|
|
||
| ```````````````````````````````` example | ||
| **この文を強調できますか(Can I emphasize this sentence)?**残念ながらこの文のせいでできません(Unfortunately not possible due to this sentence)。 | ||
| . | ||
| <p><strong>この文を強調できますか(Can I emphasize this sentence)?</strong>残念ながらこの文のせいでできません(Unfortunately not possible due to this sentence)。</p> | ||
| ```````````````````````````````` | ||
|
|
||
| ````````````````````````````````` example | ||
| 我可以强调**这个`code`**吗(Can I emphasize **this `code`**)? | ||
| . | ||
| <p>我可以强调<code>这个`code`</code>吗(Can I emphasize <strong>this <code>code</code></strong>)?</p> | ||
| ````````````````````````````````` | ||
|
|
||
| ```````````````````````````````` example | ||
| **이 용어(This term)**를 강조해 주세요. (Please emphasize **this term**.) | ||
| . | ||
| <p><strong>이 용어(This term)</strong>를 강조해 주세요. (Please emphasize <strong>this term</strong>.)</p> | ||
| ```````````````````````````````` | ||
|
|
||
| You can compare the results with and without this extension: https://tats-u.github.io/markdown-cjk-friendly/?sc8=KirjgZPjga7mlofjgpLlvLfoqr_jgafjgY3jgb7jgZnjgYvvvIhDYW4gSSBlbXBoYXNpemUgdGhpcyBzZW50ZW5jZe-8ie-8nyoq5q6L5b-144Gq44GM44KJ44GT44Gu5paH44Gu44Gb44GE44Gn44Gn44GN44G-44Gb44KT77yIVW5mb3J0dW5hdGVseSBub3QgcG9zc2libGUgZHVlIHRvIHRoaXMgc2VudGVuY2XvvInjgIIKCuaIkeWPr-S7peW8uuiwgyoq6L-Z5LiqYGNvZGVgKirlkJfvvIhDYW4gSSBlbXBoYXNpemUgKip0aGlzIGBjb2RlYCoq77yJ77yfCgoqKuydtCDsmqnslrQoVGhpcyB0ZXJtKSoq66W8IOqwleyhsO2VtCDso7zshLjsmpQuIChQbGVhc2UgZW1waGFzaXplICoqdGhpcyB0ZXJtKiouKQo&gfm=1&engine=markdown-it | ||
|
|
||
| You will find how poor the plain CommonMark is for CJK languages. | ||
|
|
||
| To use this extension, configure the pipeline as follows: | ||
|
|
||
| ```csharp | ||
| var pipeline = new MarkdownPipelineBuilder() | ||
| .UseCJKFriendlyEmphasis() // Add this | ||
| .Build(); | ||
| ``` | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.