본문 바로가기
비전공자 IT 이야기/TIL (Today I Learn)

tistory의 syntax highlight 플러그인

by firewood tokyo 2022. 5. 29.

2022.05.28 - [비전공자 IT 이야기/TIL (Today I Learn)] - git merge strategy

 

어제 ↑의 글을 쓰다가 발견 && 적용한 것.

티스토리에서 제공하는 syntax highlight 기능에서 diff를 선택지로 주지 않길래 약간 의아해서 메모

 

티스토리 플러그인-코드블럭 삽입에서 기본으로 제공하는 선택지에는 diff가 없다.

 

 

하지만.. highlight.js 는 diff가 가능한 것!

 

발췌

https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.3/highlight.min.js

~$ grep 'registerLanguage' highlight.min.js
        }, registerLanguage: (t, i) => {
        }, unregisterLanguage: e => {
hljs.registerLanguage("apache", (() => {
hljs.registerLanguage("bash", (() => {
hljs.registerLanguage("c", (() => {
hljs.registerLanguage("coffeescript", (() => {
hljs.registerLanguage("cpp", (() => {
hljs.registerLanguage("csharp", (() => {
hljs.registerLanguage("css", (() => {
hljs.registerLanguage("diff", (() => {
hljs.registerLanguage("go", (() => {
hljs.registerLanguage("http", (() => {
hljs.registerLanguage("ini", (() => {
hljs.registerLanguage("java", (() => {
hljs.registerLanguage("javascript", (() => {
hljs.registerLanguage("json", (() => {
hljs.registerLanguage("kotlin", (() => {
hljs.registerLanguage("less", (() => {
hljs.registerLanguage("lua", (() => {
hljs.registerLanguage("makefile", (() => {
hljs.registerLanguage("xml", (() => {
hljs.registerLanguage("markdown", (() => {
hljs.registerLanguage("nginx", (() => {
hljs.registerLanguage("objectivec", (() => {
hljs.registerLanguage("perl", (() => {
hljs.registerLanguage("php", (() => {
hljs.registerLanguage("php-template", (() => {
hljs.registerLanguage("plaintext", (() => {
hljs.registerLanguage("properties", (() => {
hljs.registerLanguage("python", (() => {
hljs.registerLanguage("python-repl", (() => {
hljs.registerLanguage("r", (() => {
hljs.registerLanguage("ruby", (() => {
hljs.registerLanguage("rust", (() => {
hljs.registerLanguage("scss", (() => {
hljs.registerLanguage("shell", (() => {
hljs.registerLanguage("sql", (() => {
hljs.registerLanguage("swift", (() => {
hljs.registerLanguage("typescript", (() => {
hljs.registerLanguage("vbnet", (() => {
hljs.registerLanguage("yaml", (() => {
~$

 

 

yaml 이나 json, diff 정도면 그래도 자주 쓰일만한 선택지일 것 같은데... 

편집기에서 html모드로 변경해서 강제로 diff를 설정해 주면 사용이 가능하다.

sample: https://github.com/highlightjs/highlight.js/commit/4dfb4ae6eec1d9b7234d2150d9e9f068e520bfed?diff=unified 

 

fix(rust) recognize `include_bytes!` macro (#3541) · highlightjs/highlight.js@4dfb4ae

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

github.com

commit 4dfb4ae6eec1d9b7234d2150d9e9f068e520bfed (HEAD -> main, origin/main, origin/HEAD)
Author: Alex <69764315+Serial-ATA@users.noreply.github.com>
Date:   Mon May 23 07:41:23 2022 -0400

    fix(rust) recognize `include_bytes!` macro (#3541)

diff --git a/CHANGES.md b/CHANGES.md
index 59a37643..350267fb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@

 Grammars:

+- fix(rust) recognize `include_bytes!` macro (#3541) [Serial-ATA][]
 - enh(swift) add SE-0335 existential `any` keyword (#3515) [Bradley Mackey][]
 - enh(swift) add support for `distributed` keyword [Marcus Ortiz][]
 - enh(xml) recognize Unicode letters instead of only ASCII letters in XML element and attribute names (#3256)[Martin Honnen][]
@@ -10,6 +11,7 @@ Grammars:
 - Added 3rd party Oak grammar to SUPPORTED_LANGUAGES [Tim Smith][]
 - enh(python) add `match` and `case` keywords [Avrumy Lunger][]

+[Serial-ATA]: https://github.com/Serial-ATA
 [Bradley Mackey]: https://github.com/bradleymackey
 [Marcus Ortiz]: https://github.com/mportiz08
 [Martin Honnen]: https://github.com/martin-honnen
diff --git a/src/languages/rust.js b/src/languages/rust.js
index 005d2da7..4e65b578 100644
--- a/src/languages/rust.js
+++ b/src/languages/rust.js
@@ -127,7 +127,7 @@ export default function(hljs) {
     "file!",
     "format!",
     "format_args!",
-    "include_bin!",
+    "include_bytes!",
     "include_str!",
     "line!",
     "local_data_key!",

 

뭔가 변변한 것을 포스트 하면 좋을텐데 🤔

변변치 않은 것만 하고 있는 것 같아서 반성합니다.

 

また、つまらぬものを斬ってしまった…。
- 石川五右衛門、ルパン三世

 

 

- firewood

댓글