Update fixes

This commit is contained in:
Mayuran Visakan 2023-08-15 13:57:35 +01:00
parent 13ce814f29
commit 1d992adf78
11 changed files with 17763 additions and 6508 deletions

View file

@ -5,7 +5,8 @@
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"plugin:json/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
@ -13,7 +14,8 @@
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
"@typescript-eslint",
"json"
],
"rules": {
"indent": [

View file

@ -25,10 +25,11 @@ jobs:
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }} # tag="${GITHUB_REF#refs/tags/}"
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "$tag" \
--title="$tag" \
--notes="${git tag -l --format='%(contents:subject)' $tag}" \
--verify-tag \
--draft \
main.js manifest.json styles.css

View file

@ -3,10 +3,19 @@
"plugins": [
"stylelint-order",
"stylelint-use-logical-spec",
"stylelint-declaration-block-no-ignored-properties"
"stylelint-declaration-block-no-ignored-properties",
"stylelint-no-nested-media",
"stylelint-plugin-defensive-css",
"stylelint-high-performance-animation",
"stylelint-gamut",
"stylelint-stylistic"
],
"rules": {
"liberty/use-logical-spec": "ignore",
"plugin/declaration-block-no-ignored-properties": true
"plugin/declaration-block-no-ignored-properties": true,
"pitcher/no-nested-media": true,
"plugin/use-defensive-css": [true, {"accidental-hover": true, "background-repeat": true, "custom-property-fallbacks": true, "flex-wrapping": true, "scroll-chaining": true, "vendor-prefix-grouping": true}],
"plugin/no-low-performance-animation-properties": true,
"gamut/color-no-out-gamut-range": true
}
}

View file

@ -26,10 +26,13 @@ See this project's [releases](/../../../releases).
### Changed
- Replaced deprecated `MarkdownRenderer.renderMarkdown` to `MarkdownRenderer.render`
- Changed parsing of HTML tags
### Fixed
- Parsing error for codeblock delimiters
- Readded scrollbar after css bug caused it to disappear
- Fixed `wrap` parameter actually applying class `.unwrapped`
## [1.0.5] - 2023-08-11

17811
main.js

File diff suppressed because one or more lines are too long

6342
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -20,12 +20,20 @@
"builtin-modules": "3.3.0",
"esbuild": "0.19.1",
"eslint": "^8.47.0",
"eslint-plugin-json": "^3.1.0",
"obsidian": "latest",
"stylelint": "^15.10.2",
"stylelint-config-idiomatic-order": "^9.0.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-declaration-block-no-ignored-properties": "^2.7.0",
"stylelint-gamut": "^1.3.3",
"stylelint-high-performance-animation": "^1.9.0",
"stylelint-no-browser-hacks": "^1.2.1",
"stylelint-no-nested-media": "^0.1.0",
"stylelint-no-unsupported-browser-features": "^7.0.0",
"stylelint-order": "^6.0.3",
"stylelint-plugin-defensive-css": "^0.8.1",
"stylelint-stylistic": "^0.4.3",
"stylelint-use-logical-spec": "^5.0.0",
"tslib": "2.6.1",
"typescript": "5.1.6"
@ -38,8 +46,15 @@
"@lezer/highlight": "^1.1.6",
"@simonwep/pickr": "^1.8.2",
"colortranslator": "^3.0.2",
"remark-parse": "^10.0.2",
"unified": "^10.1.2",
"unist-util-visit": "^5.0.0"
}
"hast-util-from-html": "^2.0.1",
"hast-util-to-html": "^9.0.0",
"unist-util-visit-parents": "^6.0.1"
},
"contributors": [
"Mayuran Visakan <mayuran.k.v@gmail.com>",
"mugiwara85 <65603765+mugiwara85@users.noreply.github.com>",
"Zsolt Szalai <kampimester@gmail.com>",
"Dimava <dimava2@ya.ru>",
"Michael Naumov <mnaoumov@gmail.com>"
]
}

View file

