fix(docs-infra): do not auto-link code in bash and json snippets (#33877)
Previously any code block, which was not marked with `no-auto-link` css class would have its contents auto-linked to API pages. Sometimes this results in false positive links being generated. This is problematic for triple backticked blocks, which cannot provide the `no-auto-link` CSS class to prevent the linking. This commit fixes the problem by allowing the auto-linker to be configured not to auto-link code blocks that have been marked with an "ignored" language. By default these are `bash` and `json`. Triple backticked blocks are able to specify the language directly after the first set of triple backticks. Fixes #33859 PR Close #33877
This commit is contained in:

committed by
Alex Rickabaugh

parent
526537fefe
commit
06bca0cc66
@ -168,4 +168,11 @@ describe('autoLinkCode post-processor', () => {
|
||||
processor.$process([doc]);
|
||||
expect(doc.renderedContent).toEqual('<code class="no-auto-link">MyClass</code>');
|
||||
});
|
||||
|
||||
it('should ignore code blocks that are marked with an "ignored" language', () => {
|
||||
aliasMap.addDoc({docType: 'class', id: 'MyClass', aliases: ['MyClass'], path: 'a/b/myclass'});
|
||||
const doc = {docType: 'test-doc', renderedContent: '<code language="bash">MyClass</code>'};
|
||||
processor.$process([doc]);
|
||||
expect(doc.renderedContent).toEqual('<code language="bash">MyClass</code>');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user