From 212e5e554284bc9368e52a512ed09be5a0224d3e Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Sat, 2 Jan 2021 20:52:37 +0100 Subject: [PATCH] deps: Update go-org to v1.4.0 - Add support for pretty urls [1]. Rewrite file links: 1. replace the `.org` extension with `/` (`/foo.org` -> `/foo/`) 2. prefix unrooted links with `../` as relative links start in the fake subdirectory `/foo/` rather than `/` - Fix case-sensitivity of org drawer `:end:` [1] https://gohugo.io/content-management/urls/#pretty-urls --- go.mod | 4 ++-- go.sum | 8 ++++++-- markup/org/convert.go | 1 + markup/org/convert_test.go | 6 +++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index c6f95a117..cdc3ee0fe 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/muesli/smartcrop v0.3.0 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/nicksnyder/go-i18n/v2 v2.1.1 - github.com/niklasfasching/go-org v1.3.2 + github.com/niklasfasching/go-org v1.4.0 github.com/olekukonko/tablewriter v0.0.4 github.com/pelletier/go-toml v1.8.1 github.com/pkg/errors v0.9.1 @@ -60,7 +60,7 @@ require ( github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 gocloud.dev v0.20.0 golang.org/x/image v0.0.0-20191214001246-9130b4cfad52 - golang.org/x/net v0.0.0-20200602114024-627f9648deb9 + golang.org/x/net v0.0.0-20201224014010-6772e930b67b golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a golang.org/x/text v0.3.4 google.golang.org/api v0.26.0 diff --git a/go.sum b/go.sum index 645087bc0..012b82f60 100644 --- a/go.sum +++ b/go.sum @@ -389,8 +389,8 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/nicksnyder/go-i18n/v2 v2.1.1 h1:ATCOanRDlrfKVB4WHAdJnLEqZtDmKYsweqsOUYflnBU= github.com/nicksnyder/go-i18n/v2 v2.1.1/go.mod h1:d++QJC9ZVf7pa48qrsRWhMJ5pSHIPmS3OLqK1niyLxs= -github.com/niklasfasching/go-org v1.3.2 h1:ZKTSd+GdJYkoZl1pBXLR/k7DRiRXnmB96TRiHmHdzwI= -github.com/niklasfasching/go-org v1.3.2/go.mod h1:AsLD6X7djzRIz4/RFZu8vwRL0VGjUvGZCCH1Nz0VdrU= +github.com/niklasfasching/go-org v1.4.0 h1:qPy4VEdX55f5QcLiaD3X7N/tY5XOgk4y2uEyQa02i7A= +github.com/niklasfasching/go-org v1.4.0/go.mod h1:4FWT4U/Anir9ewjwNpbZIzMjG5RaXFafkyWZNEPRdk8= github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= @@ -579,6 +579,8 @@ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -633,6 +635,8 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/markup/org/convert.go b/markup/org/convert.go index 34043e18d..845ee3f3b 100644 --- a/markup/org/convert.go +++ b/markup/org/convert.go @@ -52,6 +52,7 @@ func (c *orgConverter) Convert(ctx converter.RenderContext) (converter.Result, e return afero.ReadFile(c.cfg.ContentFs, filename) } writer := org.NewHTMLWriter() + writer.PrettyRelativeLinks = !c.cfg.Cfg.GetBool("uglyURLs") writer.HighlightCodeBlock = func(source, lang string, inline bool) string { highlightedSource, err := c.cfg.Highlight(source, lang, "") if err != nil { diff --git a/markup/org/convert_test.go b/markup/org/convert_test.go index 9fc946ca6..96c388457 100644 --- a/markup/org/convert_test.go +++ b/markup/org/convert_test.go @@ -17,6 +17,7 @@ import ( "testing" "github.com/gohugoio/hugo/common/loggers" + "github.com/spf13/viper" "github.com/gohugoio/hugo/markup/converter" @@ -25,7 +26,10 @@ import ( func TestConvert(t *testing.T) { c := qt.New(t) - p, err := Provider.New(converter.ProviderConfig{Logger: loggers.NewErrorLogger()}) + p, err := Provider.New(converter.ProviderConfig{ + Logger: loggers.NewErrorLogger(), + Cfg: viper.New(), + }) c.Assert(err, qt.IsNil) conv, err := p.New(converter.DocumentContext{}) c.Assert(err, qt.IsNil)