mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
docs(docs-infra): fix heading ID generation and display
Ensures that custom heading IDs are properly handled
This commit is contained in:
committed by
Andrew Kushnir
parent
fd293d3397
commit
dd15efb7c3
@@ -104,6 +104,10 @@ describe('markdown to html', () => {
|
||||
|
||||
expect(h2HeaderId).toBe('my-custom-id');
|
||||
expect(h2AnchorHref).toBe(`#${h2HeaderId}`);
|
||||
|
||||
// Verify that the custom ID syntax is removed from the displayed text
|
||||
expect(h2Anchor?.textContent?.trim()).toBe('My heading');
|
||||
expect(h2Anchor?.textContent).not.toContain('{#');
|
||||
});
|
||||
|
||||
it('should be able to parse heading with a valid tag in a code block', () => {
|
||||
|
||||
@@ -34,7 +34,9 @@ export function headingRender(
|
||||
|
||||
const link = customId ?? getIdFromHeading(headingText);
|
||||
|
||||
const label = parsedText.replace(/`(.*?)`/g, '<code>$1</code>');
|
||||
// Replace code backticks and remove custom ID syntax from the displayed label
|
||||
let label = parsedText.replace(/`(.*?)`/g, '<code>$1</code>');
|
||||
label = label.replace(/{#\s*[\w-]+\s*}/g, '').trim();
|
||||
const normalizedLabel = label.replace(/<\/?code>/g, '');
|
||||
|
||||
return `
|
||||
|
||||
@@ -222,7 +222,7 @@ Each parameter is written as an attribute prefixed with `let-` with a value matc
|
||||
</ng-template>
|
||||
```
|
||||
|
||||
### Using `NgTemplateOutlet`
|
||||
### Using `NgTemplateOutlet` {#using-ngtemplateoutlet-with-parameters}
|
||||
|
||||
You can bind a context object to the `ngTemplateOutletContext` input:
|
||||
|
||||
@@ -234,11 +234,11 @@ You can bind a context object to the `ngTemplateOutletContext` input:
|
||||
<ng-container [ngTemplateOutlet]="myFragment" [ngTemplateOutletContext]="{topping: 'onion'}" />
|
||||
```
|
||||
|
||||
### Using `ViewContainerRef`
|
||||
### Using `ViewContainerRef` {#using-viewcontainerref-with-parameters}
|
||||
|
||||
You can pass a context object as the second argument to `createEmbeddedView`:
|
||||
|
||||
```angular-ts
|
||||
```ts
|
||||
this.viewContainer.createEmbeddedView(this.myFragment, {topping: 'onion'});
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user