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

Fix list indents #116

Closed
wants to merge 1 commit into from
Closed

Conversation

baltitenger
Copy link

Indent all lists a uniform amount, and also support items with multiple paragraphs.

Fixes #107

@cpuguy83
Copy link
Owner

Can you add a test case along with a before/after example?

@cpuguy83
Copy link
Owner

This is also failing the existing test cases:

?   	github.com/cpuguy83/go-md2man/v2	[no test files]
--- FAIL: TestListLists (0.16s)
    --- FAIL: TestListLists/__**[grpc]**_:_Section_for_gRPC_socket_listener_settings._Contains_three_properties:__-_**address**_(Default:_"/run/containerd/containerd.sock")__-_**uid**_(Default:_0)__-_**gid**_(Default:_0) (0.15s)
        roff_test.go:455:
            Input   ["\n\n**[grpc]**\n: Section for gRPC socket listener settings. Contains three properties:\n - **address** (Default: \"/run/containerd/containerd.sock\")\n - **uid** (Default: 0)\n - **gid** (Default: 0)"]
            Expected[".nh\n\n.TP\n\\fB[grpc]\\fP\nSection for gRPC socket listener settings. Contains three properties:\n.RS\n.IP \\(bu 2\n\\fBaddress\\fP (Default: \"/run/containerd/containerd.sock\")\n.IP \\(bu 2\n\\fBuid\\fP (Default: 0)\n.IP \\(bu 2\n\\fBgid\\fP (Default: 0)\n\n.RE\n\n"]
            Actual  [".nh\n\n.TP 5\n\\fB[grpc]\\fP\nSection for gRPC socket listener settings. Contains three properties:\n.RS 5\n.IP \"   \\(bu\" 5\n\\fBaddress\\fP (Default: \"/run/containerd/containerd.sock\")\n.RS 5\n\n.RE\n.IP \"   \\(bu\" 5\n\\fBuid\\fP (Default: 0)\n.RS 5\n\n.RE\n.IP \"   \\(bu\" 5\n\\fBgid\\fP (Default: 0)\n.RS 5\n\n.RE\n\n.RE\n"]
    --- FAIL: TestListLists/Definition_title_:_Definition_description_one_:_And_two_:_And_three_ (0.02s)
        roff_test.go:455:
            Input   ["Definition title\n: Definition description one\n: And two\n: And three\n"]
            Expected[".nh\n\n.TP\nDefinition title\nDefinition description one\n\nAnd two\n\nAnd three\n"]
            Actual  [".nh\n\n.TP 5\nDefinition title\nDefinition description one\n.RS 5\n\n.PP\nAnd two\n\n.PP\nAnd three\n\n.RE\n"]
FAIL
FAIL	github.com/cpuguy83/go-md2man/v2/md2man	7.782s
FAIL

@baltitenger
Copy link
Author

Sorry, I didn't notice you had tests.

Note that this pr slightly changes the rendering of all list types (unordered, ordered, definition), so while I can update the test cases, you should check if you're happy with the new rendering. Basically, now all of these use an indent of 5.

From this input:

test
====

text

**Term**
:   Def Autem repellendus recusandae sint deserunt non. Quas maxime delectus
    suscipit quis facere doloribus. Rerum omnis provident unde non sapiente
    magni.

**Long term**
:   Long definition

    Multiple paragraphs

    - including
    - lists
:   Second definition

more text

1. ordered lists

    Also multiple paragraphs
2. second item
    - with
    - nested

        Unordered second paragraph
    - item

    Another here
3. third

Current master generates:

test()                                                                   test()

       text

       Term   Def  Autem  repellendus recusandae sint deserunt non. Quas maxime
              delectus suscipit quis facere doloribus.  Rerum  omnis  provident
              unde non sapiente magni.

       Long term
              Long definitionMultiple paragraphs

              • including

              • lists

       Second definition

       more text

                1. ordered listsAlso multiple paragraphs

                2. second item

                   • with

                   • nestedUnordered second paragraph

                   • item

              Another here

                3. third

                                                                         test()

This PR:

test()                                                                   test()

       text

       Term Def  Autem  repellendus  recusandae  sint deserunt non. Quas maxime
            delectus suscipit quis facere doloribus. Rerum omnis provident unde
            non sapiente magni.

       Long term
            Long definition

            Multiple paragraphs

               • including

               • lists

            Second definition

       more text

         1. ordered lists

            Also multiple paragraphs

         2. second item

               • with

               • nested

                 Unordered second paragraph

               • item

            Another here

         3. third

                                                                         test()

If this is ok, I'll just update the tests to match current rendering.

@baltitenger
Copy link
Author

Hmm, were there no tests for regular lists before?

@cpuguy83
Copy link
Owner

It's possible there weren't tests specifically for it.

Indent all lists a uniform amount, and also support items with multiple
paragraphs.
@baltitenger
Copy link
Author

Oops, didn't know it had to be formatted. Updated the PR.

@corhere corhere mentioned this pull request Aug 7, 2024
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.

Too many spaces in front of a list
2 participants