Comments (8)
In a Lua filter you can return {}
and it will just omit the element.
from pandoc-types.
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.
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.
@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.
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.
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.
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.
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 aBlock -> [Block]
and promote it to[Block] -> [Block]
usingconcatMap
.
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)
- Improving tables HOT 20
- Why do we need isNull? HOT 1
- Use Map for key-value pairs HOT 4
- Emph with custom class HOT 1
- Backward- and forward-compatibility HOT 3
- Broken dependency constraints for pandoc-types 1.20 HOT 2
- Single constructor data types and JSON serialization HOT 4
- Tag 1.20 seems to be missing in git HOT 3
- Crazy ideas: table structure HOT 25
- Pandoc not parsing metadata when invoked inside Haskell program HOT 2
- Walkable instance (and newtype) for Attributes HOT 7
- Improve Walk HOT 2
- "Functored" AST HOT 18
- github actions caching
- What is the purpose of Table's ShortCaption? HOT 6
- Work with a StateT transformator HOT 4
- Issue with compiling pandoc-theorem HOT 2
- nullAttr doesn't seem to work as before with pandoc filter HOT 4
- add ListAttributes support for BulletList
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandoc-types.