-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add enrich_li_class for nested tasklist #29
Add enrich_li_class for nested tasklist #29
Conversation
it "must enrich task list parent 3" do | ||
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true) | ||
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return('- [O] This is a parent 3 line') | ||
expect(wiki_body.to_s).to match(/<li class="done3"> This is a parent 3 line<\/li>/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RegexpLiteral: Use %r around regular expression.
it "must enrich task list parent 2" do | ||
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true) | ||
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return('- [o] This is a parent 2 line') | ||
expect(wiki_body.to_s).to match(/<li class="done2"> This is a parent 2 line<\/li>/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RegexpLiteral: Use %r around regular expression.
it "must enrich task list parent 1" do | ||
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true) | ||
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return('- [.] This is a parent 1 line') | ||
expect(wiki_body.to_s).to match(/<li class="done1"> This is a parent 1 line<\/li>/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RegexpLiteral: Use %r around regular expression.
it "must enrich task list checked" do | ||
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true) | ||
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return('- [X] This is a checked line') | ||
expect(wiki_body.to_s).to match(/<li class="done4"> This is a checked line<\/li>/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RegexpLiteral: Use %r around regular expression.
it "must enrich task list unchecked" do | ||
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true) | ||
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return('- [ ] This is one line') | ||
expect(wiki_body.to_s).to match(/<li class="done0"> This is one line<\/li>/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RegexpLiteral: Use %r around regular expression.
Nice work! Especially if you're new to ruby :) Decisions decisions eh. I reckon, as Also, we don't currently propertly support task lists we're in the nice position of just being able to make it work how we want to. So, I reckon yip, lets go with #29 . If you're happy to tidy up the I did have a little play, and slightly tweaked the def enrich_li_class!
syms_hash = {" ]" => 0, ".]" => 1, "o]" => 2, "O]" => 3, "X]" => 4}
checkbox = /<li>\s*\[[\s.oOX]\]/
checkbox_start = /<li>\s*\[/
@result.gsub!(checkbox) do |m|
m.sub(checkbox_start, '<li class="done')
.sub(/[\s.oOX\]]*$/, syms_hash) << '">'
end
@result
end Again, don't really mind if you want to keep it as is. I slightly preferred the above as it's using the same regex Great work though :) Happy to merge, happy to wait if you want to try fix the code violations. Thanks! |
This intends to generate tasklist the same way vimwiki does for .wiki extensions. Allows for a visualization of progress in nested tasklists, and customization of the same via html templates
1fc9b09
to
2a4820a
Compare
Your version looks definitely tidier. Thanks for the suggestion! I added it and updated the rubocop checks as well. I gotta admit that I like this approach better just because I enjoy seeing those visuals in the HTML. |
I'll update the README and push out a new version in the next hour or so hopefully (assuming my daughter stays alseep ;) Thanks for the PR & discussion. |
This intends to generate tasklist the same way vimwiki does
for .wiki extensions. Allows for a visualization of
progress in nested tasklists, and customization of
the same via html templates