diff --git a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js
index 589af005bf..7ed9f89b24 100644
--- a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js
+++ b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js
@@ -24,15 +24,19 @@ module.exports = function autoLinkCode(getDocFromAlias) {
autoLinkCodeImpl.docTypes = [];
autoLinkCodeImpl.customFilters = [];
autoLinkCodeImpl.codeElements = ['code'];
+ autoLinkCodeImpl.ignoredLanguages = ['bash', 'sh', 'shell', 'json', 'markdown'];
return autoLinkCodeImpl;
function autoLinkCodeImpl() {
return (ast) => {
visit(ast, 'element', (node, ancestors) => {
- // Only interested in code elements that are not inside links
+ // Only interested in code elements that:
+ // * do not have `no-auto-link` class
+ // * do not have an ignored language
+ // * are not inside links
if (autoLinkCodeImpl.codeElements.some(elementType => is(node, elementType)) &&
- (!node.properties.className ||
- node.properties.className.indexOf('no-auto-link') === -1) &&
+ (!node.properties.className || !node.properties.className.includes('no-auto-link')) &&
+ !autoLinkCodeImpl.ignoredLanguages.includes(node.properties.language) &&
ancestors.every(ancestor => !is(ancestor, 'a'))) {
visit(node, 'text', (node, ancestors) => {
// Only interested in text nodes that are not inside links
diff --git a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js
index fa8e3a740d..59281a5a73 100644
--- a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js
+++ b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js
@@ -168,4 +168,11 @@ describe('autoLinkCode post-processor', () => {
processor.$process([doc]);
expect(doc.renderedContent).toEqual('MyClass
');
});
+
+ 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: 'MyClass
'};
+ processor.$process([doc]);
+ expect(doc.renderedContent).toEqual('MyClass
');
+ });
});