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 92f5cf06ee..5285de6e62 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 @@ -30,7 +30,9 @@ module.exports = function autoLinkCode(getDocFromAlias) { return (ast) => { visit(ast, 'element', (node, ancestors) => { // Only interested in code elements that are not inside links - if (autoLinkCodeImpl.codeElements.some(elementType => is(node, elementType)) && + if (autoLinkCodeImpl.codeElements.some(elementType => + is(node, elementType)) && + (!node.properties.className || node.properties.className.indexOf('no-auto-link') === -1) && 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 c5fabf43d3..414bac60fd 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 @@ -109,4 +109,11 @@ describe('autoLinkCode post-processor', () => { processor.$process([doc]); expect(doc.renderedContent).toEqual('MyClass'); }); + + it('should ignore code blocks that are marked with a `no-auto-link` class', () => { + 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'); + }); });