Skip to content

Commit

Permalink
remove hard wraps
Browse files Browse the repository at this point in the history
  • Loading branch information
Skeeve committed Jul 22, 2020
1 parent 91a92cb commit 072de96
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ For best practice we recommend you [authenticate using an API token](https://id.
-s, --space string Space in which page should be created
-t, --title string Set the page title on upload (defaults to filename without extension)
-u, --username string Confluence username. (Alternatively set CONFLUENCE_USERNAME environment variable)
-w, --hardwraps Render newlines as <br />
--version version for markdown2confluence

## Examples
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&m.Endpoint, "endpoint", "e", lib.DefaultEndpoint, "Confluence endpoint. (Alternatively set CONFLUENCE_ENDPOINT environment variable)")
rootCmd.PersistentFlags().StringVar(&m.Parent, "parent", "", "Optional parent page to next content under")
rootCmd.PersistentFlags().BoolVarP(&m.Debug, "debug", "d", false, "Enable debug logging")
rootCmd.PersistentFlags().BoolVarP(&m.WithHardWraps, "hardwraps", "w", false, "Render newlines as <br />")
rootCmd.PersistentFlags().IntVarP(&m.Since, "modified-since", "m", 0, "Only upload files that have modifed in the past n minutes")
rootCmd.PersistentFlags().StringVarP(&m.Title, "title", "t", "", "Set the page title on upload (defaults to filename without extension)")

Expand Down
15 changes: 11 additions & 4 deletions lib/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Markdown2Confluence struct {
File string
Ancestor string
Debug bool
WithHardWraps bool
Since int
Username string
Password string
Expand Down Expand Up @@ -240,15 +241,21 @@ func validateInput(s string, msg string) {

func renderContent(filePath, s string) (content string, images []string, err error) {
confluenceExtension := e.NewConfluenceExtension(filePath)
ro := goldmark.WithRendererOptions(
html.WithXHTML(),
)
if m.WithHardWraps {
ro = goldmark.WithRendererOptions(
html.WithHardWraps(),
html.WithXHTML(),
)
}
md := goldmark.New(
goldmark.WithExtensions(extension.GFM, extension.DefinitionList),
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
),
goldmark.WithRendererOptions(
html.WithHardWraps(),
html.WithXHTML(),
),
ro,
goldmark.WithExtensions(
confluenceExtension,
),
Expand Down

0 comments on commit 072de96

Please sign in to comment.