Advertisement
VanGans

Prism Syntax Highlighter di Blog

Mar 1st, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.53 KB | None | 0 0
  1. Cara Mudah Memasang Box Script (Prism Syntax Highlighter di Blog) -
  2. LPrism Syntax Highlighter adalah berupa border teks kode (Pre Code) yang biasa diisi dengan kode script seperti HTML, CSS, JavaScript, JQuery dan sebagainya. Fitur ini memberikan kesan yang menarik karena di penuhi dengan boder yang berwarna, tidak seperti syntax boder yang lainnya, Prism Syntax Highlighter ini ringan dan cantik luar biasa untuk di terapkan dalam situs anda. Oke bagi anda yang penasaran dengan cara memasang Prism Syntax Highlighter ini di blog anda silahkan simak pemabahsan yang berikut ini.
  3.  
  4.  
  5. Oke Langsung Saja Simak Dengan Baik
  6.  
  7. 1.Login Ke Blogger Tema > Edit Html
  8.  
  9. 2.Copas kode dibawah ini. Lalu, pastekan tepat diatas ]]></b:skin> atau </style> (gunakan ctrl+f untuk mempermudah pencarian).
  10.  
  11.  
  12. /* CSS Prism Syntax Highlighter */
  13. pre {
  14. padding: 50px 10px 10px 10px;
  15. margin: .5em 0;
  16. white-space: pre;
  17. word-wrap: break-word;
  18. overflow: auto;
  19. background-color: #2c323c;
  20. position: relative;
  21. border-radius: 4px;
  22. max-height: 500px;
  23. }
  24.  
  25. pre::before {
  26. font-size: 16px;
  27. content: attr(title);
  28. position: absolute;
  29. top: 0;
  30. background-color: #eee;
  31. padding: 10px;
  32. left: 0;
  33. right: 0;
  34. color: #fff;
  35. text-transform: uppercase;
  36. display: block;
  37. margin: 0 0 15px 0;
  38. font-weight: bold;
  39. }
  40.  
  41. pre::after {
  42. content: 'Double click to selection';
  43. padding: 2px 10px;
  44. width: auto;
  45. height: auto;
  46. position: absolute;
  47. right: 8px;
  48. top: 8px;
  49. color: #fff;
  50. line-height: 20px;
  51. transition: all 0.3s ease-in-out;
  52. }
  53.  
  54. pre:hover::after {
  55. opacity: 0;
  56. top: -8px;
  57. visibility: visible;
  58. }
  59.  
  60. code {
  61. font-family: Consolas,Monaco,'
  62. Andale Mono','Courier New',Courier,Monospace;
  63. line-height: 16px;
  64. color: #88a9ad;
  65. background-color: transparent;
  66. padding: 1px 2px;
  67. font-size: 12px;
  68. }
  69.  
  70. pre code {
  71. display: block;
  72. background: none;
  73. border: none;
  74. color: #e9e9e9;
  75. direction: ltr;
  76. text-align: left;
  77. word-spacing: normal;
  78. padding: 0 0;
  79. font-weight: bold;
  80. }
  81.  
  82. code .token.punctuation {
  83. color: #ccc;
  84. }
  85.  
  86. pre code .token.punctuation {
  87. color: #fafafa;
  88. }
  89.  
  90. code .token.comment,code .token.prolog,code .token.doctype,code .token.cdata {
  91. color: #777;
  92. }
  93.  
  94. code .namespace {
  95. opacity: .8;
  96. }
  97.  
  98. code .token.property,code .token.tag,code .token.boolean,code .token.number {
  99. color: #e5dc56;
  100. }
  101.  
  102. code .token.selector,code .token.attr-name,code .token.string {
  103. color: #88a9ad;
  104. }
  105.  
  106. pre code .token.selector,pre code .token.attr-name {
  107. color: #fafafa;
  108. }
  109.  
  110. pre code .token.string {
  111. color: #40ee46;
  112. }
  113.  
  114. code .token.entity,code .token.url,pre .language-css .token.string,pre .style .token.string {
  115. color: #ccc;
  116. }
  117.  
  118. code .token.operator {
  119. color: #1887dd;
  120. }
  121.  
  122. code .token.atrule,code .token.attr-value {
  123. color: #009999;
  124. }
  125.  
  126. pre code .token.atrule,pre code .token.attr-value {
  127. color: #1baeb0;
  128. }
  129.  
  130. code .token.keyword {
  131. color: #e13200;
  132. font-style: italic;
  133. }
  134.  
  135. code .token.comment {
  136. font-style: italic;
  137. }
  138.  
  139. code .token.regex {
  140. color: #ccc;
  141. }
  142.  
  143. code .token.important {
  144. font-weight: bold;
  145. }
  146.  
  147. code .token.entity {
  148. cursor: help;
  149. }
  150.  
  151. pre mark {
  152. background-color: #ea4f4e!important;
  153. color: #fff!important;
  154. padding: 2px;
  155. border-radius: 2px;
  156. }
  157.  
  158. code mark {
  159. background-color: #ea4f4e!important;
  160. color: #fff!important;
  161. padding: 2px;
  162. border-radius: 2px;
  163. }
  164.  
  165. pre code mark {
  166. background-color: #ea4f4e!important;
  167. color: #fff!important;
  168. padding: 2px;
  169. border-radius: 2px;
  170. }
  171.  
  172. .comments pre {
  173. padding: 10px 10px 15px 10px;
  174. background: #2c323c;
  175. }
  176.  
  177. .comments pre::before {
  178. content: 'Code';
  179. font-size: 13px;
  180. position: relative;
  181. top: 0;
  182. background-color: #f56954;
  183. padding: 3px 10px;
  184. left: 0;
  185. right: 0;
  186. color: #fff;
  187. text-transform: uppercase;
  188. display: inline-block;
  189. margin: 0 0 10px 0;
  190. font-weight: bold;
  191. border-radius: 4px;
  192. border: none;
  193. }
  194.  
  195. .comments pre::after {
  196. font-size: 11px;
  197. }
  198.  
  199. .comments pre code {
  200. color: #eee;
  201. }
  202.  
  203. .comments pre.line-numbers {
  204. padding-left: 10px;
  205. }
  206.  
  207. pre.line-numbers {
  208. position: relative;
  209. padding-left: 3.0em;
  210. counter-reset: linenumber;
  211. }
  212.  
  213. pre.line-numbers &gt; code {
  214. position: relative;
  215. }
  216.  
  217. .line-numbers .line-numbers-rows {
  218. height: 100%;
  219. position: absolute;
  220. pointer-events: none;
  221. top: 0;
  222. font-size: 100%;
  223. left: -3.5em;
  224. width: 3em;
  225. -webkit-user-select: none;
  226. -moz-user-select: none;
  227. -ms-user-select: none;
  228. padding: 0;
  229. }
  230.  
  231. .line-numbers-rows &gt; span {
  232. pointer-events: none;
  233. display: block;
  234. counter-increment: linenumber;
  235. }
  236.  
  237. .line-numbers-rows &gt; span:before {
  238. content: counter(linenumber);
  239. color: #999;
  240. display: block;
  241. padding-right: 0.8em;
  242. text-align: right;
  243. transition: 350ms;
  244. }
  245.  
  246. pre[data-codetype='CSSku']:before {
  247. background-color: #00a1d6;
  248. }
  249.  
  250. pre[data-codetype='HTMLku']:before {
  251. background-color: #3cc888;
  252. }
  253.  
  254. pre[data-codetype='JavaScriptku']:before {
  255. background-color: #75d6d0;
  256. }
  257.  
  258. pre[data-codetype='JQueryku']:before {
  259. background-color: #e5b460;
  260. }
  261.  
  262. 4.Lalu anda masukan kembali kode di bawah ini tepat diatas kode </body>.
  263.  
  264.  
  265. <script src='https://librasbr.googlecode.com/svn/prism.js' type='text/javascript'/>
  266.  
  267. <script>
  268.  
  269. $('pre').attr('class', 'line-numbers');
  270.  
  271. Prism.hooks.add("after-highlight",function(e){var
  272. t=e.element.parentNode;if(!t||!/pre/i.test(t.nodeName)||t.className.indexOf("line-numbers")===-1){return}var
  273. n=1+e.code.split("\n").length;var r;lines=new
  274. Array(n);lines=lines.join("<span></span>");r=document.createElement("span");r.className="line-numbers-rows";r.innerHTML=lines;if(t.hasAttribute("data-start")){t.style.counterReset="linenumber
  275.  
  276. "+(parseInt(t.getAttribute("data-start"),10)-1)}e.element.appendChild(r)})
  277.  
  278. </script>
  279.  
  280. <script type='text/javascript'>
  281.  
  282. var pres = document.getElementsByTagName(&quot;pre&quot;);
  283.  
  284. for (var i = 0; i &lt; pres.length; i++) {
  285.  
  286. pres[i].addEventListener(&quot;dblclick&quot;, function () {
  287.  
  288. var selection = getSelection();
  289.  
  290. var range = document.createRange();
  291.  
  292. range.selectNodeContents(this);
  293.  
  294. selection.removeAllRanges();
  295.  
  296. selection.addRange(range);
  297.  
  298. }, false);
  299.  
  300. }
  301.  
  302. </script>
  303.  
  304. 5.Terkahir anda "Simpan Template".
  305.  
  306. 6. Jika script prism syntax sudah di terapkan, sekarang yang anda harus lakukan hanyalah tinggal memasangnya di artikel kalian dengan cara buka "Entri Baru" dan pilih menu "HTML", dan masukan script di bawah ini sesuai keinginan kalian.
  307. <pre class="line-numbers language-markup" data-codetype="HTMLku" title="HTML"><code class=" language-markup"> ...Masukan Kode HTML Disini (masuk Compose dulu)... </code></pre>
  308. <pre class="line-numbers language-css" data-codetype="CSSku" title="CSS"><code class=" language-css"> ...Masukan Kode CSS Disini... </code></pre>
  309. <pre class="line-numbers language-javascript" data-codetype="JavaScriptku" title="JavaScript"><code class=" language-javascript"> ...Masukan Kode JavaScript Disini... </code></pre>
  310. <pre class="line-numbers language-javascript" data-codetype="JQueryku" title="jQuery"><code class=" language-javascript"> ...Masukan Kode jQuery disini... </code></pre>
  311.  
  312. 7. Jika sudah anda bisa pilih menu "Compose" untuk melihatnya, jika belum terlihat anda bisa langsung Pritinjau hasil script yang kalian pasang.
  313.  
  314. 8. Selesai dan lihat hasilnya.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement