mirror of
https://github.com/dragonish/obsidian-heading-decorator.git
synced 2026-07-22 05:42:05 +00:00
merge(main): merge branch 'dev'
This commit is contained in:
commit
79ac8aa1c3
5 changed files with 53 additions and 23 deletions
|
|
@ -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
|
||||
|
|
|
|||
2
.github/workflows/release.yaml
vendored
2
.github/workflows/release.yaml
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue