fix(docs-infra): always default to no linenums in <aio-code> (#31674)
Previously, `linenums` defaulted to true if the content was more than 10 lines long and false otherwise. Since in most cases linenums add unnecessary visual noise, this commit changes `linenums` to always default to false (regardless of the size of the content). It can be still be turned on by explicitly setting to true or a number. PR Close #31674
This commit is contained in:
committed by
Miško Hevery
parent
3d7303efc0
commit
dd0be7feb7
@@ -5,12 +5,6 @@ import { CopierService } from 'app/shared/copier.service';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
/**
|
||||
* If linenums is not set, this is the default maximum number of lines that
|
||||
* an example can display without line numbers.
|
||||
*/
|
||||
const DEFAULT_LINE_NUMS_COUNT = 10;
|
||||
|
||||
/**
|
||||
* Formatted Code Block
|
||||
*
|
||||
@@ -170,9 +164,7 @@ export class CodeComponent implements OnChanges {
|
||||
typeof this.linenums === 'string' ? parseInt(this.linenums, 10) :
|
||||
this.linenums;
|
||||
|
||||
// if no linenums, enable line numbers if more than one line
|
||||
return linenums == null || isNaN(linenums as number) ?
|
||||
(code.match(/\n/g) || []).length > DEFAULT_LINE_NUMS_COUNT : linenums;
|
||||
return (linenums != null) && !isNaN(linenums as number) && linenums;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user