Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: render heading support restricted level #28

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

StrivingRabbit
Copy link

No description provided.

src/render.ts Outdated
@@ -14,6 +14,7 @@
* @group render_utils
*/
export function heading(text: string, level: number): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should restrict the type for level as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean

Suggested change
export function heading(text: string, level: number): string {
export function heading(text: string, level: 1|2|3|4|5|6): string {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't pin all my hopes on typescript, I will if you want.

Copy link
Member

@pi0 pi0 Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also use |(number & {}) to make your life better? :p

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still want to use the number type and handle the level inside the function, So that it can be called recursively without error.

src/render.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants