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

Option to display copy buttons. #1050

Merged
merged 4 commits into from
Oct 17, 2019
Merged

Conversation

andymac-2
Copy link
Contributor

  • Added field to playpen data structure, book.toml
  • Communicate through window.playpen_copyable
  • Javascript updated to check before displaying copy buttons.

Fixes #1043

- Added field to playpen data structure
- Communicate through window.playpen_copyable
- Javascript updated to check before displaying copy buttons.
@andymac-2 andymac-2 marked this pull request as ready for review October 4, 2019 14:01
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Awesome! Just need a little changes.

src/config.rs Outdated
@@ -476,6 +476,8 @@ impl HtmlConfig {
pub struct Playpen {
/// Should playpen snippets be editable? Default: `false`.
pub editable: bool,
/// display the copy button
Copy link
Member

Choose a reason for hiding this comment

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

Uppercase the first letter might be better and more consistent across comments. Also, we love to document default values especially when it is not the default of that type.

Suggested change
/// display the copy button
/// Display the copy button. Default: `true`.

@@ -445,6 +445,9 @@ fn make_data(
data.insert("playpen_line_numbers".to_owned(), json!(true));
}
}
if html.playpen.copyable {
Copy link
Member

Choose a reason for hiding this comment

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

It should be html_config.

Suggested change
if html.playpen.copyable {
if html_config.playpen.copyable {

Also:
- update description of copyable in source code.
- update description of line_numbers (my last PR to this repository)
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Nice work! @Dylan-DPC this seems can be merged.

@Dylan-DPC-zz Dylan-DPC-zz merged commit e5f74b6 into rust-lang:master Oct 17, 2019
@andymac-2
Copy link
Contributor Author

Thank you!

Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
* Option to display copy buttons.

- Added field to playpen data structure
- Communicate through window.playpen_copyable
- Javascript updated to check before displaying copy buttons.

* html -> html_config

Also:
- update description of copyable in source code.
- update description of line_numbers (my last PR to this repository)
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.

[Feature Request] Copy code button should be optional
3 participants