Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make multiple initial list levels work for docx #6522

Merged
merged 1 commit into from
Oct 2, 2020

Conversation

brisad
Copy link
Contributor

@brisad brisad commented Jul 10, 2020

Hi, is this an okay way to solve #5948 ?
I'm not sure how what the best way to test this would be. The existing docx tests seem to use golden copies, is that the way to go here too?

@lierdakil
Copy link
Contributor

The existing docx tests seem to use golden copies, is that the way to go here too?

Most certainly. How else would one check that the docx produced by pandoc matches the expected? Granted, not very flexible, but neither is docx.

The code looks fine (provided Word renders the document as expected), although I'd suggest using record syntax for matching OrderedList, i.e. use OrderedList{} instead of OrderedList _ _. That way even if the number of argument changes, the code will still work.

Also, why OrderedList specifically? Doesn't this also happen with BulletList? Pretty sure it does.

@brisad brisad force-pushed the initial-list-levels branch from bd0de3c to 4356b86 Compare August 16, 2020 19:08
@brisad brisad marked this pull request as ready for review August 16, 2020 19:22
@brisad
Copy link
Contributor Author

brisad commented Aug 16, 2020

Sorry for the long delay. I have updated the PR with your suggestions and added tests. The resulting docx-file rendered fine in Word.

@brisad
Copy link
Contributor Author

brisad commented Oct 1, 2020

I realized this PR has been lying here for a while now. It is ready for review, how would I best notify someone that it can be looked at? Should I assign someone myself? I'm pinging you here now, but I'm asking for future contributions I hope to make :-) @lierdakil @jgm

Copy link
Collaborator

@tarleb tarleb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

One could remove a tiny bit of repetition by defining

let isListBlock = \case
      BulletList {}  -> True
      OrderedList {} -> True
      _              -> False

and using an if ... then ... else ... term instead of a case. I think that's a little cleaner, but it's a matter of taste.

@jgm
Copy link
Owner

jgm commented Oct 1, 2020

@brisad - up to you whether you want to implement @tarleb's stylistic suggestion.
Let me know and I can merge.

@brisad
Copy link
Contributor Author

brisad commented Oct 1, 2020

@jgm I'll implement the suggestion. Thanks @tarleb!

If the first element of a bulleted or ordered list is another list,
then that first item will disappear if the target format is docx. This
changes the docx writer so that it prepends an empty string for those
cases. With this, no items will disappear.
@brisad brisad force-pushed the initial-list-levels branch from 4356b86 to 7ac7dce Compare October 1, 2020 20:38
@brisad
Copy link
Contributor Author

brisad commented Oct 1, 2020

I've updated the PR :)

@jgm jgm merged commit 74bd5a4 into jgm:master Oct 2, 2020
@jgm
Copy link
Owner

jgm commented Oct 2, 2020

Perfect, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants