mirror of
https://github.com/kovetskiy/mark.git
synced 2025-06-02 03:32:42 +08:00
Adding linebreak stripping
This commit is contained in:
parent
11896e43ec
commit
20c65ca373
@ -750,6 +750,7 @@ GLOBAL OPTIONS:
|
|||||||
--dry-run resolve page and ancestry, show resulting HTML and exit. (default: false) [$MARK_DRY_RUN]
|
--dry-run resolve page and ancestry, show resulting HTML and exit. (default: false) [$MARK_DRY_RUN]
|
||||||
--edit-lock, -k lock page editing to current user only to prevent accidental manual edits over Confluence Web UI. (default: false) [$MARK_EDIT_LOCK]
|
--edit-lock, -k lock page editing to current user only to prevent accidental manual edits over Confluence Web UI. (default: false) [$MARK_EDIT_LOCK]
|
||||||
--drop-h1, --h1_drop don't include the first H1 heading in Confluence output. (default: false) [$MARK_H1_DROP]
|
--drop-h1, --h1_drop don't include the first H1 heading in Confluence output. (default: false) [$MARK_H1_DROP]
|
||||||
|
--strip-linebreak remove linebreaks inside of tags, to accomodate Confluence non-standard behavior (default: false)
|
||||||
--title-from-h1, --h1_title extract page title from a leading H1 heading. If no H1 heading on a page exists, then title must be set in the page metadata. (default: false) [$MARK_H1_TITLE]
|
--title-from-h1, --h1_title extract page title from a leading H1 heading. If no H1 heading on a page exists, then title must be set in the page metadata. (default: false) [$MARK_H1_TITLE]
|
||||||
--minor-edit don't send notifications while updating Confluence page. (default: false) [$MARK_MINOR_EDIT]
|
--minor-edit don't send notifications while updating Confluence page. (default: false) [$MARK_MINOR_EDIT]
|
||||||
--color value display logs in color. Possible values: auto, never. (default: "auto") [$MARK_COLOR]
|
--color value display logs in color. Possible values: auto, never. (default: "auto") [$MARK_COLOR]
|
||||||
|
@ -23,7 +23,7 @@ services:
|
|||||||
# Linux 32-bit
|
# Linux 32-bit
|
||||||
# - GOOS=linux
|
# - GOOS=linux
|
||||||
# - GOARCH=386
|
# - GOARCH=386
|
||||||
|
|
||||||
# Windows 64-bit
|
# Windows 64-bit
|
||||||
# - GOOS=windows
|
# - GOOS=windows
|
||||||
# - GOARCH=amd64
|
# - GOARCH=amd64
|
||||||
|
11
main.go
11
main.go
@ -63,6 +63,13 @@ var flags = []cli.Flag{
|
|||||||
Usage: "don't include the first H1 heading in Confluence output.",
|
Usage: "don't include the first H1 heading in Confluence output.",
|
||||||
EnvVars: []string{"MARK_H1_DROP"},
|
EnvVars: []string{"MARK_H1_DROP"},
|
||||||
}),
|
}),
|
||||||
|
altsrc.NewBoolFlag(&cli.BoolFlag{
|
||||||
|
Name: "strip-linebreaks",
|
||||||
|
Value: false,
|
||||||
|
Aliases: []string{"L"},
|
||||||
|
Usage: "remove linebreaks inside of tags, to accomodate non-standard Confluence behavior",
|
||||||
|
EnvVars: []string{"MARK_STRIP_LINEBREAK"},
|
||||||
|
}),
|
||||||
altsrc.NewBoolFlag(&cli.BoolFlag{
|
altsrc.NewBoolFlag(&cli.BoolFlag{
|
||||||
Name: "title-from-h1",
|
Name: "title-from-h1",
|
||||||
Value: false,
|
Value: false,
|
||||||
@ -383,7 +390,7 @@ func processFile(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
html, _ := mark.CompileMarkdown(markdown, stdlib, file, cCtx.String("mermaid-provider"), cCtx.Float64("mermaid-scale"), cCtx.Bool("drop-h1"))
|
html, _ := mark.CompileMarkdown(markdown, stdlib, file, cCtx.String("mermaid-provider"), cCtx.Float64("mermaid-scale"), cCtx.Bool("drop-h1"), cCtx.Bool("strip-linebreaks"))
|
||||||
fmt.Println(html)
|
fmt.Println(html)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
@ -459,7 +466,7 @@ func processFile(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
html, inlineAttachments := mark.CompileMarkdown(markdown, stdlib, file, cCtx.String("mermaid-provider"), cCtx.Float64("mermaid-scale"), cCtx.Bool("drop-h1"))
|
html, inlineAttachments := mark.CompileMarkdown(markdown, stdlib, file, cCtx.String("mermaid-provider"), cCtx.Float64("mermaid-scale"), cCtx.Bool("drop-h1"), cCtx.Bool("strip-linebreaks"))
|
||||||
|
|
||||||
// Resolve attachements detected from markdown
|
// Resolve attachements detected from markdown
|
||||||
_, err = attachment.ResolveAttachments(
|
_, err = attachment.ResolveAttachments(
|
||||||
|
@ -26,11 +26,12 @@ type ConfluenceExtension struct {
|
|||||||
MermaidProvider string
|
MermaidProvider string
|
||||||
MermaidScale float64
|
MermaidScale float64
|
||||||
DropFirstH1 bool
|
DropFirstH1 bool
|
||||||
|
StripNewlines bool
|
||||||
Attachments []attachment.Attachment
|
Attachments []attachment.Attachment
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfluenceRenderer creates a new instance of the ConfluenceRenderer
|
// NewConfluenceRenderer creates a new instance of the ConfluenceRenderer
|
||||||
func NewConfluenceExtension(stdlib *stdlib.Lib, path string, mermaidProvider string, mermaidScale float64, dropFirstH1 bool) *ConfluenceExtension {
|
func NewConfluenceExtension(stdlib *stdlib.Lib, path string, mermaidProvider string, mermaidScale float64, dropFirstH1 bool, stripNewlines bool) *ConfluenceExtension {
|
||||||
return &ConfluenceExtension{
|
return &ConfluenceExtension{
|
||||||
Config: html.NewConfig(),
|
Config: html.NewConfig(),
|
||||||
Stdlib: stdlib,
|
Stdlib: stdlib,
|
||||||
@ -38,6 +39,7 @@ func NewConfluenceExtension(stdlib *stdlib.Lib, path string, mermaidProvider str
|
|||||||
MermaidProvider: mermaidProvider,
|
MermaidProvider: mermaidProvider,
|
||||||
MermaidScale: mermaidScale,
|
MermaidScale: mermaidScale,
|
||||||
DropFirstH1: dropFirstH1,
|
DropFirstH1: dropFirstH1,
|
||||||
|
StripNewlines: stripNewlines,
|
||||||
Attachments: []attachment.Attachment{},
|
Attachments: []attachment.Attachment{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,6 +47,7 @@ func NewConfluenceExtension(stdlib *stdlib.Lib, path string, mermaidProvider str
|
|||||||
func (c *ConfluenceExtension) Extend(m goldmark.Markdown) {
|
func (c *ConfluenceExtension) Extend(m goldmark.Markdown) {
|
||||||
|
|
||||||
m.Renderer().AddOptions(renderer.WithNodeRenderers(
|
m.Renderer().AddOptions(renderer.WithNodeRenderers(
|
||||||
|
util.Prioritized(crenderer.NewConfluenceTextRenderer(c.StripNewlines), 100),
|
||||||
util.Prioritized(crenderer.NewConfluenceBlockQuoteRenderer(), 100),
|
util.Prioritized(crenderer.NewConfluenceBlockQuoteRenderer(), 100),
|
||||||
util.Prioritized(crenderer.NewConfluenceCodeBlockRenderer(c.Stdlib, c.Path), 100),
|
util.Prioritized(crenderer.NewConfluenceCodeBlockRenderer(c.Stdlib, c.Path), 100),
|
||||||
util.Prioritized(crenderer.NewConfluenceFencedCodeBlockRenderer(c.Stdlib, &c.Attachments, c.MermaidProvider, c.MermaidScale), 100),
|
util.Prioritized(crenderer.NewConfluenceFencedCodeBlockRenderer(c.Stdlib, &c.Attachments, c.MermaidProvider, c.MermaidScale), 100),
|
||||||
@ -61,10 +64,10 @@ func (c *ConfluenceExtension) Extend(m goldmark.Markdown) {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
func CompileMarkdown(markdown []byte, stdlib *stdlib.Lib, path string, mermaidProvider string, mermaidScale float64, dropFirstH1 bool) (string, []attachment.Attachment) {
|
func CompileMarkdown(markdown []byte, stdlib *stdlib.Lib, path string, mermaidProvider string, mermaidScale float64, dropFirstH1 bool, stripNewlines bool) (string, []attachment.Attachment) {
|
||||||
log.Tracef(nil, "rendering markdown:\n%s", string(markdown))
|
log.Tracef(nil, "rendering markdown:\n%s", string(markdown))
|
||||||
|
|
||||||
confluenceExtension := NewConfluenceExtension(stdlib, path, mermaidProvider, mermaidScale, dropFirstH1)
|
confluenceExtension := NewConfluenceExtension(stdlib, path, mermaidProvider, mermaidScale, dropFirstH1, stripNewlines)
|
||||||
|
|
||||||
converter := goldmark.New(
|
converter := goldmark.New(
|
||||||
goldmark.WithExtensions(
|
goldmark.WithExtensions(
|
||||||
|
@ -10,6 +10,24 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func loadData(t *testing.T, filename, variant string) ([]byte, string, []byte) {
|
||||||
|
t.Helper()
|
||||||
|
basename := filepath.Base(filename)
|
||||||
|
testname := strings.TrimSuffix(basename, ".md")
|
||||||
|
htmlname := filepath.Join(filepath.Dir(filename), testname+variant+".html")
|
||||||
|
|
||||||
|
markdown, err := os.ReadFile(filename)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
html, err := os.ReadFile(htmlname)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return markdown, htmlname, html
|
||||||
|
}
|
||||||
|
|
||||||
func TestCompileMarkdown(t *testing.T) {
|
func TestCompileMarkdown(t *testing.T) {
|
||||||
test := assert.New(t)
|
test := assert.New(t)
|
||||||
|
|
||||||
@ -19,24 +37,50 @@ func TestCompileMarkdown(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, filename := range testcases {
|
for _, filename := range testcases {
|
||||||
basename := filepath.Base(filename)
|
|
||||||
testname := strings.TrimSuffix(basename, ".md")
|
|
||||||
htmlname := filepath.Join(filepath.Dir(filename), testname+".html")
|
|
||||||
|
|
||||||
markdown, err := os.ReadFile(filename)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
html, err := os.ReadFile(htmlname)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
lib, err := stdlib.New(nil)
|
lib, err := stdlib.New(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
actual, _ := CompileMarkdown(markdown, lib, filename, "", 1.0, false)
|
markdown, htmlname, html := loadData(t, filename, "")
|
||||||
|
actual, _ := CompileMarkdown(markdown, lib, filename, "", 1.0, false, false)
|
||||||
|
test.EqualValues(string(html), actual, filename+" vs "+htmlname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompileMarkdownDropH1(t *testing.T) {
|
||||||
|
test := assert.New(t)
|
||||||
|
|
||||||
|
testcases, err := filepath.Glob("testdata/*.md")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, filename := range testcases {
|
||||||
|
lib, err := stdlib.New(nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
markdown, htmlname, html := loadData(t, filename, "-droph1")
|
||||||
|
actual, _ := CompileMarkdown(markdown, lib, filename, "", 1.0, true, false)
|
||||||
|
test.EqualValues(string(html), actual, filename+" vs "+htmlname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCompileMarkdownStripNewlines(t *testing.T) {
|
||||||
|
test := assert.New(t)
|
||||||
|
|
||||||
|
testcases, err := filepath.Glob("testdata/*.md")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, filename := range testcases {
|
||||||
|
lib, err := stdlib.New(nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
markdown, htmlname, html := loadData(t, filename, "-stripnewlines")
|
||||||
|
actual, _ := CompileMarkdown(markdown, lib, filename, "", 1.0, false, true)
|
||||||
test.EqualValues(string(html), actual, filename+" vs "+htmlname)
|
test.EqualValues(string(html), actual, filename+" vs "+htmlname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
71
pkg/mark/renderer/text.go
Normal file
71
pkg/mark/renderer/text.go
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package renderer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
|
//"github.com/kovetskiy/mark/pkg/mark/stdlib"
|
||||||
|
"github.com/yuin/goldmark/ast"
|
||||||
|
"github.com/yuin/goldmark/renderer"
|
||||||
|
"github.com/yuin/goldmark/renderer/html"
|
||||||
|
"github.com/yuin/goldmark/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConfluenceTextRenderer struct {
|
||||||
|
html.Config
|
||||||
|
softBreak rune
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewConfluenceRenderer creates a new instance of the ConfluenceRenderer
|
||||||
|
func NewConfluenceTextRenderer(stripNL bool, opts ...html.Option) renderer.NodeRenderer {
|
||||||
|
sb := '\n'
|
||||||
|
if stripNL {
|
||||||
|
sb = ' '
|
||||||
|
}
|
||||||
|
return &ConfluenceTextRenderer{
|
||||||
|
Config: html.NewConfig(),
|
||||||
|
softBreak: sb,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterFuncs implements NodeRenderer.RegisterFuncs .
|
||||||
|
func (r *ConfluenceTextRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
|
||||||
|
reg.Register(ast.KindText, r.renderText)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *ConfluenceTextRenderer) renderText(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
|
||||||
|
if !entering {
|
||||||
|
return ast.WalkContinue, nil
|
||||||
|
}
|
||||||
|
n := node.(*ast.Text)
|
||||||
|
segment := n.Segment
|
||||||
|
if n.IsRaw() {
|
||||||
|
r.Writer.RawWrite(w, segment.Value(source))
|
||||||
|
} else {
|
||||||
|
value := segment.Value(source)
|
||||||
|
r.Writer.Write(w, value)
|
||||||
|
if n.HardLineBreak() || (n.SoftLineBreak() && r.HardWraps) {
|
||||||
|
if r.XHTML {
|
||||||
|
_, _ = w.WriteString("<br />\n")
|
||||||
|
} else {
|
||||||
|
_, _ = w.WriteString("<br>\n")
|
||||||
|
}
|
||||||
|
} else if n.SoftLineBreak() {
|
||||||
|
if r.EastAsianLineBreaks && len(value) != 0 {
|
||||||
|
sibling := node.NextSibling()
|
||||||
|
if sibling != nil && sibling.Kind() == ast.KindText {
|
||||||
|
if siblingText := sibling.(*ast.Text).Text(source); len(siblingText) != 0 {
|
||||||
|
thisLastRune := util.ToRune(value, len(value)-1)
|
||||||
|
siblingFirstRune, _ := utf8.DecodeRune(siblingText)
|
||||||
|
if !(util.IsEastAsianWideRune(thisLastRune) &&
|
||||||
|
util.IsEastAsianWideRune(siblingFirstRune)) {
|
||||||
|
_ = w.WriteByte(byte(r.softBreak))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_ = w.WriteByte(byte(r.softBreak))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ast.WalkContinue, nil
|
||||||
|
}
|
20
pkg/mark/testdata/codes-droph1.html
vendored
Normal file
20
pkg/mark/testdata/codes-droph1.html
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<p><code>inline</code></p>
|
||||||
|
<ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[some code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code bash]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[with a newline
|
||||||
|
]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code]]></ac:plain-text-body></ac:structured-macro><p>text
|
||||||
|
text 2</p>
|
||||||
|
<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code 2]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">sh</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[no-collapse-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[collapse-and-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">c</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:plain-text-body><![CDATA[collapse-no-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">nested</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code
|
||||||
|
``` more code ```
|
||||||
|
even more code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[indented code block
|
||||||
|
with multiple lines]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="cloudscript-confluence-mermaid"><ac:parameter ac:name="showSource">true</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[graph TD;
|
||||||
|
A-->B;
|
||||||
|
A-->C;
|
||||||
|
B-->D;
|
||||||
|
C-->D;]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="cloudscript-confluence-mermaid"><ac:parameter ac:name="showSource">true</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:parameter ac:name="title">my mermaid graph</ac:parameter><ac:plain-text-body><![CDATA[graph TD;
|
||||||
|
A-->B;
|
||||||
|
A-->C;
|
||||||
|
B-->D;
|
||||||
|
C-->D;]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="cloudscript-confluence-mermaid"><ac:parameter ac:name="showSource">true</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:parameter ac:name="title">my mermaid graph</ac:parameter><ac:plain-text-body><![CDATA[graph TD;
|
||||||
|
A-->B;
|
||||||
|
A-->C;
|
||||||
|
B-->D;
|
||||||
|
C-->D;]]></ac:plain-text-body></ac:structured-macro>
|
19
pkg/mark/testdata/codes-stripnewlines.html
vendored
Normal file
19
pkg/mark/testdata/codes-stripnewlines.html
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<p><code>inline</code></p>
|
||||||
|
<ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[some code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code bash]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[with a newline
|
||||||
|
]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code]]></ac:plain-text-body></ac:structured-macro><p>text text 2</p>
|
||||||
|
<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknown</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[unknown code 2]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">sh</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[no-collapse-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:parameter ac:name="title">A b c</ac:parameter><ac:plain-text-body><![CDATA[collapse-and-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">c</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:plain-text-body><![CDATA[collapse-no-title]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language">nested</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[code
|
||||||
|
``` more code ```
|
||||||
|
even more code]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="code"><ac:parameter ac:name="language"></ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[indented code block
|
||||||
|
with multiple lines]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="cloudscript-confluence-mermaid"><ac:parameter ac:name="showSource">true</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:plain-text-body><![CDATA[graph TD;
|
||||||
|
A-->B;
|
||||||
|
A-->C;
|
||||||
|
B-->D;
|
||||||
|
C-->D;]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="cloudscript-confluence-mermaid"><ac:parameter ac:name="showSource">true</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:parameter ac:name="title">my mermaid graph</ac:parameter><ac:plain-text-body><![CDATA[graph TD;
|
||||||
|
A-->B;
|
||||||
|
A-->C;
|
||||||
|
B-->D;
|
||||||
|
C-->D;]]></ac:plain-text-body></ac:structured-macro><ac:structured-macro ac:name="cloudscript-confluence-mermaid"><ac:parameter ac:name="showSource">true</ac:parameter><ac:parameter ac:name="collapse">false</ac:parameter><ac:parameter ac:name="title">my mermaid graph</ac:parameter><ac:plain-text-body><![CDATA[graph TD;
|
||||||
|
A-->B;
|
||||||
|
A-->C;
|
||||||
|
B-->D;
|
||||||
|
C-->D;]]></ac:plain-text-body></ac:structured-macro>
|
6
pkg/mark/testdata/header-droph1.html
vendored
Normal file
6
pkg/mark/testdata/header-droph1.html
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<h2 id="b">b</h2>
|
||||||
|
<h3 id="c">c</h3>
|
||||||
|
<h4 id="d">d</h4>
|
||||||
|
<h5 id="e">e</h5>
|
||||||
|
<h1 id="f">f</h1>
|
||||||
|
<h2 id="g">g</h2>
|
7
pkg/mark/testdata/header-stripnewlines.html
vendored
Normal file
7
pkg/mark/testdata/header-stripnewlines.html
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<h1 id="a">a</h1>
|
||||||
|
<h2 id="b">b</h2>
|
||||||
|
<h3 id="c">c</h3>
|
||||||
|
<h4 id="d">d</h4>
|
||||||
|
<h5 id="e">e</h5>
|
||||||
|
<h1 id="f">f</h1>
|
||||||
|
<h2 id="g">g</h2>
|
1
pkg/mark/testdata/issue-64-broken-link-droph1.html
vendored
Normal file
1
pkg/mark/testdata/issue-64-broken-link-droph1.html
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p><a href="Page2#Page2-Releasev71-22-Feb-2018(intern)">v71</a></p>
|
1
pkg/mark/testdata/issue-64-broken-link-stripnewlines.html
vendored
Normal file
1
pkg/mark/testdata/issue-64-broken-link-stripnewlines.html
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p><a href="Page2#Page2-Releasev71-22-Feb-2018(intern)">v71</a></p>
|
17
pkg/mark/testdata/links-droph1.html
vendored
Normal file
17
pkg/mark/testdata/links-droph1.html
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<p>Use <a href="https://example.com">https://example.com</a></p>
|
||||||
|
<p>Use <ac:rich-text-body>aaa</ac:rich-text-body></p>
|
||||||
|
<p>Use <ac:link><ri:page ri:content-title="Page"/><ac:plain-text-link-body><![CDATA[page link]]></ac:plain-text-link-body></ac:link></p>
|
||||||
|
<p>Use <ac:link><ri:page ri:content-title="AnotherPage"/><ac:plain-text-link-body><![CDATA[AnotherPage]]></ac:plain-text-link-body></ac:link></p>
|
||||||
|
<p>Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link></p>
|
||||||
|
<p>Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link></p>
|
||||||
|
<p><ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image></p>
|
||||||
|
<p><ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&key2=value2"/></ac:image></p>
|
||||||
|
<p>Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
|
||||||
|
<div class="footnotes" role="doc-endnotes">
|
||||||
|
<hr />
|
||||||
|
<ol>
|
||||||
|
<li id="fn:1">
|
||||||
|
<p>a footnote link <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
17
pkg/mark/testdata/links-stripnewlines.html
vendored
Normal file
17
pkg/mark/testdata/links-stripnewlines.html
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<p>Use <a href="https://example.com">https://example.com</a></p>
|
||||||
|
<p>Use <ac:rich-text-body>aaa</ac:rich-text-body></p>
|
||||||
|
<p>Use <ac:link><ri:page ri:content-title="Page"/><ac:plain-text-link-body><![CDATA[page link]]></ac:plain-text-link-body></ac:link></p>
|
||||||
|
<p>Use <ac:link><ri:page ri:content-title="AnotherPage"/><ac:plain-text-link-body><![CDATA[AnotherPage]]></ac:plain-text-link-body></ac:link></p>
|
||||||
|
<p>Use <ac:link><ri:page ri:content-title="Another Page"/><ac:plain-text-link-body><![CDATA[Another Page]]></ac:plain-text-link-body></ac:link></p>
|
||||||
|
<p>Use <ac:link><ri:page ri:content-title="Page With Space"/><ac:plain-text-link-body><![CDATA[page link with spaces]]></ac:plain-text-link-body></ac:link></p>
|
||||||
|
<p><ac:image ac:alt="My Image"><ri:attachment ri:filename="test.png"/></ac:image></p>
|
||||||
|
<p><ac:image ac:alt="My External Image"><ri:url ri:value="http://confluence.atlassian.com/images/logo/confluence_48_trans.png?key1=value1&key2=value2"/></ac:image></p>
|
||||||
|
<p>Use footnotes link <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
|
||||||
|
<div class="footnotes" role="doc-endnotes">
|
||||||
|
<hr />
|
||||||
|
<ol>
|
||||||
|
<li id="fn:1">
|
||||||
|
<p>a footnote link <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
21
pkg/mark/testdata/lists-droph1.html
vendored
Normal file
21
pkg/mark/testdata/lists-droph1.html
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<ul>
|
||||||
|
<li>dash 1-1</li>
|
||||||
|
<li>dash 1-2</li>
|
||||||
|
<li>dash 1-3
|
||||||
|
<ul>
|
||||||
|
<li>dash 1-3-1</li>
|
||||||
|
<li>dash 1-3-2</li>
|
||||||
|
<li>dash 1-3-3
|
||||||
|
<ul>
|
||||||
|
<li>dash 1-3-3-1</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>text</p>
|
||||||
|
<ul>
|
||||||
|
<li>a</li>
|
||||||
|
<li>b</li>
|
||||||
|
<li>c</li>
|
||||||
|
</ul>
|
21
pkg/mark/testdata/lists-stripnewlines.html
vendored
Normal file
21
pkg/mark/testdata/lists-stripnewlines.html
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<ul>
|
||||||
|
<li>dash 1-1</li>
|
||||||
|
<li>dash 1-2</li>
|
||||||
|
<li>dash 1-3
|
||||||
|
<ul>
|
||||||
|
<li>dash 1-3-1</li>
|
||||||
|
<li>dash 1-3-2</li>
|
||||||
|
<li>dash 1-3-3
|
||||||
|
<ul>
|
||||||
|
<li>dash 1-3-3-1</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>text</p>
|
||||||
|
<ul>
|
||||||
|
<li>a</li>
|
||||||
|
<li>b</li>
|
||||||
|
<li>c</li>
|
||||||
|
</ul>
|
6
pkg/mark/testdata/macro-include-droph1.html
vendored
Normal file
6
pkg/mark/testdata/macro-include-droph1.html
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<p><foo>bar</foo></p>
|
||||||
|
<p><ac:structured-macro ac:name="info">
|
||||||
|
<ac:parameter ac:name="icon">true</ac:parameter>
|
||||||
|
<ac:parameter ac:name="title">Attention</ac:parameter>
|
||||||
|
<ac:rich-text-body>This is an info!</ac:rich-text-body>
|
||||||
|
</ac:structured-macro></p>
|
2
pkg/mark/testdata/macro-include-stripnewlines.html
vendored
Normal file
2
pkg/mark/testdata/macro-include-stripnewlines.html
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<p><foo>bar</foo></p>
|
||||||
|
<p><ac:structured-macro ac:name="info"> <ac:parameter ac:name="icon">true</ac:parameter> <ac:parameter ac:name="title">Attention</ac:parameter> <ac:rich-text-body>This is an info!</ac:rich-text-body> </ac:structured-macro></p>
|
10
pkg/mark/testdata/newlines-droph1.html
vendored
Normal file
10
pkg/mark/testdata/newlines-droph1.html
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<p>one-1
|
||||||
|
one-2</p>
|
||||||
|
<p>two-1</p>
|
||||||
|
<p>two-2</p>
|
||||||
|
<p>three-1</p>
|
||||||
|
<p>three-2</p>
|
||||||
|
<p>space-1
|
||||||
|
space-2</p>
|
||||||
|
<p>2space-1<br />
|
||||||
|
2space-2</p>
|
8
pkg/mark/testdata/newlines-stripnewlines.html
vendored
Normal file
8
pkg/mark/testdata/newlines-stripnewlines.html
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<p>one-1 one-2</p>
|
||||||
|
<p>two-1</p>
|
||||||
|
<p>two-2</p>
|
||||||
|
<p>three-1</p>
|
||||||
|
<p>three-2</p>
|
||||||
|
<p>space-1 space-2</p>
|
||||||
|
<p>2space-1<br />
|
||||||
|
2space-2</p>
|
18
pkg/mark/testdata/pagelayout-droph1.html
vendored
Normal file
18
pkg/mark/testdata/pagelayout-droph1.html
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<ac:layout>
|
||||||
|
<ac:layout-section type="three_with_sidebars">
|
||||||
|
<ac:layout-cell>
|
||||||
|
<p>More Content</p>
|
||||||
|
</ac:layout-cell>
|
||||||
|
<ac:layout-cell>
|
||||||
|
<p>More Content</p>
|
||||||
|
</ac:layout-cell>
|
||||||
|
<ac:layout-cell>
|
||||||
|
<p>Even More Content</p>
|
||||||
|
</ac:layout-cell>
|
||||||
|
</ac:layout-section>
|
||||||
|
<ac:layout-section type="single">
|
||||||
|
<ac:layout-cell>
|
||||||
|
<p>Still More Content</p>
|
||||||
|
</ac:layout-cell>
|
||||||
|
</ac:layout-section>
|
||||||
|
</ac:layout>
|
18
pkg/mark/testdata/pagelayout-stripnewlines.html
vendored
Normal file
18
pkg/mark/testdata/pagelayout-stripnewlines.html
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<ac:layout>
|
||||||
|
<ac:layout-section type="three_with_sidebars">
|
||||||
|
<ac:layout-cell>
|
||||||
|
<p>More Content</p>
|
||||||
|
</ac:layout-cell>
|
||||||
|
<ac:layout-cell>
|
||||||
|
<p>More Content</p>
|
||||||
|
</ac:layout-cell>
|
||||||
|
<ac:layout-cell>
|
||||||
|
<p>Even More Content</p>
|
||||||
|
</ac:layout-cell>
|
||||||
|
</ac:layout-section>
|
||||||
|
<ac:layout-section type="single">
|
||||||
|
<ac:layout-cell>
|
||||||
|
<p>Still More Content</p>
|
||||||
|
</ac:layout-cell>
|
||||||
|
</ac:layout-section>
|
||||||
|
</ac:layout>
|
34
pkg/mark/testdata/quotes-droph1.html
vendored
Normal file
34
pkg/mark/testdata/quotes-droph1.html
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<h2 id="first-heading">First Heading</h2>
|
||||||
|
<ac:structured-macro ac:name="note"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
|
||||||
|
<p><strong>NOTES:</strong></p>
|
||||||
|
<ol>
|
||||||
|
<li>Note number one</li>
|
||||||
|
<li>Note number two</li>
|
||||||
|
</ol>
|
||||||
|
<blockquote>
|
||||||
|
<p>a
|
||||||
|
b</p>
|
||||||
|
</blockquote>
|
||||||
|
<p><strong>Warn (Should not be picked as blockquote type)</strong></p>
|
||||||
|
</ac:rich-text-body></ac:structured-macro>
|
||||||
|
<h2 id="second-heading">Second Heading</h2>
|
||||||
|
<ac:structured-macro ac:name="warn"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
|
||||||
|
<p><strong>Warn</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li>Warn bullet 1</li>
|
||||||
|
<li>Warn bullet 2</li>
|
||||||
|
</ul>
|
||||||
|
</ac:rich-text-body></ac:structured-macro>
|
||||||
|
<ul>
|
||||||
|
<li>Regular list
|
||||||
|
that runs long</li>
|
||||||
|
</ul>
|
||||||
|
<h2 id="third-heading">Third Heading</h2>
|
||||||
|
<ac:structured-macro ac:name="info"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
|
||||||
|
<!-- Info -->
|
||||||
|
<p>Test</p>
|
||||||
|
</ac:rich-text-body></ac:structured-macro>
|
||||||
|
<h2 id="simple-blockquote">Simple Blockquote</h2>
|
||||||
|
<blockquote>
|
||||||
|
<p>This paragraph is a simple blockquote</p>
|
||||||
|
</blockquote>
|
33
pkg/mark/testdata/quotes-stripnewlines.html
vendored
Normal file
33
pkg/mark/testdata/quotes-stripnewlines.html
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<h1 id="main-heading">Main Heading</h1>
|
||||||
|
<h2 id="first-heading">First Heading</h2>
|
||||||
|
<ac:structured-macro ac:name="note"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
|
||||||
|
<p><strong>NOTES:</strong></p>
|
||||||
|
<ol>
|
||||||
|
<li>Note number one</li>
|
||||||
|
<li>Note number two</li>
|
||||||
|
</ol>
|
||||||
|
<blockquote>
|
||||||
|
<p>a b</p>
|
||||||
|
</blockquote>
|
||||||
|
<p><strong>Warn (Should not be picked as blockquote type)</strong></p>
|
||||||
|
</ac:rich-text-body></ac:structured-macro>
|
||||||
|
<h2 id="second-heading">Second Heading</h2>
|
||||||
|
<ac:structured-macro ac:name="warn"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
|
||||||
|
<p><strong>Warn</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li>Warn bullet 1</li>
|
||||||
|
<li>Warn bullet 2</li>
|
||||||
|
</ul>
|
||||||
|
</ac:rich-text-body></ac:structured-macro>
|
||||||
|
<ul>
|
||||||
|
<li>Regular list that runs long</li>
|
||||||
|
</ul>
|
||||||
|
<h2 id="third-heading">Third Heading</h2>
|
||||||
|
<ac:structured-macro ac:name="info"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
|
||||||
|
<!-- Info -->
|
||||||
|
<p>Test</p>
|
||||||
|
</ac:rich-text-body></ac:structured-macro>
|
||||||
|
<h2 id="simple-blockquote">Simple Blockquote</h2>
|
||||||
|
<blockquote>
|
||||||
|
<p>This paragraph is a simple blockquote</p>
|
||||||
|
</blockquote>
|
4
pkg/mark/testdata/quotes.html
vendored
4
pkg/mark/testdata/quotes.html
vendored
@ -20,6 +20,10 @@ b</p>
|
|||||||
<li>Warn bullet 2</li>
|
<li>Warn bullet 2</li>
|
||||||
</ul>
|
</ul>
|
||||||
</ac:rich-text-body></ac:structured-macro>
|
</ac:rich-text-body></ac:structured-macro>
|
||||||
|
<ul>
|
||||||
|
<li>Regular list
|
||||||
|
that runs long</li>
|
||||||
|
</ul>
|
||||||
<h2 id="third-heading">Third Heading</h2>
|
<h2 id="third-heading">Third Heading</h2>
|
||||||
<ac:structured-macro ac:name="info"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
|
<ac:structured-macro ac:name="info"><ac:parameter ac:name="icon">true</ac:parameter><ac:rich-text-body>
|
||||||
<!-- Info -->
|
<!-- Info -->
|
||||||
|
2
pkg/mark/testdata/quotes.md
vendored
2
pkg/mark/testdata/quotes.md
vendored
@ -19,6 +19,8 @@
|
|||||||
> * Warn bullet 1
|
> * Warn bullet 1
|
||||||
> * Warn bullet 2
|
> * Warn bullet 2
|
||||||
|
|
||||||
|
* Regular list
|
||||||
|
that runs long
|
||||||
|
|
||||||
## Third Heading
|
## Third Heading
|
||||||
> <!-- Info -->
|
> <!-- Info -->
|
||||||
|
14
pkg/mark/testdata/table-droph1.html
vendored
Normal file
14
pkg/mark/testdata/table-droph1.html
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>HEADER1</th>
|
||||||
|
<th>HEADER2</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>row1</td>
|
||||||
|
<td>row2</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
14
pkg/mark/testdata/table-stripnewlines.html
vendored
Normal file
14
pkg/mark/testdata/table-stripnewlines.html
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>HEADER1</th>
|
||||||
|
<th>HEADER2</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>row1</td>
|
||||||
|
<td>row2</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
6
pkg/mark/testdata/tags-droph1.html
vendored
Normal file
6
pkg/mark/testdata/tags-droph1.html
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<p><b>bold</b>
|
||||||
|
<strong>bold</strong></p>
|
||||||
|
<p><i>vitalik</i>
|
||||||
|
<em>vitalik</em></p>
|
||||||
|
<p><s>strikethrough</s>
|
||||||
|
<del>strikethrough</del></p>
|
3
pkg/mark/testdata/tags-stripnewlines.html
vendored
Normal file
3
pkg/mark/testdata/tags-stripnewlines.html
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<p><b>bold</b> <strong>bold</strong></p>
|
||||||
|
<p><i>vitalik</i> <em>vitalik</em></p>
|
||||||
|
<p><s>strikethrough</s> <del>strikethrough</del></p>
|
Loading…
x
Reference in New Issue
Block a user