Compare commits
1 Commits
25c39036d3
...
v0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 8126ded0a6 |
@@ -22,7 +22,7 @@ func runApp() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
html, err := gmi2html.Gmi2html(string(data), "")
|
html, err := gmi2html.Gmi2html(string(data), "", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,13 @@ import (
|
|||||||
// Based on https://geminiprotocol.net/docs/gemtext-specification.gmi
|
// Based on https://geminiprotocol.net/docs/gemtext-specification.gmi
|
||||||
|
|
||||||
// Gmi2html converts Gemini text to HTML with proper escaping and wraps it in a container with typography-focused CSS
|
// Gmi2html converts Gemini text to HTML with proper escaping and wraps it in a container with typography-focused CSS
|
||||||
func Gmi2html(text string, title string) (string, error) {
|
func Gmi2html(text string, title string, contentOnly bool) (string, error) {
|
||||||
content := convertGeminiContent(text)
|
content := convertGeminiContent(text)
|
||||||
|
|
||||||
// Handle any template errors with container
|
if contentOnly {
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
err := containerTmpl.Execute(&buffer, struct {
|
err := containerTmpl.Execute(&buffer, struct {
|
||||||
Title string
|
Title string
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func TestConvertGeminiContent(t *testing.T) {
|
|||||||
|
|
||||||
func TestGmi2html(t *testing.T) {
|
func TestGmi2html(t *testing.T) {
|
||||||
sample := "# Hello Gemini\n\nThis is a test document.\n\n=> https://gemini.circumlunar.space/ Project Gemini"
|
sample := "# Hello Gemini\n\nThis is a test document.\n\n=> https://gemini.circumlunar.space/ Project Gemini"
|
||||||
result, _ := Gmi2html(sample, "Gemini Test")
|
result, _ := Gmi2html(sample, "Gemini Test", false)
|
||||||
|
|
||||||
// Check that it contains the expected elements
|
// Check that it contains the expected elements
|
||||||
if !strings.Contains(result, "<title>Gemini Test</title>") {
|
if !strings.Contains(result, "<title>Gemini Test</title>") {
|
||||||
|
|||||||
Reference in New Issue
Block a user