diff options
| author | 2025-08-14 04:18:31 +0700 | |
|---|---|---|
| committer | 2025-08-14 04:18:31 +0700 | |
| commit | 85d4a9799ce2ce663af25be8c7e8f59f8d43761d (patch) | |
| tree | 1956c3b72dfe132fe044e6b5bede460a49b5b136 /internal/lightgallery/parser.go | |
| parent | d15630a014e31835f66b0b50d9cc1e59ee4f203c (diff) | |
| download | web-0.5.7.tar.gz web-0.5.7.zip | |
feat: parse gallery caption as an inline markdownv0.5.7
feat: stylize href links for themes
feat: adapt map palette for dark themes like night and ram
feat: add popup for markers on maps
feat: dump z-index from 13 to 8 for zoom on region level
feat: show timezone in catalogue with colon
fix: ignore empty lines inside gallery block
fix: enable closing tag for gallery block with slash
fix: on filter reset in catalogue default to publication date desc sort
Diffstat (limited to 'internal/lightgallery/parser.go')
| -rw-r--r-- | internal/lightgallery/parser.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/internal/lightgallery/parser.go b/internal/lightgallery/parser.go index bd7483a..daec797 100644 --- a/internal/lightgallery/parser.go +++ b/internal/lightgallery/parser.go @@ -4,7 +4,6 @@ import ( "bytes" "log/slog" "regexp" - "strings" "time" "github.com/yuin/goldmark/ast" @@ -25,7 +24,7 @@ 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 } @@ -50,28 +49,27 @@ func (p *LightGalleryParser) Open(parent ast.Node, reader text.Reader, pc parser func (p *LightGalleryParser) Continue(node ast.Node, reader text.Reader, pc parser.Context) parser.State { line, segment := reader.PeekLine() if len(line) == 0 || segment.Len() == 0 { - return parser.Close + return parser.Continue | parser.NoChildren } trimmed := bytes.TrimSpace(line) - if bytes.Equal(trimmed, []byte("{Gallery}")) { + if bytes.Equal(trimmed, []byte("{Gallery}")) || bytes.Equal(trimmed, []byte("{/Gallery}")) { reader.AdvanceLine() return parser.Close } gallery := node.(*LightGalleryBlock) - lineStr := string(trimmed) - parts := strings.SplitN(lineStr, "|", 2) - url := strings.TrimSpace(parts[0]) - caption := "" + parts := bytes.SplitN(trimmed, []byte{'|'}, 2) + url := bytes.TrimSpace(parts[0]) + caption := make([]byte, 0) if len(parts) > 1 { - caption = strings.TrimSpace(parts[1]) + caption = bytes.TrimSpace(parts[1]) } gallery.Images = append(gallery.Images, LightGalleryImage{ - URL: url, + URL: string(url), Caption: caption, }) |