Giter Club home page Giter Club logo

Comments (5)

somelinguist avatar somelinguist commented on July 20, 2024

It looks like maybe the frame attribute classes are getting removed from first level headings at line 219:

pandoc-ling/pandoc-ling.lua

Lines 210 to 222 in a9eae71

-- add temporary divs to first header level
-------------------------------------------
-- will be removed again once the chapters are counted
function addDivToHeader (head)
if head.tag == "Header"
and head.level == 1
and head.classes[1] ~= "unnumbered"
then
head.attr = {id = head.identifier, class = "restart"}
return pandoc.Div(head)
end
end

I don't know enough about Lua to suggest a fix, but I think any solution would probably need to take into account lines 230-238 as well:

pandoc-ling/pandoc-ling.lua

Lines 228 to 238 in a9eae71

function processDiv (div)
-- keep track of chapters (header == 1)
-- included in this loop by trick "addDivToHeader"
if div.content[1].tag == "Header" and div.content[1].classes[1] == "restart" then
chapter = chapter + 1
counterInChapter = 0
div.content[1].attr = {id = div.content[1].identifier, class = ""}
-- remove div
return div.content
end

from pandoc-ling.

somelinguist avatar somelinguist commented on July 20, 2024

The change in my fork seems to work? Again, I don't know much Lua, but the changes I made:

  1. Add a "restart" class to the header instead of overwriting existing ones
  2. Only remove the inserted "restart" class when it's done instead of existing classes.

The removal code is based on the example for minted here:

https://github.com/pandoc/lua-filters/blob/2aa98bfda556c7d4dfb8e30c20b318b6fd1f5091/minted/minted.lua#L237-L248

Running on the modified filter on my example maintains the beamer frame attributes, and I tried it with a few examples from the readme here that didn't seem to break anything. But, again, I don't know much about Lua. :)

from pandoc-ling.

somelinguist avatar somelinguist commented on July 20, 2024

I just realized I probably broke the intent of tracking the headers by accidental removing the check for "restart". :)

from pandoc-ling.

somelinguist avatar somelinguist commented on July 20, 2024

I did some further tests, and I guess I didn't actually seem to break it. But something doesn't seem quite right about skipping the check.

from pandoc-ling.

somelinguist avatar somelinguist commented on July 20, 2024

Ok. I figured out the reason it still worked was because only the first level headers were being converted to divs.

The second commit in my fork (somelinguist@4e4da4e) adds back the check and is probably more efficient than my first attempt. It just inserts the "restart" class at index 1 so that it's easy to check later and remove.

from pandoc-ling.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.