Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Documentation Manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Utilities
Documentation Manager
Commits
0bc0afb0
Verified
Commit
0bc0afb0
authored
2 years ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: missing headline id
parent
fb3d4d38
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
application/source/document/html.go
+27
-4
27 additions, 4 deletions
application/source/document/html.go
application/source/go.mod
+2
-0
2 additions, 0 deletions
application/source/go.mod
application/source/go.sum
+4
-0
4 additions, 0 deletions
application/source/go.sum
with
33 additions
and
4 deletions
application/source/document/html.go
+
27
−
4
View file @
0bc0afb0
...
@@ -14,11 +14,13 @@ import (
...
@@ -14,11 +14,13 @@ import (
"github.com/gomarkdown/markdown/ast"
"github.com/gomarkdown/markdown/ast"
markdownHTML
"github.com/gomarkdown/markdown/html"
markdownHTML
"github.com/gomarkdown/markdown/html"
"github.com/gomarkdown/markdown/parser"
"github.com/gomarkdown/markdown/parser"
"github.com/gosimple/slug"
"github.com/mattn/go-shellwords"
"github.com/mattn/go-shellwords"
"github.com/tdewolff/minify/v2"
"github.com/tdewolff/minify/v2"
minHTML
"github.com/tdewolff/minify/v2/html"
minHTML
"github.com/tdewolff/minify/v2/html"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/extension"
goldmarkParser
"github.com/yuin/goldmark/parser"
goldmarkHTML
"github.com/yuin/goldmark/renderer/html"
goldmarkHTML
"github.com/yuin/goldmark/renderer/html"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
...
@@ -223,7 +225,7 @@ func buildTree(body string) *Tree[DocumentNode] {
...
@@ -223,7 +225,7 @@ func buildTree(body string) *Tree[DocumentNode] {
obj
:=
newTree
[
DocumentNode
]()
obj
:=
newTree
[
DocumentNode
]()
ptr
:=
obj
ptr
:=
obj
doc
.
Find
(
"h1,h2,h3,h4"
)
.
Each
(
func
(
k
int
,
s
*
goquery
.
Selection
)
{
doc
.
Find
(
"h1,h2,h3,h4
,h5,h6
"
)
.
Each
(
func
(
k
int
,
s
*
goquery
.
Selection
)
{
e
:=
s
.
Get
(
0
)
e
:=
s
.
Get
(
0
)
t
:=
[]
rune
(
e
.
DataAtom
.
String
())
t
:=
[]
rune
(
e
.
DataAtom
.
String
())
l
:=
t
[
1
:
len
(
t
)]
l
:=
t
[
1
:
len
(
t
)]
...
@@ -234,7 +236,15 @@ func buildTree(body string) *Tree[DocumentNode] {
...
@@ -234,7 +236,15 @@ func buildTree(body string) *Tree[DocumentNode] {
aID
,
found
:=
s
.
Attr
(
"id"
)
aID
,
found
:=
s
.
Attr
(
"id"
)
if
!
found
{
if
!
found
{
aID
=
"rel-"
+
e
.
DataAtom
.
String
()
if
title
,
err
:=
s
.
Html
();
err
==
nil
{
aID
=
slug
.
Make
(
title
)
}
else
{
aID
=
""
+
e
.
DataAtom
.
String
()
+
"-"
+
randomID
()
}
s
.
SetAttr
(
"id"
,
aID
)
}
}
payload
:=
DocumentNode
{
payload
:=
DocumentNode
{
...
@@ -589,8 +599,21 @@ func renderHook(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool
...
@@ -589,8 +599,21 @@ func renderHook(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool
func
createHtmlFromMarkdown
(
text
string
)
string
{
func
createHtmlFromMarkdown
(
text
string
)
string
{
md
:=
goldmark
.
New
(
md
:=
goldmark
.
New
(
goldmark
.
WithExtensions
(
extension
.
GFM
),
goldmark
.
WithExtensions
(
goldmark
.
WithParserOptions
(),
extension
.
GFM
,
extension
.
DefinitionList
,
extension
.
Footnote
,
extension
.
Typographer
,
extension
.
Linkify
,
extension
.
Table
,
extension
.
Strikethrough
,
extension
.
TaskList
),
goldmark
.
WithParserOptions
(
goldmarkParser
.
WithAutoHeadingID
(),
goldmarkParser
.
WithAttribute
(),
goldmarkParser
.
WithHeadingAttribute
(),
),
goldmark
.
WithRendererOptions
(
goldmark
.
WithRendererOptions
(
goldmarkHTML
.
WithUnsafe
(),
goldmarkHTML
.
WithUnsafe
(),
),
),
...
...
This diff is collapsed.
Click to expand it.
application/source/go.mod
+
2
−
0
View file @
0bc0afb0
...
@@ -24,6 +24,8 @@ require (
...
@@ -24,6 +24,8 @@ require (
github.com/go-chi/chi/v5 v5.0.7 // indirect
github.com/go-chi/chi/v5 v5.0.7 // indirect
github.com/go-chi/docgen v1.2.0 // indirect
github.com/go-chi/docgen v1.2.0 // indirect
github.com/go-chi/httprate v0.5.3 // indirect
github.com/go-chi/httprate v0.5.3 // indirect
github.com/gosimple/slug v1.13.1 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/tdewolff/parse/v2 v2.6.5 // indirect
github.com/tdewolff/parse/v2 v2.6.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
...
...
This diff is collapsed.
Click to expand it.
application/source/go.sum
+
4
−
0
View file @
0bc0afb0
...
@@ -29,6 +29,10 @@ github.com/gookit/color v1.5.1 h1:Vjg2VEcdHpwq+oY63s/ksHrgJYCTo0bwWvmmYWdE9fQ=
...
@@ -29,6 +29,10 @@ github.com/gookit/color v1.5.1 h1:Vjg2VEcdHpwq+oY63s/ksHrgJYCTo0bwWvmmYWdE9fQ=
github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM=
github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM=
github.com/gookit/color v1.5.2 h1:uLnfXcaFjlrDnQDT+NCBcfhrXqYTx/rcCa6xn01Y8yI=
github.com/gookit/color v1.5.2 h1:uLnfXcaFjlrDnQDT+NCBcfhrXqYTx/rcCa6xn01Y8yI=
github.com/gookit/color v1.5.2/go.mod h1:w8h4bGiHeeBpvQVePTutdbERIUf3oJE5lZ8HM0UgXyg=
github.com/gookit/color v1.5.2/go.mod h1:w8h4bGiHeeBpvQVePTutdbERIUf3oJE5lZ8HM0UgXyg=
github.com/gosimple/slug v1.13.1 h1:bQ+kpX9Qa6tHRaK+fZR0A0M2Kd7Pa5eHPPsb1JpHD+Q=
github.com/gosimple/slug v1.13.1/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=
github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment