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

Improve rendering of nested lists #30

Merged
merged 1 commit into from
Dec 23, 2017
Merged

Conversation

msimacek
Copy link
Contributor

@msimacek msimacek commented Nov 1, 2017

Adds additional indentation to support nesting of lists. Uses a stack to
keep track of numbering for ordered lists.

Fixes #18

Copy link
Owner

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

Thanks, can you provide a sample output? A test would be nice, but I know this project is severely lacking in that area.

md2man/roff.go Outdated
@@ -11,7 +11,7 @@ import (

type roffRenderer struct{}

var listCounter int
Copy link
Owner

Choose a reason for hiding this comment

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

oh wow, I can't believe this global is even here... should be moved to the renderer object

Adds additional indentation to support nesting of lists. Uses a stack to
keep track of numbering for ordered lists.

Fixes cpuguy83#18
@msimacek
Copy link
Contributor Author

msimacek commented Nov 9, 2017

Sample input (excerpt from docker-cp manpage):

Assuming a path separator of `/`, a first argument of `SRC_PATH` and second
argument of `DEST_PATH`, the behavior is as follows:

- `SRC_PATH` specifies a file
    - `DEST_PATH` does not exist
        - the file is saved to a file created at `DEST_PATH`
    - `DEST_PATH` does not exist and ends with `/`
        - Error condition: the destination directory must exist.
    - `DEST_PATH` exists and is a file
        - the destination is overwritten with the source file's contents
    - `DEST_PATH` exists and is a directory
        - the file is copied into this directory using the basename from
          `SRC_PATH`
- `SRC_PATH` specifies a directory
    - `DEST_PATH` does not exist
        - `DEST_PATH` is created as a directory and the *contents* of the source
           directory are copied into this directory

Output:

.PP
Assuming a path separator of \fB\fC/\fR, a first argument of \fB\fCSRC\_PATH\fR and second
argument of \fB\fCDEST\_PATH\fR, the behavior is as follows:

.RS
.IP \(bu 2
\fB\fCSRC\_PATH\fR specifies a file

.RS
.IP \(bu 2
\fB\fCDEST\_PATH\fR does not exist

.RS
.IP \(bu 2
the file is saved to a file created at \fB\fCDEST\_PATH\fR

.RE
.IP \(bu 2
\fB\fCDEST\_PATH\fR does not exist and ends with \fB\fC/\fR

.RS
.IP \(bu 2
Error condition: the destination directory must exist.

.RE
.IP \(bu 2
\fB\fCDEST\_PATH\fR exists and is a file

.RS
.IP \(bu 2
the destination is overwritten with the source file's contents

.RE
.IP \(bu 2
\fB\fCDEST\_PATH\fR exists and is a directory

.RS
.IP \(bu 2
the file is copied into this directory using the basename from
\fB\fCSRC\_PATH\fR

.RE

.RE
.IP \(bu 2
\fB\fCSRC\_PATH\fR specifies a directory

.RS
.IP \(bu 2
\fB\fCDEST\_PATH\fR does not exist

.RS
.IP \(bu 2
\fB\fCDEST\_PATH\fR is created as a directory and the \fIcontents\fP of the source
directory are copied into this directory

Output rendered:

       Assuming a path separator of /, a first argument of SRC_PATH and second
       argument of DEST_PATH, the behavior is as follows:

              · SRC_PATH specifies a file

                · DEST_PATH does not exist

                  · the file is saved to a file created at DEST_PATH

                · DEST_PATH does not exist and ends with /

                  · Error condition: the destination directory must exist.

                · DEST_PATH exists and is a file

                  · the destination is overwritten with the source file's contents

                · DEST_PATH exists and is a directory

                  · the file is copied into this directory using the basename from
                    SRC_PATH

              · SRC_PATH specifies a directory

                · DEST_PATH does not exist

                  · DEST_PATH is created as a directory and the contents of the
                    source directory are copied into this directory

Ouput without this PR for comparison:

       Assuming a path separator of /, a first argument of SRC_PATH and second
       argument of DEST_PATH, the behavior is as follows:

       · SRC_PATH specifies a file

       · DEST_PATH does not exist

       · the file is saved to a file created at DEST_PATH

       · DEST_PATH does not exist and ends with /

       · Error condition: the destination directory must exist.

       · DEST_PATH exists and is a file

       · the destination is overwritten with the source file's contents

       · DEST_PATH exists and is a directory

       · the file is copied into this directory using the basename from SRC_PATH

       · SRC_PATH specifies a directory

       · DEST_PATH does not exist

       · DEST_PATH is created as a directory and the contents of the source directory
         are copied into this directory

Copy link
Owner

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

thanks!

@cpuguy83 cpuguy83 merged commit 8d868be into cpuguy83:master Dec 23, 2017
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.

None yet

2 participants