Fix rendering bugs, update name
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/.idea
|
||||
/.vscode
|
||||
/dist
|
||||
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
||||
SHELL := /bin/env oksh
|
||||
SHELL := /bin/sh
|
||||
export PATH := $(PATH)
|
||||
|
||||
all: fmt lintfix tidy test clean build
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<title>{{.Title}}</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--text-color: #eee;
|
||||
@@ -20,9 +20,9 @@
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Source Code Pro", monospace;
|
||||
font-weight: 300;
|
||||
font-size: 14px;
|
||||
font-family: "Source Serif Pro", serif;
|
||||
/* font-weight: 300; */
|
||||
font-size: 16px;
|
||||
color: var(--text-color);
|
||||
background-color: var(--bg-color);
|
||||
max-width: 34rem;
|
||||
@@ -97,6 +97,7 @@
|
||||
}
|
||||
|
||||
.gemini-preformatted {
|
||||
font-family: "Source Code Pro", monospace !important;
|
||||
background-color: var(--pre-bg);
|
||||
border: 1px solid var(--pre-border);
|
||||
border-radius: 3px;
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/antanst/gmi2html/pkg/gmi2html"
|
||||
"git.antanst.com/antanst/gmi2html"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -15,7 +15,7 @@ func main() {
|
||||
flag.Parse()
|
||||
err := runApp(*noContainer, *replaceGmiExt)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +48,7 @@ func convertGeminiContent(text string, replaceGmiExt bool) string {
|
||||
normalMode := true
|
||||
|
||||
for _, line := range lines {
|
||||
switch {
|
||||
case strings.HasPrefix(line, "=>"):
|
||||
handleLinkLine(&buffer, line, replaceGmiExt)
|
||||
case strings.HasPrefix(line, "```"):
|
||||
if strings.HasPrefix(line, "```") {
|
||||
if normalMode {
|
||||
err := preformattedTmplStart.Execute(&buffer, line)
|
||||
if err != nil {
|
||||
@@ -65,7 +62,21 @@ func convertGeminiContent(text string, replaceGmiExt bool) string {
|
||||
}
|
||||
}
|
||||
normalMode = !normalMode
|
||||
// Don't output the ``` line
|
||||
// Don't output the ``` line itself
|
||||
continue
|
||||
}
|
||||
|
||||
if !normalMode {
|
||||
// Inside preformatted block - output line directly with HTML escaping
|
||||
buffer.WriteString(template.HTMLEscapeString(line))
|
||||
buffer.WriteString("\n")
|
||||
continue
|
||||
}
|
||||
|
||||
// Normal mode - process gemini markup
|
||||
switch {
|
||||
case strings.HasPrefix(line, "=>"):
|
||||
handleLinkLine(&buffer, line, replaceGmiExt)
|
||||
case strings.HasPrefix(line, "###"):
|
||||
content := strings.TrimSpace(strings.TrimPrefix(line, "###"))
|
||||
err := h3Tmpl.Execute(&buffer, content)
|
||||
@@ -97,15 +108,10 @@ func convertGeminiContent(text string, replaceGmiExt bool) string {
|
||||
return ""
|
||||
}
|
||||
default:
|
||||
if normalMode {
|
||||
err := textLineTmpl.Execute(&buffer, line)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
} else {
|
||||
buffer.WriteString(line)
|
||||
buffer.WriteString("\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,3 +1,3 @@
|
||||
module github.com/antanst/gmi2html
|
||||
module git.antanst.com/antanst/gmi2html
|
||||
|
||||
go 1.21
|
||||
|
||||
Reference in New Issue
Block a user