History

Fix merge conflict

Jasper van Merle committed 7 years ago

Commit 186932e2 parents 57232ce b34dbb2450 files · +6920 −1990Browse files

Showing the changes to assets/javascripts (37 of 450 files). Show all

Unified · Split

37 files
  1. assets/javascripts/app/app.coffee +21 −14
  2. assets/javascripts/app/appcache.coffee +0 −42
  3. assets/javascripts/app/config.coffee.erb +3 −0
  4. assets/javascripts/app/serviceworker.coffee +49 −0
  5. assets/javascripts/app/settings.coffee +34 −1
  6. assets/javascripts/app/shortcuts.coffee +3 −0
  7. assets/javascripts/app/update_checker.coffee +3 −3
  8. assets/javascripts/lib/cookies_store.coffee +5 −1
  9. assets/javascripts/lib/favicon.coffee +64 −0
  10. assets/javascripts/lib/license.coffee +1 −1
  11. assets/javascripts/lib/page.coffee +18 −2
  12. assets/javascripts/lib/util.coffee +4 −0
  13. assets/javascripts/models/doc.coffee +3 −1
  14. assets/javascripts/news.json +17 −0
  15. assets/javascripts/templates/error_tmpl.coffee +9 −12
  16. assets/javascripts/templates/notif_tmpl.coffee +6 −0
  17. assets/javascripts/templates/pages/about_tmpl.coffee +96 −31
  18. assets/javascripts/templates/pages/help_tmpl.coffee +3 −0
  19. assets/javascripts/templates/pages/offline_tmpl.coffee +9 −4
  20. assets/javascripts/templates/pages/root_tmpl.coffee.erb +3 −14
  21. assets/javascripts/templates/pages/settings_tmpl.coffee +8 −0
  22. assets/javascripts/tracking.js +27 −23
  23. assets/javascripts/vendor/fastclick.js +2 −2
  24. assets/javascripts/vendor/prism.js +633 −352
  25. assets/javascripts/vendor/raven.js +1 −1
  26. assets/javascripts/views/content/content.coffee +3 −0
  27. assets/javascripts/views/content/entry_page.coffee +2 −1
  28. assets/javascripts/views/content/offline_page.coffee +1 −0
  29. assets/javascripts/views/content/root_page.coffee +0 −4
  30. assets/javascripts/views/content/settings_page.coffee +10 −12
  31. assets/javascripts/views/content/type_page.coffee +1 −0
  32. assets/javascripts/views/layout/document.coffee +7 −5
  33. assets/javascripts/views/layout/resizer.coffee +2 −9
  34. assets/javascripts/views/layout/settings.coffee +1 −9
  35. assets/javascripts/views/search/search.coffee +13 −0
  36. assets/javascripts/views/search/search_scope.coffee +23 −5
  37. assets/javascripts/views/sidebar/sidebar.coffee +1 −1
