Skip to content

Commit 0f53804

Browse files
Revert highlight.js to 10.7 because of issue with callouts.
Add callout examples in code blocks.
1 parent ee49281 commit 0f53804

File tree

4 files changed

+80
-11
lines changed

4 files changed

+80
-11
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"gulp-uglify": "~3.0",
4545
"gulp-vinyl-zip": "~2.2",
4646
"handlebars": "~4.7",
47-
"highlight.js": "^11.0",
47+
"highlight.js": "^10.7",
4848
"highlightjs-cypher": "^1.1",
4949
"husky": "^4.3.0",
5050
"js-yaml": "~3.13",

preview-src/example.adoc

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,37 @@ console.log('hello')
201201
[source,js,role=noheader]
202202
console.log('hello')
203203

204-
=== Expand code block
204+
205+
== Reference lines
206+
207+
You can add number bubbles to reference specific lines by appending `<n>` to a line. It is advised to put them behind a line comment for the language the code is in.
208+
209+
[source,ruby]
210+
----
211+
require 'sinatra' <1>
212+
213+
get '/hi' do <2> <3>
214+
"Hello World!"
215+
end
216+
----
217+
<1> Library import
218+
<2> URL mapping
219+
<3> Response block
220+
221+
[source]
222+
----
223+
line of code // <1>
224+
line of code # <2>
225+
line of code ;; <3>
226+
line of code <!--4-->
227+
----
228+
<1> A callout behind a line comment for C-style languages.
229+
<2> A callout behind a line comment for Ruby, Python, Perl, etc.
230+
<3> A callout behind a line comment for Clojure.
231+
<4> A callout behind a line comment for XML or SGML languages like HTML.
232+
233+
234+
== Expand code block
205235

206236
Code blocks longer than 15 lines (+5 of tolerance) are collapsed, unless you add `role=nocollapse`
207237

src/js/vendor/highlight.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,45 @@
5252
})
5353
// add an alias, use properties syntax highlighter on conf
5454
hljs.registerLanguage('conf', require('highlight.js/lib/languages/properties'))
55-
hljs.registerLanguage('graphql', require('highlight.js/lib/languages/graphql'))
55+
hljs.registerLanguage('graphql', function (hljs) {
56+
return {
57+
aliases: ['gql'],
58+
keywords: {
59+
keyword:
60+
'query mutation subscription|10 type interface union scalar fragment|10 enum on ...',
61+
literal: 'true false null',
62+
},
63+
contains: [
64+
hljs.HASH_COMMENT_MODE,
65+
hljs.QUOTE_STRING_MODE,
66+
hljs.NUMBER_MODE,
67+
{
68+
className: 'type',
69+
begin: '[^\\w][A-Z][a-z]',
70+
end: '\\W',
71+
excludeEnd: true,
72+
},
73+
{
74+
className: 'literal',
75+
begin: '[^\\w][A-Z][A-Z]',
76+
end: '\\W',
77+
excludeEnd: true,
78+
},
79+
{ className: 'variable', begin: '\\$', end: '\\W', excludeEnd: true },
80+
{
81+
className: 'keyword',
82+
begin: '[.]{2}',
83+
end: '\\.',
84+
},
85+
{
86+
className: 'meta',
87+
begin: '@',
88+
end: '\\W',
89+
excludeEnd: true,
90+
},
91+
],
92+
illegal: /([;<']|BEGIN)/,
93+
}
94+
})
5695
hljs.highlightAll()
5796
})()

0 commit comments

Comments
 (0)