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 for "spacing issue with list in definition list" is confused if the list item starts with a Div #10241

Closed
ptoboley opened this issue Sep 30, 2024 · 5 comments
Labels

Comments

@ptoboley
Copy link

The code for "LaTeX writer: fix spacing issue with list in definition list." (a26ec96) gets confused / does the wrong thing if the first item in the BulletList is a Div. There might be other cases where it has a similar issue.

Here's a test case (test.md):

**Here is a dictionary item**

:   <div>

    Here is some text.

    Here is a bullet list:

    -   Item 1.
    -   Item 2.

    Here is another bullet list:

    -   Item 3.
    -   Item 4.

    </div>

When rendering the bullet lists inside the Div inserts an extra \item[] at the start of the bullet list, causing extra blank lines to be output.

Tested as:

pandoc -o test.tex test.md

Output (text.tex):

\begin{description}
\item[\textbf{Here is a dictionary item}]
Here is some text.

Here is a bullet list:

\begin{itemize}
\tightlist
\item[]
\item
  Item 1.
\item
  Item 2.
\end{itemize}

Here is another bullet list:

\begin{itemize}
\tightlist
\item[]
\item
  Item 3.
\item
  Item 4.
\end{itemize}
\end{description}

I believe this is caused by the code treating the whole Div as isFirstInDefinition meaning every bullet list inside the Div gets treated in that way. Possibly isFirstInDefinition should be cleared as soon as anything is output inside the definition, although perhaps other nested items (particularly another definition inside the definition?) could cause that approach to fail?

Expected output (output if the Div is removed):

\begin{description}
\item[\textbf{Here is a dictionary item}]
Here is some text.

Here is a bullet list:

\begin{itemize}
\tightlist
\item
  Item 1.
\item
  Item 2.
\end{itemize}

Here is another bullet list:

\begin{itemize}
\tightlist
\item
  Item 3.
\item
  Item 4.
\end{itemize}
\end{description}

Wrapping the content in the Div is a peculiar behavior of our content generator. I can probably work around this by inserting some dummy item before the Div.

@ptoboley ptoboley added the bug label Sep 30, 2024
@jgm
Copy link
Owner

jgm commented Sep 30, 2024

What would be a better fix for the original issue? Adding an empty list item seems like an ugly way to do it, anyway.

@ptoboley
Copy link
Author

I don't know LaTeX well enough to suggest an alternative, sorry. I've not actually run into the original problem, only the fix.

Locally, I have set the following for description lists, which forces a break after each description anyway,

\setlist[description]{style=nextline}

However, I can't see making that a default would be acceptable (it would break a lot of documents here that don't use that setting, and create it in other ways, like inserting \hfill manually).

@jgm
Copy link
Owner

jgm commented Sep 30, 2024

Hm, maybe inserting \hfill would be a good alternative to adding the empty \item[]?

@bpj
Copy link

bpj commented Sep 30, 2024

Using\item[term]\hfill definition is the usual way to make the definition start on its own line without redefining \item.

@jgm jgm closed this as completed in b4df43b Sep 30, 2024
@jgm
Copy link
Owner

jgm commented Sep 30, 2024

I've used \hfill instead. But I think we may want to rethink this a bit.
Perhaps we should always use \hfill except when the body of the definition list is of the shape [Para _] or [Plain x].

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

No branches or pull requests

3 participants