feat: add syntax highlighting

This commit is contained in:
log101 2023-12-07 17:35:44 +00:00
parent 958cb153c0
commit 1a670eed59
10 changed files with 135 additions and 24 deletions

86
assets/scss/_syntax.scss Normal file
View File

@ -0,0 +1,86 @@
/* Background */ .bg { background-color: #f8f8f8; }
/* PreWrapper */ .chroma { background-color: #f8f8f8; padding: 16px; border-radius: 4px;}
/* Other */ .chroma .x { }
/* Error */ .chroma .err { }
/* CodeLine */ .chroma .cl { }
/* LineLink */ .chroma .lnlinks { outline: none; text-decoration: none; color: inherit }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
/* LineHighlight */ .chroma .hl { background-color: #dfdfdf }
/* LineNumbersTable */ .chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
/* LineNumbers */ .chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
/* Line */ .chroma .line { display: flex; }
/* Keyword */ .chroma .k { color: #aa22ff; font-weight: bold }
/* KeywordConstant */ .chroma .kc { color: #aa22ff; font-weight: bold }
/* KeywordDeclaration */ .chroma .kd { color: #aa22ff; font-weight: bold }
/* KeywordNamespace */ .chroma .kn { color: #aa22ff; font-weight: bold }
/* KeywordPseudo */ .chroma .kp { color: #aa22ff }
/* KeywordReserved */ .chroma .kr { color: #aa22ff; font-weight: bold }
/* KeywordType */ .chroma .kt { color: #00bb00; font-weight: bold }
/* Name */ .chroma .n { }
/* NameAttribute */ .chroma .na { color: #bb4444 }
/* NameBuiltin */ .chroma .nb { color: #aa22ff }
/* NameBuiltinPseudo */ .chroma .bp { }
/* NameClass */ .chroma .nc { color: #0000ff }
/* NameConstant */ .chroma .no { color: #880000 }
/* NameDecorator */ .chroma .nd { color: #aa22ff }
/* NameEntity */ .chroma .ni { color: #999999; font-weight: bold }
/* NameException */ .chroma .ne { color: #d2413a; font-weight: bold }
/* NameFunction */ .chroma .nf { color: #00a000 }
/* NameFunctionMagic */ .chroma .fm { }
/* NameLabel */ .chroma .nl { color: #a0a000 }
/* NameNamespace */ .chroma .nn { color: #0000ff; font-weight: bold }
/* NameOther */ .chroma .nx { }
/* NameProperty */ .chroma .py { }
/* NameTag */ .chroma .nt { color: #008000; font-weight: bold }
/* NameVariable */ .chroma .nv { color: #b8860b }
/* NameVariableClass */ .chroma .vc { }
/* NameVariableGlobal */ .chroma .vg { }
/* NameVariableInstance */ .chroma .vi { }
/* NameVariableMagic */ .chroma .vm { }
/* Literal */ .chroma .l { }
/* LiteralDate */ .chroma .ld { }
/* LiteralString */ .chroma .s { color: #bb4444 }
/* LiteralStringAffix */ .chroma .sa { color: #bb4444 }
/* LiteralStringBacktick */ .chroma .sb { color: #bb4444 }
/* LiteralStringChar */ .chroma .sc { color: #bb4444 }
/* LiteralStringDelimiter */ .chroma .dl { color: #bb4444 }
/* LiteralStringDoc */ .chroma .sd { color: #bb4444; font-style: italic }
/* LiteralStringDouble */ .chroma .s2 { color: #bb4444 }
/* LiteralStringEscape */ .chroma .se { color: #bb6622; font-weight: bold }
/* LiteralStringHeredoc */ .chroma .sh { color: #bb4444 }
/* LiteralStringInterpol */ .chroma .si { color: #bb6688; font-weight: bold }
/* LiteralStringOther */ .chroma .sx { color: #008000 }
/* LiteralStringRegex */ .chroma .sr { color: #bb6688 }
/* LiteralStringSingle */ .chroma .s1 { color: #bb4444 }
/* LiteralStringSymbol */ .chroma .ss { color: #b8860b }
/* LiteralNumber */ .chroma .m { color: #666666 }
/* LiteralNumberBin */ .chroma .mb { color: #666666 }
/* LiteralNumberFloat */ .chroma .mf { color: #666666 }
/* LiteralNumberHex */ .chroma .mh { color: #666666 }
/* LiteralNumberInteger */ .chroma .mi { color: #666666 }
/* LiteralNumberIntegerLong */ .chroma .il { color: #666666 }
/* LiteralNumberOct */ .chroma .mo { color: #666666 }
/* Operator */ .chroma .o { color: #666666 }
/* OperatorWord */ .chroma .ow { color: #aa22ff; font-weight: bold }
/* Punctuation */ .chroma .p { }
/* Comment */ .chroma .c { color: #008800; font-style: italic }
/* CommentHashbang */ .chroma .ch { color: #008800; font-style: italic }
/* CommentMultiline */ .chroma .cm { color: #008800; font-style: italic }
/* CommentSingle */ .chroma .c1 { color: #008800; font-style: italic }
/* CommentSpecial */ .chroma .cs { color: #008800; font-weight: bold }
/* CommentPreproc */ .chroma .cp { color: #008800 }
/* CommentPreprocFile */ .chroma .cpf { color: #008800 }
/* Generic */ .chroma .g { }
/* GenericDeleted */ .chroma .gd { color: #a00000 }
/* GenericEmph */ .chroma .ge { font-style: italic }
/* GenericError */ .chroma .gr { color: #ff0000 }
/* GenericHeading */ .chroma .gh { color: #000080; font-weight: bold }
/* GenericInserted */ .chroma .gi { color: #00a000 }
/* GenericOutput */ .chroma .go { color: #888888 }
/* GenericPrompt */ .chroma .gp { color: #000080; font-weight: bold }
/* GenericStrong */ .chroma .gs { font-weight: bold }
/* GenericSubheading */ .chroma .gu { color: #800080; font-weight: bold }
/* GenericTraceback */ .chroma .gt { color: #0044dd }
/* GenericUnderline */ .chroma .gl { text-decoration: underline }
/* TextWhitespace */ .chroma .w { color: #bbbbbb }

View File

@ -1,3 +1,5 @@
@import "_syntax.scss";
#page {
height: 100vh;
margin: 0
@ -9,11 +11,11 @@
flex-direction: column;
align-items: start;
justify-content: space-between;
max-width: 400px;
max-width: 720px;
margin: auto;
font-size: 1.5rem;
@media (max-width: 448px) {
@media (max-width: 768px) {
margin-left: 24px;
}
}
@ -170,7 +172,7 @@
}
#site-footer {
width: 400px;
width: 100%;
user-select: none;
#copyright {
@ -180,7 +182,6 @@
}
}
#home-footer {
width: 400px;
}
@ -196,3 +197,7 @@
}
}
}
.content {
max-width: 720px;
}

View File

@ -11,6 +11,21 @@ rssLimit = 10 # Maximum number of items in the RSS feed.
enableEmoji = true
paginate = 5
[markup]
[markup.highlight]
anchorLineNos = false
codeFences = true
guessSyntax = false
hl_Lines = ''
hl_inline = false
lineAnchors = ''
lineNoStart = 1
lineNos = false
lineNumbersInTable = true
noClasses = true
style = 'emacs'
tabWidth = 4
[languages]
[languages.tr]
disabled = false
@ -51,7 +66,7 @@ paginate = 5
code_copy_button = true # Turn on/off the code-copy-button for code-fields
# Add custom css
# customCSS = ["css/foo.css", "css/bar.css"]
# customCSS = ["css/syntax.css"]
[params.author]
name = "Furkan Erdem"

View File

@ -8,10 +8,9 @@ tags = [
"development",
]
date = "2014-04-02"
toc = true
+++
Hugo uses the excellent [Go][] [html/template][gohtmltemplate] library for
Hugo and uses the excellent [Go][] [html/template][gohtmltemplate] library for
its template engine. It is an extremely lightweight engine that provides a very
small amount of logic. In our experience that it is just the right amount of
logic to be able to create a good static website. If you have used other
@ -40,7 +39,9 @@ functions.
Accessing a predefined variable "foo":
{{ foo }}
```go
{{ foo }} asdadasdasad
```
**Parameters are separated using spaces**

View File

@ -40,7 +40,15 @@ functions.
Accessing a predefined variable "foo":
{{ foo }}
```go
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
```
**Parameters are separated using spaces**

View File

@ -40,7 +40,6 @@
<div id="site-footer">
{{ block "footer" . -}}{{ end }}
</div>
</div>
{{ $main := resources.Get "js/main.js" -}}

View File

@ -8,9 +8,6 @@
{{ if (or .Params.images .Params.featuredImg) -}}
<button id="img-btn" class="hdr-btn" title="{{i18n "featuredImage"}}"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-image"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg></button>
{{- end }}
{{- with .Params.toc -}}
<button id="toc-btn" class="hdr-btn desktop-only-ib" title="{{i18n "tableOfContents"}}"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-list"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3" y2="6"></line><line x1="3" y1="12" x2="3" y2="12"></line><line x1="3" y1="18" x2="3" y2="18"></line></svg></button>
{{- end }}
</div>
</div>
</header>

View File

@ -19,8 +19,16 @@
<main class="site-main section-inner animated fadeIn faster">
<article class="thin">
<header class="post-header">
<div class="post-meta"><span>{{ .Date.Format .Site.Params.dateform }}</span></div>
<h1>{{ .Title }}</h1>
<div class="post-meta"><span>{{ .Date.Format .Site.Params.dateform }}</span></div>
{{- with .Params.tags }}
<p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg>
{{- range . -}}
<span class="tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span>
{{- end }}
</p>
{{- end }}
</header>
<div class="content">
{{ .Content | replaceRE "(<h[1-6] id=\"([^\"]+)\".+)(</h[1-6]+>)" `${1}<a href="#${2}" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a>${3}` | safeHTML }}
@ -33,14 +41,6 @@
{{- with $.Param "author" }}
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-feather"><path d="M20.24 12.24a6 6 0 0 0-8.49-8.49L5 10.5V19h8.5z"></path><line x1="16" y1="8" x2="2" y2="22"></line><line x1="17.5" y1="15" x2="9" y2="15"></line></svg>{{ . }}</p>
{{- end }}
{{- with .Params.tags }}
<p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg>
{{- range . -}}
<span class="tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span>
{{- end }}
</p>
{{- end }}
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>{{ i18n "wordCount" . }}</p>
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>{{ dateFormat .Site.Params.dateformNumTime .Date.Local }}</p>
{{- if and .GitInfo .Site.Params.gitUrl }}

View File

@ -1 +1 @@
#page{height:100vh;margin:0}#spotlight{display:flex;min-height:100vh;flex-direction:column;align-items:start;justify-content:space-between;max-width:400px;margin:auto;font-size:1.5rem}@media(max-width:448px){#spotlight{margin-left:24px}}#home-center{display:flex;flex-direction:column;flex-grow:1;align-items:flex-start;margin-top:10vh}#home-title{color:#202020;font-family:Inter;font-size:48px;font-style:normal;font-weight:500;line-height:normal}#home-nav{display:flex;flex-direction:column}#home-nav a{color:#252525;font-family:Inter;font-size:40px;font-style:normal;font-weight:400;line-height:150%;text-decoration-line:underline}.post-item .post-day,.post-item a{color:#252525;font-family:Inter;font-size:40px;font-style:normal;font-weight:400;line-height:150%;text-decoration-line:underline}#site-footer,#home-footer{width:100%}#site-footer p,#home-footer p{color:#5c5c5c;font-family:Inter;font-size:20px;font-style:normal;font-weight:300;line-height:normal;display:flex;gap:8px;justify-content:center}#site-footer a,#home-footer a{color:#5c5c5c;font-family:Inter;font-size:20px;font-style:normal;font-weight:300;line-height:normal;display:flex;gap:8px;justify-content:center;text-decoration:none}#site-footer a:hover,#home-footer a:hover{text-decoration:underline}.posts-group{width:400px}.back-title{font-family:Inter;font-size:20px;font-style:normal;font-weight:400}.back-title a{text-decoration:none;color:#252525}.back-title a:hover{text-decoration:underline;color:#151515}.post-item{display:flex;justify-content:space-between;align-items:center;width:100%}.post-item a{font-size:30px}.post-item .post-day{font-size:30px;text-decoration:none;color:#787878}.pagination{display:flex;list-style:none;padding:0;margin:0;justify-content:center;align-items:center;font-family:Inter}.pagination a{text-decoration:none;color:#252525}.pagination .page-item{margin:0}.pagination .page-link{display:block;padding:5px 10px;margin:0 2px}#site-footer{width:400px;user-select:none}#site-footer #copyright{display:flex;align-items:center;justify-content:center}#home-footer{width:400px}[aria-disabled=true]{text-decoration:none!important}.page-item.active a{text-decoration:none!important}
.bg{background-color:#f8f8f8}.chroma{background-color:#f8f8f8;padding:16px;border-radius:4px}.chroma .lnlinks{outline:none;text-decoration:none;color:inherit}.chroma .lntd{vertical-align:top;padding:0;margin:0;border:0}.chroma .lntable{border-spacing:0;padding:0;margin:0;border:0}.chroma .hl{background-color:#dfdfdf}.chroma .lnt{white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f}.chroma .ln{white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f}.chroma .line{display:flex}.chroma .k{color:#a2f;font-weight:700}.chroma .kc{color:#a2f;font-weight:700}.chroma .kd{color:#a2f;font-weight:700}.chroma .kn{color:#a2f;font-weight:700}.chroma .kp{color:#a2f}.chroma .kr{color:#a2f;font-weight:700}.chroma .kt{color:#0b0;font-weight:700}.chroma .na{color:#b44}.chroma .nb{color:#a2f}.chroma .nc{color:#00f}.chroma .no{color:#800}.chroma .nd{color:#a2f}.chroma .ni{color:#999;font-weight:700}.chroma .ne{color:#d2413a;font-weight:700}.chroma .nf{color:#00a000}.chroma .nl{color:#a0a000}.chroma .nn{color:#00f;font-weight:700}.chroma .nt{color:green;font-weight:700}.chroma .nv{color:#b8860b}.chroma .s{color:#b44}.chroma .sa{color:#b44}.chroma .sb{color:#b44}.chroma .sc{color:#b44}.chroma .dl{color:#b44}.chroma .sd{color:#b44;font-style:italic}.chroma .s2{color:#b44}.chroma .se{color:#b62;font-weight:700}.chroma .sh{color:#b44}.chroma .si{color:#b68;font-weight:700}.chroma .sx{color:green}.chroma .sr{color:#b68}.chroma .s1{color:#b44}.chroma .ss{color:#b8860b}.chroma .m{color:#666}.chroma .mb{color:#666}.chroma .mf{color:#666}.chroma .mh{color:#666}.chroma .mi{color:#666}.chroma .il{color:#666}.chroma .mo{color:#666}.chroma .o{color:#666}.chroma .ow{color:#a2f;font-weight:700}.chroma .c{color:#080;font-style:italic}.chroma .ch{color:#080;font-style:italic}.chroma .cm{color:#080;font-style:italic}.chroma .c1{color:#080;font-style:italic}.chroma .cs{color:#080;font-weight:700}.chroma .cp{color:#080}.chroma .cpf{color:#080}.chroma .gd{color:#a00000}.chroma .ge{font-style:italic}.chroma .gr{color:red}.chroma .gh{color:navy;font-weight:700}.chroma .gi{color:#00a000}.chroma .go{color:#888}.chroma .gp{color:navy;font-weight:700}.chroma .gs{font-weight:700}.chroma .gu{color:purple;font-weight:700}.chroma .gt{color:#04d}.chroma .gl{text-decoration:underline}.chroma .w{color:#bbb}#page{height:100vh;margin:0}#spotlight{display:flex;min-height:100vh;flex-direction:column;align-items:start;justify-content:space-between;max-width:720px;margin:auto;font-size:1.5rem}@media(max-width:768px){#spotlight{margin-left:24px}}#home-center{display:flex;flex-direction:column;flex-grow:1;align-items:flex-start;margin-top:10vh}#home-title{color:#202020;font-family:Inter;font-size:48px;font-style:normal;font-weight:500;line-height:normal}#home-nav{display:flex;flex-direction:column}#home-nav a{color:#252525;font-family:Inter;font-size:40px;font-style:normal;font-weight:400;line-height:150%;text-decoration-line:underline}.post-item .post-day,.post-item a{color:#252525;font-family:Inter;font-size:40px;font-style:normal;font-weight:400;line-height:150%;text-decoration-line:underline}#site-footer,#home-footer{width:100%}#site-footer p,#home-footer p{color:#5c5c5c;font-family:Inter;font-size:20px;font-style:normal;font-weight:300;line-height:normal;display:flex;gap:8px;justify-content:center}#site-footer a,#home-footer a{color:#5c5c5c;font-family:Inter;font-size:20px;font-style:normal;font-weight:300;line-height:normal;display:flex;gap:8px;justify-content:center;text-decoration:none}#site-footer a:hover,#home-footer a:hover{text-decoration:underline}.posts-group{width:400px}.back-title{font-family:Inter;font-size:20px;font-style:normal;font-weight:400}.back-title a{text-decoration:none;color:#252525}.back-title a:hover{text-decoration:underline;color:#151515}.post-item{display:flex;justify-content:space-between;align-items:center;width:100%}.post-item a{font-size:30px}.post-item .post-day{font-size:30px;text-decoration:none;color:#787878}.pagination{display:flex;list-style:none;padding:0;margin:0;justify-content:center;align-items:center;font-family:Inter}.pagination a{text-decoration:none;color:#252525}.pagination .page-item{margin:0}.pagination .page-link{display:block;padding:5px 10px;margin:0 2px}#site-footer{width:100%;user-select:none}#site-footer #copyright{display:flex;align-items:center;justify-content:center}#home-footer{width:400px}[aria-disabled=true]{text-decoration:none!important}.page-item.active a{text-decoration:none!important}.content{max-width:720px}

View File

@ -1 +1 @@
{"Target":"css/style.min.d94259078fcaba762f125ab49e299e6b28e6e0f25357161fa02e5e5146f41260.css","MediaType":"text/css","Data":{"Integrity":"sha256-2UJZB4/KunYvElq0nimeayjm4PJTVxYfoC5eUUb0EmA="}}
{"Target":"css/style.min.7c30431c941fd683f6909898424496e6ad0fee9bd65dfcd9cbf840011ff84aad.css","MediaType":"text/css","Data":{"Integrity":"sha256-fDBDHJQf1oP2kJiYQkSW5q0P7pvWXfzZy/hAAR/4Sq0="}}