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)
|
export PATH := $(PATH)
|
||||||
|
|
||||||
all: fmt lintfix tidy test clean build
|
all: fmt lintfix tidy test clean build
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<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>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
--text-color: #eee;
|
--text-color: #eee;
|
||||||
@@ -20,9 +20,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: "Source Code Pro", monospace;
|
font-family: "Source Serif Pro", serif;
|
||||||
font-weight: 300;
|
/* font-weight: 300; */
|
||||||
font-size: 14px;
|
font-size: 16px;
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
background-color: var(--bg-color);
|
background-color: var(--bg-color);
|
||||||
max-width: 34rem;
|
max-width: 34rem;
|
||||||
@@ -97,6 +97,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.gemini-preformatted {
|
.gemini-preformatted {
|
||||||
|
font-family: "Source Code Pro", monospace !important;
|
||||||
background-color: var(--pre-bg);
|
background-color: var(--pre-bg);
|
||||||
border: 1px solid var(--pre-border);
|
border: 1px solid var(--pre-border);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/antanst/gmi2html/pkg/gmi2html"
|
"git.antanst.com/antanst/gmi2html"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -15,7 +15,7 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
err := runApp(*noContainer, *replaceGmiExt)
|
err := runApp(*noContainer, *replaceGmiExt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,10 +48,7 @@ func convertGeminiContent(text string, replaceGmiExt bool) string {
|
|||||||
normalMode := true
|
normalMode := true
|
||||||
|
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
switch {
|
if strings.HasPrefix(line, "```") {
|
||||||
case strings.HasPrefix(line, "=>"):
|
|
||||||
handleLinkLine(&buffer, line, replaceGmiExt)
|
|
||||||
case strings.HasPrefix(line, "```"):
|
|
||||||
if normalMode {
|
if normalMode {
|
||||||
err := preformattedTmplStart.Execute(&buffer, line)
|
err := preformattedTmplStart.Execute(&buffer, line)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -65,7 +62,21 @@ func convertGeminiContent(text string, replaceGmiExt bool) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
normalMode = !normalMode
|
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, "###"):
|
case strings.HasPrefix(line, "###"):
|
||||||
content := strings.TrimSpace(strings.TrimPrefix(line, "###"))
|
content := strings.TrimSpace(strings.TrimPrefix(line, "###"))
|
||||||
err := h3Tmpl.Execute(&buffer, content)
|
err := h3Tmpl.Execute(&buffer, content)
|
||||||
@@ -97,15 +108,10 @@ func convertGeminiContent(text string, replaceGmiExt bool) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if normalMode {
|
|
||||||
err := textLineTmpl.Execute(&buffer, line)
|
err := textLineTmpl.Execute(&buffer, line)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
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
|
go 1.21
|
||||||
|
|||||||
Reference in New Issue
Block a user