Skip to content

feat: Add support for checkbox inputs in markdown with tests ☑️ - #9

Open
sanjaiyan-dev wants to merge 3 commits into
SoonIter:mainfrom
sanjaiyan-dev:sanjaiyan-react-markdown-add-input
Open

sanjaiyan-dev wants to merge 3 commits into
SoonIter:mainfrom
sanjaiyan-dev:sanjaiyan-react-markdown-add-input

Conversation

@sanjaiyan-dev

Copy link
Copy Markdown

Hi,

Added support for rendering checkbox inputs properly so task lists can output as [x] or [ ] . It checks both checked and defaultChecked props, and other input types are ignored as empty strings.

Also added a test case covering checked, defaultChecked, unchecked, and ignored inputs. All tests are passing.

Please have a look and let me know if any changes are needed. Thanks :)

Comment thread src/react/render.ts
if (props.type === 'checkbox') {
return props.checked || props.defaultChecked ? '[x] ' : '[ ] ';
}
return '';

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Suggested change
return '';
return getChildrenMarkdown();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi, I initially thought that returning an empty string would be correct because the input tag is a self-closing tag when executing getChildrenMarkdown(). I apologize for the inconvenience.

@sanjaiyan-dev

Copy link
Copy Markdown
Author

Hi @SoonIter, could you approve the CI workflow and take a look at this when you get a chance? I needed checkbox support for a project I'm working on, so I figured I'd send a PR. No rush, just let me know if anything needs changing

This branch has not been deployed

No deployments
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.

1 participant