-
-
Notifications
You must be signed in to change notification settings - Fork 735
fix: Markdown link parsing #2960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you! |
This still isn't quite right... I was looking at reducing the number of test cases, picking key things to check as it slowed down the tests by about 15% on my machine to generate a ludicrous number of checks (3.5 -> 4 seconds) and found these cases, which are incorrectly captured as links:
|
Can you elaborate? Handling of those inputs looks correct to me: code$ npx tsx -e '
import { lexCommentString } from "./src/lib/converter/comments/rawLexer.ts";
import { lexBlockComment } from "./src/lib/converter/comments/blockLexer.ts";
import { parseCommentString, parseComment } from "./src/lib/converter/comments/parser.ts";
import { FileRegistry } from "./src/lib/models/FileRegistry.ts";
import { TestLogger } from "./src/test/TestLogger.ts";
import { MinimalSourceFile } from "#utils";
const inputs = ["[\n\n](./no)", "[\n\n`code`](./no)", "[\n\ntext](./no)"];
inputs.push(inputs.join("\n\n"));
const makeParse = (lex, parse) => {
const config = {
blockTags: new Set("@param @remarks @module @inheritDoc @defaultValue".split(" ")),
inlineTags: new Set(["@link"]),
modifierTags: new Set("@public @private @protected @readonly @enum @event @packageDocumentation".split(" ")),
jsDocCompatibility: { defaultTag: true, exampleTag: true, ignoreUnescapedBraces: false, inheritDocTag: false },
suppressCommentWarningsInDeclarationFiles: false,
useTsLinkResolution: false,
commentStyle: "jsdoc",
};
return text => {
const files = new FileRegistry();
const logger = new TestLogger();
const content = lex(text);
const sourceFile = new MinimalSourceFile(text, "/dev/zero");
const result = parse(content, config, sourceFile, logger, files);
logger.expectNoOtherMessages();
return result;
};
};
const parseRaw = makeParse(lexCommentString, parseCommentString);
const parseBlockComment = makeParse(lexBlockComment, parseComment);
const embedInComment = input => {
const lines = input.split("\n");
const embedded = `/**\n${lines.map(line => " * " + line).join("\n")}\n */`;
return embedded;
};
for (const rawInput of inputs) {
console.log("\n\n==== raw input");
console.log(rawInput);
console.log("==== raw parse");
console.log(parseRaw(rawInput));
const commentInput = embedInComment(rawInput);
console.log("\n==== comment input");
console.log(commentInput);
console.log("==== comment parse");
console.log(parseBlockComment(commentInput));
}
' result
|
Sorry about that! I had apparently added a test case with just one newline, but didn't have different links, so I didn't realize it was that link that cased it. |
Fixes #2959
Improves alignment with CommonMark, although does not include support for unescaped nesting.
Can be reviewed commit-by-commit.