assets/javascripts/app/app.coffee+21−14
@@ -13,10 +13,12 @@ · 12 unmodified lines
13 13
14 @el = $('._app')14 @el = $('._app')
15 @localStorage = new LocalStorageStore15 @localStorage = new LocalStorageStore
16 @appCache = new app.AppCache if app.AppCache.isEnabled()16 @serviceWorker = new app.ServiceWorker if app.ServiceWorker.isEnabled()
17 @settings = new app.Settings17 @settings = new app.Settings
18 @db = new app.DB()18 @db = new app.DB()
19 19
20 @settings.initLayout()
21
20 @docs = new app.collections.Docs22 @docs = new app.collections.Docs
21 @disabledDocs = new app.collections.Docs23 @disabledDocs = new app.collections.Docs
22 @entries = new app.collections.Entries24 @entries = new app.collections.Entries
@@ -76,7 +78,7 @@ · 53 unmodified lines
76 .install()78 .install()
77 @previousErrorHandler = onerror79 @previousErrorHandler = onerror
78 window.onerror = @onWindowError.bind(@)80 window.onerror = @onWindowError.bind(@)
79 CookieStore.onBlocked = @onCookieBlocked81 CookiesStore.onBlocked = @onCookieBlocked
80 return82 return
81 83
82 bootOne: ->84 bootOne: ->
@@ -138,7 +140,10 @@ · 55 unmodified lines
138 @docs.sort()140 @docs.sort()
139 @initDoc(doc)141 @initDoc(doc)
140 @saveDocs()142 @saveDocs()
141 _onSuccess()143 if app.settings.get('autoInstall')
144 doc.install(_onSuccess, onError)
145 else
146 _onSuccess()
142 return147 return
143 148
144 doc.load onSuccess, onError, writeCache: true149 doc.load onSuccess, onError, writeCache: true
@@ -147,7 +152,7 @@ · 2 unmodified lines
147 saveDocs: ->152 saveDocs: ->
148 @settings.setDocs(doc.slug for doc in @docs.all())153 @settings.setDocs(doc.slug for doc in @docs.all())
149 @db.migrate()154 @db.migrate()
150 @appCache?.updateInBackground()155 @serviceWorker?.updateInBackground()
151 156
152 welcomeBack: ->157 welcomeBack: ->
153 visitCount = @settings.get('count')158 visitCount = @settings.get('count')
@@ -157,17 +162,24 @@ · 3 unmodified lines
157 new app.views.Updates()162 new app.views.Updates()
158 @updateChecker = new app.UpdateChecker()163 @updateChecker = new app.UpdateChecker()
159 164
165 reboot: ->
166 if location.pathname isnt '/' and location.pathname isnt '/settings'
167 window.location = "/##{location.pathname}"
168 else
169 window.location = '/'
170 return
171
160 reload: ->172 reload: ->
161 @docs.clearCache()173 @docs.clearCache()
162 @disabledDocs.clearCache()174 @disabledDocs.clearCache()
163 if @appCache then @appCache.reload() else window.location = '/'175 if @serviceWorker then @serviceWorker.reload() else @reboot()
164 return176 return
165 177
166 reset: ->178 reset: ->
167 @localStorage.reset()179 @localStorage.reset()
168 @settings.reset()180 @settings.reset()
169 @db?.reset()181 @db?.reset()
170 @appCache?.update()182 @serviceWorker?.update()
171 window.location = '/'183 window.location = '/'
172 return184 return
173 185
@@ -186,9 +198,9 @@ · 12 unmodified lines
186 return198 return
187 199
188 indexHost: ->200 indexHost: ->
189 # Can't load the index files from the host/CDN when applicationCache is201 # Can't load the index files from the host/CDN when service worker is
190 # enabled because it doesn't support caching URLs that use CORS.202 # enabled because it doesn't support caching URLs that use CORS.
191 @config[if @appCache and @settings.hasDocs() then 'index_path' else 'docs_origin']203 @config[if @serviceWorker and @settings.hasDocs() then 'index_path' else 'docs_origin']
192 204
193 onBootError: (args...) ->205 onBootError: (args...) ->
194 @trigger 'bootError'206 @trigger 'bootError'
@@ -245,7 +257,7 @@ · 50 unmodified lines
245 matchMedia: !!window.matchMedia257 matchMedia: !!window.matchMedia
246 insertAdjacentHTML: !!document.body.insertAdjacentHTML258 insertAdjacentHTML: !!document.body.insertAdjacentHTML
247 defaultPrevented: document.createEvent('CustomEvent').defaultPrevented is false259 defaultPrevented: document.createEvent('CustomEvent').defaultPrevented is false
248 cssGradients: supportsCssGradients()260 cssVariables: !!CSS?.supports?('(--t: 0)')
249 261
250 for key, value of features when not value262 for key, value of features when not value
251 Raven.captureMessage "unsupported/#{key}", level: 'info'263 Raven.captureMessage "unsupported/#{key}", level: 'info'
@@ -268,9 +280,4 @@ · 16 unmodified lines
268 isInvalidLocation: ->280 isInvalidLocation: ->
269 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0281 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0
270 282
271supportsCssGradients = ->
272 el = document.createElement('div')
273 el.style.cssText = "background-image: -webkit-linear-gradient(top, #000, #fff); background-image: linear-gradient(to top, #000, #fff);"
274 el.style.backgroundImage.indexOf('gradient') >= 0
275
276$.extend app, Events283$.extend app, Events
assets/javascripts/app/appcache.coffee+0−42
@@ -1,42 +0,0 @@
1class app.AppCache
2 $.extend @prototype, Events
3
4 @isEnabled: ->
5 try
6 applicationCache and applicationCache.status isnt applicationCache.UNCACHED
7 catch
8
9 constructor: ->
10 @cache = applicationCache
11 @notifyUpdate = true
12 @onUpdateReady() if @cache.status is @cache.UPDATEREADY
13
14 $.on @cache, 'progress', @onProgress
15 $.on @cache, 'updateready', @onUpdateReady
16
17 update: ->
18 @notifyUpdate = true
19 @notifyProgress = true
20 try @cache.update() catch
21 return
22
23 updateInBackground: ->
24 @notifyUpdate = false
25 @notifyProgress = false
26 try @cache.update() catch
27 return
28
29 reload: ->
30 $.on @cache, 'updateready noupdate error', -> window.location = '/'
31 @notifyUpdate = false
32 @notifyProgress = true
33 try @cache.update() catch
34 return
35
36 onProgress: (event) =>
37 @trigger 'progress', event if @notifyProgress
38 return
39
40 onUpdateReady: =>
41 @trigger 'updateready' if @notifyUpdate
42 return
assets/javascripts/app/config.coffee.erb+3−0
@@ -13,3 +13,6 @@ app.config = · 12 unmodified lines
13 version: <%= Time.now.to_i %>13 version: <%= Time.now.to_i %>
14 release: <%= Time.now.utc.httpdate.to_json %>14 release: <%= Time.now.utc.httpdate.to_json %>
15 mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css'15 mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css'
16 favicon_spritesheet: '<%= image_path('sprites/docs.png') %>'
17 service_worker_path: '/service-worker.js'
18 service_worker_enabled: <%= App.environment == :production || ENV['ENABLE_SERVICE_WORKER'] == 'true' %>
assets/javascripts/app/serviceworker.coffee+49−0
@@ -0,0 +1,49 @@
1class app.ServiceWorker
2 $.extend @prototype, Events
3
4 @isEnabled: ->
5 !!navigator.serviceWorker and app.config.service_worker_enabled
6
7 constructor: ->
8 @registration = null
9 @notifyUpdate = true
10
11 navigator.serviceWorker.register(app.config.service_worker_path, {scope: '/'})
12 .then(
13 (registration) => @updateRegistration(registration),
14 (error) -> console.error('Could not register service worker:', error)
15 )
16
17 update: ->
18 return unless @registration
19 @notifyUpdate = true
20 return @registration.update().catch(->)
21
22 updateInBackground: ->
23 return unless @registration
24 @notifyUpdate = false
25 return @registration.update().catch(->)
26
27 reload: ->
28 return @updateInBackground().then(() -> app.reboot())
29
30 updateRegistration: (registration) ->
31 @registration = registration
32 $.on @registration, 'updatefound', @onUpdateFound
33 return
34
35 onUpdateFound: =>
36 $.off @installingRegistration, 'statechange', @onStateChange() if @installingRegistration
37 @installingRegistration = @registration.installing
38 $.on @installingRegistration, 'statechange', @onStateChange
39 return
40
41 onStateChange: =>
42 if @installingRegistration and @installingRegistration.state == 'installed' and navigator.serviceWorker.controller
43 @installingRegistration = null
44 @onUpdateReady()
45 return
46
47 onUpdateReady: ->
48 @trigger 'updateready' if @notifyUpdate
49 return
assets/javascripts/app/settings.coffee+34−1
@@ -5,11 +5,13 @@ class app.Settings · 4 unmodified lines
5 'manualUpdate'5 'manualUpdate'
6 'fastScroll'6 'fastScroll'
7 'arrowScroll'7 'arrowScroll'
8 'analyticsConsent'
8 'docs'9 'docs'
9 'dark'10 'dark'
10 'layout'11 'layout'
11 'size'12 'size'
12 'tips'13 'tips'
14 'autoInstall'
13 ]15 ]
14 16
15 INTERNAL_KEYS = [17 INTERNAL_KEYS = [
@@ -19,6 +21,8 @@ class app.Settings · 3 unmodified lines
19 'news'21 'news'
20 ]22 ]
21 23
24 LAYOUTS: ['_max-width', '_sidebar-hidden', '_native-scrollbars']
25
22 @defaults:26 @defaults:
23 count: 027 count: 0
24 hideDisabled: false28 hideDisabled: false
@@ -26,9 +30,10 @@ class app.Settings · 1 unmodified line
26 news: 030 news: 0
27 manualUpdate: false31 manualUpdate: false
28 schema: 132 schema: 1
33 analyticsConsent: false
29 34
30 constructor: ->35 constructor: ->
31 @store = new CookieStore36 @store = new CookiesStore
32 @cache = {}37 @cache = {}
33 38
34 get: (key) ->39 get: (key) ->
@@ -38,6 +43,7 @@ class app.Settings · 3 unmodified lines
38 set: (key, value) ->43 set: (key, value) ->
39 @store.set(key, value)44 @store.set(key, value)
40 delete @cache[key]45 delete @cache[key]
46 @toggleDark(value) if key == 'dark'
41 return47 return
42 48
43 del: (key) ->49 del: (key) ->
@@ -63,6 +69,8 @@ class app.Settings · 19 unmodified lines
63 return69 return
64 70
65 setLayout: (name, enable) ->71 setLayout: (name, enable) ->
72 @toggleLayout(name, enable)
73
66 layout = (@store.get('layout') || '').split(' ')74 layout = (@store.get('layout') || '').split(' ')
67 $.arrayDelete(layout, '')75 $.arrayDelete(layout, '')
68 76
@@ -104,3 +112,28 @@ class app.Settings · 35 unmodified lines
104 @store.reset()112 @store.reset()
105 @cache = {}113 @cache = {}
106 return114 return
115
116 initLayout: ->
117 @toggleDark(@get('dark') is 1)
118 @toggleLayout(layout, @hasLayout(layout)) for layout in @LAYOUTS
119 @initSidebarWidth()
120 return
121
122 toggleDark: (enable) ->
123 classList = document.documentElement.classList
124 classList.toggle('_theme-default', !enable)
125 classList.toggle('_theme-dark', enable)
126 color = getComputedStyle(document.documentElement).getPropertyValue('--headerBackground').trim()
127 $('meta[name=theme-color]').setAttribute('content', color)
128 return
129
130 toggleLayout: (layout, enable) ->
131 classList = document.body.classList
132 classList.toggle(layout, enable) unless layout is '_sidebar-hidden'
133 classList.toggle('_overlay-scrollbars', $.overlayScrollbarsEnabled())
134 return
135
136 initSidebarWidth: ->
137 size = @get('size')
138 document.documentElement.style.setProperty('--sidebarWidth', size + 'px') if size
139 return
assets/javascripts/app/shortcuts.coffee+3−0
@@ -149,6 +149,9 @@ class app.Shortcuts · 148 unmodified lines
149 when 40149 when 40
150 @trigger 'altDown'150 @trigger 'altDown'
151 false151 false
152 when 68
153 @trigger 'altD'
154 false
152 when 70155 when 70
153 @trigger 'altF', event156 @trigger 'altF', event
154 when 71157 when 71
assets/javascripts/app/update_checker.coffee+3−3
@@ -3,13 +3,13 @@ class app.UpdateChecker · 2 unmodified lines
3 @lastCheck = Date.now()3 @lastCheck = Date.now()
4 4
5 $.on window, 'focus', @onFocus5 $.on window, 'focus', @onFocus
6 app.appCache.on 'updateready', @onUpdateReady if app.appCache6 app.serviceWorker?.on 'updateready', @onUpdateReady
7 7
8 setTimeout @checkDocs, 08 setTimeout @checkDocs, 0
9 9
10 check: ->10 check: ->
11 if app.appCache11 if app.serviceWorker
12 app.appCache.update()12 app.serviceWorker.update()
13 else13 else
14 ajax14 ajax
15 url: $('script[src*="application"]').getAttribute('src')15 url: $('script[src*="application"]').getAttribute('src')
assets/javascripts/lib/cookies_store.coffeerenamed from assets/javascripts/lib/cookie_store.coffee+5−1
@@ -1,4 +1,8 @@
1class @CookieStore1class @CookiesStore
2 # Intentionally called CookiesStore instead of CookieStore
3 # Calling it CookieStore causes issues when the Experimental Web Platform features flag is enabled in Chrome
4 # Related issue: https://github.com/freeCodeCamp/devdocs/issues/932
5
2 INT = /^\d+$/6 INT = /^\d+$/
3 7
4 @onBlocked: ->8 @onBlocked: ->
assets/javascripts/lib/favicon.coffee+64−0
@@ -0,0 +1,64 @@
1defaultUrl = null
2currentSlug = null
3
4imageCache = {}
5urlCache = {}
6
7withImage = (url, action) ->
8 if imageCache[url]
9 action(imageCache[url])
10 else
11 img = new Image()
12 img.crossOrigin = 'anonymous'
13 img.src = url
14 img.onload = () =>
15 imageCache[url] = img
16 action(img)
17
18@setFaviconForDoc = (doc) ->
19 return if currentSlug == doc.slug
20
21 favicon = $('link[rel="icon"]')
22
23 if defaultUrl == null
24 defaultUrl = favicon.href
25
26 if urlCache[doc.slug]
27 favicon.href = urlCache[doc.slug]
28 currentSlug = doc.slug
29 return
30
31 styles = window.getComputedStyle($("._icon-#{doc.slug.split('~')[0]}"), ':before')
32
33 bgUrl = app.config.favicon_spritesheet
34 sourceSize = 16
35 sourceX = Math.abs(parseInt(styles['background-position-x'].slice(0, -2)))
36 sourceY = Math.abs(parseInt(styles['background-position-y'].slice(0, -2)))
37
38 withImage(bgUrl, (docImg) ->
39 withImage(defaultUrl, (defaultImg) ->
40 size = defaultImg.width
41
42 canvas = document.createElement('canvas')
43 ctx = canvas.getContext('2d')
44
45 canvas.width = size
46 canvas.height = size
47 ctx.drawImage(defaultImg, 0, 0)
48
49 docIconPercentage = 65
50 destinationCoords = size / 100 * (100 - docIconPercentage)
51 destinationSize = size / 100 * docIconPercentage
52 ctx.drawImage(docImg, sourceX, sourceY, sourceSize, sourceSize, destinationCoords, destinationCoords, destinationSize, destinationSize)
53
54 urlCache[doc.slug] = canvas.toDataURL()
55 favicon.href = urlCache[doc.slug]
56
57 currentSlug = doc.slug
58 )
59 )
60
61@resetFavicon = () ->
62 if defaultUrl != null and currentSlug != null
63 $('link[rel="icon"]').href = defaultUrl
64 currentSlug = null
assets/javascripts/lib/license.coffee+1−1
@@ -1,5 +1,5 @@
1###1###
2 * Copyright 2013-2018 Thibaut Courouble and other contributors2 * Copyright 2013-2019 Thibaut Courouble and other contributors
3 *3 *
4 * This source code is licensed under the terms of the Mozilla4 * This source code is licensed under the terms of the Mozilla
5 * Public License, v. 2.0, a copy of which may be obtained at:5 * Public License, v. 2.0, a copy of which may be obtained at:
assets/javascripts/lib/page.coffee+18−2
@@ -190,7 +190,7 @@ isSameOrigin = (url) -> · 189 unmodified lines
190 190
191updateCanonicalLink = ->191updateCanonicalLink = ->
192 @canonicalLink ||= document.head.querySelector('link[rel="canonical"]')192 @canonicalLink ||= document.head.querySelector('link[rel="canonical"]')
193 @canonicalLink.setAttribute('href', "http://#{location.host}#{location.pathname}")193 @canonicalLink.setAttribute('href', "https://#{location.host}#{location.pathname}")
194 194
195trackers = []195trackers = []
196 196
@@ -199,5 +199,21 @@ page.track = (fn) -> · 2 unmodified lines
199 return199 return
200 200
201track = ->201track = ->
202 tracker.call() for tracker in trackers202 consentGiven = Cookies.get('analyticsConsent')
203 consentAsked = Cookies.get('analyticsConsentAsked')
204
205 if consentGiven == '1'
206 tracker.call() for tracker in trackers
207 else if consentGiven == undefined and consentAsked == undefined
208 # Only ask for consent once per browser session
209 Cookies.set('analyticsConsentAsked', '1')
210
211 new app.views.Notif 'AnalyticsConsent', autoHide: null
212 return
213
214@resetAnalytics = ->
215 for cookie in document.cookie.split(/;\s?/)
216 name = cookie.split('=')[0]
217 if name[0] == '_' && name[1] != '_'
218 Cookies.expire(name)
203 return219 return
assets/javascripts/lib/util.coffee+4−0
@@ -352,6 +352,10 @@ isIE = null · 351 unmodified lines
352$.isIE = ->352$.isIE = ->
353 isIE ?= navigator.userAgent?.indexOf('MSIE') >= 0 || navigator.userAgent?.indexOf('rv:11.0') >= 0353 isIE ?= navigator.userAgent?.indexOf('MSIE') >= 0 || navigator.userAgent?.indexOf('rv:11.0') >= 0
354 354
355isChromeForAndroid = null
356$.isChromeForAndroid = ->
357 isChromeForAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 && /Chrome\/([.0-9])+ Mobile/.test(navigator.userAgent)
358
355isAndroid = null359isAndroid = null
356$.isAndroid = ->360$.isAndroid = ->
357 isAndroid ?= navigator.userAgent?.indexOf('Android') >= 0361 isAndroid ?= navigator.userAgent?.indexOf('Android') >= 0
assets/javascripts/models/doc.coffee+3−1
@@ -142,4 +142,6 @@ class app.models.Doc extends app.Model · 141 unmodified lines
142 return142 return
143 143
144 isOutdated: (status) ->144 isOutdated: (status) ->
145 status and status.installed and @mtime isnt status.mtime145 return false if not status
146 isInstalled = status.installed or app.settings.get('autoInstall')
147 isInstalled and @mtime isnt status.mtime
assets/javascripts/news.json+17−0
@@ -1,5 +1,22 @@
1[1[
2 [2 [
3 "2019-07-21",
4 "Fixed several bugs, added an option to automatically download documentation and <a href=\"https://github.com/freeCodeCamp/devdocs/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aclosed+sort%3Aupdated-desc+closed%3A%3E2019-07-18+977+988+986+870+886+1024+979+975+941+831+1005+848+942\" target=\"_blank\">more</a>."
5 ],
6 [
7 "2019-07-19",
8 "Replaced the AppCache with a Service Worker (which makes DevDocs an installable PWA) and fixed layout preferences on Firefox."
9 ],
10 [
11 "2018-09-23",
12 "New documentations: <a href=\"/puppeteer/\">Puppeteer</a> and <a href=\"/handlebars/\">Handlebars.js</a>"
13 ], [
14 "2018-08-12",
15 "New documentations: <a href=\"/dart/\">Dart</a> and <a href=\"/qt/\">Qt</a>"
16 ], [
17 "2018-07-29",
18 "New documentations: <a href=\"/bash/\">Bash</a>, <a href=\"/graphite/\">Graphite</a> and <a href=\"/pygame/\">Pygame</a>"
19 ], [
3 "2018-07-08",20 "2018-07-08",
4 "New documentations: <a href=\"/leaflet/\">Leaflet</a>, <a href=\"/terraform/\">Terraform</a> and <a href=\"/koa/\">Koa</a>"21 "New documentations: <a href=\"/leaflet/\">Leaflet</a>, <a href=\"/terraform/\">Terraform</a> and <a href=\"/koa/\">Koa</a>"
5 ], [22 ], [
assets/javascripts/templates/error_tmpl.coffee+9−12
@@ -12,8 +12,8 @@ app.templates.notFoundPage = -> · 11 unmodified lines
12 12
13app.templates.pageLoadError = ->13app.templates.pageLoadError = ->
14 error """ The page failed to load. """,14 error """ The page failed to load. """,
15 """ It may be missing from the server (try reloading the app) or you could be offline.<br>15 """ It may be missing from the server (try reloading the app) or you could be offline (try <a href="/offline">installing the documentation for offline usage</a> when online again).<br>
16 If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,16 If you're online and you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
17 """ #{back} &middot; <a href="/##{location.pathname}" target="_top" class="_error-link">Reload</a>17 """ #{back} &middot; <a href="/##{location.pathname}" target="_top" class="_error-link">Reload</a>
18 &middot; <a href="#" class="_error-link" data-retry>Retry</a> """18 &middot; <a href="#" class="_error-link" data-retry>Retry</a> """
19 19
@@ -56,21 +56,18 @@ app.templates.unsupportedBrowser = """ · 36 unmodified lines
56 <h1 class="_fail-title">Your browser is unsupported, sorry.</h1>56 <h1 class="_fail-title">Your browser is unsupported, sorry.</h1>
57 <p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers:57 <p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers:
58 <ul class="_fail-list">58 <ul class="_fail-list">
59 <li>Recent versions of Chrome and Firefox59 <li>Recent versions of Firefox, Chrome, or Opera
60 <li>Safari 5.1+60 <li>Safari 11.1+
61 <li>Opera 12.1+61 <li>Edge 17+
62 <li>Internet Explorer 10+62 <li>iOS 11.3+
63 <li>iOS 6+
64 <li>Android 4.1+
65 <li>Windows Phone 8+
66 </ul>63 </ul>
67 <p class="_fail-text">64 <p class="_fail-text">
68 If you're unable to upgrade, I apologize.65 If you're unable to upgrade, we apologize.
69 I decided to prioritize speed and new features over support for older browsers.66 We decided to prioritize speed and new features over support for older browsers.
70 <p class="_fail-text">67 <p class="_fail-text">
71 Note: if you're already using one of the browsers above, check your settings and add-ons.68 Note: if you're already using one of the browsers above, check your settings and add-ons.
72 The app uses feature detection, not user agent sniffing.69 The app uses feature detection, not user agent sniffing.
73 <p class="_fail-text">70 <p class="_fail-text">
74 &mdash; Thibaut <a href="https://twitter.com/DevDocs" class="_fail-link">@DevDocs</a>71 &mdash; <a href="https://twitter.com/DevDocs">@DevDocs</a>
75 </div>72 </div>
76"""73"""
assets/javascripts/templates/notif_tmpl.coffee+6−0
@@ -68,3 +68,9 @@ app.templates.notifShare = -> · 67 unmodified lines
68app.templates.notifUpdateDocs = ->68app.templates.notifUpdateDocs = ->
69 textNotif """ Documentation updates available. """,69 textNotif """ Documentation updates available. """,
70 """ <a href="/offline">Install them</a> as soon as possible to avoid broken pages. """70 """ <a href="/offline">Install them</a> as soon as possible to avoid broken pages. """
71
72app.templates.notifAnalyticsConsent = ->
73 textNotif """ Tracking cookies """,
74 """ We would like to gather usage data about how DevDocs is used through Google Analytics and Gauges. We only collect anonymous traffic information.
75 Please confirm if you accept our tracking cookies. You can always change your decision in the settings.
76 <br><span class="_notif-right"><a href="#" data-behavior="accept-analytics">Accept</a> or <a href="#" data-behavior="decline-analytics">Decline</a></span> """
assets/javascripts/templates/pages/about_tmpl.coffee+96−31
@@ -11,22 +11,18 @@ app.templates.aboutPage = -> """ · 10 unmodified lines
11 </nav>11 </nav>
12 12
13 <h1 class="_lined-heading">DevDocs: API Documentation Browser</h1>13 <h1 class="_lined-heading">DevDocs: API Documentation Browser</h1>
14 <p>DevDocs combines multiple API documentations in a clean and organized web UI with instant search, offline support, mobile version, dark theme, keyboard shortcuts, and more.14 <p>DevDocs combines multiple developer documentations in a clean and organized web UI with instant search, offline support, mobile version, dark theme, keyboard shortcuts, and more.
15 <ul>15 <p>DevDocs is free and <a href="https://github.com/freeCodeCamp/devdocs">open source</a>. It was created by <a href="https://thibaut.me">Thibaut Courouble</a> and is operated by <a href="https://www.freecodecamp.org/">freeCodeCamp</a>.
16 <li>Created and maintained by <a href="https://thibaut.me">Thibaut Courouble</a>
17 <li>Free and <a href="https://github.com/freeCodeCamp/devdocs">open source</a>
18 <iframe class="_github-btn" src="https://ghbtns.com/github-btn.html?user=freeCodeCamp&repo=devdocs&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20" tabindex="-1"></iframe>
19 </ul>
20 <p>To keep up-to-date with the latest news:16 <p>To keep up-to-date with the latest news:
21 <ul>17 <ul>
22 <li>Follow <a href="https://twitter.com/DevDocs">@DevDocs</a> on Twitter18 <li>Follow <a href="https://twitter.com/DevDocs">@DevDocs</a> on Twitter
23 <li>Watch the repository on <a href="https://github.com/freeCodeCamp/devdocs/subscription">GitHub</a>19 <li>Watch the repository on <a href="https://github.com/freeCodeCamp/devdocs/subscription">GitHub</a> <iframe class="_github-btn" src="https://ghbtns.com/github-btn.html?user=freeCodeCamp&repo=devdocs&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20" tabindex="-1"></iframe>
24 <li>Join the <a href="https://groups.google.com/d/forum/devdocs">mailing list</a>20 <li>Join the <a href="https://gitter.im/FreeCodeCamp/DevDocs">Gitter</a> chat room
25 </ul>21 </ul>
26 22
27 <h2 class="_block-heading" id="copyright">Copyright and License</h2>23 <h2 class="_block-heading" id="copyright">Copyright and License</h2>
28 <p class="_note">24 <p class="_note">
29 <strong>Copyright 2013&ndash;2018 Thibaut Courouble and <a href="https://github.com/freeCodeCamp/devdocs/graphs/contributors">other contributors</a></strong><br>25 <strong>Copyright 2013&ndash;2019 Thibaut Courouble and <a href="https://github.com/freeCodeCamp/devdocs/graphs/contributors">other contributors</a></strong><br>
30 This software is licensed under the terms of the Mozilla Public License v2.0.<br>26 This software is licensed under the terms of the Mozilla Public License v2.0.<br>
31 You may obtain a copy of the source code at <a href="https://github.com/freeCodeCamp/devdocs">github.com/freeCodeCamp/devdocs</a>.<br>27 You may obtain a copy of the source code at <a href="https://github.com/freeCodeCamp/devdocs">github.com/freeCodeCamp/devdocs</a>.<br>
32 For more information, see the <a href="https://github.com/freeCodeCamp/devdocs/blob/master/COPYRIGHT">COPYRIGHT</a>28 For more information, see the <a href="https://github.com/freeCodeCamp/devdocs/blob/master/COPYRIGHT">COPYRIGHT</a>
@@ -48,11 +44,10 @@ app.templates.aboutPage = -> """ · 15 unmodified lines
48 <dt>Where can I suggest new docs and features?44 <dt>Where can I suggest new docs and features?
49 <dd>You can suggest and vote for new docs on the <a href="https://trello.com/b/6BmTulfx/devdocs-documentation">Trello board</a>.<br>45 <dd>You can suggest and vote for new docs on the <a href="https://trello.com/b/6BmTulfx/devdocs-documentation">Trello board</a>.<br>
50 If you have a specific feature request, add it to the <a href="https://github.com/freeCodeCamp/devdocs/issues">issue tracker</a>.<br>46 If you have a specific feature request, add it to the <a href="https://github.com/freeCodeCamp/devdocs/issues">issue tracker</a>.<br>
51 Otherwise use the <a href="https://groups.google.com/d/forum/devdocs">mailing list</a>.47 Otherwise, come talk to us in the <a href="https://gitter.im/FreeCodeCamp/DevDocs">Gitter</a> chat room.
52 <dt>Where can I report bugs?48 <dt>Where can I report bugs?
53 <dd>In the <a href="https://github.com/freeCodeCamp/devdocs/issues">issue tracker</a>. Thanks!49 <dd>In the <a href="https://github.com/freeCodeCamp/devdocs/issues">issue tracker</a>. Thanks!
54 </dl>50 </dl>
55 <p>For anything else, feel free to email me at <a href="mailto:thibaut@devdocs.io">thibaut@devdocs.io</a>.
56 51
57 <h2 class="_block-heading" id="credits">Credits</h2>52 <h2 class="_block-heading" id="credits">Credits</h2>
58 53
@@ -76,12 +71,13 @@ app.templates.aboutPage = -> """ · 17 unmodified lines
76 71
77 <h2 class="_block-heading" id="privacy">Privacy Policy</h2>72 <h2 class="_block-heading" id="privacy">Privacy Policy</h2>
78 <ul>73 <ul>
79 <li><a href="https://devdocs.io">devdocs.io</a> ("App") is operated by Thibaut Courouble ("We").74 <li><a href="https://devdocs.io">devdocs.io</a> ("App") is operated by <a href="https://www.freecodecamp.org/">freeCodeCamp</a> ("We").
80 <li>We do not collect personal information.75 <li>We do not collect personal information through the app.
81 <li>We use Google Analytics, Gauges and Sentry to collect anonymous traffic information and improve the app.76 <li>We use Google Analytics and Gauges to collect anonymous traffic information if you have given consent to this. You can change your decision in the <a href="/settings">settings</a>.
77 <li>We use Sentry to collect crash data and improve the app.
82 <li>The app uses cookies to store user preferences.78 <li>The app uses cookies to store user preferences.
83 <li>By using the app, you signify your acceptance of this policy. If you do not agree to this policy, please do not use the app.79 <li>By using the app, you signify your acceptance of this policy. If you do not agree to this policy, please do not use the app.
84 <li>If you have any questions regarding privacy, please email <a href="mailto:thibaut@devdocs.io">thibaut@devdocs.io</a>.80 <li>If you have any questions regarding privacy, please email <a href="mailto:privacy@freecodecamp.org">privacy@freecodecamp.org</a>.
85 </ul>81 </ul>
86"""82"""
87 83
@@ -92,7 +88,7 @@ credits = [ · 4 unmodified lines
92 'https://creativecommons.org/licenses/by/4.0/'88 'https://creativecommons.org/licenses/by/4.0/'
93 ], [89 ], [
94 'Ansible',90 'Ansible',
95 '2012-2018 Michael DeHaan<br>&copy; 2018 Red Hat, Inc.',91 '2012-2018 Michael DeHaan<br>&copy; 2018–2019 Red Hat, Inc.',
96 'GPLv3',92 'GPLv3',
97 'https://raw.githubusercontent.com/ansible/ansible/devel/COPYING'93 'https://raw.githubusercontent.com/ansible/ansible/devel/COPYING'
98 ], [94 ], [
@@ -102,7 +98,7 @@ credits = [ · 3 unmodified lines
102 'https://www.apache.org/licenses/LICENSE-2.0'98 'https://www.apache.org/licenses/LICENSE-2.0'
103 ], [99 ], [
104 'Async',100 'Async',
105 '2010-2017 Caolan McMahon',101 '2010-2018 Caolan McMahon',
106 'MIT',102 'MIT',
107 'https://raw.githubusercontent.com/caolan/async/master/LICENSE'103 'https://raw.githubusercontent.com/caolan/async/master/LICENSE'
108 ], [104 ], [
@@ -115,6 +111,11 @@ credits = [ · 6 unmodified lines
115 '2010-2016 Jeremy Ashkenas, DocumentCloud',111 '2010-2016 Jeremy Ashkenas, DocumentCloud',
116 'MIT',112 'MIT',
117 'https://raw.githubusercontent.com/jashkenas/backbone/master/LICENSE'113 'https://raw.githubusercontent.com/jashkenas/backbone/master/LICENSE'
114 ], [
115 'Bash',
116 '2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.',
117 'GFDL',
118 'https://www.gnu.org/licenses/fdl-1.3.en.html'
118 ], [119 ], [
119 'Bluebird',120 'Bluebird',
120 '2013-2017 Petka Antonov',121 '2013-2017 Petka Antonov',
@@ -122,7 +123,7 @@ credits = [ · 1 unmodified line
122 'https://raw.githubusercontent.com/petkaantonov/bluebird/master/LICENSE'123 'https://raw.githubusercontent.com/petkaantonov/bluebird/master/LICENSE'
123 ], [124 ], [
124 'Bootstrap',125 'Bootstrap',
125 '2011-2018 Twitter, Inc.<br>2011-2018 The Bootstrap Authors',126 '2011-2019 Twitter, Inc.<br>2011-2019 The Bootstrap Authors',
126 'CC BY',127 'CC BY',
127 'https://creativecommons.org/licenses/by/3.0/'128 'https://creativecommons.org/licenses/by/3.0/'
128 ], [129 ], [
@@ -162,7 +163,7 @@ credits = [ · 33 unmodified lines
162 'https://github.com/clojure/clojure/blob/master/epl-v10.html'163 'https://github.com/clojure/clojure/blob/master/epl-v10.html'
163 ], [164 ], [
164 'CMake',165 'CMake',
165 '2000-2017 Kitware, Inc. and Contributors',166 '2000-2019 Kitware, Inc. and Contributors',
166 'BSD',167 'BSD',
167 'https://cmake.org/licensing/'168 'https://cmake.org/licensing/'
168 ], [169 ], [
@@ -185,9 +186,14 @@ credits = [ · 16 unmodified lines
185 '2009-2018 Jeremy Ashkenas',186 '2009-2018 Jeremy Ashkenas',
186 'MIT',187 'MIT',
187 'https://raw.githubusercontent.com/jashkenas/coffeescript/master/LICENSE'188 'https://raw.githubusercontent.com/jashkenas/coffeescript/master/LICENSE'
189 ], [
190 'Composer',
191 'Nils Adermann, Jordi Boggiano',
192 'MIT',
193 'https://raw.githubusercontent.com/composer/composer/master/LICENSE'
188 ], [194 ], [
189 'Cordova',195 'Cordova',
190 '2012-2017 The Apache Software Foundation',196 '2012-2018 The Apache Software Foundation',
191 'Apache',197 'Apache',
192 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'198 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'
193 ], [199 ], [
@@ -201,6 +207,12 @@ credits = [ · 7 unmodified lines
201 'Apache',207 'Apache',
202 'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE'208 'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE'
203 ], [209 ], [
210 'Cypress',
211 '2017 Cypress.io',
212 'MIT',
213 'https://raw.githubusercontent.com/cypress-io/cypress-documentation/develop/LICENSE.md'
214 ],
215 [
204 'D',216 'D',
205 '1999-2018 The D Language Foundation',217 '1999-2018 The D Language Foundation',
206 'Boost',218 'Boost',
@@ -210,6 +222,11 @@ credits = [ · 3 unmodified lines
210 '2010-2018 Michael Bostock',222 '2010-2018 Michael Bostock',
211 'BSD',223 'BSD',
212 'https://raw.githubusercontent.com/d3/d3/master/LICENSE'224 'https://raw.githubusercontent.com/d3/d3/master/LICENSE'
225 ], [
226 'Dart',
227 '2012 the Dart project authors',
228 'CC BY-SA',
229 'https://creativecommons.org/licenses/by-sa/4.0/'
213 ], [230 ], [
214 'Django',231 'Django',
215 'Django Software Foundation and individual contributors',232 'Django Software Foundation and individual contributors',
@@ -217,7 +234,7 @@ credits = [ · 1 unmodified line
217 'https://raw.githubusercontent.com/django/django/master/LICENSE'234 'https://raw.githubusercontent.com/django/django/master/LICENSE'
218 ], [235 ], [
219 'Docker',236 'Docker',
220 '2017 Docker, Inc.<br>Docker and the Docker logo are trademarks of Docker, Inc.',237 '2019 Docker, Inc.<br>Docker and the Docker logo are trademarks of Docker, Inc.',
221 'Apache',238 'Apache',
222 'https://raw.githubusercontent.com/docker/docker.github.io/master/LICENSE'239 'https://raw.githubusercontent.com/docker/docker.github.io/master/LICENSE'
223 ], [240 ], [
@@ -290,11 +307,21 @@ credits = [ · 66 unmodified lines
290 '2014-2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors',307 '2014-2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors',
291 'MIT',308 'MIT',
292 'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt'309 'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt'
310 ], [
311 'Graphite',
312 '2008-2012 Chris Davis<br>&copy; 2011-2016 The Graphite Project',
313 'Apache',
314 'https://raw.githubusercontent.com/graphite-project/graphite-web/master/LICENSE'
293 ], [315 ], [
294 'Grunt',316 'Grunt',
295 'GruntJS Team',317 'GruntJS Team',
296 'MIT',318 'MIT',
297 'https://github.com/gruntjs/grunt-docs/blob/master/package.json#L10'319 'https://github.com/gruntjs/grunt-docs/blob/master/package.json#L10'
320 ], [
321 'Handlebars',
322 '2011-2017 Yehuda Katz',
323 'MIT',
324 'https://raw.githubusercontent.com/wycats/handlebars.js/master/LICENSE'
298 ], [325 ], [
299 'Haskell',326 'Haskell',
300 'The University of Glasgow',327 'The University of Glasgow',
@@ -352,7 +379,7 @@ credits = [ · 51 unmodified lines
352 'https://raw.githubusercontent.com/jquery/api.jqueryui.com/master/LICENSE.txt'379 'https://raw.githubusercontent.com/jquery/api.jqueryui.com/master/LICENSE.txt'
353 ], [380 ], [
354 'Julia',381 'Julia',
355 '2009-2016 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors',382 '2009-2018 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors',
356 'MIT',383 'MIT',
357 'https://raw.githubusercontent.com/JuliaLang/julia/master/LICENSE.md'384 'https://raw.githubusercontent.com/JuliaLang/julia/master/LICENSE.md'
358 ], [385 ], [
@@ -372,7 +399,7 @@ credits = [ · 13 unmodified lines
372 'https://raw.githubusercontent.com/koajs/koa/master/LICENSE'399 'https://raw.githubusercontent.com/koajs/koa/master/LICENSE'
373 ], [400 ], [
374 'Kotlin',401 'Kotlin',
375 '2010-2018 JetBrains s.r.o.',402 '2010-2019 JetBrains s.r.o.',
376 'Apache',403 'Apache',
377 'https://raw.githubusercontent.com/JetBrains/kotlin/master/license/LICENSE.txt'404 'https://raw.githubusercontent.com/JetBrains/kotlin/master/license/LICENSE.txt'
378 ], [405 ], [
@@ -382,7 +409,7 @@ credits = [ · 3 unmodified lines
382 'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt'409 'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt'
383 ], [410 ], [
384 'Leaflet',411 'Leaflet',
385 '2010-2018 Vladimir Agafonkin<br>&copy; 2010-2011, CloudMade<br>Maps &copy; OpenStreetMap contributors.',412 '2010-2019 Vladimir Agafonkin<br>&copy; 2010-2011, CloudMade<br>Maps &copy; OpenStreetMap contributors.',
386 'BSD',413 'BSD',
387 'https://raw.githubusercontent.com/Leaflet/Leaflet/master/LICENSE'414 'https://raw.githubusercontent.com/Leaflet/Leaflet/master/LICENSE'
388 ], [415 ], [
@@ -422,7 +449,7 @@ credits = [ · 33 unmodified lines
422 'https://daringfireball.net/projects/markdown/license'449 'https://daringfireball.net/projects/markdown/license'
423 ], [450 ], [
424 'Matplotlib',451 'Matplotlib',
425 '2012-2017 Matplotlib Development Team. All rights reserved.',452 '2012-2018 Matplotlib Development Team. All rights reserved.',
426 'Custom',453 'Custom',
427 'https://raw.githubusercontent.com/matplotlib/matplotlib/master/LICENSE/LICENSE'454 'https://raw.githubusercontent.com/matplotlib/matplotlib/master/LICENSE/LICENSE'
428 ], [455 ], [
@@ -457,7 +484,7 @@ credits = [ · 28 unmodified lines
457 'https://github.com/LearnBoost/mongoose/blob/master/README.md#license'484 'https://github.com/LearnBoost/mongoose/blob/master/README.md#license'
458 ], [485 ], [
459 'nginx',486 'nginx',
460 '2002-2018 Igor Sysoev<br>&copy; 2011-2018 Nginx, Inc.',487 '2002-2019 Igor Sysoev<br>&copy; 2011-2019 Nginx, Inc.',
461 'BSD',488 'BSD',
462 'http://nginx.org/LICENSE'489 'http://nginx.org/LICENSE'
463 ], [490 ], [
@@ -502,7 +529,7 @@ credits = [ · 38 unmodified lines
502 'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER'529 'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER'
503 ], [530 ], [
504 'Padrino',531 'Padrino',
505 '2010-2016 Padrino',532 '2010-2019 Padrino',
506 'MIT',533 'MIT',
507 'https://raw.githubusercontent.com/padrino/padrino-framework/master/padrino/LICENSE.txt'534 'https://raw.githubusercontent.com/padrino/padrino-framework/master/padrino/LICENSE.txt'
508 ], [535 ], [
@@ -545,6 +572,16 @@ credits = [ · 36 unmodified lines
545 '1996-2018 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',572 '1996-2018 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',
546 'PostgreSQL',573 'PostgreSQL',
547 'https://www.postgresql.org/about/licence/'574 'https://www.postgresql.org/about/licence/'
575 ], [
576 'Puppeteer',
577 '2017 Google Inc',
578 'Apache',
579 'https://raw.githubusercontent.com/GoogleChrome/puppeteer/master/LICENSE'
580 ], [
581 'Pygame',
582 'Pygame Developers',
583 'LGPLv2.1',
584 'https://raw.githubusercontent.com/pygame/pygame/master/LICENSE'
548 ], [585 ], [
549 'Python',586 'Python',
550 '2001-2018 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.',587 '2001-2018 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.',
@@ -555,6 +592,11 @@ credits = [ · 4 unmodified lines
555 '2009-2017 Kristopher Michael Kowal',592 '2009-2017 Kristopher Michael Kowal',
556 'MIT',593 'MIT',
557 'https://raw.githubusercontent.com/kriskowal/q/master/LICENSE'594 'https://raw.githubusercontent.com/kriskowal/q/master/LICENSE'
595 ], [
596 'Qt',
597 '2012-2018 The Qt Company Ltd',
598 'GFDL',
599 'https://doc.qt.io/qt-5/licensing.html'
558 ], [600 ], [
559 'Ramda',601 'Ramda',
560 '2013-2016 Scott Sauyet and Michael Hurley',602 '2013-2016 Scott Sauyet and Michael Hurley',
@@ -601,18 +643,30 @@ credits = [ · 40 unmodified lines
601 'MIT',643 'MIT',
602 'https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT'644 'https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT'
603 ], [645 ], [
646 'Salt Stack',
647 '2019 SaltStack',
648 'Apache',
649 'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE'
650 ],
651 [
604 'Sass',652 'Sass',
605 '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',653 '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',
606 'MIT',654 'MIT',
607 'https://raw.githubusercontent.com/sass/sass/stable/MIT-LICENSE'655 'https://raw.githubusercontent.com/sass/sass/stable/MIT-LICENSE'
608 ], [656 ], [
657 'Scala',
658 '2002-2019 EPFL, with contributions from Lightbend',
659 'Apache',
660 'https://raw.githubusercontent.com/scala/scala-lang/master/license.md'
661 ],
662 [
609 'scikit-image',663 'scikit-image',
610 '2011 the scikit-image team',664 '2011 the scikit-image team',
611 'BSD',665 'BSD',
612 'http://scikit-image.org/docs/dev/license.html'666 'http://scikit-image.org/docs/dev/license.html'
613 ], [667 ], [
614 'scikit-learn',668 'scikit-learn',
615 '2007-2017 The scikit-learn developers',669 '2007-2018 The scikit-learn developers',
616 'BSD',670 'BSD',
617 'https://raw.githubusercontent.com/scikit-learn/scikit-learn/master/COPYING'671 'https://raw.githubusercontent.com/scikit-learn/scikit-learn/master/COPYING'
618 ], [672 ], [
@@ -657,9 +711,9 @@ credits = [ · 38 unmodified lines
657 'https://raw.githubusercontent.com/hashicorp/terraform-website/master/LICENSE.md'711 'https://raw.githubusercontent.com/hashicorp/terraform-website/master/LICENSE.md'
658 ], [712 ], [
659 'Twig',713 'Twig',
660 '2009-2017 The Twig Team',714 '2009-2018 The Twig Team',
661 'BSD',715 'BSD',
662 'https://twig.sensiolabs.org/license'716 'https://twig.symfony.com/license'
663 ], [717 ], [
664 'TypeScript',718 'TypeScript',
665 'Microsoft and other contributors',719 'Microsoft and other contributors',
@@ -667,7 +721,7 @@ credits = [ · 1 unmodified line
667 'https://raw.githubusercontent.com/Microsoft/TypeScript-Handbook/master/LICENSE'721 'https://raw.githubusercontent.com/Microsoft/TypeScript-Handbook/master/LICENSE'
668 ], [722 ], [
669 'Underscore.js',723 'Underscore.js',
670 '2009-2017 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',724 '2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
671 'MIT',725 'MIT',
672 'https://raw.githubusercontent.com/jashkenas/underscore/master/LICENSE'726 'https://raw.githubusercontent.com/jashkenas/underscore/master/LICENSE'
673 ], [727 ], [
@@ -685,6 +739,11 @@ credits = [ · 11 unmodified lines
685 '2015-2018 Evan You, Vue.js contributors',739 '2015-2018 Evan You, Vue.js contributors',
686 'MIT',740 'MIT',
687 'https://raw.githubusercontent.com/vuejs/vuex/master/LICENSE'741 'https://raw.githubusercontent.com/vuejs/vuex/master/LICENSE'
742 ], [
743 'Vue Router',
744 '2013-present Evan You',
745 'MIT',
746 'https://raw.githubusercontent.com/vuejs/vue-router/dev/LICENSE'
688 ], [747 ], [
689 'Vulkan',748 'Vulkan',
690 '2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',749 '2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',
@@ -696,6 +755,12 @@ credits = [ · 5 unmodified lines
696 'CC BY',755 'CC BY',
697 'https://creativecommons.org/licenses/by/4.0/'756 'https://creativecommons.org/licenses/by/4.0/'
698 ], [757 ], [
758 'Wordpress',
759 '2003-2019 WordPress Foundation',
760 'GPLv2+',
761 'https://wordpress.org/about/license/'
762 ],
763 [
699 'Yarn',764 'Yarn',
700 '2016-present Yarn Contributors',765 '2016-present Yarn Contributors',
701 'BSD',766 'BSD',
assets/javascripts/templates/pages/help_tmpl.coffee+3−0
@@ -131,6 +131,9 @@ app.templates.helpPage = -> · 130 unmodified lines
131 <dt class="_shortcuts-dt">131 <dt class="_shortcuts-dt">
132 <code class="_shortcut-code">alt + s</code>132 <code class="_shortcut-code">alt + s</code>
133 <dd class="_shortcuts-dd">Search on Stack Overflow133 <dd class="_shortcuts-dd">Search on Stack Overflow
134 <dt class="_shortcuts-dt">
135 <code class="_shortcut-code">alt + d</code>
136 <dd class="_shortcuts-dd">Search on DuckDuckGo
134 </dl>137 </dl>
135 <p class="_note _note-green">138 <p class="_note _note-green">
136 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or139 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or
assets/javascripts/templates/pages/offline_tmpl.coffee+9−4
@@ -25,8 +25,8 @@ app.templates.offlinePage = (docs) -> """ · 24 unmodified lines
25 <h2 class="_block-heading">Questions & Answers</h2>25 <h2 class="_block-heading">Questions & Answers</h2>
26 <dl>26 <dl>
27 <dt>How does this work?27 <dt>How does this work?
28 <dd>Each page is cached as a key-value pair in <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> (downloaded from a single file).<br>28 <dd>Each page is cached as a key-value pair in <a href="https://devdocs.io/dom/indexeddb_api">IndexedDB</a> (downloaded from a single file).<br>
29 The app also uses <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache">AppCache</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API">localStorage</a> to cache the assets and index files.29 The app also uses <a href="https://devdocs.io/dom/service_worker_api/using_service_workers">Service Workers</a> and <a href="https://devdocs.io/dom/web_storage_api">localStorage</a> to cache the assets and index files.
30 <dt>Can I close the tab/browser?30 <dt>Can I close the tab/browser?
31 <dd>#{canICloseTheTab()}31 <dd>#{canICloseTheTab()}
32 <dt>What if I don't update a documentation?32 <dt>What if I don't update a documentation?
@@ -41,10 +41,15 @@ app.templates.offlinePage = (docs) -> """ · 8 unmodified lines
41"""41"""
42 42
43canICloseTheTab = ->43canICloseTheTab = ->
44 if app.AppCache.isEnabled()44 if app.ServiceWorker.isEnabled()
45 """ Yes! Even offline, you can open a new tab, go to <a href="//devdocs.io">devdocs.io</a>, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand). """45 """ Yes! Even offline, you can open a new tab, go to <a href="//devdocs.io">devdocs.io</a>, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand). """
46 else46 else
47 """ No. AppCache isn't available in your browser (or is disabled), so loading <a href="//devdocs.io">devdocs.io</a> offline won't work.<br>47 reason = "aren't available in your browser (or are disabled)"
48
49 if app.config.env != 'production'
50 reason = "are disabled in your development instance of DevDocs (enable them by setting the <code>ENABLE_SERVICE_WORKER</code> environment variable to <code>true</code>)"
51
52 """ No. Service Workers #{reason}, so loading <a href="//devdocs.io">devdocs.io</a> offline won't work.<br>
48 The current tab will continue to function even when you go offline (provided you installed all the documentations beforehand). """53 The current tab will continue to function even when you go offline (provided you installed all the documentations beforehand). """
49 54
50app.templates.offlineDoc = (doc, status) ->55app.templates.offlineDoc = (doc, status) ->
assets/javascripts/templates/pages/root_tmpl.coffee.erb+3−14
@@ -8,13 +8,13 @@ app.templates.intro = """ · 7 unmodified lines
8 <p>Thanks for downloading DevDocs. Here are a few things you should know:8 <p>Thanks for downloading DevDocs. Here are a few things you should know:
9 <ol class="_intro-list">9 <ol class="_intro-list">
10 <li>Your local version of DevDocs won't self-update. Unless you're modifying the code,10 <li>Your local version of DevDocs won't self-update. Unless you're modifying the code,
11 I&nbsp;recommend using the hosted version at <a href="https://devdocs.io">devdocs.io</a>.11 we&nbsp;recommend using the hosted version at <a href="https://devdocs.io">devdocs.io</a>.
12 <li>Run <code>thor docs:list</code> to see all available documentations.12 <li>Run <code>thor docs:list</code> to see all available documentations.
13 <li>Run <code>thor docs:download &lt;name&gt;</code> to download documentations.13 <li>Run <code>thor docs:download &lt;name&gt;</code> to download documentations.
14 <li>Run <code>thor docs:download --installed</code> to update all downloaded documentations.14 <li>Run <code>thor docs:download --installed</code> to update all downloaded documentations.
15 <li>To be notified about new versions, don't forget to <a href="https://github.com/freeCodeCamp/devdocs/subscription">watch the repository</a> on GitHub.15 <li>To be notified about new versions, don't forget to <a href="https://github.com/freeCodeCamp/devdocs/subscription">watch the repository</a> on GitHub.
16 <li>The <a href="https://github.com/freeCodeCamp/devdocs/issues">issue tracker</a> is the preferred channel for bug reports and16 <li>The <a href="https://github.com/freeCodeCamp/devdocs/issues">issue tracker</a> is the preferred channel for bug reports and
17 feature requests. For everything else, use the <a href="https://groups.google.com/d/forum/devdocs">mailing list</a>.17 feature requests. For everything else, use <a href="https://gitter.im/FreeCodeCamp/DevDocs">Gitter</a>.
18 <li>Contributions are welcome. See the <a href="https://github.com/freeCodeCamp/devdocs/blob/master/CONTRIBUTING.md">guidelines</a>.18 <li>Contributions are welcome. See the <a href="https://github.com/freeCodeCamp/devdocs/blob/master/CONTRIBUTING.md">guidelines</a>.
19 <li>DevDocs is licensed under the terms of the Mozilla Public License v2.0. For more information,19 <li>DevDocs is licensed under the terms of the Mozilla Public License v2.0. For more information,
20 see the <a href="https://github.com/freeCodeCamp/devdocs/blob/master/COPYRIGHT">COPYRIGHT</a> and20 see the <a href="https://github.com/freeCodeCamp/devdocs/blob/master/COPYRIGHT">COPYRIGHT</a> and
@@ -39,7 +39,7 @@ app.templates.intro = """ · 18 unmodified lines
39 <li>DevDocs works <a href="/offline">offline</a>, on mobile, and can be installed on <a href="https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe">Chrome</a>.39 <li>DevDocs works <a href="/offline">offline</a>, on mobile, and can be installed on <a href="https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe">Chrome</a>.
40 <li>For the latest news, follow <a href="https://twitter.com/DevDocs">@DevDocs</a>.40 <li>For the latest news, follow <a href="https://twitter.com/DevDocs">@DevDocs</a>.
41 <li>DevDocs is free and <a href="https://github.com/freeCodeCamp/devdocs">open source</a>.41 <li>DevDocs is free and <a href="https://github.com/freeCodeCamp/devdocs">open source</a>.
42 <iframe class="_github-btn" src="//ghbtns.com/github-btn.html?user=freeCodeCamp&repo=devdocs&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>42 <object data="https://img.shields.io/github/stars/freeCodeCamp/devdocs.svg?style=social" type="image/svg+xml" aria-hidden="true"></object>
43 <li>And if you're new to coding, check out <a href="https://www.freecodecamp.org/">freeCodeCamp's open source curriculum</a>.43 <li>And if you're new to coding, check out <a href="https://www.freecodecamp.org/">freeCodeCamp's open source curriculum</a>.
44 </ol>44 </ol>
45 <p>Happy coding!45 <p>Happy coding!
@@ -72,14 +72,3 @@ app.templates.androidWarning = """ · 26 unmodified lines
72 <p>To install DevDocs on your phone, visit <a href="https://devdocs.io" target="_blank" rel="noopener">devdocs.io</a> in Chrome and select "Add to home screen" in the menu.72 <p>To install DevDocs on your phone, visit <a href="https://devdocs.io" target="_blank" rel="noopener">devdocs.io</a> in Chrome and select "Add to home screen" in the menu.
73 </div>73 </div>
74"""74"""
75
76app.templates.httpWarning = """
77 <div class="_intro"><div class="_intro-message">
78 <h2 class="_intro-title">Hi there!</h2>
79 <p>DevDocs is migrating to HTTPS.
80 <p>Please update your bookmarks to point to <a href="https://devdocs.io">https://devdocs.io</a>.
81 <p>When using the HTTPS version, your preferences will carry over automatically, but your offline data will be reset. Simply re-download documentation in the <a href="https://devdocs.io/offline">Offline area</a>, and you'll be all set to use DevDocs securely offline.
82 <p>Sorry for the inconvenience. This migration is needed because browsers are removing support for certain DOM APIs that power DevDocs's offline mode over non-secure origins.
83 <p>Thanks for using DevDocs, and happy coding!
84 </div></div>
85"""
assets/javascripts/templates/pages/settings_tmpl.coffee+8−0
@@ -15,6 +15,14 @@ app.templates.settingsPage = (settings) -> """ · 14 unmodified lines
15 <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar15 <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
16 <small>Tip: drag the edge of the sidebar to resize it.</small>16 <small>Tip: drag the edge of the sidebar to resize it.</small>
17 </label>17 </label>
18 <label class="_settings-label">
19 <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use
20 <small>Only enable this when bandwidth isn't a concern to you.</small>
21 </label>
22 <label class="_settings-label">
23 <input type="checkbox" form="settings" name="analyticsConsent"#{if settings.analyticsConsent then ' checked' else ''}>Enable tracking cookies
24 <small>With this checked, we enable Google Analytics and Gauges to collect anonymous traffic information.</small>
25 </label>
18 </div>26 </div>
19 </div>27 </div>
20 28
assets/javascripts/tracking.js+27−23
@@ -1,28 +1,32 @@
1try {1try {
2 if (app.config.env == 'production') {2 if (app.config.env === 'production') {
3 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){3 if (Cookies.get('analyticsConsent') === '1') {
4 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),4 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)5 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6 })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');6 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7 ga('create', 'UA-5544833-12', 'devdocs.io');7 })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
8 page.track(function() {8 ga('create', 'UA-5544833-12', 'devdocs.io');
9 ga('send', 'pageview', {9 page.track(function() {
10 page: location.pathname + location.search + location.hash,10 ga('send', 'pageview', {
11 dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version11 page: location.pathname + location.search + location.hash,
12 dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version
13 });
12 });14 });
13 });
14 15
15 page.track(function() {16 page.track(function() {
16 if (window._gauges)17 if (window._gauges)
17 _gauges.push(['track']);18 _gauges.push(['track']);
18 else19 else
19 (function() {20 (function() {
20 var _gauges=_gauges||[];!function(){var a=document.createElement("script");21 var _gauges=_gauges||[];!function(){var a=document.createElement("script");
21 a.type="text/javascript",a.async=!0,a.id="gauges-tracker",22 a.type="text/javascript",a.async=!0,a.id="gauges-tracker",
22 a.setAttribute("data-site-id","51c15f82613f5d7819000067"),23 a.setAttribute("data-site-id","51c15f82613f5d7819000067"),
23 a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0];24 a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0];
24 b.parentNode.insertBefore(a,b)}();25 b.parentNode.insertBefore(a,b)}();
25 })();26 })();
26 });27 });
28 } else {
29 resetAnalytics();
30 }
27 }31 }
28} catch(e) { }32} catch(e) { }
assets/javascripts/vendor/fastclick.js+2−2
@@ -413,7 +413,7 @@ · 412 unmodified lines
413 // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched413 // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
414 // with the same identifier as the touch event that previously triggered the click that triggered the alert.414 // with the same identifier as the touch event that previously triggered the click that triggered the alert.
415 // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an415 // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
416 // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.416 // immediately preceding touch event (issue #52), so this fix is unavailable on that platform.
417 // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,417 // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
418 // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,418 // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
419 // random integers, it's safe to to continue if the identifier is 0 here.419 // random integers, it's safe to to continue if the identifier is 0 here.
@@ -805,7 +805,7 @@ · 385 unmodified lines
805 }805 }
806 }806 }
807 807
808 // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version808 // IE11: prefixed -ms-touch-action is no longer supported and it's recommended to use non-prefixed version
809 // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx809 // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx
810 if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {810 if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {
811 return true;811 return true;
assets/javascripts/vendor/prism.js+633−352
@@ -1,4 +1,5 @@
1/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+django+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+jsx+crystal+rust+scss+sql+typescript+yaml */1/* PrismJS 1.15.0
2https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+dart+django+elixir+markup-templating+erlang+go+java+json+kotlin+lua+crystal+nginx+nim+perl+php+sql+scss+python+jsx+typescript+rust+yaml */
2var _self = (typeof window !== 'undefined')3var _self = (typeof window !== 'undefined')
3 ? window // if in browser4 ? window // if in browser
4 : (5 : (
@@ -16,11 +17,12 @@ var _self = (typeof window !== 'undefined') · 11 unmodified lines
16var Prism = (function(){17var Prism = (function(){
17 18
18// Private helper vars19// Private helper vars
19var lang = /\blang(?:uage)?-(\w+)\b/i;20var lang = /\blang(?:uage)?-([\w-]+)\b/i;
20var uniqueId = 0;21var uniqueId = 0;
21 22
22var _ = _self.Prism = {23var _ = _self.Prism = {
23 manual: _self.Prism && _self.Prism.manual,24 manual: _self.Prism && _self.Prism.manual,
25 disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
24 util: {26 util: {
25 encode: function (tokens) {27 encode: function (tokens) {
26 if (tokens instanceof Token) {28 if (tokens instanceof Token) {
@@ -44,23 +46,38 @@ var _ = _self.Prism = { · 17 unmodified lines
44 },46 },
45 47
46 // Deep clone a language definition (e.g. to extend it)48 // Deep clone a language definition (e.g. to extend it)
47 clone: function (o) {49 clone: function (o, visited) {
48 var type = _.util.type(o);50 var type = _.util.type(o);
51 visited = visited || {};
49 52
50 switch (type) {53 switch (type) {
51 case 'Object':54 case 'Object':
55 if (visited[_.util.objId(o)]) {
56 return visited[_.util.objId(o)];
57 }
52 var clone = {};58 var clone = {};
59 visited[_.util.objId(o)] = clone;
53 60
54 for (var key in o) {61 for (var key in o) {
55 if (o.hasOwnProperty(key)) {62 if (o.hasOwnProperty(key)) {
56 clone[key] = _.util.clone(o[key]);63 clone[key] = _.util.clone(o[key], visited);
57 }64 }
58 }65 }
59 66
60 return clone;67 return clone;
61 68
62 case 'Array':69 case 'Array':
63 return o.map(function(v) { return _.util.clone(v); });70 if (visited[_.util.objId(o)]) {
71 return visited[_.util.objId(o)];
72 }
73 var clone = [];
74 visited[_.util.objId(o)] = clone;
75
76 o.forEach(function (v, i) {
77 clone[i] = _.util.clone(v, visited);
78 });
79
80 return clone;
64 }81 }
65 82
66 return o;83 return o;
@@ -155,6 +172,10 @@ var _ = _self.Prism = { · 88 unmodified lines
155 plugins: {},172 plugins: {},
156 173
157 highlightAll: function(async, callback) {174 highlightAll: function(async, callback) {
175 _.highlightAllUnder(document, async, callback);
176 },
177
178 highlightAllUnder: function(container, async, callback) {
158 var env = {179 var env = {
159 callback: callback,180 callback: callback,
160 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'181 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
@@ -162,7 +183,7 @@ var _ = _self.Prism = { · 1 unmodified line
162 183
163 _.hooks.run("before-highlightall", env);184 _.hooks.run("before-highlightall", env);
164 185
165 var elements = env.elements || document.querySelectorAll(env.selector);186 var elements = env.elements || container.querySelectorAll(env.selector);
166 187
167 for (var i=0, element; element = elements[i++];) {188 for (var i=0, element; element = elements[i++];) {
168 _.highlightElement(element, async === true, env.callback);189 _.highlightElement(element, async === true, env.callback);
@@ -185,11 +206,13 @@ var _ = _self.Prism = { · 16 unmodified lines
185 // Set language on the element, if not present206 // Set language on the element, if not present
186 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;207 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
187 208
188 // Set language on the parent, for styling209 if (element.parentNode) {
189 parent = element.parentNode;210 // Set language on the parent, for styling
211 parent = element.parentNode;
190 212
191 if (/pre/i.test(parent.nodeName)) {213 if (/pre/i.test(parent.nodeName)) {
192 parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;214 parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
215 }
193 }216 }
194 217
195 var code = element.textContent;218 var code = element.textContent;
@@ -251,8 +274,15 @@ var _ = _self.Prism = { · 55 unmodified lines
251 },274 },
252 275
253 highlight: function (text, grammar, language) {276 highlight: function (text, grammar, language) {
254 var tokens = _.tokenize(text, grammar);277 var env = {
255 return Token.stringify(_.util.encode(tokens), language);278 code: text,
279 grammar: grammar,
280 language: language
281 };
282 _.hooks.run('before-tokenize', env);
283 env.tokens = _.tokenize(env.code, env.grammar);
284 _.hooks.run('after-tokenize', env);
285 return Token.stringify(_.util.encode(env.tokens), env.language);
256 },286 },
257 287
258 matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {288 matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
@@ -300,15 +330,9 @@ var _ = _self.Prism = { · 41 unmodified lines
300 continue;330 continue;
301 }331 }
302 332
303 pattern.lastIndex = 0;333 if (greedy && i != strarr.length - 1) {
304
305 var match = pattern.exec(str),
306 delNum = 1;
307
308 // Greedy patterns can override/remove up to two previously matched tokens
309 if (!match && greedy && i != strarr.length - 1) {
310 pattern.lastIndex = pos;334 pattern.lastIndex = pos;
311 match = pattern.exec(text);335 var match = pattern.exec(text);
312 if (!match) {336 if (!match) {
313 break;337 break;
314 }338 }
@@ -327,11 +351,8 @@ var _ = _self.Prism = { · 12 unmodified lines
327 }351 }
328 }352 }
329 353
330 /*354 // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
331 * If strarr[i] is a Token, then the match starts inside another Token, which is invalid355 if (strarr[i] instanceof Token) {
332 * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
333 */
334 if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
335 continue;356 continue;
336 }357 }
337 358
@@ -339,6 +360,11 @@ var _ = _self.Prism = { · 1 unmodified line
339 delNum = k - i;360 delNum = k - i;
340 str = text.slice(pos, p);361 str = text.slice(pos, p);
341 match.index -= pos;362 match.index -= pos;
363 } else {
364 pattern.lastIndex = 0;
365
366 var match = pattern.exec(str),
367 delNum = 1;
342 }368 }
343 369
344 if (!match) {370 if (!match) {
@@ -350,7 +376,7 @@ var _ = _self.Prism = { · 5 unmodified lines
350 }376 }
351 377
352 if(lookbehind) {378 if(lookbehind) {
353 lookbehindLength = match[1].length;379 lookbehindLength = match[1] ? match[1].length : 0;
354 }380 }
355 381
356 var from = match.index + lookbehindLength,382 var from = match.index + lookbehindLength,
@@ -480,18 +506,21 @@ Token.stringify = function(o, language, parent) { · 123 unmodified lines
480// // in Node.js506// // in Node.js
481// return _self.Prism;507// return _self.Prism;
482// }508// }
483// // In worker509
484// _self.addEventListener('message', function(evt) {510// if (!_.disableWorkerMessageHandler) {
485// var message = JSON.parse(evt.data),511// // In worker
486// lang = message.language,512// _self.addEventListener('message', function (evt) {
487// code = message.code,513// var message = JSON.parse(evt.data),
488// immediateClose = message.immediateClose;514// lang = message.language,
489 515// code = message.code,
490// _self.postMessage(_.highlight(code, _.languages[lang], lang));516// immediateClose = message.immediateClose;
491// if (immediateClose) {517
492// _self.close();518// _self.postMessage(_.highlight(code, _.languages[lang], lang));
493// }519// if (immediateClose) {
494// }, false);520// _self.close();
521// }
522// }, false);
523// }
495 524
496// return _self.Prism;525// return _self.Prism;
497// }526// }
@@ -535,7 +564,8 @@ Prism.languages.markup = { · 37 unmodified lines
535 'doctype': /<!DOCTYPE[\s\S]+?>/i,564 'doctype': /<!DOCTYPE[\s\S]+?>/i,
536 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,565 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
537 'tag': {566 'tag': {
538 pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,567 pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
568 greedy: true,
539 inside: {569 inside: {
540 'tag': {570 'tag': {
541 pattern: /^<\/?[^\s>\/]+/i,571 pattern: /^<\/?[^\s>\/]+/i,
@@ -600,13 +630,13 @@ Prism.languages.css = { · 58 unmodified lines
600 pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,630 pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
601 greedy: true631 greedy: true
602 },632 },
603 'property': /[\w-]+(?=\s*:)/i,633 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
604 'important': /\B!important\b/i,634 'important': /\B!important\b/i,
605 'function': /[-a-z0-9]+(?=\()/i,635 'function': /[-a-z0-9]+(?=\()/i,
606 'punctuation': /[(){};:]/636 'punctuation': /[(){};:]/
607};637};
608 638
609Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);639Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
610 640
611if (Prism.languages.markup) {641if (Prism.languages.markup) {
612 Prism.languages.insertBefore('markup', 'tag', {642 Prism.languages.insertBefore('markup', 'tag', {
@@ -614,10 +644,11 @@ if (Prism.languages.markup) { · 1 unmodified line
614 pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,644 pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
615 lookbehind: true,645 lookbehind: true,
616 inside: Prism.languages.css,646 inside: Prism.languages.css,
617 alias: 'language-css'647 alias: 'language-css',
648 greedy: true
618 }649 }
619 });650 });
620 651
621 Prism.languages.insertBefore('inside', 'attr-value', {652 Prism.languages.insertBefore('inside', 'attr-value', {
622 'style-attr': {653 'style-attr': {
623 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,654 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
@@ -644,7 +675,8 @@ Prism.languages.clike = { · 20 unmodified lines
644 },675 },
645 {676 {
646 pattern: /(^|[^\\:])\/\/.*/,677 pattern: /(^|[^\\:])\/\/.*/,
647 lookbehind: true678 lookbehind: true,
679 greedy: true
648 }680 }
649 ],681 ],
650 'string': {682 'string': {
@@ -661,51 +693,53 @@ Prism.languages.clike = { · 10 unmodified lines
661 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,693 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
662 'boolean': /\b(?:true|false)\b/,694 'boolean': /\b(?:true|false)\b/,
663 'function': /[a-z0-9_]+(?=\()/i,695 'function': /[a-z0-9_]+(?=\()/i,
664 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,696 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
665 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,697 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
666 'punctuation': /[{}[\];(),.:]/698 'punctuation': /[{}[\];(),.:]/
667};699};
668 700
669Prism.languages.javascript = Prism.languages.extend('clike', {701Prism.languages.javascript = Prism.languages.extend('clike', {
670 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,702 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,
671 'number': /\b-?(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+(?:[Ee][+-]?\d+)?|NaN|Infinity)\b/,703 'number': /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
672 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)704 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
673 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*\()/i,705 'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i,
674 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/706 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
675});707});
676 708
677Prism.languages.insertBefore('javascript', 'keyword', {709Prism.languages.insertBefore('javascript', 'keyword', {
678 'regex': {710 'regex': {
679 pattern: /(^|[^/])\/(?!\/)(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,711 pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,
680 lookbehind: true,712 lookbehind: true,
681 greedy: true713 greedy: true
682 },714 },
683 // This must be declared before keyword because we use "function" inside the look-forward715 // This must be declared before keyword because we use "function" inside the look-forward
684 'function-variable': {716 'function-variable': {
685 pattern: /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)\s*=>))/i,717 pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,
686 alias: 'function'718 alias: 'function'
687 }719 },
720 'constant': /\b[A-Z][A-Z\d_]*\b/
688});721});
689 722
690Prism.languages.insertBefore('javascript', 'string', {723Prism.languages.insertBefore('javascript', 'string', {
691 'template-string': {724 'template-string': {
692 pattern: /`(?:\\[\s\S]|[^\\`])*`/,725 pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,
693 greedy: true,726 greedy: true,
694 inside: {727 inside: {
695 'interpolation': {728 'interpolation': {
696 pattern: /\$\{[^}]+\}/,729 pattern: /\${[^}]+}/,
697 inside: {730 inside: {
698 'interpolation-punctuation': {731 'interpolation-punctuation': {
699 pattern: /^\$\{|\}$/,732 pattern: /^\${|}$/,
700 alias: 'punctuation'733 alias: 'punctuation'
701 },734 },
702 rest: Prism.languages.javascript735 rest: null // See below
703 }736 }
704 },737 },
705 'string': /[\s\S]+/738 'string': /[\s\S]+/
706 }739 }
707 }740 }
708});741});
742Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript;
709 743
710if (Prism.languages.markup) {744if (Prism.languages.markup) {
711 Prism.languages.insertBefore('markup', 'tag', {745 Prism.languages.insertBefore('markup', 'tag', {
@@ -713,7 +747,8 @@ if (Prism.languages.markup) { · 1 unmodified line
713 pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,747 pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
714 lookbehind: true,748 lookbehind: true,
715 inside: Prism.languages.javascript,749 inside: Prism.languages.javascript,
716 alias: 'language-javascript'750 alias: 'language-javascript',
751 greedy: true
717 }752 }
718 });753 });
719}754}
@@ -723,7 +758,7 @@ Prism.languages.js = Prism.languages.javascript; · 3 unmodified lines
723Prism.languages.c = Prism.languages.extend('clike', {758Prism.languages.c = Prism.languages.extend('clike', {
724 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,759 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
725 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,760 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,
726 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i761 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
727});762});
728 763
729Prism.languages.insertBefore('c', 'string', {764Prism.languages.insertBefore('c', 'string', {
@@ -768,7 +803,7 @@ delete Prism.languages.c['boolean']; · 38 unmodified lines
768 },803 },
769 /^\$\(\(/804 /^\$\(\(/
770 ],805 ],
771 number: /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee]-?\d+)?)\b/,806 number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
772 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic807 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
773 operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,808 operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
774 // If there is no $ sign at the beginning highlight (( and )) as punctuation809 // If there is no $ sign at the beginning highlight (( and )) as punctuation
@@ -778,6 +813,7 @@ delete Prism.languages.c['boolean']; · 3 unmodified lines
778 // Command Substitution813 // Command Substitution
779 {814 {
780 pattern: /\$\([^)]+\)|`[^`]+`/,815 pattern: /\$\([^)]+\)|`[^`]+`/,
816 greedy: true,
781 inside: {817 inside: {
782 variable: /^\$\(|^`|\)$|`$/818 variable: /^\$\(|^`|\)$|`$/
783 }819 }
@@ -804,7 +840,7 @@ delete Prism.languages.c['boolean']; · 20 unmodified lines
804 inside: insideString840 inside: insideString
805 },841 },
806 {842 {
807 pattern: /(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/,843 pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
808 greedy: true,844 greedy: true,
809 inside: insideString845 inside: insideString
810 }846 }
@@ -812,7 +848,7 @@ delete Prism.languages.c['boolean']; · 1 unmodified line
812 'variable': insideString.variable,848 'variable': insideString.variable,
813 // Originally based on http://ss64.com/bash/849 // Originally based on http://ss64.com/bash/
814 'function': {850 'function': {
815 pattern: /(^|[\s;|&])(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|[\s;|&])/,851 pattern: /(^|[\s;|&])(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|[\s;|&])/,
816 lookbehind: true852 lookbehind: true
817 },853 },
818 'keyword': {854 'keyword': {
@@ -828,15 +864,18 @@ delete Prism.languages.c['boolean']; · 9 unmodified lines
828 };864 };
829 865
830 var inside = insideString.variable[1].inside;866 var inside = insideString.variable[1].inside;
867 inside.string = Prism.languages.bash.string;
831 inside['function'] = Prism.languages.bash['function'];868 inside['function'] = Prism.languages.bash['function'];
832 inside.keyword = Prism.languages.bash.keyword;869 inside.keyword = Prism.languages.bash.keyword;
833 inside.boolean = Prism.languages.bash.boolean;870 inside['boolean'] = Prism.languages.bash['boolean'];
834 inside.operator = Prism.languages.bash.operator;871 inside.operator = Prism.languages.bash.operator;
835 inside.punctuation = Prism.languages.bash.punctuation;872 inside.punctuation = Prism.languages.bash.punctuation;
873
874 Prism.languages.shell = Prism.languages.bash;
836})(Prism);875})(Prism);
837 876
838Prism.languages.cpp = Prism.languages.extend('c', {877Prism.languages.cpp = Prism.languages.extend('c', {
839 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,878 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
840 'boolean': /\b(?:true|false)\b/,879 'boolean': /\b(?:true|false)\b/,
841 'operator': /--?|\+\+?|!=?|<{1,2}=?|>{1,2}=?|->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|\|?|\?|\*|\/|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/880 'operator': /--?|\+\+?|!=?|<{1,2}=?|>{1,2}=?|->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|\|?|\?|\*|\/|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/
842});881});
@@ -847,6 +886,15 @@ Prism.languages.insertBefore('cpp', 'keyword', { · 4 unmodified lines
847 lookbehind: true886 lookbehind: true
848 }887 }
849});888});
889
890Prism.languages.insertBefore('cpp', 'string', {
891 'raw-string': {
892 pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
893 alias: 'string',
894 greedy: true
895 }
896});
897
850(function(Prism) {898(function(Prism) {
851 899
852// Ignore comments starting with { to privilege string interpolation highlighting900// Ignore comments starting with { to privilege string interpolation highlighting
@@ -947,10 +995,13 @@ delete Prism.languages.coffeescript['template-string']; · 94 unmodified lines
947(function(Prism) {995(function(Prism) {
948 Prism.languages.ruby = Prism.languages.extend('clike', {996 Prism.languages.ruby = Prism.languages.extend('clike', {
949 'comment': [997 'comment': [
950 /#(?!\{[^\r\n]*?\}).*/,998 /#.*/,
951 /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m999 {
1000 pattern: /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m,
1001 greedy: true
1002 }
952 ],1003 ],
953 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/1004 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
954 });1005 });
955 1006
956 var interpolation = {1007 var interpolation = {
@@ -960,7 +1011,7 @@ delete Prism.languages.coffeescript['template-string']; · 3 unmodified lines
960 pattern: /^#\{|\}$/,1011 pattern: /^#\{|\}$/,
961 alias: 'tag'1012 alias: 'tag'
962 },1013 },
963 rest: Prism.util.clone(Prism.languages.ruby)1014 rest: Prism.languages.ruby
964 }1015 }
965 };1016 };
966 1017
@@ -1009,7 +1060,10 @@ delete Prism.languages.coffeescript['template-string']; · 42 unmodified lines
1009 }1060 }
1010 ],1061 ],
1011 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,1062 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
1012 'symbol': /:[a-zA-Z_]\w*(?:[?!]|\b)/1063 'symbol': {
1064 pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
1065 lookbehind: true
1066 }
1013 });1067 });
1014 1068
1015 Prism.languages.insertBefore('ruby', 'number', {1069 Prism.languages.insertBefore('ruby', 'number', {
@@ -1127,6 +1181,30 @@ Prism.languages.insertBefore('d', 'function', { · 111 unmodified lines
1127 alias: 'variable'1181 alias: 'variable'
1128 }1182 }
1129});1183});
1184Prism.languages.dart = Prism.languages.extend('clike', {
1185 'string': [
1186 {
1187 pattern: /r?("""|''')[\s\S]*?\1/,
1188 greedy: true
1189 },
1190 {
1191 pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
1192 greedy: true
1193 }
1194 ],
1195 'keyword': [
1196 /\b(?:async|sync|yield)\*/,
1197 /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/
1198 ],
1199 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
1200});
1201
1202Prism.languages.insertBefore('dart','function',{
1203 'metadata': {
1204 pattern: /@\w+/,
1205 alias: 'symbol'
1206 }
1207});
1130// Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.1208// Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
1131// Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.1209// Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
1132 1210
@@ -1170,15 +1248,15 @@ if (Prism.languages.css) { · 37 unmodified lines
1170Prism.languages.jinja2 = Prism.languages.django;1248Prism.languages.jinja2 = Prism.languages.django;
1171 1249
1172Prism.languages.elixir = {1250Prism.languages.elixir = {
1173 // Negative look-ahead is needed for string interpolation
1174 // Negative look-behind is needed to avoid highlighting markdown headers in
1175 // multi-line doc strings
1176 'comment': {1251 'comment': {
1177 pattern: /(^|[^#])#(?![{#]).*/m,1252 pattern: /#.*/m,
1178 lookbehind: true1253 lookbehind: true
1179 },1254 },
1180 // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>1255 // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
1181 'regex': /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,1256 'regex': {
1257 pattern: /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
1258 greedy: true
1259 },
1182 'string': [1260 'string': [
1183 {1261 {
1184 // ~s"""foo""" (multi-line), ~s'''foo''' (multi-line), ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo} (with interpolation care), ~s<foo>1262 // ~s"""foo""" (multi-line), ~s'''foo''' (multi-line), ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo} (with interpolation care), ~s<foo>
@@ -1225,7 +1303,7 @@ Prism.languages.elixir = { · 40 unmodified lines
1225 alias: 'variable'1303 alias: 'variable'
1226 },1304 },
1227 'attribute': {1305 'attribute': {
1228 pattern: /@[\S]+/,1306 pattern: /@\w+/,
1229 alias: 'variable'1307 alias: 'variable'
1230 },1308 },
1231 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,1309 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
@@ -1256,13 +1334,102 @@ Prism.languages.elixir.string.forEach(function(o) { · 24 unmodified lines
1256 pattern: /^#\{|\}$/,1334 pattern: /^#\{|\}$/,
1257 alias: 'punctuation'1335 alias: 'punctuation'
1258 },1336 },
1259 rest: Prism.util.clone(Prism.languages.elixir)1337 rest: Prism.languages.elixir
1260 }1338 }
1261 }1339 }
1262 };1340 };
1263});1341});
1264 1342
1265 1343
1344Prism.languages['markup-templating'] = {};
1345
1346Object.defineProperties(Prism.languages['markup-templating'], {
1347 buildPlaceholders: {
1348 // Tokenize all inline templating expressions matching placeholderPattern
1349 // If the replaceFilter function is provided, it will be called with every match.
1350 // If it returns false, the match will not be replaced.
1351 value: function (env, language, placeholderPattern, replaceFilter) {
1352 if (env.language !== language) {
1353 return;
1354 }
1355
1356 env.tokenStack = [];
1357
1358 env.code = env.code.replace(placeholderPattern, function(match) {
1359 if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
1360 return match;
1361 }
1362 var i = env.tokenStack.length;
1363 // Check for existing strings
1364 while (env.code.indexOf('___' + language.toUpperCase() + i + '___') !== -1)
1365 ++i;
1366
1367 // Create a sparse array
1368 env.tokenStack[i] = match;
1369
1370 return '___' + language.toUpperCase() + i + '___';
1371 });
1372
1373 // Switch the grammar to markup
1374 env.grammar = Prism.languages.markup;
1375 }
1376 },
1377 tokenizePlaceholders: {
1378 // Replace placeholders with proper tokens after tokenizing
1379 value: function (env, language) {
1380 if (env.language !== language || !env.tokenStack) {
1381 return;
1382 }
1383
1384 // Switch the grammar back
1385 env.grammar = Prism.languages[language];
1386
1387 var j = 0;
1388 var keys = Object.keys(env.tokenStack);
1389 var walkTokens = function (tokens) {
1390 if (j >= keys.length) {
1391 return;
1392 }
1393 for (var i = 0; i < tokens.length; i++) {
1394 var token = tokens[i];
1395 if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
1396 var k = keys[j];
1397 var t = env.tokenStack[k];
1398 var s = typeof token === 'string' ? token : token.content;
1399
1400 var index = s.indexOf('___' + language.toUpperCase() + k + '___');
1401 if (index > -1) {
1402 ++j;
1403 var before = s.substring(0, index);
1404 var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar, language), 'language-' + language, t);
1405 var after = s.substring(index + ('___' + language.toUpperCase() + k + '___').length);
1406 var replacement;
1407 if (before || after) {
1408 replacement = [before, middle, after].filter(function (v) { return !!v; });
1409 walkTokens(replacement);
1410 } else {
1411 replacement = middle;
1412 }
1413 if (typeof token === 'string') {
1414 Array.prototype.splice.apply(tokens, [i, 1].concat(replacement));
1415 } else {
1416 token.content = replacement;
1417 }
1418
1419 if (j >= keys.length) {
1420 break;
1421 }
1422 }
1423 } else if (token.content && typeof token.content !== 'string') {
1424 walkTokens(token.content);
1425 }
1426 }
1427 };
1428
1429 walkTokens(env.tokens);
1430 }
1431 }
1432});
1266Prism.languages.erlang = {1433Prism.languages.erlang = {
1267 'comment': /%.+/,1434 'comment': /%.+/,
1268 'string': {1435 'string': {
@@ -1282,7 +1449,7 @@ Prism.languages.erlang = { · 13 unmodified lines
1282 'number': [1449 'number': [
1283 /\$\\?./,1450 /\$\\?./,
1284 /\d+#[a-z0-9]+/i,1451 /\d+#[a-z0-9]+/i,
1285 /(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/1452 /(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i
1286 ],1453 ],
1287 'function': /\b[a-z][\w@]*(?=\()/,1454 'function': /\b[a-z][\w@]*(?=\()/,
1288 'variable': {1455 'variable': {
@@ -1312,7 +1479,7 @@ Prism.languages.go = Prism.languages.extend('clike', { · 23 unmodified lines
1312 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,1479 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,
1313 'boolean': /\b(?:_|iota|nil|true|false)\b/,1480 'boolean': /\b(?:_|iota|nil|true|false)\b/,
1314 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,1481 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
1315 'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,1482 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
1316 'string': {1483 'string': {
1317 pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,1484 pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
1318 greedy: true1485 greedy: true
@@ -1322,7 +1489,7 @@ delete Prism.languages.go['class-name']; · 3 unmodified lines
1322 1489
1323Prism.languages.java = Prism.languages.extend('clike', {1490Prism.languages.java = Prism.languages.extend('clike', {
1324 'keyword': /\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,1491 'keyword': /\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,
1325 'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,1492 'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp-]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?[df]?/i,
1326 'operator': {1493 'operator': {
1327 pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,1494 pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
1328 lookbehind: true1495 lookbehind: true
@@ -1337,14 +1504,25 @@ Prism.languages.insertBefore('java','function', { · 8 unmodified lines
1337 }1504 }
1338});1505});
1339 1506
1507Prism.languages.insertBefore('java', 'class-name', {
1508 'generics': {
1509 pattern: /<\s*\w+(?:\.\w+)?(?:\s*,\s*\w+(?:\.\w+)?)*>/i,
1510 alias: 'function',
1511 inside: {
1512 keyword: Prism.languages.java.keyword,
1513 punctuation: /[<>(),.:]/
1514 }
1515 }
1516});
1517
1340Prism.languages.json = {1518Prism.languages.json = {
1341 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,1519 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
1342 'string': {1520 'string': {
1343 pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,1521 pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
1344 greedy: true1522 greedy: true
1345 },1523 },
1346 'number': /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee][+-]?\d+)?)\b/,1524 'number': /-?\d+\.?\d*([Ee][+-]?\d+)?/,
1347 'punctuation': /[{}[\]);,]/,1525 'punctuation': /[{}[\],]/,
1348 'operator': /:/g,1526 'operator': /:/g,
1349 'boolean': /\b(?:true|false)\b/i,1527 'boolean': /\b(?:true|false)\b/i,
1350 'null': /\bnull\b/i1528 'null': /\bnull\b/i
@@ -1356,7 +1534,7 @@ Prism.languages.jsonp = Prism.languages.json; · 5 unmodified lines
1356 Prism.languages.kotlin = Prism.languages.extend('clike', {1534 Prism.languages.kotlin = Prism.languages.extend('clike', {
1357 'keyword': {1535 'keyword': {
1358 // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get1536 // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
1359 pattern: /(^|[^.])\b(?:abstract|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|else|enum|final|finally|for|fun|get|if|import|in|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|out|override|package|private|protected|public|reified|return|sealed|set|super|tailrec|this|throw|to|try|val|var|when|where|while)\b/,1537 pattern: /(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,
1360 lookbehind: true1538 lookbehind: true
1361 },1539 },
1362 'function': [1540 'function': [
@@ -1366,7 +1544,7 @@ Prism.languages.jsonp = Prism.languages.json; · 3 unmodified lines
1366 lookbehind: true1544 lookbehind: true
1367 }1545 }
1368 ],1546 ],
1369 'number': /\b(?:0[bx][\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?[fFL]?)\b/,1547 'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,
1370 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/1548 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
1371 });1549 });
1372 1550
@@ -1400,7 +1578,7 @@ Prism.languages.jsonp = Prism.languages.json; · 27 unmodified lines
1400 pattern: /^\$\{|\}$/,1578 pattern: /^\$\{|\}$/,
1401 alias: 'variable'1579 alias: 'variable'
1402 },1580 },
1403 rest: Prism.util.clone(Prism.languages.kotlin)1581 rest: Prism.languages.kotlin
1404 }1582 }
1405 },1583 },
1406 {1584 {
@@ -1414,6 +1592,7 @@ Prism.languages.jsonp = Prism.languages.json; · 7 unmodified lines
1414 };1592 };
1415 1593
1416}(Prism));1594}(Prism));
1595
1417Prism.languages.lua = {1596Prism.languages.lua = {
1418 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,1597 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
1419 // \z may be used to skip the following space1598 // \z may be used to skip the following space
@@ -1434,16 +1613,68 @@ Prism.languages.lua = { · 14 unmodified lines
1434 ],1613 ],
1435 'punctuation': /[\[\](){},;]|\.+|:+/1614 'punctuation': /[\[\](){},;]|\.+|:+/
1436};1615};
1616(function(Prism) {
1617 Prism.languages.crystal = Prism.languages.extend('ruby', {
1618 keyword: [
1619 /\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|select|self|sizeof|struct|super|then|type|typeof|uninitialized|union|unless|until|when|while|with|yield|__DIR__|__END_LINE__|__FILE__|__LINE__)\b/,
1620 {
1621 pattern: /(\.\s*)(?:is_a|responds_to)\?/,
1622 lookbehind: true
1623 }
1624 ],
1625
1626 number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[\da-fA-F_]*[\da-fA-F]|(?:\d(?:[\d_]*\d)?)(?:\.[\d_]*\d)?(?:[eE][+-]?[\d_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/
1627 });
1628
1629 Prism.languages.insertBefore('crystal', 'string', {
1630 attribute: {
1631 pattern: /@\[.+?\]/,
1632 alias: 'attr-name',
1633 inside: {
1634 delimiter: {
1635 pattern: /^@\[|\]$/,
1636 alias: 'tag'
1637 },
1638 rest: Prism.languages.crystal
1639 }
1640 },
1641
1642 expansion: [
1643 {
1644 pattern: /\{\{.+?\}\}/,
1645 inside: {
1646 delimiter: {
1647 pattern: /^\{\{|\}\}$/,
1648 alias: 'tag'
1649 },
1650 rest: Prism.languages.crystal
1651 }
1652 },
1653 {
1654 pattern: /\{%.+?%\}/,
1655 inside: {
1656 delimiter: {
1657 pattern: /^\{%|%\}$/,
1658 alias: 'tag'
1659 },
1660 rest: Prism.languages.crystal
1661 }
1662 }
1663 ]
1664 });
1665
1666}(Prism));
1667
1437Prism.languages.nginx = Prism.languages.extend('clike', {1668Prism.languages.nginx = Prism.languages.extend('clike', {
1438 'comment': {1669 'comment': {
1439 pattern: /(^|[^"{\\])#.*/,1670 pattern: /(^|[^"{\\])#.*/,
1440 lookbehind: true1671 lookbehind: true
1441 },1672 },
1442 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types)\b/i1673 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types)\b/i
1443});1674});
1444 1675
1445Prism.languages.insertBefore('nginx', 'keyword', {1676Prism.languages.insertBefore('nginx', 'keyword', {
1446 'variable': /\$[a-z_]+/i1677 'variable': /\$[a-z_]+/i
1447});1678});
1448Prism.languages.nim = {1679Prism.languages.nim = {
1449 'comment': /#.*/,1680 'comment': /#.*/,
@@ -1497,31 +1728,31 @@ Prism.languages.perl = { · 47 unmodified lines
1497 pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,1728 pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
1498 greedy: true1729 greedy: true
1499 },1730 },
1500 1731
1501 // q a...a1732 // q a...a
1502 {1733 {
1503 pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,1734 pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
1504 greedy: true1735 greedy: true
1505 },1736 },
1506 1737
1507 // q(...)1738 // q(...)
1508 {1739 {
1509 pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,1740 pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
1510 greedy: true1741 greedy: true
1511 },1742 },
1512 1743
1513 // q{...}1744 // q{...}
1514 {1745 {
1515 pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,1746 pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
1516 greedy: true1747 greedy: true
1517 },1748 },
1518 1749
1519 // q[...]1750 // q[...]
1520 {1751 {
1521 pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,1752 pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
1522 greedy: true1753 greedy: true
1523 },1754 },
1524 1755
1525 // q<...>1756 // q<...>
1526 {1757 {
1527 pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,1758 pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
@@ -1547,31 +1778,31 @@ Prism.languages.perl = { · 19 unmodified lines
1547 pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,1778 pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
1548 greedy: true1779 greedy: true
1549 },1780 },
1550 1781
1551 // m a...a1782 // m a...a
1552 {1783 {
1553 pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,1784 pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
1554 greedy: true1785 greedy: true
1555 },1786 },
1556 1787
1557 // m(...)1788 // m(...)
1558 {1789 {
1559 pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,1790 pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
1560 greedy: true1791 greedy: true
1561 },1792 },
1562 1793
1563 // m{...}1794 // m{...}
1564 {1795 {
1565 pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,1796 pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
1566 greedy: true1797 greedy: true
1567 },1798 },
1568 1799
1569 // m[...]1800 // m[...]
1570 {1801 {
1571 pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,1802 pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
1572 greedy: true1803 greedy: true
1573 },1804 },
1574 1805
1575 // m<...>1806 // m<...>
1576 {1807 {
1577 pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,1808 pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
@@ -1586,42 +1817,42 @@ Prism.languages.perl = { · 8 unmodified lines
1586 lookbehind: true,1817 lookbehind: true,
1587 greedy: true1818 greedy: true
1588 },1819 },
1589 1820
1590 // s a...a...a1821 // s a...a...a
1591 {1822 {
1592 pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,1823 pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
1593 lookbehind: true,1824 lookbehind: true,
1594 greedy: true1825 greedy: true
1595 },1826 },
1596 1827
1597 // s(...)(...)1828 // s(...)(...)
1598 {1829 {
1599 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,1830 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
1600 lookbehind: true,1831 lookbehind: true,
1601 greedy: true1832 greedy: true
1602 },1833 },
1603 1834
1604 // s{...}{...}1835 // s{...}{...}
1605 {1836 {
1606 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,1837 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
1607 lookbehind: true,1838 lookbehind: true,
1608 greedy: true1839 greedy: true
1609 },1840 },
1610 1841
1611 // s[...][...]1842 // s[...][...]
1612 {1843 {
1613 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,1844 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
1614 lookbehind: true,1845 lookbehind: true,
1615 greedy: true1846 greedy: true
1616 },1847 },
1617 1848
1618 // s<...><...>1849 // s<...><...>
1619 {1850 {
1620 pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,1851 pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
1621 lookbehind: true,1852 lookbehind: true,
1622 greedy: true1853 greedy: true
1623 },1854 },
1624 1855
1625 // /.../1856 // /.../
1626 // The look-ahead tries to prevent two divisions on1857 // The look-ahead tries to prevent two divisions on
1627 // the same line from being highlighted as regex.1858 // the same line from being highlighted as regex.
@@ -1665,7 +1896,7 @@ Prism.languages.perl = { · 37 unmodified lines
1665 }1896 }
1666 },1897 },
1667 'keyword': /\b(?:any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while)\b/,1898 'keyword': /\b(?:any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while)\b/,
1668 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,1899 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
1669 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,1900 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
1670 'punctuation': /[{}[\];(),:]/1901 'punctuation': /[{}[\];(),:]/
1671};1902};
@@ -1682,110 +1913,211 @@ Prism.languages.perl = { · 10 unmodified lines
1682 * Adds the following new token classes:1913 * Adds the following new token classes:
1683 * constant, delimiter, variable, function, package1914 * constant, delimiter, variable, function, package
1684 */1915 */
1916(function (Prism) {
1917 Prism.languages.php = Prism.languages.extend('clike', {
1918 'keyword': /\b(?:and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,
1919 'constant': /\b[A-Z0-9_]{2,}\b/,
1920 'comment': {
1921 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1922 lookbehind: true
1923 }
1924 });
1685 1925
1686Prism.languages.php = Prism.languages.extend('clike', {1926 Prism.languages.insertBefore('php', 'string', {
1687 'keyword': /\b(?:and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,1927 'shell-comment': {
1688 'constant': /\b[A-Z0-9_]{2,}\b/,1928 pattern: /(^|[^\\])#.*/,
1689 'comment': {1929 lookbehind: true,
1690 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,1930 alias: 'comment'
1691 lookbehind: true1931 }
1692 }1932 });
1693});
1694 1933
1695// Shell-like comments are matched after strings, because they are less1934 Prism.languages.insertBefore('php', 'keyword', {
1696// common than strings containing hashes...1935 'delimiter': {
1697Prism.languages.insertBefore('php', 'class-name', {1936 pattern: /\?>|<\?(?:php|=)?/i,
1698 'shell-comment': {1937 alias: 'important'
1699 pattern: /(^|[^\\])#.*/,1938 },
1700 lookbehind: true,1939 'variable': /\$+(?:\w+\b|(?={))/i,
1701 alias: 'comment'1940 'package': {
1702 }1941 pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1703});1942 lookbehind: true,
1943 inside: {
1944 punctuation: /\\/
1945 }
1946 }
1947 });
1704 1948
1705Prism.languages.insertBefore('php', 'keyword', {1949 // Must be defined after the function pattern
1706 'delimiter': {1950 Prism.languages.insertBefore('php', 'operator', {
1707 pattern: /\?>|<\?(?:php|=)?/i,1951 'property': {
1708 alias: 'important'1952 pattern: /(->)[\w]+/,
1709 },1953 lookbehind: true
1710 'variable': /\$\w+\b/i,
1711 'package': {
1712 pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1713 lookbehind: true,
1714 inside: {
1715 punctuation: /\\/
1716 }1954 }
1717 }1955 });
1718});
1719 1956
1720// Must be defined after the function pattern1957 Prism.languages.insertBefore('php', 'string', {
1721Prism.languages.insertBefore('php', 'operator', {1958 'nowdoc-string': {
1722 'property': {1959 pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
1723 pattern: /(->)[\w]+/,1960 greedy: true,
1724 lookbehind: true1961 alias: 'string',
1725 }1962 inside: {
1726});1963 'delimiter': {
1964 pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
1965 alias: 'symbol',
1966 inside: {
1967 'punctuation': /^<<<'?|[';]$/
1968 }
1969 }
1970 }
1971 },
1972 'heredoc-string': {
1973 pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
1974 greedy: true,
1975 alias: 'string',
1976 inside: {
1977 'delimiter': {
1978 pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
1979 alias: 'symbol',
1980 inside: {
1981 'punctuation': /^<<<"?|[";]$/
1982 }
1983 },
1984 'interpolation': null // See below
1985 }
1986 },
1987 'single-quoted-string': {
1988 pattern: /'(?:\\[\s\S]|[^\\'])*'/,
1989 greedy: true,
1990 alias: 'string'
1991 },
1992 'double-quoted-string': {
1993 pattern: /"(?:\\[\s\S]|[^\\"])*"/,
1994 greedy: true,
1995 alias: 'string',
1996 inside: {
1997 'interpolation': null // See below
1998 }
1999 }
2000 });
2001 // The different types of PHP strings "replace" the C-like standard string
2002 delete Prism.languages.php['string'];
1727 2003
1728// Add HTML support if the markup language exists2004 var string_interpolation = {
1729if (Prism.languages.markup) {2005 pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
2006 lookbehind: true,
2007 inside: {
2008 rest: Prism.languages.php
2009 }
2010 };
2011 Prism.languages.php['heredoc-string'].inside['interpolation'] = string_interpolation;
2012 Prism.languages.php['double-quoted-string'].inside['interpolation'] = string_interpolation;
1730 2013
1731 // Tokenize all inline PHP blocks that are wrapped in <?php ?>2014 Prism.hooks.add('before-tokenize', function(env) {
1732 // This allows for easy PHP + markup highlighting2015 if (!/(?:<\?php|<\?)/ig.test(env.code)) {
1733 Prism.hooks.add('before-highlight', function(env) {
1734 if (env.language !== 'php' || !/(?:<\?php|<\?)/ig.test(env.code)) {
1735 return;2016 return;
1736 }2017 }
1737 2018
1738 env.tokenStack = [];2019 var phpPattern = /(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/ig;
1739 2020 Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
1740 env.backupCode = env.code;2021 });
1741 env.code = env.code.replace(/(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/ig, function(match) {
1742 var i = env.tokenStack.length;
1743 // Check for existing strings
1744 while (env.backupCode.indexOf('___PHP' + i + '___') !== -1)
1745 ++i;
1746
1747 // Create a sparse array
1748 env.tokenStack[i] = match;
1749
1750 return '___PHP' + i + '___';
1751 });
1752 2022
1753 // Switch the grammar to markup2023 Prism.hooks.add('after-tokenize', function(env) {
1754 env.grammar = Prism.languages.markup;2024 Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
1755 });2025 });
1756 2026
1757 // Restore env.code for other plugins (e.g. line-numbers)2027}(Prism));
1758 Prism.hooks.add('before-insert', function(env) {2028Prism.languages.sql= {
1759 if (env.language === 'php' && env.backupCode) {2029 'comment': {
1760 env.code = env.backupCode;2030 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
1761 delete env.backupCode;2031 lookbehind: true
2032 },
2033 'string' : {
2034 pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\])*\2/,
2035 greedy: true,
2036 lookbehind: true
2037 },
2038 'variable': /@[\w.$]+|@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2039 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too?
2040 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
2041 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
2042 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
2043 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2044 'punctuation': /[;[\]()`,.]/
2045};
2046Prism.languages.scss = Prism.languages.extend('css', {
2047 'comment': {
2048 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
2049 lookbehind: true
2050 },
2051 'atrule': {
2052 pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
2053 inside: {
2054 'rule': /@[\w-]+/
2055 // See rest below
1762 }2056 }
1763 });2057 },
2058 // url, compassified
2059 'url': /(?:[-a-z]+-)*url(?=\()/i,
2060 // CSS selector regex is not appropriate for Sass
2061 // since there can be lot more things (var, @ directive, nesting..)
2062 // a selector must start at the end of a property or after a brace (end of other rules or nesting)
2063 // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
2064 // the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
2065 // can "pass" as a selector- e.g: proper#{$erty})
2066 // this one was hard to do, so please be careful if you edit this one :)
2067 'selector': {
2068 // Initial look-ahead is used to prevent matching of blank selectors
2069 pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|&|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
2070 inside: {
2071 'parent': {
2072 pattern: /&/,
2073 alias: 'important'
2074 },
2075 'placeholder': /%[-\w]+/,
2076 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2077 }
2078 }
2079});
1764 2080
1765 // Re-insert the tokens after highlighting2081Prism.languages.insertBefore('scss', 'atrule', {
1766 Prism.hooks.add('after-highlight', function(env) {2082 'keyword': [
1767 if (env.language !== 'php' || !env.tokenStack) {2083 /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
1768 return;2084 {
2085 pattern: /( +)(?:from|through)(?= )/,
2086 lookbehind: true
1769 }2087 }
2088 ]
2089});
1770 2090
1771 // Switch the grammar back2091Prism.languages.scss.property = {
1772 env.grammar = Prism.languages.php;2092 pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
2093 inside: {
2094 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2095 }
2096};
1773 2097
1774 for (var i = 0, keys = Object.keys(env.tokenStack); i < keys.length; ++i) {2098Prism.languages.insertBefore('scss', 'important', {
1775 var k = keys[i];2099 // var and interpolated vars
1776 var t = env.tokenStack[k];2100 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2101});
1777 2102
1778 // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns2103Prism.languages.insertBefore('scss', 'function', {
1779 env.highlightedCode = env.highlightedCode.replace('___PHP' + k + '___',2104 'placeholder': {
1780 "<span class=\"token php language-php\">" +2105 pattern: /%[-\w]+/,
1781 Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$') +2106 alias: 'selector'
1782 "</span>");2107 },
1783 }2108 'statement': {
2109 pattern: /\B!(?:default|optional)\b/i,
2110 alias: 'keyword'
2111 },
2112 'boolean': /\b(?:true|false)\b/,
2113 'null': /\bnull\b/,
2114 'operator': {
2115 pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
2116 lookbehind: true
2117 }
2118});
1784 2119
1785 env.element.innerHTML = env.highlightedCode;2120Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
1786 });
1787}
1788;
1789Prism.languages.python = {2121Prism.languages.python = {
1790 'comment': {2122 'comment': {
1791 pattern: /(^|[^\\])#.*/,2123 pattern: /(^|[^\\])#.*/,
@@ -1811,7 +2143,7 @@ Prism.languages.python = { · 19 unmodified lines
1811 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/,2143 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/,
1812 'builtin':/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,2144 'builtin':/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
1813 'boolean': /\b(?:True|False|None)\b/,2145 'boolean': /\b(?:True|False|None)\b/,
1814 'number': /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,2146 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
1815 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,2147 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
1816 'punctuation': /[{}[\];(),.:]/2148 'punctuation': /[{}[\];(),.:]/
1817};2149};
@@ -1821,93 +2153,134 @@ Prism.languages.python = { · 3 unmodified lines
1821var javascript = Prism.util.clone(Prism.languages.javascript);2153var javascript = Prism.util.clone(Prism.languages.javascript);
1822 2154
1823Prism.languages.jsx = Prism.languages.extend('markup', javascript);2155Prism.languages.jsx = Prism.languages.extend('markup', javascript);
1824Prism.languages.jsx.tag.pattern= /<\/?[\w.:-]+\s*(?:\s+(?:[\w\.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+|(?:\{[^}]*\})))?|\{\.{3}\w+\}))*\s*\/?>/i;2156Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
1825 2157
2158Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
1826Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;2159Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
1827 2160
1828Prism.languages.insertBefore('inside', 'attr-name', {2161Prism.languages.insertBefore('inside', 'attr-name', {
1829 'spread': {2162 'spread': {
1830 pattern: /\{\.{3}\w+\}/,2163 pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
1831 inside: {2164 inside: {
1832 'punctuation': /[{}]|\.{3}/,2165 'punctuation': /\.{3}|[{}.]/,
1833 'attr-value': /\w+/2166 'attr-value': /\w+/
1834 }2167 }
1835 }2168 }
1836}, Prism.languages.jsx.tag);2169}, Prism.languages.jsx.tag);
1837 2170
1838var jsxExpression = Prism.util.clone(Prism.languages.jsx);
1839
1840delete jsxExpression.punctuation;
1841
1842jsxExpression = Prism.languages.insertBefore('jsx', 'operator', {
1843 'punctuation': /=(?={)|[{}[\];(),.:]/
1844}, { jsx: jsxExpression });
1845
1846Prism.languages.insertBefore('inside', 'attr-value',{2171Prism.languages.insertBefore('inside', 'attr-value',{
1847 'script': {2172 'script': {
1848 // Allow for one level of nesting2173 // Allow for two levels of nesting
1849 pattern: /=(\{(?:\{[^}]*\}|[^}])+\})/i,2174 pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
1850 inside: jsxExpression,2175 inside: {
2176 'script-punctuation': {
2177 pattern: /^=(?={)/,
2178 alias: 'punctuation'
2179 },
2180 rest: Prism.languages.jsx
2181 },
1851 'alias': 'language-javascript'2182 'alias': 'language-javascript'
1852 }2183 }
1853}, Prism.languages.jsx.tag);2184}, Prism.languages.jsx.tag);
1854 2185
1855}(Prism));2186// The following will handle plain text inside tags
2187var stringifyToken = function (token) {
2188 if (!token) {
2189 return '';
2190 }
2191 if (typeof token === 'string') {
2192 return token;
2193 }
2194 if (typeof token.content === 'string') {
2195 return token.content;
2196 }
2197 return token.content.map(stringifyToken).join('');
2198};
1856 2199
1857(function(Prism) {2200var walkTokens = function (tokens) {
1858 Prism.languages.crystal = Prism.languages.extend('ruby', {2201 var openedTags = [];
1859 keyword: [2202 for (var i = 0; i < tokens.length; i++) {
1860 /\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|select|self|sizeof|struct|super|then|type|typeof|uninitialized|union|unless|until|when|while|with|yield|__DIR__|__END_LINE__|__FILE__|__LINE__)\b/,2203 var token = tokens[i];
1861 {2204 var notTagNorBrace = false;
1862 pattern: /(\.\s*)(?:is_a|responds_to)\?/,2205
1863 lookbehind: true2206 if (typeof token !== 'string') {
1864 }2207 if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
1865 ],2208 // We found a tag, now find its kind
2209
2210 if (token.content[0].content[0].content === '</') {
2211 // Closing tag
2212 if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
2213 // Pop matching opening tag
2214 openedTags.pop();
2215 }
2216 } else {
2217 if (token.content[token.content.length - 1].content === '/>') {
2218 // Autoclosed tag, ignore
2219 } else {
2220 // Opening tag
2221 openedTags.push({
2222 tagName: stringifyToken(token.content[0].content[1]),
2223 openedBraces: 0
2224 });
2225 }
2226 }
2227 } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
1866 2228
1867 number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[0-9a-fA-F_]*[0-9a-fA-F]|(?:\d(?:[0-9_]*\d)?)(?:\.[0-9_]*\d)?(?:[eE][+-]?[0-9_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/2229 // Here we might have entered a JSX context inside a tag
1868 });2230 openedTags[openedTags.length - 1].openedBraces++;
1869 2231
1870 var rest = Prism.util.clone(Prism.languages.crystal);2232 } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
1871 2233
1872 Prism.languages.insertBefore('crystal', 'string', {2234 // Here we might have left a JSX context inside a tag
1873 attribute: {2235 openedTags[openedTags.length - 1].openedBraces--;
1874 pattern: /@\[.+?\]/,
1875 alias: 'attr-name',
1876 inside: {
1877 delimiter: {
1878 pattern: /^@\[|\]$/,
1879 alias: 'tag'
1880 },
1881 rest: rest
1882 }
1883 },
1884 2236
1885 expansion: [2237 } else {
1886 {2238 notTagNorBrace = true
1887 pattern: /\{\{.+?\}\}/,
1888 inside: {
1889 delimiter: {
1890 pattern: /^\{\{|\}\}$/,
1891 alias: 'tag'
1892 },
1893 rest: rest
1894 }2239 }
1895 },2240 }
1896 {2241 if (notTagNorBrace || typeof token === 'string') {
1897 pattern: /\{%.+?%\}/,2242 if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
1898 inside: {2243 // Here we are inside a tag, and not inside a JSX context.
1899 delimiter: {2244 // That's plain text: drop any tokens matched.
1900 pattern: /^\{%|%\}$/,2245 var plainText = stringifyToken(token);
1901 alias: 'tag'2246
1902 },2247 // And merge text with adjacent text
1903 rest: rest2248 if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
2249 plainText += stringifyToken(tokens[i + 1]);
2250 tokens.splice(i + 1, 1);
2251 }
2252 if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
2253 plainText = stringifyToken(tokens[i - 1]) + plainText;
2254 tokens.splice(i - 1, 1);
2255 i--;
2256 }
2257
2258 tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
1904 }2259 }
1905 }2260 }
1906 ]2261
1907 });2262 if (token.content && typeof token.content !== 'string') {
2263 walkTokens(token.content);
2264 }
2265 }
2266};
2267
2268Prism.hooks.add('after-tokenize', function (env) {
2269 if (env.language !== 'jsx' && env.language !== 'tsx') {
2270 return;
2271 }
2272 walkTokens(env.tokens);
2273});
1908 2274
1909}(Prism));2275}(Prism));
1910 2276
2277Prism.languages.typescript = Prism.languages.extend('javascript', {
2278 // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
2279 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield|module|declare|constructor|namespace|abstract|require|type)\b/,
2280 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console)\b/,
2281});
2282
2283Prism.languages.ts = Prism.languages.typescript;
1911/* TODO2284/* TODO
1912 Add support for Markdown notation inside doc comments2285 Add support for Markdown notation inside doc comments
1913 Add support for nested block comments...2286 Add support for nested block comments...
@@ -1932,10 +2305,18 @@ Prism.languages.rust = { · 18 unmodified lines
1932 greedy: true2305 greedy: true
1933 },2306 },
1934 {2307 {
1935 pattern: /b?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,2308 pattern: /b?"(?:\\.|[^\\\r\n"])*"/,
1936 greedy: true2309 greedy: true
1937 }2310 }
1938 ],2311 ],
2312 'char': {
2313 pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
2314 alias: 'string'
2315 },
2316 'lifetime-annotation': {
2317 pattern: /'[^\s>']+/,
2318 alias: 'symbol'
2319 },
1939 'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/,2320 'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/,
1940 2321
1941 'attribute': {2322 'attribute': {
@@ -1955,7 +2336,7 @@ Prism.languages.rust = { · 13 unmodified lines
1955 },2336 },
1956 2337
1957 // Hex, oct, bin, dec numbers with visual separators and type suffix2338 // Hex, oct, bin, dec numbers with visual separators and type suffix
1958 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,2339 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,
1959 2340
1960 // Closure params should not be confused with bitwise OR |2341 // Closure params should not be confused with bitwise OR |
1961 'closure-params': {2342 'closure-params': {
@@ -1966,107 +2347,8 @@ Prism.languages.rust = { · 4 unmodified lines
1966 }2347 }
1967 },2348 },
1968 'punctuation': /[{}[\];(),:]|\.+|->/,2349 'punctuation': /[{}[\];(),:]|\.+|->/,
1969 'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/2350 'operator': /[-+*\/%!^]=?|=[=>]?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
1970};2351};
1971Prism.languages.scss = Prism.languages.extend('css', {
1972 'comment': {
1973 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1974 lookbehind: true
1975 },
1976 'atrule': {
1977 pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
1978 inside: {
1979 'rule': /@[\w-]+/
1980 // See rest below
1981 }
1982 },
1983 // url, compassified
1984 'url': /(?:[-a-z]+-)*url(?=\()/i,
1985 // CSS selector regex is not appropriate for Sass
1986 // since there can be lot more things (var, @ directive, nesting..)
1987 // a selector must start at the end of a property or after a brace (end of other rules or nesting)
1988 // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
1989 // the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
1990 // can "pass" as a selector- e.g: proper#{$erty})
1991 // this one was hard to do, so please be careful if you edit this one :)
1992 'selector': {
1993 // Initial look-ahead is used to prevent matching of blank selectors
1994 pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|&|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
1995 inside: {
1996 'parent': {
1997 pattern: /&/,
1998 alias: 'important'
1999 },
2000 'placeholder': /%[-\w]+/,
2001 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2002 }
2003 }
2004});
2005
2006Prism.languages.insertBefore('scss', 'atrule', {
2007 'keyword': [
2008 /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
2009 {
2010 pattern: /( +)(?:from|through)(?= )/,
2011 lookbehind: true
2012 }
2013 ]
2014});
2015
2016Prism.languages.scss.property = {
2017 pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
2018 inside: {
2019 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2020 }
2021};
2022
2023Prism.languages.insertBefore('scss', 'important', {
2024 // var and interpolated vars
2025 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2026});
2027
2028Prism.languages.insertBefore('scss', 'function', {
2029 'placeholder': {
2030 pattern: /%[-\w]+/,
2031 alias: 'selector'
2032 },
2033 'statement': {
2034 pattern: /\B!(?:default|optional)\b/i,
2035 alias: 'keyword'
2036 },
2037 'boolean': /\b(?:true|false)\b/,
2038 'null': /\bnull\b/,
2039 'operator': {
2040 pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
2041 lookbehind: true
2042 }
2043});
2044
2045Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss);
2046Prism.languages.sql= {
2047 'comment': {
2048 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
2049 lookbehind: true
2050 },
2051 'string' : {
2052 pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\])*\2/,
2053 greedy: true,
2054 lookbehind: true
2055 },
2056 'variable': /@[\w.$]+|@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2057 'function': /\b(?:COUNT|SUM|AVG|MIN|MAX|FIRST|LAST|UCASE|LCASE|MID|LEN|ROUND|NOW|FORMAT)(?=\s*\()/i, // Should we highlight user defined functions too?
2058 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR VARYING|CHARACTER (?:SET|VARYING)|CHARSET|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COLUMNS|COMMENT|COMMIT|COMMITTED|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|DATA(?:BASES?)?|DATE(?:TIME)?|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITER(?:S)?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE(?: PRECISION)?|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE KEY|ELSE|ENABLE|ENCLOSED BY|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPE(?:D BY)?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTO|INVOKER|ISOLATION LEVEL|JOIN|KEYS?|KILL|LANGUAGE SQL|LAST|LEFT|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MODIFIES SQL DATA|MODIFY|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL(?: CHAR VARYING| CHARACTER(?: VARYING)?| VARCHAR)?|NATURAL|NCHAR(?: VARCHAR)?|NEXT|NO(?: SQL|CHECK|CYCLE)?|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READ(?:S SQL DATA|TEXT)?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEATABLE|REPLICATION|REQUIRE|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE MODE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|START(?:ING BY)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED BY|TEXT(?:SIZE)?|THEN|TIMESTAMP|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNPIVOT|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?)\b/i,
2059 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
2060 'number': /\b-?(?:0x)?\d*\.?[\da-f]+\b/,
2061 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2062 'punctuation': /[;[\]()`,.]/
2063};
2064Prism.languages.typescript = Prism.languages.extend('javascript', {
2065 // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
2066 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield|false|true|module|declare|constructor|string|Function|any|number|boolean|Array|symbol|namespace|abstract|require|type)\b/
2067});
2068
2069Prism.languages.ts = Prism.languages.typescript;
2070Prism.languages.yaml = {2352Prism.languages.yaml = {
2071 'scalar': {2353 'scalar': {
2072 pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,2354 pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,
@@ -2105,11 +2387,10 @@ Prism.languages.yaml = { · 32 unmodified lines
2105 greedy: true2387 greedy: true
2106 },2388 },
2107 'number': {2389 'number': {
2108 pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+\-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,2390 pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,
2109 lookbehind: true2391 lookbehind: true
2110 },2392 },
2111 'tag': /![^\s]+/,2393 'tag': /![^\s]+/,
2112 'important': /[&*][\w]+/,2394 'important': /[&*][\w]+/,
2113 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./2395 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
2114};2396};
2115
assets/javascripts/vendor/raven.js+1−1
@@ -856,7 +856,7 @@ Raven.prototype = { · 855 unmodified lines
856 },856 },
857 857
858 _triggerEvent: function(eventType, options) {858 _triggerEvent: function(eventType, options) {
859 // NOTE: `event` is a native browser thing, so let's avoid conflicting wiht it859 // NOTE: `event` is a native browser thing, so let's avoid conflicting with it
860 var evt, key;860 var evt, key;
861 861
862 if (!this._hasDocument) return;862 if (!this._hasDocument) return;
assets/javascripts/views/content/content.coffee+3−0
@@ -153,6 +153,9 @@ class app.views.Content extends app.View · 152 unmodified lines
153 return153 return
154 154
155 afterRoute: (route, context) =>155 afterRoute: (route, context) =>
156 if route != 'entry' and route != 'type'
157 resetFavicon()
158
156 switch route159 switch route
157 when 'root'160 when 'root'
158 @show @rootPage161 @show @rootPage
assets/javascripts/views/content/entry_page.coffee+2−1
@@ -40,6 +40,7 @@ class app.views.EntryPage extends app.View · 39 unmodified lines
40 if app.disabledDocs.findBy 'slug', @entry.doc.slug40 if app.disabledDocs.findBy 'slug', @entry.doc.slug
41 @hiddenView = new app.views.HiddenPage @el, @entry41 @hiddenView = new app.views.HiddenPage @el, @entry
42 42
43 setFaviconForDoc(@entry.doc)
43 @delay @polyfillMathML44 @delay @polyfillMathML
44 @trigger 'loaded'45 @trigger 'loaded'
45 return46 return
@@ -123,7 +124,7 @@ class app.views.EntryPage extends app.View · 77 unmodified lines
123 @render @tmpl('pageLoadError')124 @render @tmpl('pageLoadError')
124 @resetClass()125 @resetClass()
125 @addClass @constructor.errorClass126 @addClass @constructor.errorClass
126 app.appCache?.update()127 app.serviceWorker?.update()
127 return128 return
128 129
129 cache: ->130 cache: ->
assets/javascripts/views/content/offline_page.coffee+1−0
@@ -57,6 +57,7 @@ class app.views.OfflinePage extends app.View · 56 unmodified lines
57 doc[action](@onInstallSuccess.bind(@, doc), @onInstallError.bind(@, doc), @onInstallProgress.bind(@, doc))57 doc[action](@onInstallSuccess.bind(@, doc), @onInstallError.bind(@, doc), @onInstallProgress.bind(@, doc))
58 el.parentNode.innerHTML = "#{el.textContent.replace(/e$/, '')}ing…"58 el.parentNode.innerHTML = "#{el.textContent.replace(/e$/, '')}ing…"
59 else if action = el.getAttribute('data-action-all')59 else if action = el.getAttribute('data-action-all')
60 return unless action isnt 'uninstall' or window.confirm('Uninstall all docs?')
60 app.db.migrate()61 app.db.migrate()
61 $.click(el) for el in @findAll("[data-action='#{action}']")62 $.click(el) for el in @findAll("[data-action='#{action}']")
62 return63 return
assets/javascripts/views/content/root_page.coffee+0−4
@@ -19,10 +19,6 @@ class app.views.RootPage extends app.View · 18 unmodified lines
19 else19 else
20 'intro'20 'intro'
21 21
22 # temporary
23 if location.host is 'devdocs.io' and location.protocol is 'http:'
24 tmpl = 'httpWarning'
25
26 @append @tmpl(tmpl)22 @append @tmpl(tmpl)
27 return23 return
28 24
assets/javascripts/views/content/settings_page.coffee+10−12
@@ -1,7 +1,4 @@
1class app.views.SettingsPage extends app.View1class app.views.SettingsPage extends app.View
2 LAYOUTS = ['_max-width', '_sidebar-hidden', '_native-scrollbars']
3 SIDEBAR_HIDDEN_LAYOUT = '_sidebar-hidden'
4
5 @className: '_static'2 @className: '_static'
6 3
7 @events:4 @events:
@@ -17,32 +14,31 @@ class app.views.SettingsPage extends app.View · 9 unmodified lines
17 settings.dark = app.settings.get('dark')14 settings.dark = app.settings.get('dark')
18 settings.smoothScroll = !app.settings.get('fastScroll')15 settings.smoothScroll = !app.settings.get('fastScroll')
19 settings.arrowScroll = app.settings.get('arrowScroll')16 settings.arrowScroll = app.settings.get('arrowScroll')
20 settings[layout] = app.settings.hasLayout(layout) for layout in LAYOUTS17 settings.autoInstall = app.settings.get('autoInstall')
18 settings.analyticsConsent = app.settings.get('analyticsConsent')
19 settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS
21 settings20 settings
22 21
23 getTitle: ->22 getTitle: ->
24 'Preferences'23 'Preferences'
25 24
26 toggleDark: (enable) ->25 toggleDark: (enable) ->
27 css = $('link[rel="stylesheet"][data-alt]')
28 alt = css.getAttribute('data-alt')
29 css.setAttribute('data-alt', css.getAttribute('href'))
30 css.setAttribute('href', alt)
31 app.settings.set('dark', !!enable)26 app.settings.set('dark', !!enable)
32 app.appCache?.updateInBackground()
33 return27 return
34 28
35 toggleLayout: (layout, enable) ->29 toggleLayout: (layout, enable) ->
36 document.body.classList[if enable then 'add' else 'remove'](layout) unless layout is SIDEBAR_HIDDEN_LAYOUT
37 document.body.classList[if $.overlayScrollbarsEnabled() then 'add' else 'remove']('_overlay-scrollbars')
38 app.settings.setLayout(layout, enable)30 app.settings.setLayout(layout, enable)
39 app.appCache?.updateInBackground()
40 return31 return
41 32
42 toggleSmoothScroll: (enable) ->33 toggleSmoothScroll: (enable) ->
43 app.settings.set('fastScroll', !enable)34 app.settings.set('fastScroll', !enable)
44 return35 return
45 36
37 toggleAnalyticsConsent: (enable) ->
38 app.settings.set('analyticsConsent', if enable then '1' else '0')
39 resetAnalytics() unless enable
40 return
41
46 toggle: (name, enable) ->42 toggle: (name, enable) ->
47 app.settings.set(name, enable)43 app.settings.set(name, enable)
48 return44 return
@@ -86,6 +82,8 @@ class app.views.SettingsPage extends app.View · 37 unmodified lines
86 @toggleSmoothScroll input.checked82 @toggleSmoothScroll input.checked
87 when 'import'83 when 'import'
88 @import input.files[0], input84 @import input.files[0], input
85 when 'analyticsConsent'
86 @toggleAnalyticsConsent input.checked
89 else87 else
90 @toggle input.name, input.checked88 @toggle input.name, input.checked
91 return89 return
assets/javascripts/views/content/type_page.coffee+1−0
@@ -9,6 +9,7 @@ class app.views.TypePage extends app.View · 8 unmodified lines
9 9
10 render: (@type) ->10 render: (@type) ->
11 @html @tmpl('typePage', @type)11 @html @tmpl('typePage', @type)
12 setFaviconForDoc(@type.doc)
12 return13 return
13 14
14 getTitle: ->15 getTitle: ->
assets/javascripts/views/layout/document.coffee+7−5
@@ -75,9 +75,11 @@ class app.views.Document extends app.View · 74 unmodified lines
75 return unless target.hasAttribute('data-behavior')75 return unless target.hasAttribute('data-behavior')
76 $.stopEvent(event)76 $.stopEvent(event)
77 switch target.getAttribute('data-behavior')77 switch target.getAttribute('data-behavior')
78 when 'back' then history.back()78 when 'back' then history.back()
79 when 'reload' then window.location.reload()79 when 'reload' then window.location.reload()
80 when 'reboot' then window.location = '/'80 when 'reboot' then app.reboot()
81 when 'hard-reload' then app.reload()81 when 'hard-reload' then app.reload()
82 when 'reset' then app.reset() if confirm('Are you sure you want to reset DevDocs?')82 when 'reset' then app.reset() if confirm('Are you sure you want to reset DevDocs?')
83 when 'accept-analytics' then Cookies.set('analyticsConsent', '1', expires: 1e8) && app.reboot()
84 when 'decline-analytics' then Cookies.set('analyticsConsent', '0', expires: 1e8) && app.reboot()
83 return85 return
assets/javascripts/views/layout/resizer.coffee+2−9
@@ -11,9 +11,6 @@ class app.views.Resizer extends app.View · 10 unmodified lines
11 init: ->11 init: ->
12 @el.setAttribute('draggable', 'true')12 @el.setAttribute('draggable', 'true')
13 @appendTo $('._app')13 @appendTo $('._app')
14
15 @style = $('style[data-resizer]')
16 @size = @style.getAttribute('data-size')
17 return14 return
18 15
19 MIN = 26016 MIN = 260
@@ -24,15 +21,11 @@ class app.views.Resizer extends app.View · 4 unmodified lines
24 return unless value > 021 return unless value > 0
25 value = Math.min(Math.max(Math.round(value), MIN), MAX)22 value = Math.min(Math.max(Math.round(value), MIN), MAX)
26 newSize = "#{value}px"23 newSize = "#{value}px"
27 @style.innerHTML = @style.innerHTML.replace(new RegExp(@size, 'g'), newSize)24 document.documentElement.style.setProperty('--sidebarWidth', newSize)
28 @size = newSize25 app.settings.setSize(value) if save
29 if save
30 app.settings.setSize(value)
31 app.appCache?.updateInBackground()
32 return26 return
33 27
34 onDragStart: (event) =>28 onDragStart: (event) =>
35 @style.removeAttribute('disabled')
36 event.dataTransfer.effectAllowed = 'link'29 event.dataTransfer.effectAllowed = 'link'
37 event.dataTransfer.setData('Text', '')30 event.dataTransfer.setData('Text', '')
38 $.on(window, 'dragover', @onDrag)31 $.on(window, 'dragover', @onDrag)
assets/javascripts/views/layout/settings.coffee+1−9
@@ -25,7 +25,6 @@ class app.views.Settings extends app.View · 24 unmodified lines
25 if super25 if super
26 @render()26 @render()
27 document.body.classList.remove(SIDEBAR_HIDDEN_LAYOUT)27 document.body.classList.remove(SIDEBAR_HIDDEN_LAYOUT)
28 app.appCache?.on 'progress', @onAppCacheProgress
29 return28 return
30 29
31 deactivate: ->30 deactivate: ->
@@ -33,7 +32,6 @@ class app.views.Settings extends app.View · 1 unmodified line
33 @resetClass()32 @resetClass()
34 @docPicker.detach()33 @docPicker.detach()
35 document.body.classList.add(SIDEBAR_HIDDEN_LAYOUT) if app.settings.hasLayout(SIDEBAR_HIDDEN_LAYOUT)34 document.body.classList.add(SIDEBAR_HIDDEN_LAYOUT) if app.settings.hasLayout(SIDEBAR_HIDDEN_LAYOUT)
36 app.appCache?.off 'progress', @onAppCacheProgress
37 return35 return
38 36
39 render: ->37 render: ->
@@ -52,7 +50,7 @@ class app.views.Settings extends app.View · 12 unmodified lines
52 docs = @docPicker.getSelectedDocs()50 docs = @docPicker.getSelectedDocs()
53 app.settings.setDocs(docs)51 app.settings.setDocs(docs)
54 52
55 @saveBtn.textContent = if app.appCache then 'Downloading\u2026' else 'Saving\u2026'53 @saveBtn.textContent = 'Saving\u2026'
56 disabledDocs = new app.collections.Docs(doc for doc in app.docs.all() when docs.indexOf(doc.slug) is -1)54 disabledDocs = new app.collections.Docs(doc for doc in app.docs.all() when docs.indexOf(doc.slug) is -1)
57 disabledDocs.uninstall ->55 disabledDocs.uninstall ->
58 app.db.migrate()56 app.db.migrate()
@@ -83,9 +81,3 @@ class app.views.Settings extends app.View · 24 unmodified lines
83 $.stopEvent(event)81 $.stopEvent(event)
84 app.router.show '/'82 app.router.show '/'
85 return83 return
86
87 onAppCacheProgress: (event) =>
88 if event.lengthComputable
89 percentage = Math.round event.loaded * 100 / event.total
90 @saveBtn.textContent = "Downloading\u2026 (#{percentage}%)"
91 return
assets/javascripts/views/search/search.coffee+13−0
@@ -17,6 +17,7 @@ class app.views.Search extends app.View · 16 unmodified lines
17 typing: 'focus'17 typing: 'focus'
18 altG: 'google'18 altG: 'google'
19 altS: 'stackoverflow'19 altS: 'stackoverflow'
20 altD: 'duckduckgo'
20 21
21 @routes:22 @routes:
22 after: 'afterRoute'23 after: 'afterRoute'
@@ -29,6 +30,9 @@ class app.views.Search extends app.View · 6 unmodified lines
29 .on 'results', @onResults30 .on 'results', @onResults
30 .on 'end', @onEnd31 .on 'end', @onEnd
31 32
33 @scope
34 .on 'change', @onScopeChange
35
32 app.on 'ready', @onReady36 app.on 'ready', @onReady
33 $.on window, 'hashchange', @searchUrl37 $.on window, 'hashchange', @searchUrl
34 $.on window, 'focus', @onWindowFocus38 $.on window, 'focus', @onWindowFocus
@@ -113,6 +117,10 @@ class app.views.Search extends app.View · 78 unmodified lines
113 @externalSearch "https://stackoverflow.com/search?q="117 @externalSearch "https://stackoverflow.com/search?q="
114 return118 return
115 119
120 duckduckgo: =>
121 @externalSearch "https://duckduckgo.com/?t=devdocs&q="
122 return
123
116 onResults: (results) =>124 onResults: (results) =>
117 @hasResults = true if results.length125 @hasResults = true if results.length
118 @trigger 'results', results, @flags126 @trigger 'results', results, @flags
@@ -133,6 +141,11 @@ class app.views.Search extends app.View · 14 unmodified lines
133 $.stopEvent(event)141 $.stopEvent(event)
134 return142 return
135 143
144 onScopeChange: =>
145 @value = ''
146 @onInput()
147 return
148
136 afterRoute: (name, context) =>149 afterRoute: (name, context) =>
137 return if app.shortcuts.eventInProgress?.name is 'escape'150 return if app.shortcuts.eventInProgress?.name is 'escape'
138 @reset(true) if not context.init and app.router.isIndex()151 @reset(true) if not context.init and app.router.isIndex()
assets/javascripts/views/search/search_scope.coffee+23−5
@@ -6,7 +6,9 @@ class app.views.SearchScope extends app.View · 5 unmodified lines
6 tag: '._search-tag'6 tag: '._search-tag'
7 7
8 @events:8 @events:
9 click: 'onClick'
9 keydown: 'onKeydown'10 keydown: 'onKeydown'
11 textInput: 'onTextInput'
10 12
11 @routes:13 @routes:
12 after: 'afterRoute'14 after: 'afterRoute'
@@ -87,17 +89,33 @@ class app.views.SearchScope extends app.View · 74 unmodified lines
87 @trigger 'change', null, previousDoc89 @trigger 'change', null, previousDoc
88 return90 return
89 91
92 doScopeSearch: (event) =>
93 @search @input.value[0...@input.selectionStart]
94 $.stopEvent(event) if @doc
95 return
96
97 onClick: (event) =>
98 if event.target is @tag
99 @reset()
100 $.stopEvent(event)
101 return
102
90 onKeydown: (event) =>103 onKeydown: (event) =>
91 if event.which is 8 # backspace104 if event.which is 8 # backspace
92 if @doc and not @input.value105 if @doc and @input.selectionEnd is 0
93 $.stopEvent(event)
94 @reset()106 @reset()
95 else if not @doc and @input.value107 $.stopEvent(event)
108 else if not @doc and @input.value and not $.isChromeForAndroid()
96 return if event.ctrlKey or event.metaKey or event.altKey or event.shiftKey109 return if event.ctrlKey or event.metaKey or event.altKey or event.shiftKey
97 if event.which is 9 or # tab110 if event.which is 9 or # tab
98 (event.which is 32 and app.isMobile()) # space111 (event.which is 32 and app.isMobile()) # space
99 @search @input.value[0...@input.selectionStart]112 @doScopeSearch(event)
100 $.stopEvent(event) if @doc113 return
114
115 onTextInput: (event) =>
116 return unless $.isChromeForAndroid()
117 if not @doc and @input.value and event.data == ' '
118 @doScopeSearch(event)
101 return119 return
102 120
103 extractHashValue: ->121 extractHashValue: ->
assets/javascripts/views/sidebar/sidebar.coffee+1−1
@@ -28,7 +28,7 @@ class app.views.Sidebar extends app.View · 27 unmodified lines
28 28
29 app.on 'ready', @onReady29 app.on 'ready', @onReady
30 30
31 $.on document.documentElement, 'mouseleave', (event) => @display() if event.clientX < 1031 $.on document.documentElement, 'mouseleave', (event) => @display() unless event.clientX <= 0
32 $.on document.documentElement, 'mouseenter', => @resetDisplay(forceNoHover: false)32 $.on document.documentElement, 'mouseenter', => @resetDisplay(forceNoHover: false)
33 return33 return
34 34

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t