Skip to content

Commit

Permalink
Support multiline graphql descriptions (Fix PrismJS#2405)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Mabry committed May 27, 2020
1 parent 4fe0367 commit 93e6f0f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@
},
"graphql": {
"title": "GraphQL",
"optional": ["markdown"],
"owner": "Golmote"
},
"groovy": {
Expand Down
11 changes: 11 additions & 0 deletions components/prism-graphql.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
Prism.languages.graphql = {
'comment': /#.*/,
'multiline-string': {
pattern: /"""[\s\S]*?"""/,
greedy: true,
alias: 'string',
inside: {
'language-markdown': {
pattern: /[\s\S]+/,
inside: Prism.languages.markdown
}
}
},
'string': {
pattern: /"(?:\\.|[^\\"\r\n])*"/,
greedy: true
Expand Down
17 changes: 16 additions & 1 deletion examples/prism-graphql.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,19 @@ <h2>Keywords</h2>
id
name
profilePic(size: 50)
}</code></pre>
}</code></pre>

Markdown inside of descriptions require markdown to be loaded. On this page, checking Markdown before checking GraphQL should make the example below work properly.

<h2>Descriptions</h2>
<pre><code>"""
This is a multiline description
# Heading
[Prism](http://www.prismjs.com)

It can contain **Markdown
on multiple lines**
"""

"This is a single line description"
</code></pre>

0 comments on commit 93e6f0f

Please sign in to comment.