@ -1,7 +1,7 @@
import { MarkdownSectionInformation, CachedMetadata, sanitizeHTMLToDom, FrontMatterCache, MarkdownRenderer, Component } from "obsidian";
import {unified} from "unified";
import {visit} from "unist-util-visit";
import remarkParse from "remark-parse";
import { visitParents } from "unist-util-visit-parents";
import { fromHtml } from "hast-util-from-html";
import { toHtml } from "hast-util-to-html";
import CodeStylerPlugin from "./main";
import { TRANSITION_LENGTH } from "./Settings";
@ -224,7 +224,7 @@ function getPreClasses(codeblockParameters: CodeblockParameters, dynamic: boolea
if (codeblockParameters.lineUnwrap.alwaysEnabled)
preClassList.push(codeblockParameters.lineUnwrap.activeWrap?"unwrapped-inactive":"unwrapped");
else if (codeblockParameters.lineUnwrap.alwaysDisabled)
preClassList.push("unwrapped");
preClassList.push("wrapped");
}
return preClassList;
}
@ -235,28 +235,23 @@ function decorateCodeblockLines(codeblockCodeElement: HTMLElement, codeblockPara
});
}
function getCodeblockLines(codeblockCodeElement: HTMLElement): Array<string> {
function escapeHTML(plaintext: string) {
return plaintext.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");
}
const tree = unified().use(remarkParse).parse(codeblockCodeElement.innerHTML.replace(/\n/g,"<br>"));
const stack: Array<string> = [];
let codeblockHTML = "";
visit(tree,["text","html"],(node)=>{
if (node.type === "html" && node.value !== "<br>") {
if (node.value.startsWith("<span"))
stack.push(node.value);
else if (node.value.startsWith("</span"))
stack.pop();
} else if (node.type === "html" && node.value === "<br>")
node.value = "</span>".repeat(stack.length)+"<br>"+stack.join("");
else if (node.type === "text")
node.value = escapeHTML(node.value);
if ("value" in node)
codeblockHTML += node.value;
const htmlTree = fromHtml(codeblockCodeElement.innerHTML.replace(/\n/g,"<br>"),{fragment: true});
let codeblockHTML = codeblockCodeElement.innerHTML;
visitParents(htmlTree,["text","element"],(node,ancestors)=>{
if (node.type === "element" && node.tagName === "br") {
if (ancestors.length >= 2) {
codeblockHTML = codeblockHTML.replace(/\n/,ancestors.slice(1).reduce((result,element)=>{
const elementCopy = structuredClone(element);
elementCopy.children = [];
const splitTag = toHtml(elementCopy).split(/(?<=>)(?=<\/)/);
return splitTag.splice(-1)+result+splitTag.join("");
},"<br>"));
} else
codeblockHTML = codeblockHTML.replace(/\n/,"<br>");
}
});
let codeblockLines = codeblockHTML.split("<br>");
if (codeblockLines.length == 1)
if (codeblockLines.length === 1)
codeblockLines = ["",""];
codeblockCodeElement.innerHTML = "";
return codeblockLines;

View file

@ -381,10 +381,15 @@ pre.code-styler-pre .code-styler-line-text {
/** Scroll Bar */
pre.code-styler-pre::-webkit-scrollbar,
pre.code-styler-pre > code::-webkit-scrollbar {
width: var(--code-padding) !important;
height: var(--code-padding) !important;
width: var(--code-padding);
height: var(--code-padding);
background-color: var(--code-styler-codeblock-background-colour);
}
pre.code-styler-pre::-webkit-scrollbar-thumb,
pre.code-styler-pre > code::-webkit-scrollbar-thumb {
border-radius: 999px;
background-color: var(--background-modifier-border);
}
pre.code-styler-pre.code-styler-collapsed::-webkit-scrollbar,
pre.code-styler-pre.code-styler-collapsed code::-webkit-scrollbar {
display: none;

File diff suppressed because one or more lines are too long

View file

@ -24,4 +24,4 @@ writeFileSync("CHANGELOG.md",changelog.replace(/## \[Unreleased\]/,`## [Unreleas
// Push to origin
exec(`gitall "Ready release $npm_package_version" && git tag -a $npm_package_version -F- <<EOF && git push origin $npm_package_version
$release_notes
EOF`,(error,stdout,stderr)=>console.log(error));
EOF`,(error)=>console.log(error));