Git Product home page Git Product logo

Comments (8)

jgm avatar jgm commented on August 24, 2024 1

In a Lua filter you can return {} and it will just omit the element.

from pandoc-types.

jgm avatar jgm commented on August 24, 2024

I decided to wait on this until it can be packaged with other breaking API changes. Otherwise this causes too much disruption for what it gains us.

from pandoc-types.

nichtich avatar nichtich commented on August 24, 2024

Null is useful in filters that remove block elements by replacing them with a Null element. Pandoc should not throw an error when a Null element is found in JSON input, but silently ignore it.

from pandoc-types.

jgm avatar jgm commented on August 24, 2024

@nichtich I guess there are two potentially separate issues here:

  • should the be a Null constructor in the Haskell type Block?
  • in reading the JSON serialization, what should be done with JSON null elements?

We could, in principle, ignore JSON nulls without having a Null constructor in Block (though there may be issues of detail I'm not thinking of, especially since we're using an automatically derived FromJSON instance).

from pandoc-types.

jgm avatar jgm commented on August 24, 2024

Note also that one can always write a filter that is capable of removing Blocks by making the type of the underlying transformation [Block] -> [Block]; in fact I often use a Block -> [Block] and promote it to [Block] -> [Block] using concatMap.

from pandoc-types.

nichtich avatar nichtich commented on August 24, 2024

should the be a Null constructor in the Haskell type Block?

No, there is no need to have it.

in reading the JSON serialization, what should be done with JSON null elements?

They can be ignored but should be documented. Right now the JSON format is only described implicitly by Haskell types, so removal would also make existing AST structure invalid. Confusion such as #75 (table format changed two times from 1.20 to 1.21 to 1.22) and any breaking of backwards compatibility should be avoided.

from pandoc-types.

jgm avatar jgm commented on August 24, 2024

That's true, explicitly ignoring null in parsing JSON would keep a degree of backwards compatibility for JSON filters that use Null. (As long as they aren't written in Haskell using the Null constructor.) Doing this, however, might cause a lot of additional code complexity if it means not using automatic derivation of the FromJSON instance. In that case it may not be worth it -- and maybe we should just keep Null, as ugly but harmless.

from pandoc-types.

zkamvar avatar zkamvar commented on August 24, 2024

What is the appropriate replacement pattern for using pandoc.Null()? I don't speak enough Lua to understand what this means:

Note also that one can always write a filter that is capable of removing Blocks by making the type of the underlying transformation [Block] -> [Block]; in fact I often use a Block -> [Block] and promote it to [Block] -> [Block] using concatMap.

The solution I've come up with is to replace pandoc.Null() with pandoc.RawBlock("text", "") as in:

::::: removeme

This should disappear

:::::

::::: keep

This should stay

:::::
Div = function(el)
  v,i = el.classes:find("removeme")
  if i ~= nil then
    return pandoc.RawBlock("text", "")
  else
    return el
  end
end

Is this correct?

from pandoc-types.

Related Issues (20)

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.