Skip to content

Commit

Permalink
Merge pull request #610 from pjkaufman/master
Browse files Browse the repository at this point in the history
Fix Links in Italics or Bold Getting Spaces Added for Links with CJK and English Characters
  • Loading branch information
pjkaufman authored Feb 1, 2023
2 parents 2401f45 + 22191cd commit c7f7477
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ ruleTest({
\`filepath = './ちしき_図書館.md'\`
`,
},
{
// accounts for https://github.com/platers/obsidian-linter/issues/407
{ // accounts for https://github.com/platers/obsidian-linter/issues/407
testName: 'Make sure that inline math blocks are not affected',
before: dedent`
# Title Here
Expand All @@ -74,5 +73,27 @@ ruleTest({
$M0 = 现金$
`,
},
{ // accounts for https://github.com/platers/obsidian-linter/issues/583
testName: 'Make sure that wiki link and markdown links are ignored in italics',
before: dedent`
*[[abs 接口]]*
*[abs 接口](abs 接口.md)*
`,
after: dedent`
*[[abs 接口]]*
*[abs 接口](abs 接口.md)*
`,
},
{ // relates for https://github.com/platers/obsidian-linter/issues/583
testName: 'Make sure that wiki link and markdown links are ignored in bold',
before: dedent`
**[[abs 接口]]**
**[abs 接口](abs 接口.md)**
`,
after: dedent`
**[[abs 接口]]**
**[abs 接口](abs 接口.md)**
`,
},
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,23 @@ export default class SpaceBetweenChineseJapaneseOrKoreanAndEnglishOrNumbers exte
return text.replace(head, '$1 $3').replace(tail, '$1 $3');
};

let newText = ignoreListOfTypes(
[
IgnoreTypes.code,
IgnoreTypes.inlineCode,
IgnoreTypes.yaml,
IgnoreTypes.image,
IgnoreTypes.link,
IgnoreTypes.wikiLink,
IgnoreTypes.tag,
IgnoreTypes.italics,
IgnoreTypes.bold,
IgnoreTypes.math,
IgnoreTypes.inlineMath,
],
text,
addSpaceAroundChineseJapaneseKoreanAndEnglish,
);

newText = updateItalicsText(
newText,
addSpaceAroundChineseJapaneseKoreanAndEnglish,
);
return ignoreListOfTypes([IgnoreTypes.code, IgnoreTypes.inlineCode, IgnoreTypes.yaml, IgnoreTypes.image, IgnoreTypes.link,
IgnoreTypes.wikiLink, IgnoreTypes.tag, IgnoreTypes.math, IgnoreTypes.inlineMath], text, (text: string) => {
let newText = ignoreListOfTypes([IgnoreTypes.italics, IgnoreTypes.bold], text, addSpaceAroundChineseJapaneseKoreanAndEnglish);

newText = updateBoldText(
newText,
addSpaceAroundChineseJapaneseKoreanAndEnglish,
);
newText = updateItalicsText(
newText,
addSpaceAroundChineseJapaneseKoreanAndEnglish,
);

return newText;
newText = updateBoldText(
newText,
addSpaceAroundChineseJapaneseKoreanAndEnglish,
);

return newText;
});
}
get exampleBuilders(): ExampleBuilder<SpaceBetweenChineseJapaneseOrKoreanAndEnglishOrNumbersOptions>[] {
return [
Expand Down

0 comments on commit c7f7477

Please sign in to comment.