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
1313
1414 @el = $('._app')
1515 @localStorage = new LocalStorageStore
16− @appCache = new app.AppCache if app.AppCache.isEnabled()
16+ @serviceWorker = new app.ServiceWorker if app.ServiceWorker.isEnabled()
1717 @settings = new app.Settings
1818 @db = new app.DB()
1919
20+ @settings.initLayout()
21+
2022 @docs = new app.collections.Docs
2123 @disabledDocs = new app.collections.Docs
2224 @entries = new app.collections.Entries
@@ -76,7 +78,7 @@ · 53 unmodified lines
7678 .install()
7779 @previousErrorHandler = onerror
7880 window.onerror = @onWindowError.bind(@)
79− CookieStore.onBlocked = @onCookieBlocked
81+ CookiesStore.onBlocked = @onCookieBlocked
8082 return
8183
8284 bootOne: ->
@@ -138,7 +140,10 @@ · 55 unmodified lines
138140 @docs.sort()
139141 @initDoc(doc)
140142 @saveDocs()
141− _onSuccess()
143+ if app.settings.get('autoInstall')
144+ doc.install(_onSuccess, onError)
145+ else
146+ _onSuccess()
142147 return
143148
144149 doc.load onSuccess, onError, writeCache: true
@@ -147,7 +152,7 @@ · 2 unmodified lines
147152 saveDocs: ->
148153 @settings.setDocs(doc.slug for doc in @docs.all())
149154 @db.migrate()
150− @appCache?.updateInBackground()
155+ @serviceWorker?.updateInBackground()
151156
152157 welcomeBack: ->
153158 visitCount = @settings.get('count')
@@ -157,17 +162,24 @@ · 3 unmodified lines
157162 new app.views.Updates()
158163 @updateChecker = new app.UpdateChecker()
159164
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+
160172 reload: ->
161173 @docs.clearCache()
162174 @disabledDocs.clearCache()
163− if @appCache then @appCache.reload() else window.location = '/'
175+ if @serviceWorker then @serviceWorker.reload() else @reboot()
164176 return
165177
166178 reset: ->
167179 @localStorage.reset()
168180 @settings.reset()
169181 @db?.reset()
170− @appCache?.update()
182+ @serviceWorker?.update()
171183 window.location = '/'
172184 return
173185
@@ -186,9 +198,9 @@ · 12 unmodified lines
186198 return
187199
188200 indexHost: ->
189− # Can't load the index files from the host/CDN when applicationCache is
201+ # Can't load the index files from the host/CDN when service worker is
190202 # 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']
192204
193205 onBootError: (args...) ->
194206 @trigger 'bootError'
@@ -245,7 +257,7 @@ · 50 unmodified lines
245257 matchMedia: !!window.matchMedia
246258 insertAdjacentHTML: !!document.body.insertAdjacentHTML
247259 defaultPrevented: document.createEvent('CustomEvent').defaultPrevented is false
248− cssGradients: supportsCssGradients()
260+ cssVariables: !!CSS?.supports?('(--t: 0)')
249261
250262 for key, value of features when not value
251263 Raven.captureMessage "unsupported/#{key}", level: 'info'
@@ -268,9 +280,4 @@ · 16 unmodified lines
268280 isInvalidLocation: ->
269281 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0
270282
271−supportsCssGradients = ->
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−
276283 $.extend app, Events
assets/javascripts/app/appcache.coffee+0−42
@@ -1,42 +0,0 @@
1−class 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
1313 version: <%= Time.now.to_i %>
1414 release: <%= Time.now.utc.httpdate.to_json %>
1515 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 @@
1+class 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
55 'manualUpdate'
66 'fastScroll'
77 'arrowScroll'
8+ 'analyticsConsent'
89 'docs'
910 'dark'
1011 'layout'
1112 'size'
1213 'tips'
14+ 'autoInstall'
1315 ]
1416
1517 INTERNAL_KEYS = [
@@ -19,6 +21,8 @@ class app.Settings · 3 unmodified lines
1921 'news'
2022 ]
2123
24+ LAYOUTS: ['_max-width', '_sidebar-hidden', '_native-scrollbars']
25+
2226 @defaults:
2327 count: 0
2428 hideDisabled: false
@@ -26,9 +30,10 @@ class app.Settings · 1 unmodified line
2630 news: 0
2731 manualUpdate: false
2832 schema: 1
33+ analyticsConsent: false
2934
3035 constructor: ->
31− @store = new CookieStore
36+ @store = new CookiesStore
3237 @cache = {}
3338
3439 get: (key) ->
@@ -38,6 +43,7 @@ class app.Settings · 3 unmodified lines
3843 set: (key, value) ->
3944 @store.set(key, value)
4045 delete @cache[key]
46+ @toggleDark(value) if key == 'dark'
4147 return
4248
4349 del: (key) ->
@@ -63,6 +69,8 @@ class app.Settings · 19 unmodified lines
6369 return
6470
6571 setLayout: (name, enable) ->
72+ @toggleLayout(name, enable)
73+
6674 layout = (@store.get('layout') || '').split(' ')
6775 $.arrayDelete(layout, '')
6876
@@ -104,3 +112,28 @@ class app.Settings · 35 unmodified lines
104112 @store.reset()
105113 @cache = {}
106114 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
149149 when 40
150150 @trigger 'altDown'
151151 false
152+ when 68
153+ @trigger 'altD'
154+ false
152155 when 70
153156 @trigger 'altF', event
154157 when 71
assets/javascripts/app/update_checker.coffee+3−3
@@ -3,13 +3,13 @@ class app.UpdateChecker · 2 unmodified lines
33 @lastCheck = Date.now()
44
55 $.on window, 'focus', @onFocus
6− app.appCache.on 'updateready', @onUpdateReady if app.appCache
6+ app.serviceWorker?.on 'updateready', @onUpdateReady
77
88 setTimeout @checkDocs, 0
99
1010 check: ->
11− if app.appCache
12− app.appCache.update()
11+ if app.serviceWorker
12+ app.serviceWorker.update()
1313 else
1414 ajax
1515 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 @@
1−class @CookieStore
1+class @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+
26 INT = /^\d+$/
37
48 @onBlocked: ->
assets/javascripts/lib/favicon.coffee+64−0
@@ -0,0 +1,64 @@
1+defaultUrl = null
2+currentSlug = null
3+
4+imageCache = {}
5+urlCache = {}
6+
7+withImage = (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 @@
11 ###
2− * Copyright 2013-2018 Thibaut Courouble and other contributors
2+ * Copyright 2013-2019 Thibaut Courouble and other contributors
33 *
44 * This source code is licensed under the terms of the Mozilla
55 * 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
190190
191191 updateCanonicalLink = ->
192192 @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}")
194194
195195 trackers = []
196196
@@ -199,5 +199,21 @@ page.track = (fn) -> · 2 unmodified lines
199199 return
200200
201201 track = ->
202− tracker.call() for tracker in trackers
202+ 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)
203219 return
assets/javascripts/lib/util.coffee+4−0
@@ -352,6 +352,10 @@ isIE = null · 351 unmodified lines
352352 $.isIE = ->
353353 isIE ?= navigator.userAgent?.indexOf('MSIE') >= 0 || navigator.userAgent?.indexOf('rv:11.0') >= 0
354354
355+isChromeForAndroid = null
356+$.isChromeForAndroid = ->
357+ isChromeForAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 && /Chrome\/([.0-9])+ Mobile/.test(navigator.userAgent)
358+
355359 isAndroid = null
356360 $.isAndroid = ->
357361 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
142142 return
143143
144144 isOutdated: (status) ->
145− status and status.installed and @mtime isnt status.mtime
145+ 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 @@
11 [
22 [
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+ ], [
320 "2018-07-08",
421 "New documentations: <a href=\"/leaflet/\">Leaflet</a>, <a href=\"/terraform/\">Terraform</a> and <a href=\"/koa/\">Koa</a>"
522 ], [
assets/javascripts/templates/error_tmpl.coffee+9−12
@@ -12,8 +12,8 @@ app.templates.notFoundPage = -> · 11 unmodified lines
1212
1313 app.templates.pageLoadError = ->
1414 error """ The page failed to load. """,
15− """ It may be missing from the server (try reloading the app) or you could be offline.<br>
16− If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
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're online and you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
1717 """ #{back} &middot; <a href="/##{location.pathname}" target="_top" class="_error-link">Reload</a>
1818 &middot; <a href="#" class="_error-link" data-retry>Retry</a> """
1919
@@ -56,21 +56,18 @@ app.templates.unsupportedBrowser = """ · 36 unmodified lines
5656 <h1 class="_fail-title">Your browser is unsupported, sorry.</h1>
5757 <p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers:
5858 <ul class="_fail-list">
59− <li>Recent versions of Chrome and Firefox
60− <li>Safari 5.1+
61− <li>Opera 12.1+
62− <li>Internet Explorer 10+
63− <li>iOS 6+
64− <li>Android 4.1+
65− <li>Windows Phone 8+
59+ <li>Recent versions of Firefox, Chrome, or Opera
60+ <li>Safari 11.1+
61+ <li>Edge 17+
62+ <li>iOS 11.3+
6663 </ul>
6764 <p class="_fail-text">
68− If you're unable to upgrade, I apologize.
69− I decided to prioritize speed and new features over support for older browsers.
65+ If you're unable to upgrade, we apologize.
66+ We decided to prioritize speed and new features over support for older browsers.
7067 <p class="_fail-text">
7168 Note: if you're already using one of the browsers above, check your settings and add-ons.
7269 The app uses feature detection, not user agent sniffing.
7370 <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>
7572 </div>
7673 """
assets/javascripts/templates/notif_tmpl.coffee+6−0
@@ -68,3 +68,9 @@ app.templates.notifShare = -> · 67 unmodified lines
6868 app.templates.notifUpdateDocs = ->
6969 textNotif """ Documentation updates available. """,
7070 """ <a href="/offline">Install them</a> as soon as possible to avoid broken pages. """
71+
72+app.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
1111 </nav>
1212
1313 <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.
15− <ul>
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>
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+ <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>.
2016 <p>To keep up-to-date with the latest news:
2117 <ul>
2218 <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>
24− <li>Join the <a href="https://groups.google.com/d/forum/devdocs">mailing list</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>
20+ <li>Join the <a href="https://gitter.im/FreeCodeCamp/DevDocs">Gitter</a> chat room
2521 </ul>
2622
2723 <h2 class="_block-heading" id="copyright">Copyright and License</h2>
2824 <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>
3026 This software is licensed under the terms of the Mozilla Public License v2.0.<br>
3127 You may obtain a copy of the source code at <a href="https://github.com/freeCodeCamp/devdocs">github.com/freeCodeCamp/devdocs</a>.<br>
3228 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
4844 <dt>Where can I suggest new docs and features?
4945 <dd>You can suggest and vote for new docs on the <a href="https://trello.com/b/6BmTulfx/devdocs-documentation">Trello board</a>.<br>
5046 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.
5248 <dt>Where can I report bugs?
5349 <dd>In the <a href="https://github.com/freeCodeCamp/devdocs/issues">issue tracker</a>. Thanks!
5450 </dl>
55− <p>For anything else, feel free to email me at <a href="mailto:thibaut@devdocs.io">thibaut@devdocs.io</a>.
5651
5752 <h2 class="_block-heading" id="credits">Credits</h2>
5853
@@ -76,12 +71,13 @@ app.templates.aboutPage = -> """ · 17 unmodified lines
7671
7772 <h2 class="_block-heading" id="privacy">Privacy Policy</h2>
7873 <ul>
79− <li><a href="https://devdocs.io">devdocs.io</a> ("App") is operated by Thibaut Courouble ("We").
80− <li>We do not collect personal information.
81− <li>We use Google Analytics, Gauges and Sentry to collect anonymous traffic information and improve the app.
74+ <li><a href="https://devdocs.io">devdocs.io</a> ("App") is operated by <a href="https://www.freecodecamp.org/">freeCodeCamp</a> ("We").
75+ <li>We do not collect personal information through 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.
8278 <li>The app uses cookies to store user preferences.
8379 <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>.
8581 </ul>
8682 """
8783
@@ -92,7 +88,7 @@ credits = [ · 4 unmodified lines
9288 'https://creativecommons.org/licenses/by/4.0/'
9389 ], [
9490 'Ansible',
95− '2012-2018 Michael DeHaan<br>&copy; 2018 Red Hat, Inc.',
91+ '2012-2018 Michael DeHaan<br>&copy; 2018–2019 Red Hat, Inc.',
9692 'GPLv3',
9793 'https://raw.githubusercontent.com/ansible/ansible/devel/COPYING'
9894 ], [
@@ -102,7 +98,7 @@ credits = [ · 3 unmodified lines
10298 'https://www.apache.org/licenses/LICENSE-2.0'
10399 ], [
104100 'Async',
105− '2010-2017 Caolan McMahon',
101+ '2010-2018 Caolan McMahon',
106102 'MIT',
107103 'https://raw.githubusercontent.com/caolan/async/master/LICENSE'
108104 ], [
@@ -115,6 +111,11 @@ credits = [ · 6 unmodified lines
115111 '2010-2016 Jeremy Ashkenas, DocumentCloud',
116112 'MIT',
117113 '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'
118119 ], [
119120 'Bluebird',
120121 '2013-2017 Petka Antonov',
@@ -122,7 +123,7 @@ credits = [ · 1 unmodified line
122123 'https://raw.githubusercontent.com/petkaantonov/bluebird/master/LICENSE'
123124 ], [
124125 'Bootstrap',
125− '2011-2018 Twitter, Inc.<br>2011-2018 The Bootstrap Authors',
126+ '2011-2019 Twitter, Inc.<br>2011-2019 The Bootstrap Authors',
126127 'CC BY',
127128 'https://creativecommons.org/licenses/by/3.0/'
128129 ], [
@@ -162,7 +163,7 @@ credits = [ · 33 unmodified lines
162163 'https://github.com/clojure/clojure/blob/master/epl-v10.html'
163164 ], [
164165 'CMake',
165− '2000-2017 Kitware, Inc. and Contributors',
166+ '2000-2019 Kitware, Inc. and Contributors',
166167 'BSD',
167168 'https://cmake.org/licensing/'
168169 ], [
@@ -185,9 +186,14 @@ credits = [ · 16 unmodified lines
185186 '2009-2018 Jeremy Ashkenas',
186187 'MIT',
187188 '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'
188194 ], [
189195 'Cordova',
190− '2012-2017 The Apache Software Foundation',
196+ '2012-2018 The Apache Software Foundation',
191197 'Apache',
192198 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'
193199 ], [
@@ -201,6 +207,12 @@ credits = [ · 7 unmodified lines
201207 'Apache',
202208 'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE'
203209 ], [
210+ 'Cypress',
211+ '2017 Cypress.io',
212+ 'MIT',
213+ 'https://raw.githubusercontent.com/cypress-io/cypress-documentation/develop/LICENSE.md'
214+ ],
215+ [
204216 'D',
205217 '1999-2018 The D Language Foundation',
206218 'Boost',
@@ -210,6 +222,11 @@ credits = [ · 3 unmodified lines
210222 '2010-2018 Michael Bostock',
211223 'BSD',
212224 '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/'
213230 ], [
214231 'Django',
215232 'Django Software Foundation and individual contributors',
@@ -217,7 +234,7 @@ credits = [ · 1 unmodified line
217234 'https://raw.githubusercontent.com/django/django/master/LICENSE'
218235 ], [
219236 '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.',
221238 'Apache',
222239 'https://raw.githubusercontent.com/docker/docker.github.io/master/LICENSE'
223240 ], [
@@ -290,11 +307,21 @@ credits = [ · 66 unmodified lines
290307 '2014-2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors',
291308 'MIT',
292309 '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'
293315 ], [
294316 'Grunt',
295317 'GruntJS Team',
296318 'MIT',
297319 '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'
298325 ], [
299326 'Haskell',
300327 'The University of Glasgow',
@@ -352,7 +379,7 @@ credits = [ · 51 unmodified lines
352379 'https://raw.githubusercontent.com/jquery/api.jqueryui.com/master/LICENSE.txt'
353380 ], [
354381 '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',
356383 'MIT',
357384 'https://raw.githubusercontent.com/JuliaLang/julia/master/LICENSE.md'
358385 ], [
@@ -372,7 +399,7 @@ credits = [ · 13 unmodified lines
372399 'https://raw.githubusercontent.com/koajs/koa/master/LICENSE'
373400 ], [
374401 'Kotlin',
375− '2010-2018 JetBrains s.r.o.',
402+ '2010-2019 JetBrains s.r.o.',
376403 'Apache',
377404 'https://raw.githubusercontent.com/JetBrains/kotlin/master/license/LICENSE.txt'
378405 ], [
@@ -382,7 +409,7 @@ credits = [ · 3 unmodified lines
382409 'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt'
383410 ], [
384411 '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.',
386413 'BSD',
387414 'https://raw.githubusercontent.com/Leaflet/Leaflet/master/LICENSE'
388415 ], [
@@ -422,7 +449,7 @@ credits = [ · 33 unmodified lines
422449 'https://daringfireball.net/projects/markdown/license'
423450 ], [
424451 'Matplotlib',
425− '2012-2017 Matplotlib Development Team. All rights reserved.',
452+ '2012-2018 Matplotlib Development Team. All rights reserved.',
426453 'Custom',
427454 'https://raw.githubusercontent.com/matplotlib/matplotlib/master/LICENSE/LICENSE'
428455 ], [
@@ -457,7 +484,7 @@ credits = [ · 28 unmodified lines
457484 'https://github.com/LearnBoost/mongoose/blob/master/README.md#license'
458485 ], [
459486 'nginx',
460− '2002-2018 Igor Sysoev<br>&copy; 2011-2018 Nginx, Inc.',
487+ '2002-2019 Igor Sysoev<br>&copy; 2011-2019 Nginx, Inc.',
461488 'BSD',
462489 'http://nginx.org/LICENSE'
463490 ], [
@@ -502,7 +529,7 @@ credits = [ · 38 unmodified lines
502529 'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER'
503530 ], [
504531 'Padrino',
505− '2010-2016 Padrino',
532+ '2010-2019 Padrino',
506533 'MIT',
507534 'https://raw.githubusercontent.com/padrino/padrino-framework/master/padrino/LICENSE.txt'
508535 ], [
@@ -545,6 +572,16 @@ credits = [ · 36 unmodified lines
545572 '1996-2018 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',
546573 'PostgreSQL',
547574 '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'
548585 ], [
549586 'Python',
550587 '2001-2018 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.',
@@ -555,6 +592,11 @@ credits = [ · 4 unmodified lines
555592 '2009-2017 Kristopher Michael Kowal',
556593 'MIT',
557594 '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'
558600 ], [
559601 'Ramda',
560602 '2013-2016 Scott Sauyet and Michael Hurley',
@@ -601,18 +643,30 @@ credits = [ · 40 unmodified lines
601643 'MIT',
602644 'https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT'
603645 ], [
646+ 'Salt Stack',
647+ '2019 SaltStack',
648+ 'Apache',
649+ 'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE'
650+ ],
651+ [
604652 'Sass',
605653 '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',
606654 'MIT',
607655 'https://raw.githubusercontent.com/sass/sass/stable/MIT-LICENSE'
608656 ], [
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+ [
609663 'scikit-image',
610664 '2011 the scikit-image team',
611665 'BSD',
612666 'http://scikit-image.org/docs/dev/license.html'
613667 ], [
614668 'scikit-learn',
615− '2007-2017 The scikit-learn developers',
669+ '2007-2018 The scikit-learn developers',
616670 'BSD',
617671 'https://raw.githubusercontent.com/scikit-learn/scikit-learn/master/COPYING'
618672 ], [
@@ -657,9 +711,9 @@ credits = [ · 38 unmodified lines
657711 'https://raw.githubusercontent.com/hashicorp/terraform-website/master/LICENSE.md'
658712 ], [
659713 'Twig',
660− '2009-2017 The Twig Team',
714+ '2009-2018 The Twig Team',
661715 'BSD',
662− 'https://twig.sensiolabs.org/license'
716+ 'https://twig.symfony.com/license'
663717 ], [
664718 'TypeScript',
665719 'Microsoft and other contributors',
@@ -667,7 +721,7 @@ credits = [ · 1 unmodified line
667721 'https://raw.githubusercontent.com/Microsoft/TypeScript-Handbook/master/LICENSE'
668722 ], [
669723 'Underscore.js',
670− '2009-2017 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
724+ '2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
671725 'MIT',
672726 'https://raw.githubusercontent.com/jashkenas/underscore/master/LICENSE'
673727 ], [
@@ -685,6 +739,11 @@ credits = [ · 11 unmodified lines
685739 '2015-2018 Evan You, Vue.js contributors',
686740 'MIT',
687741 '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'
688747 ], [
689748 'Vulkan',
690749 '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
696755 'CC BY',
697756 'https://creativecommons.org/licenses/by/4.0/'
698757 ], [
758+ 'Wordpress',
759+ '2003-2019 WordPress Foundation',
760+ 'GPLv2+',
761+ 'https://wordpress.org/about/license/'
762+ ],
763+ [
699764 'Yarn',
700765 '2016-present Yarn Contributors',
701766 'BSD',
assets/javascripts/templates/pages/help_tmpl.coffee+3−0
@@ -131,6 +131,9 @@ app.templates.helpPage = -> · 130 unmodified lines
131131 <dt class="_shortcuts-dt">
132132 <code class="_shortcut-code">alt + s</code>
133133 <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
134137 </dl>
135138 <p class="_note _note-green">
136139 <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
2525 <h2 class="_block-heading">Questions & Answers</h2>
2626 <dl>
2727 <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>
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.
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://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.
3030 <dt>Can I close the tab/browser?
3131 <dd>#{canICloseTheTab()}
3232 <dt>What if I don't update a documentation?
@@ -41,10 +41,15 @@ app.templates.offlinePage = (docs) -> """ · 8 unmodified lines
4141 """
4242
4343 canICloseTheTab = ->
44− if app.AppCache.isEnabled()
44+ if app.ServiceWorker.isEnabled()
4545 """ 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). """
4646 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>
4853 The current tab will continue to function even when you go offline (provided you installed all the documentations beforehand). """
4954
5055 app.templates.offlineDoc = (doc, status) ->
assets/javascripts/templates/pages/root_tmpl.coffee.erb+3−14
@@ -8,13 +8,13 @@ app.templates.intro = """ · 7 unmodified lines
88 <p>Thanks for downloading DevDocs. Here are a few things you should know:
99 <ol class="_intro-list">
1010 <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>.
1212 <li>Run <code>thor docs:list</code> to see all available documentations.
1313 <li>Run <code>thor docs:download &lt;name&gt;</code> to download documentations.
1414 <li>Run <code>thor docs:download --installed</code> to update all downloaded documentations.
1515 <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.
1616 <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>.
1818 <li>Contributions are welcome. See the <a href="https://github.com/freeCodeCamp/devdocs/blob/master/CONTRIBUTING.md">guidelines</a>.
1919 <li>DevDocs is licensed under the terms of the Mozilla Public License v2.0. For more information,
2020 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
3939 <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>.
4040 <li>For the latest news, follow <a href="https://twitter.com/DevDocs">@DevDocs</a>.
4141 <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>
4343 <li>And if you're new to coding, check out <a href="https://www.freecodecamp.org/">freeCodeCamp's open source curriculum</a>.
4444 </ol>
4545 <p>Happy coding!
@@ -72,14 +72,3 @@ app.templates.androidWarning = """ · 26 unmodified lines
7272 <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.
7373 </div>
7474 """
75−
76−app.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
1515 <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
1616 <small>Tip: drag the edge of the sidebar to resize it.</small>
1717 </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>
1826 </div>
1927 </div>
2028
assets/javascripts/tracking.js+27−23
@@ -1,28 +1,32 @@
11 try {
2− if (app.config.env == 'production') {
3− (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
4− (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
5− m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
6− })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
7− ga('create', 'UA-5544833-12', 'devdocs.io');
8− page.track(function() {
9− ga('send', 'pageview', {
10− page: location.pathname + location.search + location.hash,
11− dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version
2+ if (app.config.env === 'production') {
3+ if (Cookies.get('analyticsConsent') === '1') {
4+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
8+ ga('create', 'UA-5544833-12', 'devdocs.io');
9+ page.track(function() {
10+ ga('send', 'pageview', {
11+ page: location.pathname + location.search + location.hash,
12+ dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version
13+ });
1214 });
13− });
1415
15− page.track(function() {
16− if (window._gauges)
17− _gauges.push(['track']);
18− else
19− (function() {
20− var _gauges=_gauges||[];!function(){var a=document.createElement("script");
21− a.type="text/javascript",a.async=!0,a.id="gauges-tracker",
22− a.setAttribute("data-site-id","51c15f82613f5d7819000067"),
23− a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0];
24− b.parentNode.insertBefore(a,b)}();
25− })();
26− });
16+ page.track(function() {
17+ if (window._gauges)
18+ _gauges.push(['track']);
19+ else
20+ (function() {
21+ var _gauges=_gauges||[];!function(){var a=document.createElement("script");
22+ a.type="text/javascript",a.async=!0,a.id="gauges-tracker",
23+ a.setAttribute("data-site-id","51c15f82613f5d7819000067"),
24+ a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0];
25+ b.parentNode.insertBefore(a,b)}();
26+ })();
27+ });
28+ } else {
29+ resetAnalytics();
30+ }
2731 }
2832 } catch(e) { }
assets/javascripts/vendor/fastclick.js+2−2
@@ -413,7 +413,7 @@ · 412 unmodified lines
413413 // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
414414 // with the same identifier as the touch event that previously triggered the click that triggered the alert.
415415 // 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.
417417 // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
418418 // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
419419 // random integers, it's safe to to continue if the identifier is 0 here.
@@ -805,7 +805,7 @@ · 385 unmodified lines
805805 }
806806 }
807807
808− // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version
808+ // IE11: prefixed -ms-touch-action is no longer supported and it's recommended to use non-prefixed version
809809 // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx
810810 if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {
811811 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
2+https://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 */
23 var _self = (typeof window !== 'undefined')
34 ? window // if in browser
45 : (
@@ -16,11 +17,12 @@ var _self = (typeof window !== 'undefined') · 11 unmodified lines
1617 var Prism = (function(){
1718
1819 // Private helper vars
19−var lang = /\blang(?:uage)?-(\w+)\b/i;
20+var lang = /\blang(?:uage)?-([\w-]+)\b/i;
2021 var uniqueId = 0;
2122
2223 var _ = _self.Prism = {
2324 manual: _self.Prism && _self.Prism.manual,
25+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
2426 util: {
2527 encode: function (tokens) {
2628 if (tokens instanceof Token) {
@@ -44,23 +46,38 @@ var _ = _self.Prism = { · 17 unmodified lines
4446 },
4547
4648 // Deep clone a language definition (e.g. to extend it)
47− clone: function (o) {
49+ clone: function (o, visited) {
4850 var type = _.util.type(o);
51+ visited = visited || {};
4952
5053 switch (type) {
5154 case 'Object':
55+ if (visited[_.util.objId(o)]) {
56+ return visited[_.util.objId(o)];
57+ }
5258 var clone = {};
59+ visited[_.util.objId(o)] = clone;
5360
5461 for (var key in o) {
5562 if (o.hasOwnProperty(key)) {
56− clone[key] = _.util.clone(o[key]);
63+ clone[key] = _.util.clone(o[key], visited);
5764 }
5865 }
5966
6067 return clone;
6168
6269 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;
6481 }
6582
6683 return o;
@@ -155,6 +172,10 @@ var _ = _self.Prism = { · 88 unmodified lines
155172 plugins: {},
156173
157174 highlightAll: function(async, callback) {
175+ _.highlightAllUnder(document, async, callback);
176+ },
177+
178+ highlightAllUnder: function(container, async, callback) {
158179 var env = {
159180 callback: callback,
160181 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
@@ -162,7 +183,7 @@ var _ = _self.Prism = { · 1 unmodified line
162183
163184 _.hooks.run("before-highlightall", env);
164185
165− var elements = env.elements || document.querySelectorAll(env.selector);
186+ var elements = env.elements || container.querySelectorAll(env.selector);
166187
167188 for (var i=0, element; element = elements[i++];) {
168189 _.highlightElement(element, async === true, env.callback);
@@ -185,11 +206,13 @@ var _ = _self.Prism = { · 16 unmodified lines
185206 // Set language on the element, if not present
186207 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
187208
188− // Set language on the parent, for styling
189− parent = element.parentNode;
209+ if (element.parentNode) {
210+ // Set language on the parent, for styling
211+ parent = element.parentNode;
190212
191− if (/pre/i.test(parent.nodeName)) {
192− parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
213+ if (/pre/i.test(parent.nodeName)) {
214+ parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
215+ }
193216 }
194217
195218 var code = element.textContent;
@@ -251,8 +274,15 @@ var _ = _self.Prism = { · 55 unmodified lines
251274 },
252275
253276 highlight: function (text, grammar, language) {
254− var tokens = _.tokenize(text, grammar);
255− return Token.stringify(_.util.encode(tokens), language);
277+ var env = {
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);
256286 },
257287
258288 matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
@@ -300,15 +330,9 @@ var _ = _self.Prism = { · 41 unmodified lines
300330 continue;
301331 }
302332
303− pattern.lastIndex = 0;
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) {
333+ if (greedy && i != strarr.length - 1) {
310334 pattern.lastIndex = pos;
311− match = pattern.exec(text);
335+ var match = pattern.exec(text);
312336 if (!match) {
313337 break;
314338 }
@@ -327,11 +351,8 @@ var _ = _self.Prism = { · 12 unmodified lines
327351 }
328352 }
329353
330− /*
331− * If strarr[i] is a Token, then the match starts inside another Token, which is invalid
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) {
354+ // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
355+ if (strarr[i] instanceof Token) {
335356 continue;
336357 }
337358
@@ -339,6 +360,11 @@ var _ = _self.Prism = { · 1 unmodified line
339360 delNum = k - i;
340361 str = text.slice(pos, p);
341362 match.index -= pos;
363+ } else {
364+ pattern.lastIndex = 0;
365+
366+ var match = pattern.exec(str),
367+ delNum = 1;
342368 }
343369
344370 if (!match) {
@@ -350,7 +376,7 @@ var _ = _self.Prism = { · 5 unmodified lines
350376 }
351377
352378 if(lookbehind) {
353− lookbehindLength = match[1].length;
379+ lookbehindLength = match[1] ? match[1].length : 0;
354380 }
355381
356382 var from = match.index + lookbehindLength,
@@ -480,18 +506,21 @@ Token.stringify = function(o, language, parent) { · 123 unmodified lines
480506 // // in Node.js
481507 // return _self.Prism;
482508 // }
483−// // In worker
484−// _self.addEventListener('message', function(evt) {
485−// var message = JSON.parse(evt.data),
486−// lang = message.language,
487−// code = message.code,
488−// immediateClose = message.immediateClose;
489−
490−// _self.postMessage(_.highlight(code, _.languages[lang], lang));
491−// if (immediateClose) {
492−// _self.close();
493−// }
494−// }, false);
509+
510+// if (!_.disableWorkerMessageHandler) {
511+// // In worker
512+// _self.addEventListener('message', function (evt) {
513+// var message = JSON.parse(evt.data),
514+// lang = message.language,
515+// code = message.code,
516+// immediateClose = message.immediateClose;
517+
518+// _self.postMessage(_.highlight(code, _.languages[lang], lang));
519+// if (immediateClose) {
520+// _self.close();
521+// }
522+// }, false);
523+// }
495524
496525 // return _self.Prism;
497526 // }
@@ -535,7 +564,8 @@ Prism.languages.markup = { · 37 unmodified lines
535564 'doctype': /<!DOCTYPE[\s\S]+?>/i,
536565 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
537566 '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,
539569 inside: {
540570 'tag': {
541571 pattern: /^<\/?[^\s>\/]+/i,
@@ -600,13 +630,13 @@ Prism.languages.css = { · 58 unmodified lines
600630 pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
601631 greedy: true
602632 },
603− 'property': /[\w-]+(?=\s*:)/i,
633+ 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
604634 'important': /\B!important\b/i,
605635 'function': /[-a-z0-9]+(?=\()/i,
606636 'punctuation': /[(){};:]/
607637 };
608638
609−Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
639+Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
610640
611641 if (Prism.languages.markup) {
612642 Prism.languages.insertBefore('markup', 'tag', {
@@ -614,10 +644,11 @@ if (Prism.languages.markup) { · 1 unmodified line
614644 pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
615645 lookbehind: true,
616646 inside: Prism.languages.css,
617− alias: 'language-css'
647+ alias: 'language-css',
648+ greedy: true
618649 }
619650 });
620−
651+
621652 Prism.languages.insertBefore('inside', 'attr-value', {
622653 'style-attr': {
623654 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
@@ -644,7 +675,8 @@ Prism.languages.clike = { · 20 unmodified lines
644675 },
645676 {
646677 pattern: /(^|[^\\:])\/\/.*/,
647− lookbehind: true
678+ lookbehind: true,
679+ greedy: true
648680 }
649681 ],
650682 'string': {
@@ -661,51 +693,53 @@ Prism.languages.clike = { · 10 unmodified lines
661693 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
662694 'boolean': /\b(?:true|false)\b/,
663695 '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,
665697 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
666698 'punctuation': /[{}[\];(),.:]/
667699 };
668700
669701 Prism.languages.javascript = Prism.languages.extend('clike', {
670702 '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+)?/,
672704 // 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,
674706 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
675707 });
676708
677709 Prism.languages.insertBefore('javascript', 'keyword', {
678710 '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,.;})\]]))/,
680712 lookbehind: true,
681713 greedy: true
682714 },
683715 // This must be declared before keyword because we use "function" inside the look-forward
684716 '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,
686718 alias: 'function'
687− }
719+ },
720+ 'constant': /\b[A-Z][A-Z\d_]*\b/
688721 });
689722
690723 Prism.languages.insertBefore('javascript', 'string', {
691724 'template-string': {
692− pattern: /`(?:\\[\s\S]|[^\\`])*`/,
725+ pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,
693726 greedy: true,
694727 inside: {
695728 'interpolation': {
696− pattern: /\$\{[^}]+\}/,
729+ pattern: /\${[^}]+}/,
697730 inside: {
698731 'interpolation-punctuation': {
699− pattern: /^\$\{|\}$/,
732+ pattern: /^\${|}$/,
700733 alias: 'punctuation'
701734 },
702− rest: Prism.languages.javascript
735+ rest: null // See below
703736 }
704737 },
705738 'string': /[\s\S]+/
706739 }
707740 }
708741 });
742+Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript;
709743
710744 if (Prism.languages.markup) {
711745 Prism.languages.insertBefore('markup', 'tag', {
@@ -713,7 +747,8 @@ if (Prism.languages.markup) { · 1 unmodified line
713747 pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
714748 lookbehind: true,
715749 inside: Prism.languages.javascript,
716− alias: 'language-javascript'
750+ alias: 'language-javascript',
751+ greedy: true
717752 }
718753 });
719754 }
@@ -723,7 +758,7 @@ Prism.languages.js = Prism.languages.javascript; · 3 unmodified lines
723758 Prism.languages.c = Prism.languages.extend('clike', {
724759 '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/,
725760 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,
726− 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
761+ 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
727762 });
728763
729764 Prism.languages.insertBefore('c', 'string', {
@@ -768,7 +803,7 @@ delete Prism.languages.c['boolean']; · 38 unmodified lines
768803 },
769804 /^\$\(\(/
770805 ],
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+)?/,
772807 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
773808 operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
774809 // If there is no $ sign at the beginning highlight (( and )) as punctuation
@@ -778,6 +813,7 @@ delete Prism.languages.c['boolean']; · 3 unmodified lines
778813 // Command Substitution
779814 {
780815 pattern: /\$\([^)]+\)|`[^`]+`/,
816+ greedy: true,
781817 inside: {
782818 variable: /^\$\(|^`|\)$|`$/
783819 }
@@ -804,7 +840,7 @@ delete Prism.languages.c['boolean']; · 20 unmodified lines
804840 inside: insideString
805841 },
806842 {
807− pattern: /(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
843+ pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
808844 greedy: true,
809845 inside: insideString
810846 }
@@ -812,7 +848,7 @@ delete Prism.languages.c['boolean']; · 1 unmodified line
812848 'variable': insideString.variable,
813849 // Originally based on http://ss64.com/bash/
814850 '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;|&])/,
816852 lookbehind: true
817853 },
818854 'keyword': {
@@ -828,15 +864,18 @@ delete Prism.languages.c['boolean']; · 9 unmodified lines
828864 };
829865
830866 var inside = insideString.variable[1].inside;
867+ inside.string = Prism.languages.bash.string;
831868 inside['function'] = Prism.languages.bash['function'];
832869 inside.keyword = Prism.languages.bash.keyword;
833− inside.boolean = Prism.languages.bash.boolean;
870+ inside['boolean'] = Prism.languages.bash['boolean'];
834871 inside.operator = Prism.languages.bash.operator;
835872 inside.punctuation = Prism.languages.bash.punctuation;
873+
874+ Prism.languages.shell = Prism.languages.bash;
836875 })(Prism);
837876
838877 Prism.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/,
840879 'boolean': /\b(?:true|false)\b/,
841880 '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/
842881 });
@@ -847,6 +886,15 @@ Prism.languages.insertBefore('cpp', 'keyword', { · 4 unmodified lines
847886 lookbehind: true
848887 }
849888 });
889+
890+Prism.languages.insertBefore('cpp', 'string', {
891+ 'raw-string': {
892+ pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
893+ alias: 'string',
894+ greedy: true
895+ }
896+});
897+
850898 (function(Prism) {
851899
852900 // Ignore comments starting with { to privilege string interpolation highlighting
@@ -947,10 +995,13 @@ delete Prism.languages.coffeescript['template-string']; · 94 unmodified lines
947995 (function(Prism) {
948996 Prism.languages.ruby = Prism.languages.extend('clike', {
949997 'comment': [
950− /#(?!\{[^\r\n]*?\}).*/,
951− /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m
998+ /#.*/,
999+ {
1000+ pattern: /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m,
1001+ greedy: true
1002+ }
9521003 ],
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/
9541005 });
9551006
9561007 var interpolation = {
@@ -960,7 +1011,7 @@ delete Prism.languages.coffeescript['template-string']; · 3 unmodified lines
9601011 pattern: /^#\{|\}$/,
9611012 alias: 'tag'
9621013 },
963− rest: Prism.util.clone(Prism.languages.ruby)
1014+ rest: Prism.languages.ruby
9641015 }
9651016 };
9661017
@@ -1009,7 +1060,10 @@ delete Prism.languages.coffeescript['template-string']; · 42 unmodified lines
10091060 }
10101061 ],
10111062 '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+ }
10131067 });
10141068
10151069 Prism.languages.insertBefore('ruby', 'number', {
@@ -1127,6 +1181,30 @@ Prism.languages.insertBefore('d', 'function', { · 111 unmodified lines
11271181 alias: 'variable'
11281182 }
11291183 });
1184+Prism.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+
1202+Prism.languages.insertBefore('dart','function',{
1203+ 'metadata': {
1204+ pattern: /@\w+/,
1205+ alias: 'symbol'
1206+ }
1207+});
11301208 // Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
11311209 // Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
11321210
@@ -1170,15 +1248,15 @@ if (Prism.languages.css) { · 37 unmodified lines
11701248 Prism.languages.jinja2 = Prism.languages.django;
11711249
11721250 Prism.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
11761251 'comment': {
1177− pattern: /(^|[^#])#(?![{#]).*/m,
1252+ pattern: /#.*/m,
11781253 lookbehind: true
11791254 },
11801255 // ~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+ },
11821260 'string': [
11831261 {
11841262 // ~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
12251303 alias: 'variable'
12261304 },
12271305 'attribute': {
1228− pattern: /@[\S]+/,
1306+ pattern: /@\w+/,
12291307 alias: 'variable'
12301308 },
12311309 '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
12561334 pattern: /^#\{|\}$/,
12571335 alias: 'punctuation'
12581336 },
1259− rest: Prism.util.clone(Prism.languages.elixir)
1337+ rest: Prism.languages.elixir
12601338 }
12611339 }
12621340 };
12631341 });
12641342
12651343
1344+Prism.languages['markup-templating'] = {};
1345+
1346+Object.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+});
12661433 Prism.languages.erlang = {
12671434 'comment': /%.+/,
12681435 'string': {
@@ -1282,7 +1449,7 @@ Prism.languages.erlang = { · 13 unmodified lines
12821449 'number': [
12831450 /\$\\?./,
12841451 /\d+#[a-z0-9]+/i,
1285− /(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/
1452+ /(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i
12861453 ],
12871454 'function': /\b[a-z][\w@]*(?=\()/,
12881455 'variable': {
@@ -1312,7 +1479,7 @@ Prism.languages.go = Prism.languages.extend('clike', { · 23 unmodified lines
13121479 '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/,
13131480 'boolean': /\b(?:_|iota|nil|true|false)\b/,
13141481 '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,
13161483 'string': {
13171484 pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
13181485 greedy: true
@@ -1322,7 +1489,7 @@ delete Prism.languages.go['class-name']; · 3 unmodified lines
13221489
13231490 Prism.languages.java = Prism.languages.extend('clike', {
13241491 '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,
13261493 'operator': {
13271494 pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
13281495 lookbehind: true
@@ -1337,14 +1504,25 @@ Prism.languages.insertBefore('java','function', { · 8 unmodified lines
13371504 }
13381505 });
13391506
1507+Prism.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+
13401518 Prism.languages.json = {
13411519 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
13421520 'string': {
13431521 pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
13441522 greedy: true
13451523 },
1346− 'number': /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee][+-]?\d+)?)\b/,
1347− 'punctuation': /[{}[\]);,]/,
1524+ 'number': /-?\d+\.?\d*([Ee][+-]?\d+)?/,
1525+ 'punctuation': /[{}[\],]/,
13481526 'operator': /:/g,
13491527 'boolean': /\b(?:true|false)\b/i,
13501528 'null': /\bnull\b/i
@@ -1356,7 +1534,7 @@ Prism.languages.jsonp = Prism.languages.json; · 5 unmodified lines
13561534 Prism.languages.kotlin = Prism.languages.extend('clike', {
13571535 'keyword': {
13581536 // 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/,
13601538 lookbehind: true
13611539 },
13621540 'function': [
@@ -1366,7 +1544,7 @@ Prism.languages.jsonp = Prism.languages.json; · 3 unmodified lines
13661544 lookbehind: true
13671545 }
13681546 ],
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/,
13701548 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
13711549 });
13721550
@@ -1400,7 +1578,7 @@ Prism.languages.jsonp = Prism.languages.json; · 27 unmodified lines
14001578 pattern: /^\$\{|\}$/,
14011579 alias: 'variable'
14021580 },
1403− rest: Prism.util.clone(Prism.languages.kotlin)
1581+ rest: Prism.languages.kotlin
14041582 }
14051583 },
14061584 {
@@ -1414,6 +1592,7 @@ Prism.languages.jsonp = Prism.languages.json; · 7 unmodified lines
14141592 };
14151593
14161594 }(Prism));
1595+
14171596 Prism.languages.lua = {
14181597 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
14191598 // \z may be used to skip the following space
@@ -1434,16 +1613,68 @@ Prism.languages.lua = { · 14 unmodified lines
14341613 ],
14351614 'punctuation': /[\[\](){},;]|\.+|:+/
14361615 };
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+
14371668 Prism.languages.nginx = Prism.languages.extend('clike', {
1438− 'comment': {
1439− pattern: /(^|[^"{\\])#.*/,
1440− lookbehind: true
1441− },
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/i
1669+ 'comment': {
1670+ pattern: /(^|[^"{\\])#.*/,
1671+ lookbehind: true
1672+ },
1673+ '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
14431674 });
14441675
14451676 Prism.languages.insertBefore('nginx', 'keyword', {
1446− 'variable': /\$[a-z_]+/i
1677+ 'variable': /\$[a-z_]+/i
14471678 });
14481679 Prism.languages.nim = {
14491680 'comment': /#.*/,
@@ -1497,31 +1728,31 @@ Prism.languages.perl = { · 47 unmodified lines
14971728 pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
14981729 greedy: true
14991730 },
1500−
1731+
15011732 // q a...a
15021733 {
15031734 pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
15041735 greedy: true
15051736 },
1506−
1737+
15071738 // q(...)
15081739 {
15091740 pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
15101741 greedy: true
15111742 },
1512−
1743+
15131744 // q{...}
15141745 {
15151746 pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
15161747 greedy: true
15171748 },
1518−
1749+
15191750 // q[...]
15201751 {
15211752 pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
15221753 greedy: true
15231754 },
1524−
1755+
15251756 // q<...>
15261757 {
15271758 pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
@@ -1547,31 +1778,31 @@ Prism.languages.perl = { · 19 unmodified lines
15471778 pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
15481779 greedy: true
15491780 },
1550−
1781+
15511782 // m a...a
15521783 {
15531784 pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
15541785 greedy: true
15551786 },
1556−
1787+
15571788 // m(...)
15581789 {
15591790 pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
15601791 greedy: true
15611792 },
1562−
1793+
15631794 // m{...}
15641795 {
15651796 pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
15661797 greedy: true
15671798 },
1568−
1799+
15691800 // m[...]
15701801 {
15711802 pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
15721803 greedy: true
15731804 },
1574−
1805+
15751806 // m<...>
15761807 {
15771808 pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
@@ -1586,42 +1817,42 @@ Prism.languages.perl = { · 8 unmodified lines
15861817 lookbehind: true,
15871818 greedy: true
15881819 },
1589−
1820+
15901821 // s a...a...a
15911822 {
15921823 pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
15931824 lookbehind: true,
15941825 greedy: true
15951826 },
1596−
1827+
15971828 // s(...)(...)
15981829 {
15991830 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
16001831 lookbehind: true,
16011832 greedy: true
16021833 },
1603−
1834+
16041835 // s{...}{...}
16051836 {
16061837 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
16071838 lookbehind: true,
16081839 greedy: true
16091840 },
1610−
1841+
16111842 // s[...][...]
16121843 {
16131844 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
16141845 lookbehind: true,
16151846 greedy: true
16161847 },
1617−
1848+
16181849 // s<...><...>
16191850 {
16201851 pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
16211852 lookbehind: true,
16221853 greedy: true
16231854 },
1624−
1855+
16251856 // /.../
16261857 // The look-ahead tries to prevent two divisions on
16271858 // the same line from being highlighted as regex.
@@ -1665,7 +1896,7 @@ Prism.languages.perl = { · 37 unmodified lines
16651896 }
16661897 },
16671898 '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/,
16691900 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
16701901 'punctuation': /[{}[\];(),:]/
16711902 };
@@ -1682,110 +1913,211 @@ Prism.languages.perl = { · 10 unmodified lines
16821913 * Adds the following new token classes:
16831914 * constant, delimiter, variable, function, package
16841915 */
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+ });
16851925
1686−Prism.languages.php = Prism.languages.extend('clike', {
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,
1688− 'constant': /\b[A-Z0-9_]{2,}\b/,
1689− 'comment': {
1690− pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1691− lookbehind: true
1692− }
1693−});
1926+ Prism.languages.insertBefore('php', 'string', {
1927+ 'shell-comment': {
1928+ pattern: /(^|[^\\])#.*/,
1929+ lookbehind: true,
1930+ alias: 'comment'
1931+ }
1932+ });
16941933
1695−// Shell-like comments are matched after strings, because they are less
1696−// common than strings containing hashes...
1697−Prism.languages.insertBefore('php', 'class-name', {
1698− 'shell-comment': {
1699− pattern: /(^|[^\\])#.*/,
1700− lookbehind: true,
1701− alias: 'comment'
1702− }
1703−});
1934+ Prism.languages.insertBefore('php', 'keyword', {
1935+ 'delimiter': {
1936+ pattern: /\?>|<\?(?:php|=)?/i,
1937+ alias: 'important'
1938+ },
1939+ 'variable': /\$+(?:\w+\b|(?={))/i,
1940+ 'package': {
1941+ pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1942+ lookbehind: true,
1943+ inside: {
1944+ punctuation: /\\/
1945+ }
1946+ }
1947+ });
17041948
1705−Prism.languages.insertBefore('php', 'keyword', {
1706− 'delimiter': {
1707− pattern: /\?>|<\?(?:php|=)?/i,
1708− alias: 'important'
1709− },
1710− 'variable': /\$\w+\b/i,
1711− 'package': {
1712− pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1713− lookbehind: true,
1714− inside: {
1715− punctuation: /\\/
1949+ // Must be defined after the function pattern
1950+ Prism.languages.insertBefore('php', 'operator', {
1951+ 'property': {
1952+ pattern: /(->)[\w]+/,
1953+ lookbehind: true
17161954 }
1717− }
1718−});
1955+ });
17191956
1720−// Must be defined after the function pattern
1721−Prism.languages.insertBefore('php', 'operator', {
1722− 'property': {
1723− pattern: /(->)[\w]+/,
1724− lookbehind: true
1725− }
1726−});
1957+ Prism.languages.insertBefore('php', 'string', {
1958+ 'nowdoc-string': {
1959+ pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
1960+ greedy: true,
1961+ alias: 'string',
1962+ inside: {
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'];
17272003
1728−// Add HTML support if the markup language exists
1729−if (Prism.languages.markup) {
2004+ var string_interpolation = {
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;
17302013
1731− // Tokenize all inline PHP blocks that are wrapped in <?php ?>
1732− // This allows for easy PHP + markup highlighting
1733− Prism.hooks.add('before-highlight', function(env) {
1734− if (env.language !== 'php' || !/(?:<\?php|<\?)/ig.test(env.code)) {
2014+ Prism.hooks.add('before-tokenize', function(env) {
2015+ if (!/(?:<\?php|<\?)/ig.test(env.code)) {
17352016 return;
17362017 }
17372018
1738− env.tokenStack = [];
1739−
1740− env.backupCode = env.code;
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− });
2019+ var phpPattern = /(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/ig;
2020+ Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
2021+ });
17522022
1753− // Switch the grammar to markup
1754− env.grammar = Prism.languages.markup;
2023+ Prism.hooks.add('after-tokenize', function(env) {
2024+ Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
17552025 });
17562026
1757− // Restore env.code for other plugins (e.g. line-numbers)
1758− Prism.hooks.add('before-insert', function(env) {
1759− if (env.language === 'php' && env.backupCode) {
1760− env.code = env.backupCode;
1761− delete env.backupCode;
2027+}(Prism));
2028+Prism.languages.sql= {
2029+ 'comment': {
2030+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
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+};
2046+Prism.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
17622056 }
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+});
17642080
1765− // Re-insert the tokens after highlighting
1766− Prism.hooks.add('after-highlight', function(env) {
1767− if (env.language !== 'php' || !env.tokenStack) {
1768− return;
2081+Prism.languages.insertBefore('scss', 'atrule', {
2082+ 'keyword': [
2083+ /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
2084+ {
2085+ pattern: /( +)(?:from|through)(?= )/,
2086+ lookbehind: true
17692087 }
2088+ ]
2089+});
17702090
1771− // Switch the grammar back
1772− env.grammar = Prism.languages.php;
2091+Prism.languages.scss.property = {
2092+ pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
2093+ inside: {
2094+ 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2095+ }
2096+};
17732097
1774− for (var i = 0, keys = Object.keys(env.tokenStack); i < keys.length; ++i) {
1775− var k = keys[i];
1776− var t = env.tokenStack[k];
2098+Prism.languages.insertBefore('scss', 'important', {
2099+ // var and interpolated vars
2100+ 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2101+});
17772102
1778− // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
1779− env.highlightedCode = env.highlightedCode.replace('___PHP' + k + '___',
1780− "<span class=\"token php language-php\">" +
1781− Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$') +
1782− "</span>");
1783− }
2103+Prism.languages.insertBefore('scss', 'function', {
2104+ 'placeholder': {
2105+ pattern: /%[-\w]+/,
2106+ alias: 'selector'
2107+ },
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+});
17842119
1785− env.element.innerHTML = env.highlightedCode;
1786− });
1787−}
1788−;
2120+Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
17892121 Prism.languages.python = {
17902122 'comment': {
17912123 pattern: /(^|[^\\])#.*/,
@@ -1811,7 +2143,7 @@ Prism.languages.python = { · 19 unmodified lines
18112143 '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/,
18122144 '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/,
18132145 '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,
18152147 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
18162148 'punctuation': /[{}[\];(),.:]/
18172149 };
@@ -1821,93 +2153,134 @@ Prism.languages.python = { · 3 unmodified lines
18212153 var javascript = Prism.util.clone(Prism.languages.javascript);
18222154
18232155 Prism.languages.jsx = Prism.languages.extend('markup', javascript);
1824−Prism.languages.jsx.tag.pattern= /<\/?[\w.:-]+\s*(?:\s+(?:[\w\.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+|(?:\{[^}]*\})))?|\{\.{3}\w+\}))*\s*\/?>/i;
2156+Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
18252157
2158+Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
18262159 Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
18272160
18282161 Prism.languages.insertBefore('inside', 'attr-name', {
18292162 'spread': {
1830− pattern: /\{\.{3}\w+\}/,
2163+ pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
18312164 inside: {
1832− 'punctuation': /[{}]|\.{3}/,
2165+ 'punctuation': /\.{3}|[{}.]/,
18332166 'attr-value': /\w+/
18342167 }
18352168 }
18362169 }, Prism.languages.jsx.tag);
18372170
1838−var jsxExpression = Prism.util.clone(Prism.languages.jsx);
1839−
1840−delete jsxExpression.punctuation;
1841−
1842−jsxExpression = Prism.languages.insertBefore('jsx', 'operator', {
1843− 'punctuation': /=(?={)|[{}[\];(),.:]/
1844−}, { jsx: jsxExpression });
1845−
18462171 Prism.languages.insertBefore('inside', 'attr-value',{
18472172 'script': {
1848− // Allow for one level of nesting
1849− pattern: /=(\{(?:\{[^}]*\}|[^}])+\})/i,
1850− inside: jsxExpression,
2173+ // Allow for two levels of nesting
2174+ pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
2175+ inside: {
2176+ 'script-punctuation': {
2177+ pattern: /^=(?={)/,
2178+ alias: 'punctuation'
2179+ },
2180+ rest: Prism.languages.jsx
2181+ },
18512182 'alias': 'language-javascript'
18522183 }
18532184 }, Prism.languages.jsx.tag);
18542185
1855−}(Prism));
2186+// The following will handle plain text inside tags
2187+var 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+};
18562199
1857−(function(Prism) {
1858− Prism.languages.crystal = Prism.languages.extend('ruby', {
1859− keyword: [
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/,
1861− {
1862− pattern: /(\.\s*)(?:is_a|responds_to)\?/,
1863− lookbehind: true
1864− }
1865− ],
2200+var walkTokens = function (tokens) {
2201+ var openedTags = [];
2202+ for (var i = 0; i < tokens.length; i++) {
2203+ var token = tokens[i];
2204+ var notTagNorBrace = false;
2205+
2206+ if (typeof token !== 'string') {
2207+ if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
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 === '{') {
18662228
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/
1868− });
2229+ // Here we might have entered a JSX context inside a tag
2230+ openedTags[openedTags.length - 1].openedBraces++;
18692231
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 === '}') {
18712233
1872− Prism.languages.insertBefore('crystal', 'string', {
1873− attribute: {
1874− pattern: /@\[.+?\]/,
1875− alias: 'attr-name',
1876− inside: {
1877− delimiter: {
1878− pattern: /^@\[|\]$/,
1879− alias: 'tag'
1880− },
1881− rest: rest
1882− }
1883− },
2234+ // Here we might have left a JSX context inside a tag
2235+ openedTags[openedTags.length - 1].openedBraces--;
18842236
1885− expansion: [
1886− {
1887− pattern: /\{\{.+?\}\}/,
1888− inside: {
1889− delimiter: {
1890− pattern: /^\{\{|\}\}$/,
1891− alias: 'tag'
1892− },
1893− rest: rest
2237+ } else {
2238+ notTagNorBrace = true
18942239 }
1895− },
1896− {
1897− pattern: /\{%.+?%\}/,
1898− inside: {
1899− delimiter: {
1900− pattern: /^\{%|%\}$/,
1901− alias: 'tag'
1902− },
1903− rest: rest
2240+ }
2241+ if (notTagNorBrace || typeof token === 'string') {
2242+ if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
2243+ // Here we are inside a tag, and not inside a JSX context.
2244+ // That's plain text: drop any tokens matched.
2245+ var plainText = stringifyToken(token);
2246+
2247+ // And merge text with adjacent text
2248+ 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);
19042259 }
19052260 }
1906− ]
1907− });
2261+
2262+ if (token.content && typeof token.content !== 'string') {
2263+ walkTokens(token.content);
2264+ }
2265+ }
2266+};
2267+
2268+Prism.hooks.add('after-tokenize', function (env) {
2269+ if (env.language !== 'jsx' && env.language !== 'tsx') {
2270+ return;
2271+ }
2272+ walkTokens(env.tokens);
2273+});
19082274
19092275 }(Prism));
19102276
2277+Prism.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+
2283+Prism.languages.ts = Prism.languages.typescript;
19112284 /* TODO
19122285 Add support for Markdown notation inside doc comments
19132286 Add support for nested block comments...
@@ -1932,10 +2305,18 @@ Prism.languages.rust = { · 18 unmodified lines
19322305 greedy: true
19332306 },
19342307 {
1935− pattern: /b?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
2308+ pattern: /b?"(?:\\.|[^\\\r\n"])*"/,
19362309 greedy: true
19372310 }
19382311 ],
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+ },
19392320 '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/,
19402321
19412322 'attribute': {
@@ -1955,7 +2336,7 @@ Prism.languages.rust = { · 13 unmodified lines
19552336 },
19562337
19572338 // 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/,
19592340
19602341 // Closure params should not be confused with bitwise OR |
19612342 'closure-params': {
@@ -1966,107 +2347,8 @@ Prism.languages.rust = { · 4 unmodified lines
19662347 }
19672348 },
19682349 'punctuation': /[{}[\];(),:]|\.+|->/,
1969− 'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
2350+ 'operator': /[-+*\/%!^]=?|=[=>]?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
19702351 };
1971−Prism.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−
2006−Prism.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−
2016−Prism.languages.scss.property = {
2017− pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
2018− inside: {
2019− 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2020− }
2021−};
2022−
2023−Prism.languages.insertBefore('scss', 'important', {
2024− // var and interpolated vars
2025− 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2026−});
2027−
2028−Prism.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−
2045−Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss);
2046−Prism.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−};
2064−Prism.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−
2069−Prism.languages.ts = Prism.languages.typescript;
20702352 Prism.languages.yaml = {
20712353 'scalar': {
20722354 pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,
@@ -2105,11 +2387,10 @@ Prism.languages.yaml = { · 32 unmodified lines
21052387 greedy: true
21062388 },
21072389 '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,
21092391 lookbehind: true
21102392 },
21112393 'tag': /![^\s]+/,
21122394 'important': /[&*][\w]+/,
21132395 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
21142396 };
2115−
assets/javascripts/vendor/raven.js+1−1
@@ -856,7 +856,7 @@ Raven.prototype = { · 855 unmodified lines
856856 },
857857
858858 _triggerEvent: function(eventType, options) {
859− // NOTE: `event` is a native browser thing, so let's avoid conflicting wiht it
859+ // NOTE: `event` is a native browser thing, so let's avoid conflicting with it
860860 var evt, key;
861861
862862 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
153153 return
154154
155155 afterRoute: (route, context) =>
156+ if route != 'entry' and route != 'type'
157+ resetFavicon()
158+
156159 switch route
157160 when 'root'
158161 @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
4040 if app.disabledDocs.findBy 'slug', @entry.doc.slug
4141 @hiddenView = new app.views.HiddenPage @el, @entry
4242
43+ setFaviconForDoc(@entry.doc)
4344 @delay @polyfillMathML
4445 @trigger 'loaded'
4546 return
@@ -123,7 +124,7 @@ class app.views.EntryPage extends app.View · 77 unmodified lines
123124 @render @tmpl('pageLoadError')
124125 @resetClass()
125126 @addClass @constructor.errorClass
126− app.appCache?.update()
127+ app.serviceWorker?.update()
127128 return
128129
129130 cache: ->
assets/javascripts/views/content/offline_page.coffee+1−0
@@ -57,6 +57,7 @@ class app.views.OfflinePage extends app.View · 56 unmodified lines
5757 doc[action](@onInstallSuccess.bind(@, doc), @onInstallError.bind(@, doc), @onInstallProgress.bind(@, doc))
5858 el.parentNode.innerHTML = "#{el.textContent.replace(/e$/, '')}ing…"
5959 else if action = el.getAttribute('data-action-all')
60+ return unless action isnt 'uninstall' or window.confirm('Uninstall all docs?')
6061 app.db.migrate()
6162 $.click(el) for el in @findAll("[data-action='#{action}']")
6263 return
assets/javascripts/views/content/root_page.coffee+0−4
@@ -19,10 +19,6 @@ class app.views.RootPage extends app.View · 18 unmodified lines
1919 else
2020 'intro'
2121
22− # temporary
23− if location.host is 'devdocs.io' and location.protocol is 'http:'
24− tmpl = 'httpWarning'
25−
2622 @append @tmpl(tmpl)
2723 return
2824
assets/javascripts/views/content/settings_page.coffee+10−12
@@ -1,7 +1,4 @@
11 class app.views.SettingsPage extends app.View
2− LAYOUTS = ['_max-width', '_sidebar-hidden', '_native-scrollbars']
3− SIDEBAR_HIDDEN_LAYOUT = '_sidebar-hidden'
4−
52 @className: '_static'
63
74 @events:
@@ -17,32 +14,31 @@ class app.views.SettingsPage extends app.View · 9 unmodified lines
1714 settings.dark = app.settings.get('dark')
1815 settings.smoothScroll = !app.settings.get('fastScroll')
1916 settings.arrowScroll = app.settings.get('arrowScroll')
20− settings[layout] = app.settings.hasLayout(layout) for layout in LAYOUTS
17+ 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
2120 settings
2221
2322 getTitle: ->
2423 'Preferences'
2524
2625 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)
3126 app.settings.set('dark', !!enable)
32− app.appCache?.updateInBackground()
3327 return
3428
3529 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')
3830 app.settings.setLayout(layout, enable)
39− app.appCache?.updateInBackground()
4031 return
4132
4233 toggleSmoothScroll: (enable) ->
4334 app.settings.set('fastScroll', !enable)
4435 return
4536
37+ toggleAnalyticsConsent: (enable) ->
38+ app.settings.set('analyticsConsent', if enable then '1' else '0')
39+ resetAnalytics() unless enable
40+ return
41+
4642 toggle: (name, enable) ->
4743 app.settings.set(name, enable)
4844 return
@@ -86,6 +82,8 @@ class app.views.SettingsPage extends app.View · 37 unmodified lines
8682 @toggleSmoothScroll input.checked
8783 when 'import'
8884 @import input.files[0], input
85+ when 'analyticsConsent'
86+ @toggleAnalyticsConsent input.checked
8987 else
9088 @toggle input.name, input.checked
9189 return
assets/javascripts/views/content/type_page.coffee+1−0
@@ -9,6 +9,7 @@ class app.views.TypePage extends app.View · 8 unmodified lines
99
1010 render: (@type) ->
1111 @html @tmpl('typePage', @type)
12+ setFaviconForDoc(@type.doc)
1213 return
1314
1415 getTitle: ->
assets/javascripts/views/layout/document.coffee+7−5
@@ -75,9 +75,11 @@ class app.views.Document extends app.View · 74 unmodified lines
7575 return unless target.hasAttribute('data-behavior')
7676 $.stopEvent(event)
7777 switch target.getAttribute('data-behavior')
78− when 'back' then history.back()
79− when 'reload' then window.location.reload()
80− when 'reboot' then window.location = '/'
81− when 'hard-reload' then app.reload()
82− when 'reset' then app.reset() if confirm('Are you sure you want to reset DevDocs?')
78+ when 'back' then history.back()
79+ when 'reload' then window.location.reload()
80+ when 'reboot' then app.reboot()
81+ when 'hard-reload' then app.reload()
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()
8385 return
assets/javascripts/views/layout/resizer.coffee+2−9
@@ -11,9 +11,6 @@ class app.views.Resizer extends app.View · 10 unmodified lines
1111 init: ->
1212 @el.setAttribute('draggable', 'true')
1313 @appendTo $('._app')
14−
15− @style = $('style[data-resizer]')
16− @size = @style.getAttribute('data-size')
1714 return
1815
1916 MIN = 260
@@ -24,15 +21,11 @@ class app.views.Resizer extends app.View · 4 unmodified lines
2421 return unless value > 0
2522 value = Math.min(Math.max(Math.round(value), MIN), MAX)
2623 newSize = "#{value}px"
27− @style.innerHTML = @style.innerHTML.replace(new RegExp(@size, 'g'), newSize)
28− @size = newSize
29− if save
30− app.settings.setSize(value)
31− app.appCache?.updateInBackground()
24+ document.documentElement.style.setProperty('--sidebarWidth', newSize)
25+ app.settings.setSize(value) if save
3226 return
3327
3428 onDragStart: (event) =>
35− @style.removeAttribute('disabled')
3629 event.dataTransfer.effectAllowed = 'link'
3730 event.dataTransfer.setData('Text', '')
3831 $.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
2525 if super
2626 @render()
2727 document.body.classList.remove(SIDEBAR_HIDDEN_LAYOUT)
28− app.appCache?.on 'progress', @onAppCacheProgress
2928 return
3029
3130 deactivate: ->
@@ -33,7 +32,6 @@ class app.views.Settings extends app.View · 1 unmodified line
3332 @resetClass()
3433 @docPicker.detach()
3534 document.body.classList.add(SIDEBAR_HIDDEN_LAYOUT) if app.settings.hasLayout(SIDEBAR_HIDDEN_LAYOUT)
36− app.appCache?.off 'progress', @onAppCacheProgress
3735 return
3836
3937 render: ->
@@ -52,7 +50,7 @@ class app.views.Settings extends app.View · 12 unmodified lines
5250 docs = @docPicker.getSelectedDocs()
5351 app.settings.setDocs(docs)
5452
55− @saveBtn.textContent = if app.appCache then 'Downloading\u2026' else 'Saving\u2026'
53+ @saveBtn.textContent = 'Saving\u2026'
5654 disabledDocs = new app.collections.Docs(doc for doc in app.docs.all() when docs.indexOf(doc.slug) is -1)
5755 disabledDocs.uninstall ->
5856 app.db.migrate()
@@ -83,9 +81,3 @@ class app.views.Settings extends app.View · 24 unmodified lines
8381 $.stopEvent(event)
8482 app.router.show '/'
8583 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
1717 typing: 'focus'
1818 altG: 'google'
1919 altS: 'stackoverflow'
20+ altD: 'duckduckgo'
2021
2122 @routes:
2223 after: 'afterRoute'
@@ -29,6 +30,9 @@ class app.views.Search extends app.View · 6 unmodified lines
2930 .on 'results', @onResults
3031 .on 'end', @onEnd
3132
33+ @scope
34+ .on 'change', @onScopeChange
35+
3236 app.on 'ready', @onReady
3337 $.on window, 'hashchange', @searchUrl
3438 $.on window, 'focus', @onWindowFocus
@@ -113,6 +117,10 @@ class app.views.Search extends app.View · 78 unmodified lines
113117 @externalSearch "https://stackoverflow.com/search?q="
114118 return
115119
120+ duckduckgo: =>
121+ @externalSearch "https://duckduckgo.com/?t=devdocs&q="
122+ return
123+
116124 onResults: (results) =>
117125 @hasResults = true if results.length
118126 @trigger 'results', results, @flags
@@ -133,6 +141,11 @@ class app.views.Search extends app.View · 14 unmodified lines
133141 $.stopEvent(event)
134142 return
135143
144+ onScopeChange: =>
145+ @value = ''
146+ @onInput()
147+ return
148+
136149 afterRoute: (name, context) =>
137150 return if app.shortcuts.eventInProgress?.name is 'escape'
138151 @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
66 tag: '._search-tag'
77
88 @events:
9+ click: 'onClick'
910 keydown: 'onKeydown'
11+ textInput: 'onTextInput'
1012
1113 @routes:
1214 after: 'afterRoute'
@@ -87,17 +89,33 @@ class app.views.SearchScope extends app.View · 74 unmodified lines
8789 @trigger 'change', null, previousDoc
8890 return
8991
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+
90103 onKeydown: (event) =>
91104 if event.which is 8 # backspace
92− if @doc and not @input.value
93− $.stopEvent(event)
105+ if @doc and @input.selectionEnd is 0
94106 @reset()
95− else if not @doc and @input.value
107+ $.stopEvent(event)
108+ else if not @doc and @input.value and not $.isChromeForAndroid()
96109 return if event.ctrlKey or event.metaKey or event.altKey or event.shiftKey
97110 if event.which is 9 or # tab
98111 (event.which is 32 and app.isMobile()) # space
99− @search @input.value[0...@input.selectionStart]
100− $.stopEvent(event) if @doc
112+ @doScopeSearch(event)
113+ return
114+
115+ onTextInput: (event) =>
116+ return unless $.isChromeForAndroid()
117+ if not @doc and @input.value and event.data == ' '
118+ @doScopeSearch(event)
101119 return
102120
103121 extractHashValue: ->
assets/javascripts/views/sidebar/sidebar.coffee+1−1
@@ -28,7 +28,7 @@ class app.views.Sidebar extends app.View · 27 unmodified lines
2828
2929 app.on 'ready', @onReady
3030
31− $.on document.documentElement, 'mouseleave', (event) => @display() if event.clientX < 10
31+ $.on document.documentElement, 'mouseleave', (event) => @display() unless event.clientX <= 0
3232 $.on document.documentElement, 'mouseenter', => @resetDisplay(forceNoHover: false)
3333 return
3434

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