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(toggle_checkbox): transform non-checkbox line into a checkbox #363

Merged
merged 4 commits into from
Jan 31, 2024

Conversation

anggerdeni
Copy link
Contributor

@anggerdeni anggerdeni commented Jan 31, 2024

toggle_checkbox function will transform a non-checkbox line into an (unchecked) checkbox by prepending - [ ] to the line. It will also respect whitespaces at the beginning of the line.

Sample cases:

before

some line
  some line with spacing

after

- [ ] some line
  - [ ] line with spacing

Closes #361

@anggerdeni anggerdeni changed the title feat(toggle_checkbox) transform non-checkbox line into a checkbox feat(toggle_checkbox): transform non-checkbox line into a checkbox Jan 31, 2024
Copy link
Owner

@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

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

When testing I noticed that if the line starts with "-" (with no checkbox), this will add a 2nd "-". Can we handle that case too?

@anggerdeni
Copy link
Contributor Author

anggerdeni commented Jan 31, 2024

Good point @epwalsh , that applies to all the other unordered list symbols as well. I've updated the code, the new behavior will simply change unordered list into checkbox

line1
 line2
  line3
- a
-  b
-   c
  - d
  -  e
  -   f
* g
*  h
*   i
  * j
  *  k
  *   l
+ m
+  n
+   o
  + p
  +  q
  +   r

will be transformed into

- [ ] line1
 - [ ] line2
  - [ ] line3
- [ ] a
- [ ]  b
- [ ]   c
  - [ ] d
  - [ ]  e
  - [ ]   f
- [ ] g
- [ ]  h
- [ ]   i
  - [ ] j
  - [ ]  k
  - [ ]   l
- [ ] m
- [ ]  n
- [ ]   o
  - [ ] p
  - [ ]  q
  - [ ]   r

Copy link
Owner

@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @anggerdeni

@epwalsh epwalsh merged commit 97f0cfe into epwalsh:main Jan 31, 2024
5 of 6 checks passed
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.

Enhance toggle_checkbox function to also convert non-checkbox lines into checkboxes
2 participants