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

Remove the need for an "output" class. #845

Merged
merged 1 commit into from
Jan 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions plugins/command-line/prism-command-line.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@

.command-line-prompt > span:before {
color: #999;
content: "[" attr(data-user) "@" attr(data-host) "] $";
content: ' ';
display: block;
padding-right: 0.8em;
}

.command-line-prompt > span[data-user]:before {
content: "[" attr(data-user) "@" attr(data-host) "] $";
}

.command-line-prompt > span[data-user="root"]:before {
content: "[" attr(data-user) "@" attr(data-host) "] #";
}

.command-line-prompt > span[data-prompt]:before {
content: attr(data-prompt);
}

.command-line-prompt > span.output:before {
content: ' ';
}
5 changes: 4 additions & 1 deletion plugins/command-line/prism-command-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ Prism.hooks.add('complete', function (env) {

if (!isNaN(outputStart) && !isNaN(outputEnd)) {
for (var j = outputStart; j <= outputEnd && j <= prompt.children.length; j++) {
prompt.children[j - 1].className = 'output';
var node = prompt.children[j - 1];
node.removeAttribute('data-user');
node.removeAttribute('data-host');
node.removeAttribute('data-prompt');
Copy link
Member

Choose a reason for hiding this comment

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

How about something like:

["user", "host", "prompt"].forEach(function(attr) { node.removeAttribute("data-" + attr); });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my opinion, the original code is cleaner and easier to read. It's "nice" that it could be done in 1 line, but saving those 18 characters effectively adds 4 function calls and 3 string concatenations.

Copy link
Member

Choose a reason for hiding this comment

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

It’s not about doing it in one line, it's about removing repetition. Actually, I wouldn't do it in one line, I would format it as 3, for readability. Anyhow, no strong opinion here.

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/command-line/prism-command-line.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.