Skip to content
This repository has been archived by the owner on Jun 1, 2020. It is now read-only.

Try to generate better playground code #39

Closed
wants to merge 1 commit into from
Closed

Try to generate better playground code #39

wants to merge 1 commit into from

Conversation

noxer
Copy link
Contributor

@noxer noxer commented Oct 11, 2018

Sorry for the format change.

This PR adds the functionality to identify code sections in a post and generate a useful code for the playground. The non-code parts are inserted as comments.

I've not used the strings.Builder for backwards compatibility reasons. I can add it if required.

Happy Hacktoberfest,
Tim

@noxer
Copy link
Contributor Author

noxer commented Oct 11, 2018

Fixes #38

// considered code and pasted as-is.
func postToPlayground(text string) string {
var pg string
parts := strings.Split(text, "```")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we just bail if this is < 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, I've seen a few posts where the author forgot the second ```.

Copy link
Collaborator

Choose a reason for hiding this comment

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

True, good point. 👍

@dlsniper
Copy link
Contributor

dlsniper commented Feb 6, 2019

Sorry, this won't be merged as the intention is to get people to use the playground when appropriate. Thank you for your time and help.

@dlsniper dlsniper closed this Feb 6, 2019
@theckman
Copy link
Collaborator

theckman commented Feb 6, 2019

@dlsniper I'm not sure I follow. This will still encourage people to use the playground, but would generate more functional code when the snippet is pasted to the playground.

As someone who spends a lot of his time helping on Slack via a mobile phone, this is a common pain point for me.

Would you be able to share more context around your concerns? I am strongly in favor of re-opening this PR with the intent to merge.

@dlsniper
Copy link
Contributor

dlsniper commented Feb 6, 2019

@theckman we discussed this extensively to the point that I should write a bot command to reply to this.

The purpose of this is not to make the bot smarter, but the humans. The fact that humans paste large swats of code/text freely and break conversations is more annoying than a message telling the user to stop doing it.

So if you are annoyed by a single line message, I find it surprising that messages larger than 10 lines don't annoy you.

@theckman
Copy link
Collaborator

theckman commented Feb 6, 2019

@dlsniper sure, I agree on the intent. But when it happens, it doesn't make sense that it generates broken code if someone has text with the code snippet.

If you're not in favor of merging this, would you be amenable to a PR just removing the functionality and putting in place an alias?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants