-
Notifications
You must be signed in to change notification settings - Fork 59
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 list fragment shorthand #26
Conversation
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.
I like the idea of simplifying the fragment shorthand, but the devil is in the syntax details.
It would be nice if it were possible to just treat any unordered list items that use the plus +
sign as fragments, but that's probably easier said than done, considering that's standard Markdown syntax.
GitPitch implements this with proprietary magic tokens inserted before and after the list: https://gitpitch.com/docs/markdown-features/list-fragments/ Where possible, I prefer the Reveal.js "magic comment" approach, so the Markdown source isn't littered with too much extra presentational markup when viewed on GitHub, but perhaps the implementation above proves useful in the search for a good compromise. |
This introduces some hacky Liquid code to get around the limitations of the filters available. It’s not possible to use regular expressions in replacements, so only replacing `+` at the start of a line requires looping over each line inspecting a substring of the line on each iteration. In addition it is not easy to iterate over each line. You have to first convert newlines to breaks, then split by those, then add the newlines back in to avoid impacting the formatting. This is considerable extra complexity but the trade-off is neater markup in the slides at the expense of less functional Liquid. I’ve removed the `-[+]` notation in favour of this simpler version.
Interesting… hadn’t seen that service!
I looked at that but don’t want to get into implementing a full-blown parser using Liquid—it wouldn’t be my language of choice! :) |
This code layout hopefully makes the logic more readable and might help people understand how to extend the syntax. To avoid introducing whitespace into the generated slide code, the flexibility of whitespace in the liquid tags has been exploited. Yes, it does remind me of this a bit ;) https://www.reddit.com/r/ProgrammerHumor/comments/2wrxyt/a_python_programmer_attempting_java/
Make list items starting with plus fragments
Marking the review as resolved as I’ve addressed the overlap with GFM task list syntax. I’m merging this PR but totally open to reverting it / changing it if others have input. |
@mrmanc Thanks for implementing this, should be really easy to use. Sorry I didn't have time to review & test earlier. I've been away from the project where I use this, but will return soon and look forward to using the new |
Awesome!
Absolutely no need to apologise! Everyone has |
Tested today after merging the latest changes to my project branch, |
This is a more controversial change, as it introduces two ways to do fragments. I wasn’t enjoying how messy the
<fragment/>
code looked in each list item, so I introduced-[+]
as a shorthand to replace-
. Open to input.