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

Add list fragment shorthand #26

Merged
merged 6 commits into from
Feb 22, 2019

Conversation

mrmanc
Copy link
Collaborator

@mrmanc mrmanc commented Feb 5, 2019

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.

Copy link
Contributor

@infotexture infotexture left a 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.

README.md Outdated Show resolved Hide resolved
@infotexture
Copy link
Contributor

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.
@mrmanc
Copy link
Collaborator Author

mrmanc commented Feb 12, 2019

GitPitch implements this with proprietary magic tokens inserted before and after the list: https://gitpitch.com/docs/markdown-features/list-fragments/

Interesting… hadn’t seen that service!

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.

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! :)

mrmanc and others added 3 commits February 12, 2019 21:00
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
@mrmanc
Copy link
Collaborator Author

mrmanc commented Feb 22, 2019

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 mrmanc merged commit 50e01b0 into dploeger:master Feb 22, 2019
@infotexture
Copy link
Contributor

@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 + markup option to “reveal” fragments incrementally. 🙏 💯

@mrmanc
Copy link
Collaborator Author

mrmanc commented Feb 22, 2019

@mrmanc Thanks for implementing this, should be really easy to use.

Awesome!

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 + markup option to “reveal” fragments incrementally. 🙏 💯

Absolutely no need to apologise! Everyone has $dayjob etc and I’ll be grateful for any feedback whenever it arises! 🙌

@infotexture
Copy link
Contributor

Tested today after merging the latest changes to my project branch, + works fine. 👍

@mrmanc mrmanc deleted the add-list-fragment-shortcut branch May 8, 2019 19:32
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.

3 participants