Skip to content

Commit 34e9927

Browse files
committed
feat: add unformatted flag to be able to avoid md parser
I encountered errors with markdown parsing when one uses: 1. {*}text text{*} to format bold text 2. brackets inside brackets like so [[EKK] Link|example.com] I don't need fancy stuff, i just want to have info so I've added flag to bypass errors with parsing
1 parent adab79f commit 34e9927

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

internal/cmd/issue/view/view.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $ jira issue view ISSUE-1 --raw`
2727
flagDebug = "debug"
2828
flagComments = "comments"
2929
flagPlain = "plain"
30+
flagUnformatted = "unformatted"
3031

3132
configProject = "project.key"
3233
configServer = "server"
@@ -52,6 +53,7 @@ func NewCmdView() *cobra.Command {
5253
cmd.Flags().Uint(flagComments, 1, "Show N comments")
5354
cmd.Flags().Bool(flagPlain, false, "Display output in plain mode")
5455
cmd.Flags().Bool(flagRaw, false, "Print raw Jira API response")
56+
cmd.Flags().Bool(flagUnformatted, false, "Don't format into MD")
5557

5658
return &cmd
5759
}
@@ -109,12 +111,13 @@ func viewPretty(cmd *cobra.Command, args []string) {
109111
cmdutil.ExitIfError(err)
110112

111113
plain, err := cmd.Flags().GetBool(flagPlain)
114+
unformatted, err := cmd.Flags().GetBool(flagUnformatted)
112115
cmdutil.ExitIfError(err)
113116

114117
v := tuiView.Issue{
115118
Server: viper.GetString(configServer),
116119
Data: iss,
117-
Display: tuiView.DisplayFormat{Plain: plain},
120+
Display: tuiView.DisplayFormat{Plain: plain, Unformatted: unformatted},
118121
Options: tuiView.IssueOption{NumComments: comments},
119122
}
120123
cmdutil.ExitIfError(v.Render())

internal/view/issue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ func (i Issue) description() string {
249249

250250
if adfNode, ok := i.Data.Fields.Description.(*adf.ADF); ok {
251251
desc = adf.NewTranslator(adfNode, adf.NewMarkdownTranslator()).Translate()
252+
} else if i.Display.Unformatted {
253+
desc = i.Data.Fields.Description.(string)
252254
} else {
253255
desc = i.Data.Fields.Description.(string)
254256
desc = md.FromJiraMD(desc)
@@ -393,6 +395,8 @@ func (i Issue) comments() []issueComment {
393395
var body string
394396
if adfNode, ok := c.Body.(*adf.ADF); ok {
395397
body = adf.NewTranslator(adfNode, adf.NewMarkdownTranslator()).Translate()
398+
} else if i.Display.Unformatted {
399+
body = c.Body.(string)
396400
} else {
397401
body = c.Body.(string)
398402
body = md.FromJiraMD(body)

internal/view/issues.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type DisplayFormat struct {
2525
Comments uint
2626
TableStyle tui.TableStyle
2727
Timezone string
28+
Unformatted bool
2829
}
2930

3031
// IssueList is a list view for issues.

0 commit comments

Comments
 (0)