mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
fc01deeefd
* chore(deps-dev): bump oxlint-tsgolint from 0.14.2 to 0.22.1 Bumps [oxlint-tsgolint](https://github.com/oxc-project/tsgolint) from 0.14.2 to 0.22.1. - [Release notes](https://github.com/oxc-project/tsgolint/releases) - [Commits](https://github.com/oxc-project/tsgolint/compare/v0.14.2...v0.22.1) --- updated-dependencies: - dependency-name: oxlint-tsgolint dependency-version: 0.22.1 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * chore: Switch tsconfig to bundler resolution for tsgolint 0.22.1 oxlint-tsgolint 0.22.1 removed support for moduleResolution=node10 (the alias for "node"). Switch to "bundler" with resolvePackageJsonExports disabled so packages whose exports field omits a types condition still resolve. Update markdown-it type imports to sub-paths since the package's .d.mts entry only re-exports a subset of named types. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: Resolve type-aware lint errors caught by tsgolint 0.22.1 oxlint-tsgolint 0.22.1 catches several await-thenable, no-floating-promises, and no-meaningless-void-operator cases the prior 0.14.2 missed: - Drop redundant inner `await` from Promise.all([await x, await y]) call sites so the array entries are real Promises rather than already-resolved values. - Replace Promise.all wrappers around synchronous presenters (presentEvent, presentTemplate, presentPublicTeam) with plain map / direct calls. - Wrap non-promise branches of ternaries inside Promise.all with Promise.resolve so the array remains thenable across both arms. - Add `void` to the unawaited provider.connect() in the auth-failed retry chain, and remove `void` from the disconnect() call which returns void. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
82 lines
2.3 KiB
TypeScript
82 lines
2.3 KiB
TypeScript
import type MarkdownIt from "markdown-it";
|
|
import type Token from "markdown-it/lib/token.mjs";
|
|
|
|
function isOldHardBreak(token: Token) {
|
|
return token.type === "text" && token.content === "\\";
|
|
}
|
|
|
|
/** Markdown plugin to convert old encoded hard breaks to paragraphs */
|
|
export default function markdownBreakToParagraphs(md: MarkdownIt) {
|
|
md.core.ruler.after("inline", "hardbreaks", (state) => {
|
|
const tokens = state.tokens;
|
|
|
|
// iterate through tokens and convert hardbreak tokens to br tokens
|
|
for (let i = 0; i < tokens.length; i++) {
|
|
const token = tokens[i];
|
|
|
|
if (token.children) {
|
|
for (let j = 0; j < token.children.length; j++) {
|
|
const child = token.children[j];
|
|
|
|
if (child.type === "hardbreak") {
|
|
// convert hardbreak token to br token, we don't care about the difference
|
|
child.type = "br";
|
|
child.tag = "br";
|
|
child.nesting = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
});
|
|
|
|
// insert a new rule after the "inline" rules are parsed
|
|
md.core.ruler.after("inline", "breaks", (state) => {
|
|
const tokens = state.tokens;
|
|
|
|
// work backwards through the tokens and find text that looks like a br
|
|
for (let i = tokens.length - 1; i > 0; i--) {
|
|
const tokenChildren = tokens[i].children || [];
|
|
const matches = tokenChildren.filter(isOldHardBreak);
|
|
|
|
if (matches.length) {
|
|
let token;
|
|
|
|
const nodes: Token[] = [];
|
|
const children = tokenChildren.filter(
|
|
(child) => !isOldHardBreak(child)
|
|
);
|
|
|
|
let count = matches.length;
|
|
if (children.length) {
|
|
count++;
|
|
}
|
|
|
|
for (let j = 0; j < count; j++) {
|
|
const isLast = j === count - 1;
|
|
|
|
token = new state.Token("paragraph_open", "p", 1);
|
|
nodes.push(token);
|
|
|
|
const text = new state.Token("text", "", 0);
|
|
text.content = "";
|
|
|
|
token = new state.Token("inline", "", 0);
|
|
token.level = 1;
|
|
token.children = isLast ? [text, ...children] : [text];
|
|
token.content = "";
|
|
nodes.push(token);
|
|
|
|
token = new state.Token("paragraph_close", "p", -1);
|
|
nodes.push(token);
|
|
}
|
|
|
|
tokens.splice(i - 1, 3, ...nodes);
|
|
}
|
|
}
|
|
|
|
return false;
|
|
});
|
|
}
|