merge(main): merge branch 'dev'

This commit is contained in:
dragonish 2025-04-19 20:24:42 +08:00
commit 79ac8aa1c3
No known key found for this signature in database
GPG key ID: 6F42FA9E807A5177
5 changed files with 53 additions and 23 deletions

View file

@ -46,7 +46,7 @@ jobs:
zip "./release/${plugin_name}_v${{ steps.git_tags.outputs.current }}.zip" "main.js" "styles.css" "manifest.json"
- name: Create changelog text
id: changelog_text
uses: loopwerk/tag-changelog@v1
uses: dragonish/tag-changelog@v1
with:
token: ${{ secrets.ACCESS_TOKEN }}
config_file: ../.gitea/scripts/tag-changelog-config.cjs

View file

@ -29,7 +29,7 @@ jobs:
pnpm run build
- name: Create changelog text
id: changelog_text
uses: loopwerk/tag-changelog@v1
uses: dragonish/tag-changelog@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
config_file: .github/scripts/tag-changelog-config.cjs

View file

@ -220,17 +220,41 @@ export function diffLevel(current: number, last: number): boolean {
/**
* Compare Markdown text.
*
* @param l left Markdown text.
* @param r right Markdown text.
* @param source The source heading text.
* @param outline The outline heading text.
* @returns boolean. if left Markdown text is equal to right Markdown text, return true. otherwise, return false.
*/
export function compareMarkdownText(l: string, r: string): boolean {
if (l === r) {
return true;
} else if (
l.replaceAll(/[`=_~*\\\s]/g, "") === r.replaceAll(/[`=_~*\\\s]/g, "")
) {
export function compareMarkdownText(source: string, outline: string): boolean {
if (source === outline) {
return true;
} else {
source = source.replaceAll(/\[(.+)\]\(.*\)/g, "$1");
if (source === outline) {
return true;
}
source = source.replaceAll(/\[\[.+\|(.+)\]\]/g, "$1");
if (source === outline) {
return true;
}
source = source.replaceAll(/\[\[(.+)#(.+)\]\]/g, "$1 > $2");
if (source === outline) {
return true;
}
source = source.replaceAll(/\[\[#?(.+)\]\]/g, "$1");
if (source === outline) {
return true;
}
if (
source.replaceAll(/[`=_~*\\\s]/g, "") ===
outline.replaceAll(/[`=_~*\\\s]/g, "")
) {
return true;
}
}
return false;

View file

@ -176,10 +176,10 @@ export function decorateOutlineElement(
/**
* Compare heading text.
*
* @param l The left heading text.
* @param r The right heading text.
* @param source The source heading text.
* @param outline The outline heading text.
* @returns true if the two headings are equal, false otherwise.
*/
export function compareHeadingText(l: string, r: string): boolean {
return compareMarkdownText(htmlToMarkdown(l), htmlToMarkdown(r));
export function compareHeadingText(source: string, outline: string): boolean {
return compareMarkdownText(htmlToMarkdown(source), htmlToMarkdown(outline));
}

View file

@ -28,16 +28,22 @@ describe("common/data", function () {
expect(compareMarkdownText("", "")).to.be.true;
expect(compareMarkdownText("h1", "h1")).to.be.true;
expect(compareMarkdownText("h1", "h2")).to.be.false;
expect(compareMarkdownText("h1", "`h1`")).to.be.true;
expect(compareMarkdownText("h1 h2", "`h1` h2")).to.be.true;
expect(compareMarkdownText("h1 `", "h1 `` ` ``")).to.be.true;
expect(compareMarkdownText("h1", "*h1*")).to.be.true;
expect(compareMarkdownText("h1", "**h1**")).to.be.true;
expect(compareMarkdownText("h1", "_h1_")).to.be.true;
expect(compareMarkdownText("h1", "__h1__")).to.be.true;
expect(compareMarkdownText("h1", "==h1==")).to.be.true;
expect(compareMarkdownText("h1", "~~h1~~")).to.be.true;
expect(compareMarkdownText("`h1`", "h1")).to.be.true;
expect(compareMarkdownText("`h1` h2", "h1 h2")).to.be.true;
expect(compareMarkdownText("h1 `` ` ``", "h1 `")).to.be.true;
expect(compareMarkdownText("*h1*", "h1")).to.be.true;
expect(compareMarkdownText("**h1**", "h1")).to.be.true;
expect(compareMarkdownText("_h1_", "h1")).to.be.true;
expect(compareMarkdownText("__h1__", "h1")).to.be.true;
expect(compareMarkdownText("==h1==", "h1")).to.be.true;
expect(compareMarkdownText("~~h1~~", "h1")).to.be.true;
expect(compareMarkdownText("h1 \\<content>", "h1 <content>")).to.be.true;
expect(compareMarkdownText("[h1](/h1)", "h1")).to.be.true;
expect(compareMarkdownText("[h1](/h1) content", "h1 content")).to.be.true;
expect(compareMarkdownText("[[h1]]", "h1")).to.be.true;
expect(compareMarkdownText("[[h2|h1]]", "h1")).to.be.true;
expect(compareMarkdownText("[[h1#h2]]", "h1 > h2")).to.be.true;
expect(compareMarkdownText("[[#h2]]", "h2")).to.be.true;
});
it("getBoolean", function () {