summaryrefslogtreecommitdiff
path: root/internal/lightgallery/parser.go
diff options
from:
to:
context:
space:
mode:
authorGravatar SayaAndy <montferrat@tuta.io> 2025-08-12 23:21:56 +0700
committerGravatar SayaAndy <montferrat@tuta.io> 2025-08-12 23:21:56 +0700
commitc5c17c6faca1bd0e7b9522010e36e4fdf87aec6a (patch)
treeebf5b5212ee0f5fb61210d587f12baa2ab70351e /internal/lightgallery/parser.go
parentcd8746883e558e8527355e1c2342e8053848e91c (diff)
downloadweb-0.5.5.tar.gz
web-0.5.5.zip
feat: make working timezone shift in galleriesv0.5.5
fix: overflown blog page content fix: raise footer a bit higher in desktop mode refactor: start blog catalogue with publication date desc sort
Diffstat (limited to 'internal/lightgallery/parser.go')
-rw-r--r--internal/lightgallery/parser.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/lightgallery/parser.go b/internal/lightgallery/parser.go
index 0ce209c..2c10c01 100644
--- a/internal/lightgallery/parser.go
+++ b/internal/lightgallery/parser.go
@@ -2,7 +2,9 @@ package lightgallery
import (
"bytes"
+ "regexp"
"strings"
+ "time"
"github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/parser"
@@ -22,16 +24,24 @@ func (p *LightGalleryParser) Trigger() []byte {
func (p *LightGalleryParser) Open(parent ast.Node, reader text.Reader, pc parser.Context) (ast.Node, parser.State) {
line, _ := reader.PeekLine()
- if !bytes.HasPrefix(line, []byte("{Gallery}")) {
+ if !bytes.HasPrefix(line, []byte("{Gallery")) {
return nil, parser.NoChildren
}
+ r := regexp.MustCompile(`^\{Gallery:([A-Za-z0-9\+\-/]+)\}$`)
+
trimmed := bytes.TrimSpace(line)
- if !bytes.Equal(trimmed, []byte("{Gallery}")) {
+ parts := r.FindSubmatch(trimmed)
+ if len(parts) < 2 {
+ return nil, parser.NoChildren
+ }
+
+ loc, err := time.LoadLocation(string(parts[1]))
+ if err != nil {
return nil, parser.NoChildren
}
- return &LightGalleryBlock{}, parser.NoChildren
+ return &LightGalleryBlock{Location: loc}, parser.NoChildren
}
func (p *LightGalleryParser) Continue(node ast.Node, reader text.Reader, pc parser.Context) parser.State {