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

Djot line breaks don't split slides like markdown line breaks #9680

Open
calebeby opened this issue Apr 21, 2024 · 5 comments
Open

Djot line breaks don't split slides like markdown line breaks #9680

calebeby opened this issue Apr 21, 2024 · 5 comments
Labels

Comments

@calebeby
Copy link

I couldn't decide if this fits better in the "bug report" or "feature request" category, it depends on the intended behavior.

Explain the problem.

When I use the following code as markdown (gfm) or as djot:

asdf

---

asdf2

And convert it with

pandoc -f djot test.djot -o test.pptx

and

pandoc -f gfm test.md -o test.pptx

(or to any of the presentation formats)

Pandoc turns the markdown version into separate slides, but the djot version is turned into a single slide. Initially I was using headings and I expected the issue to be related to the fact that the thematic break is injected into the sections that are created from the headings, but then I changed the headings to paragraphs and the issue persists.

Is it intended to be able to use top-level thematic breaks as "slide splitters" for djot, similar to markdown, or is that use case not supported?

Pandoc version? 3.1.13, Linux

@calebeby calebeby added the bug label Apr 21, 2024
@jgm
Copy link
Owner

jgm commented Apr 21, 2024

Hm. When I tried this I got two slides...

@jgm
Copy link
Owner

jgm commented Apr 21, 2024

You're right that the section-ification built into the djot reader will defeat the use of horizontal rules to split slides. That's something we should think about. But the case with no headings (as above) should still split perfectly well.

@calebeby
Copy link
Author

calebeby commented Apr 22, 2024

Hm. When I tried this I got two slides...

Huh. I did it again and it worked. Not sure what I did wrong the first time 🤦

But yeah let's make this issue about the headings then.

My initial thought was that it would make sense to have the thematic break split heading sections in general. But after reading the description of thematic breaks in HTML that specifically mentions that <hr /> is to define splits between paragraph-level elements (the HTML standard says this as well), so that would suggest that it should not split the heading section.

Maybe --- is not the best way to split slides. When I try to think of other things in the djot syntax that might work well, the first thing that comes to mind is using :::.

Ex:

::: slide
# This is the first slide
:::

::: slide
# This is the second slide
:::

It is definitely a little more clunky. What are your thoughts?

Alternatively, there could be a special-case in pandoc's djot reader to adjust how --- is interpreted at the top level (and break up the sections) for slide output formats (assuming that the readers are aware of the output format). But that feels clunky from a code perspective as well.

@jgm
Copy link
Owner

jgm commented Apr 22, 2024

I don't think that --- should generally break up sections. But it might be given a special-purpose role for breaking up slides, as it is in pandoc.

The only ways forward I see are:

  1. remove the auto-sectionification from djot
  2. make pandoc's slide splitting code more complex so that it can split a section in two if it contains a thematic break

To be sure, using explicit divs would be another option, but it makes the slides clunkier to write.

@calebeby
Copy link
Author

I would lean towards (2) since the auto-sectionification is a nice feature.

# Hello

---

## Hello2

---

### Hello3

Currently has this AST:

doc
  section
    heading level=1
      str text="Hello"
    thematic_break
    section
      heading level=2
        str text="Hello2"
      thematic_break
      section
        heading level=3
          str text="Hello3"

In this case we'd want pandoc to see that as:

doc
  section
    heading level=1
      str text="Hello"
  thematic_break
  section
    heading level=2
      str text="Hello2"
  thematic_break
  section
    heading level=3
      str text="Hello3"

Because of cases like this, I don't think that a section with a --- in it should be split into two sections:

# Hello

---

???

## Hello2

I think it should become:

doc
  section
    heading level=1
      str text="Hello"
  thematic_break
  para
    str text="???"
  section
    heading level=2
      str text="Hello2"

I think the rule could be "Search every section for its first thematic break that is a direct child. If it has one, the children before the thematic break should remain inside the section, and the thematic break and all later children should be moved outside of (after) the section".

I think this rule should work because (it looks like) sections only appear for headings that are children of other sections or children of the root, so sections are already not created for things like headings inside of blockquotes or divs.

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

2 participants