Skip to content

Commit 8cfb91b

Browse files
committed
feature #1329 Fix: source code modal doesn't show php attributes (voronkovich)
This PR was squashed before being merged into the main branch. Discussion ---------- Fix: source code modal doesn't show php attributes :hankey: :scream: :scream_cat: ![oie_h1QnxhxN05Yu](https://user-images.githubusercontent.com/2299535/166320470-382acddb-df6a-425a-bcc3-3a5dcc02f088.png) Fixed: ![Screenshot 2022-05-02 at 23-53-37 Symfony Demo application](https://user-images.githubusercontent.com/2299535/166326168-ebb6a3bf-1e06-4939-92ef-cfe15096ac96.png) Commits ------- 26c7151 Fix: source code modal doesn't show php attributes
2 parents 64005d8 + 26c7151 commit 8cfb91b

File tree

13 files changed

+60
-34
lines changed

13 files changed

+60
-34
lines changed

assets/js/doclinks.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,37 @@ $(function() {
1010
return '<a class="doclink" target="_blank" href="' + url + '">' + content + '</a>';
1111
};
1212

13+
function wrap(content, links) {
14+
return content.replace(
15+
new RegExp(Object.keys(links).join('|'), 'g'),
16+
token => anchor(links[token], token)
17+
);
18+
};
19+
1320
// Wraps links to the Symfony documentation
1421
$modal.find('.hljs-comment').each(function() {
1522
$(this).html($(this).html().replace(/https:\/\/symfony.com\/doc\/[\w/.#-]+/g, function(url) {
1623
return anchor(url, url);
1724
}));
1825
});
1926

20-
// Wraps Symfony's annotations
21-
var annotations = {
22-
'@Cache': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html',
23-
'@IsGranted': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html#isgranted',
24-
'@ParamConverter': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html',
25-
'@Route': 'https://symfony.com/doc/current/routing.html#creating-routes-as-annotations',
26-
'@Security': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html#security'
27+
// Wraps Symfony's attributes
28+
var attributes = {
29+
'Cache': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html',
30+
'IsGranted': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html#isgranted',
31+
'ParamConverter': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html',
32+
'Route': 'https://symfony.com/doc/current/routing.html#creating-routes-as-attributes-or-annotations',
33+
'Security': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html#security'
2734
};
2835

29-
$controllerCode.find('.hljs-doctag').each(function() {
30-
var annotation = $(this).text();
36+
$controllerCode.find('.hljs-meta').each(function() {
37+
var src = $(this).text();
3138

32-
if (annotations[annotation]) {
33-
$(this).html(anchor(annotations[annotation], annotation));
34-
}
39+
$(this).html(wrap(src, attributes));
3540
});
3641

3742
// Wraps Twig's tags
38-
$templateCode.find('.hljs-template-tag > .hljs-name').each(function() {
43+
$templateCode.find('.hljs-template-tag + .hljs-name').each(function() {
3944
var tag = $(this).text();
4045

4146
if ('else' === tag || tag.match(/^end/)) {

assets/js/highlight.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ import twig from 'highlight.js/lib/languages/twig';
55
hljs.registerLanguage('php', php);
66
hljs.registerLanguage('twig', twig);
77

8-
hljs.initHighlightingOnLoad();
8+
hljs.highlightAll();

assets/styles/app.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $lato-font-path: '~lato-font/fonts';
1212
@import "~bootswatch/flatly/bootswatch";
1313
@import "~@fortawesome/fontawesome-free/css/all.css";
1414
@import "~@fortawesome/fontawesome-free/css/v4-shims.css";
15-
@import "~highlight.js/styles/solarized-light.css";
15+
@import "~highlight.js/styles/base16/solarized-light.css";
1616

1717
// pick the Lato fonts individually to avoid importing the entire font family
1818
@import '~lato-font/scss/public-api';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"bootswatch": "^3.3.7",
1010
"core-js": "^3.0.0",
1111
"eonasdan-bootstrap-datetimepicker": "^4.17.47",
12-
"highlight.js": "^10.4.1",
12+
"highlight.js": "^11.5.1",
1313
"imports-loader": "^0.8.0",
1414
"jquery": "^3.5.1",
1515
"lato-font": "^3.0.0",

public/build/169.61570d43.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/build/979.4967399b.js

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

public/build/169.8ccdf84f.css renamed to public/build/979.dc75718b.css

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

public/build/app.993b7531.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/build/app.a5511055.js

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

public/build/entrypoints.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"/build/runtime.96aa4ea2.js",
66
"/build/755.f5cf308f.js",
77
"/build/498.3bafb5f9.js",
8-
"/build/169.61570d43.js",
9-
"/build/app.993b7531.js"
8+
"/build/979.4967399b.js",
9+
"/build/app.a5511055.js"
1010
],
1111
"css": [
12-
"/build/169.8ccdf84f.css",
12+
"/build/979.dc75718b.css",
1313
"/build/app.ac992678.css"
1414
]
1515
},
@@ -46,9 +46,9 @@
4646
"/build/runtime.96aa4ea2.js": "sha384-nMYLpi/v3txwhZt8UOBsMOTbgVmUPlpD8cPmrU3yblZ7Yg8l799XS9NC1BZ9P9Xs",
4747
"/build/755.f5cf308f.js": "sha384-SAv+SyvZr31CmFrJFfKEYK0fDrMVx8vh19SI4QznAB/ar+Z1k6IT9Mg2SDZtLwD2",
4848
"/build/498.3bafb5f9.js": "sha384-yoQvBlSFO4jMdQIBvie1V5XQ4M8F0CGnS2mFtS9RslTqLbW8IYO/xONlip3SUDGH",
49-
"/build/169.61570d43.js": "sha384-5YrrxLGqNa0MkTVcoUS0ey4YjDbKSGG/W253kc95h1F1B+naqWhAxdQygYmhShtF",
50-
"/build/app.993b7531.js": "sha384-j4enIn+WJyu1/cU3hEKrrpjjiUbY3/rTtftcQFZ3sH4Eg7lSVgHXfEoe8Q9fR5sO",
51-
"/build/169.8ccdf84f.css": "sha384-M2cVsp0oOWSDHv3WMyFy5lTSMmDd0cY5EMO9CX+G1xUmxH85GYNPKPeyRNzoXD0v",
49+
"/build/979.4967399b.js": "sha384-IPkjWWHEhfdos/b3w08uBZ2KjTFno/Ocwt1o6ardQjWJEbigWocfHbAeZfj+t7AX",
50+
"/build/app.a5511055.js": "sha384-t5u9zzpbS+SwUVCOSeCZdoFdZ5n1rIZ5nWHPzaEYkZ6U2oaG2AOokBmGXzL7uORK",
51+
"/build/979.dc75718b.css": "sha384-3Xq9zpkhbAPpNpmbJIfOIsDjVugU/PSQ4vcam/DSyD65+CvSOnCrlxkY+RpzfNKN",
5252
"/build/app.ac992678.css": "sha384-ICPCCj5CXbWgl5Qqe/h85MC7oJI7tfgk7ZWIPsFm93L6gG/fHXfzBERdusSM7Fy4",
5353
"/build/login.395771d5.js": "sha384-bKBy5bAsLAFHFo/zxqJkheRiwvRSVHXwogJPw7DWc6qfnP03VaNFMyEc/0cRBf0k",
5454
"/build/919.63ff4a5d.js": "sha384-0o9glCmkeYT/iE8RHdbPnoqMslSFjP/uN4ggsyjBVE5eq+V2RUFdEzYZBs5JNiyb",

0 commit comments

Comments
 (0)