Skip to content

WIP Use google-modes for syntax highlight #68

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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 examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ For instance following block of Kotlin code:
class Contact(val id: Int, var email: String)

fun main(args: Array<String>) {
val contact = Contact(1, "mary@gmail.com")
println(contact.id)
val contact = Contact(1, "mary@gmail.com $args, ${args.size}")
println(contact.id)
}
```

Expand All @@ -43,7 +43,7 @@ Turns into:
class Contact(val id: Int, var email: String)

fun main(args: Array<String>) {
val contact = Contact(1, "mary@gmail.com")
val contact = Contact(1, "mary@gmail.com $args, ${args.size}")
println(contact.id)
}
```
Expand All @@ -59,7 +59,7 @@ You can also change the playground theme or disable run button using `theme` and

```kotlin
fun main(args: Array<String>) {
println("Hello World!")
println("Hello World! $args, ${args.size}")
}
```

Expand All @@ -71,7 +71,7 @@ Or theme `darcula`

```kotlin
fun main(args: Array<String>) {
println("Hello World!")
println("Hello World! $args, ${args.size}")
}
```

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"files": [
"dist"
],
"resolutions": {
"**/codemirror": "^5.48.4"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "~7.4.4",
Expand All @@ -23,6 +26,7 @@
"babel-plugin-async-to-promises": "^1.0.5",
"ci-publish": "^1.3.1",
"codemirror": "^5.48.4",
"codemirror-grammar-mode": "^0.1.9",
"css-loader": "2.1.1",
"debounce": "^1.2.0",
"deepmerge": "^1.5.0",
Expand All @@ -32,7 +36,9 @@
"fast-async": "7",
"flatten": "^1.0.2",
"github-markdown-css": "^3.0.1",
"google_modes": "git+https://github.com/codemirror/google-modes.git",
"html-webpack-plugin": "^3.2.0",
"imports-loader": "^0.8.0",
"is-empty-object": "^1.1.1",
"markdown-it": "^8.4.2",
"markdown-it-highlightjs": "^3.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/executable-code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'codemirror/addon/comment/continuecomment'
import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/shell/shell';
import 'codemirror/mode/swift/swift';
import 'google_modes/dist/kotlin';
import merge from 'deepmerge';
import Set from 'es6-set/polyfill';
import defaultConfig, {API_URLS} from '../config';
Expand Down Expand Up @@ -51,7 +52,7 @@ const ATTRIBUTES = {

const MODES = {
JAVA: "text/x-java",
KOTLIN: "text/x-kotlin",
KOTLIN: "google-kotlin",
JS: "text/javascript",
GROOVY: "text/x-groovy",
XML: "text/html",
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ module.exports = (params = {}) => {
include: path.resolve(__dirname, 'src'),
loader: 'babel-loader'
},
{
test: require.resolve("codemirror-grammar-mode"),
use: "imports-loader?CodeMirror=codemirror"
},
{
test: /\.monk$/,
loader: 'monkberry-loader'
Expand Down
21 changes: 20 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,12 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"

codemirror@^5.48.4:
codemirror-grammar-mode@^0.1.9:
version "0.1.9"
resolved "https://registry.yarnpkg.com/codemirror-grammar-mode/-/codemirror-grammar-mode-0.1.9.tgz#2cd4f376bb5b8ed05071f5f471389aef47f0332d"
integrity sha512-F9EQ8aE2QU7Uo3rvGMs05DpAqN3muNAMvJcw27usxdyPLw7vWhHeUIuTAzo0541vDLV+JaoJItWbGo3QmMBmFw==

codemirror@^5.42.2, codemirror@^5.48.4:
version "5.48.4"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.48.4.tgz#4210fbe92be79a88f0eea348fab3ae78da85ce47"
integrity sha512-pUhZXDQ6qXSpWdwlgAwHEkd4imA0kf83hINmUEzJpmG80T/XLtDDEzZo8f6PQLuRCcUQhmzqqIo3ZPTRaWByRA==
Expand Down Expand Up @@ -2923,6 +2928,12 @@ globule@^1.0.0:
lodash "~4.17.10"
minimatch "~3.0.2"

"google_modes@git+https://github.com/codemirror/google-modes.git":
version "1.0.0"
resolved "git+https://github.com/codemirror/google-modes.git#85a10b3b46b921708a049cc643c27f4a1b4db404"
dependencies:
codemirror "^5.42.2"

got@^5.0.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/got/-/got-5.7.1.tgz#5f81635a61e4a6589f180569ea4e381680a51f35"
Expand Down Expand Up @@ -3266,6 +3277,14 @@ import-local@^2.0.0:
pkg-dir "^3.0.0"
resolve-cwd "^2.0.0"

imports-loader@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/imports-loader/-/imports-loader-0.8.0.tgz#030ea51b8ca05977c40a3abfd9b4088fe0be9a69"
integrity sha512-kXWL7Scp8KQ4552ZcdVTeaQCZSLW+e6nJfp3cwUMB673T7Hr98Xjx5JK+ql7ADlJUvj1JS5O01RLbKoutN5QDQ==
dependencies:
loader-utils "^1.0.2"
source-map "^0.6.1"

imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
Expand Down