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 rendering of lists #122

Merged
merged 2 commits into from
Sep 16, 2024
Merged

Conversation

corhere
Copy link
Contributor

@corhere corhere commented Aug 7, 2024

The AST hierarchy for a list item is always List > Item > Paragraph. Emit newlines when visiting the Paragraph node instead of the Item and List so that Items with multiple Paragraphs and nested Lists correctly render with just the right number of line breaks.

Update the man page to show off the new feature.

Stop over-indenting lists which are not nested inside a list item.

Demo

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

Rendered terminal output

example(1)                  General Commands Manual                 example(1)

       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

                                                                    example(1)

Rendered output from master branch, for comparison

example(1)                  General Commands Manual                 example(1)

       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


                                                                    example(1)

@corhere corhere changed the title Support multi-paragraph definition lists Fix rendering of lists Aug 9, 2024
@@ -13,6 +13,18 @@ written purely in Go so as to reduce dependencies on 3rd party libs.

By default, the input is stdin and the output is stdout.

# OPTIONS
Copy link
Owner

Choose a reason for hiding this comment

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

I realize I should probably include the generated roff in the repo as well so we can see the changes.

@cpuguy83
Copy link
Owner

Needs rebase.

The AST hierarchy for a list item is always List > Item > Paragraph.
Emit newlines when visiting the Paragraph node instead of the Item and
List so that Items with multiple Paragraphs and nested Lists correctly
render with just the right number of line breaks.

Signed-off-by: Cory Snider <csnider@mirantis.com>
List items are already indented paragraphs. There is no need to also
increase the relative inset unless the list is nested inside another
list.

Signed-off-by: Cory Snider <csnider@mirantis.com>
@corhere corhere force-pushed the fix-multi-paragraph-lists branch from acef982 to 149c352 Compare September 12, 2024 21:05
@cpuguy83 cpuguy83 merged commit 54d2e5c into cpuguy83:master Sep 16, 2024
5 checks passed
@corhere corhere deleted the fix-multi-paragraph-lists branch September 16, 2024 18:48
mikelolasagasti added a commit to mikelolasagasti/cobra that referenced this pull request Oct 31, 2024
Since cpuguy83/go-md2man 2.0.5 no paraTag is written after "SEE ALSO".

In 2.0.4:

.SH SEE ALSO
.PP
\fBroot-bbb(1)\fP, \fBroot-ccc(1)\fP

In 2.0.5:

.SH SEE ALSO
\fBroot-bbb(1)\fP, \fBroot-ccc(1)\fP

See: cpuguy83/go-md2man#122

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
mikelolasagasti added a commit to mikelolasagasti/cobra that referenced this pull request Oct 31, 2024
Since cpuguy83/go-md2man 2.0.5 no paraTag is written after "SEE ALSO".

With go-md2man 2.0.4:

.SH SEE ALSO
.PP
\fBroot-bbb(1)\fP, \fBroot-ccc(1)\fP

With go-md2man 2.0.5:

.SH SEE ALSO
\fBroot-bbb(1)\fP, \fBroot-ccc(1)\fP

See: cpuguy83/go-md2man#122

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
marckhouzam pushed a commit to spf13/cobra that referenced this pull request Dec 11, 2024
Since cpuguy83/go-md2man 2.0.5 no paraTag is written after "SEE ALSO".

With go-md2man 2.0.4:

.SH SEE ALSO
.PP
\fBroot-bbb(1)\fP, \fBroot-ccc(1)\fP

With go-md2man 2.0.5:

.SH SEE ALSO
\fBroot-bbb(1)\fP, \fBroot-ccc(1)\fP

See: cpuguy83/go-md2man#122

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
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