Skip to content

Use highlight js #1489

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

Merged
merged 5 commits into from
Sep 12, 2017
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ Some examples of likely triage priorities:

Please see the [dartdoc license][].

Generated docs include:

* Highlight.js -
[LICENSE](https://github.com/isagalaev/highlight.js/blob/master/LICENSE)
* With `github.css` (c) Vasily Polovnyov <[email protected]>

[GitHub Issue Tracker]: https://github.com/dart-lang/dartdoc/issues
[contributor docs]: https://github.com/dart-lang/dartdoc/blob/master/CONTRIBUTING.md
[dartdoc license]: https://github.com/dart-lang/dartdoc/blob/master/LICENSE
99 changes: 99 additions & 0 deletions lib/resources/github.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*

github.com style (c) Vasily Polovnyov <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please indicate somewhere in LICENSE/README where this and other new third-party libraries included come from (including URLs) and their licensing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


*/

.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: #333;
background: #f8f8f8;
}

.hljs-comment,
.hljs-quote {
color: #998;
font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
color: #333;
font-weight: bold;
}

.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr {
color: #008080;
}

.hljs-string,
.hljs-doctag {
color: #d14;
}

.hljs-title,
.hljs-section,
.hljs-selector-id {
color: #900;
font-weight: bold;
}

.hljs-subst {
font-weight: normal;
}

.hljs-type,
.hljs-class .hljs-title {
color: #458;
font-weight: bold;
}

.hljs-tag,
.hljs-name,
.hljs-attribute {
color: #000080;
font-weight: normal;
}

.hljs-regexp,
.hljs-link {
color: #009926;
}

.hljs-symbol,
.hljs-bullet {
color: #990073;
}

.hljs-built_in,
.hljs-builtin-name {
color: #0086b3;
}

.hljs-meta {
color: #999;
font-weight: bold;
}

.hljs-deletion {
background: #fdd;
}

.hljs-addition {
background: #dfd;
}

.hljs-emphasis {
font-style: italic;
}

.hljs-strong {
font-weight: bold;
}
2 changes: 2 additions & 0 deletions lib/resources/highlight.pack.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion lib/resources/prettify.css

This file was deleted.

32 changes: 0 additions & 32 deletions lib/resources/prettify.js

This file was deleted.

19 changes: 19 additions & 0 deletions lib/resources/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# highlight.js

Generated from https://highlightjs.org/download/ on 2017-08-30

Included languages:

* bash
* css
* dart
* java
* javascript
* json
* markdown
* objectivec
* ruby - dragged in by `yaml` - 🙄
* shell
* swift
* xml - includes html
* yaml
2 changes: 1 addition & 1 deletion lib/resources/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function initSearch() {
}

document.addEventListener("DOMContentLoaded", function() {
prettyPrint();
hljs.initHighlightingOnLoad();
initSideNav();
initSearch();
});
4 changes: 2 additions & 2 deletions lib/src/html/resources.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const List<String> resource_names = const [
'package:dartdoc/resources/css/bootstrap.css.map',
'package:dartdoc/resources/css/bootstrap.min.css',
'package:dartdoc/resources/favicon.png',
'package:dartdoc/resources/prettify.css',
'package:dartdoc/resources/prettify.js',
'package:dartdoc/resources/github.css',
'package:dartdoc/resources/highlight.pack.js',
'package:dartdoc/resources/script.js',
'package:dartdoc/resources/styles.css',
'package:dartdoc/resources/typeahead.bundle.min.js'
Expand Down
1 change: 0 additions & 1 deletion lib/src/markdown_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ class MarkdownDocument extends md.Document {
}

bool specifiesLanguage = pre.classes.isNotEmpty;
pre.classes.add('prettyprint');
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you mention a bit more about how this is replaced?

Copy link
Member Author

Choose a reason for hiding this comment

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

prettyprint was used by the pretty print library to find elements to style at runtime.

highlight.js looks at all code blocks with language-XYZ – no prettyprint needed

// Assume the user intended Dart if there are no other classes present.
if (!specifiesLanguage) pre.classes.add('language-dart');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="static-assets/typeahead.bundle.min.js"></script>
<script src="static-assets/prettify.js"></script>
<script src="static-assets/highlight.pack.js"></script>
<script src="static-assets/URI.js"></script>
<script src="static-assets/script.js"></script>
<!-- footer placeholder -->
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{/htmlBase}}

<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500,400i,400,300|Source+Sans+Pro:400,300,700" rel="stylesheet">
<link rel="stylesheet" href="static-assets/prettify.css">
<link rel="stylesheet" href="static-assets/github.css">
<link rel="stylesheet" href="static-assets/styles.css">
<link rel="icon" href="static-assets/favicon.png">

Expand Down
Loading