yst icon indicating copy to clipboard operation
yst copied to clipboard

Last div not properly closed

Open claes opened this issue 14 years ago • 3 comments

I have found an issue where the last div is not properly closed in a markdown template defined using several headings.

I added this to the demo website index.yaml:

- url      : bug.html
  title    : Bug
  template : bug.html.st
  requires : bug.st

bug.html.st contains:

<!-- Begin -->
$bug()$
<!-- End -->

bug.st contains:

# Heading 1

Lorem ipsur

# Heading 2

Lorem ipsur

The resulting page contains the following html:

      <div id="maincol" class="yui-b">
<!-- Begin --><div id="heading-1"
><h1
  >Heading 1</h1
  ><p
  >Lorem ipsur</p
  ></div
><div id="heading-2"
><h1
  >Heading 2</h1
  >Lorem ipsur<!-- End -->
</div
>
      </div>

I would have expect the div with id heading-2 to be closed prior to the end comment. It seems in this case it is closed later but in other circumstances it causes a big problem with the end comment is replaced with actual markup .

claes avatar Oct 17 '10 10:10 claes

This is the expected behavior. The templates are all applied before pandoc is used to transform the markdown. So pandoc is seeing this:

<!-- begin -->

# Heading 1

Lorem ipsur

# Heading 2

Lorem ipsur

<!-- end -->

It has no way of knowing that the <!-- end --> is not supposed to be in the section. Maybe what you're expecting is for pandoc to be run individually for each template. That's not what happens, and in general, it's not what you want (think about footnotes, table of contents, etc.).

If you have a case where the div doesn't get closed at all, that would be a bug. But you haven't provided such a case, so I can't comment on that.

Also, please see http://code.google.com/p/pandoc/issues/detail?id=230. Have you compiled your yst against the latest version of pandoc?

jgm avatar Oct 17 '10 18:10 jgm

Yes I thought that pandoc was only run on markdown templates, and that a template with suffix ".html.st" would be left "unprocessed". But I see now also the effect of markdown syntax in this template. Perhaps I need to do this differently, I haven't used the "layout" field for example.

I installed yst using cabal this weekend as in the installation instructions. My pandoc version is 1.6.

claes avatar Oct 17 '10 19:10 claes

Regarding issue 230 above, I don't mind the pandoc behavior (the div-wrapping). I think it is pretty convenient in itself. I am just trying to figure out how to adjust my layouts to work with it. If it would not be the div issue, it would be something else. Now when I realize that my html template is parsed by pandoc I need to experiment more to learn how it works.

claes avatar Oct 17 '10 19:10 claes