Comments (8)
The following might be a reasonable design:
New module pandoc.lua with three functions:
pandoc.log.warn
-- likewarn
, but without support for control messagespandoc.log.info
-- likepandoc.log.warn
, but raises a ScriptingInfo log message (requires an API change)pandoc.log.silence
-- applies a function, but returns the log messages generated by the call as the first result instead of logging them in the main log. The function's other results are returned as additional return values.
It would be enough to resolve this issues as well as #9077.
from pandoc.
I've creates #9668 for experimentation and as a proof of concept.
from pandoc.
If the output of warn
currently does go into the log file, then I don't see what more is needed. We certainly don't want io.write
to go to the log file in general. And error
should create an error, not a warning (which is what the log file contains).
from pandoc.
My thought process when I suggested to open this issue was that warn
can only produce warnings, but not info
entries. What I had in mind was to allow something like this:
local orig_io_write = io.write
io.write = function (...)
pandoc.report('This is an info', 'INFO')
return orig_io_write(...)
end
I.e., allow users to redefine io.write
such that additional info gets logged with severity INFO
.
I believe that giving users more access to the logging system would generally be a good idea. But it's difficult to make it useful without just tying it to the internals, as those should probably remain hidden.
A suitable API design might be achievable, but I don't have one yet.
from pandoc.
When they use warn
currently, what kind of LogMessage is generated? Is there a special log message for warnings from Lua filters?
from pandoc.
I understand @jgm's concern about not making pandoc too complex. But as @tarleb points out, I think it would be useful to have messages at the 'info' level (which is why I use io.write
). In my particular use case, I use io.write to notify the user of some decisions that occur during filter execution, but which are not warnings. I understand that it would be very useful to have a pandoc.report
function like the one proposed by @tarleb, that allows to make pandoc.report('This is an info', INFO')
/ pandoc.report('This is a warning', 'WARNING')
, independently from what the final user is informed. Then each filter could customise it to print or not print console output (this way you don't interfere with the behaviour of io.write
which can have other uses).
I want to clarify a few points regarding the behaviour of warn
. On one hand, the @on
/ @off
option, does not work as the first parameter of warn
(i.e. warn('@on', 'my message')
, but by setting the warn('@on')
behaviour, and then using warn('my message')
again with the message. On the other hand, even when warn('@off')
is set, the function returns a message in the console (which can be intimidating to an 'ordinary' user). In fact what '@off' does is suppress 'clean' console messages. It is because of these limitations of
warm`, that I would be interested in having another way of passing information to the user.
Thank you very much for the comments, they really help me also to clarify what is the behaviour I am asking for.
from pandoc.
When they use
warn
currently, what kind of LogMessage is generated? Is there a special log message for warnings from Lua filters?
Yes, pandoc generates a ScriptingWarning message, which was introduced specifically for that purpose. The relevant PR was #8685.
from pandoc.
The expectation is that users will use --silent
if they don't want pandoc's warning messages to be printed in the terminal. However, setting warn '@on'
will make sure that the warn message always gets printed to the terminal, as happens in the default lua
executable. But I agree that it's confusing to see the same message twice, one time as-is, and another time with info about the location where warn
was involved. There might be a better way.
from pandoc.
Related Issues (20)
- LaTeX writer: fix text style in math mode and strikethrough HOT 2
- --toc-title no effect in docx HOT 3
- `--embed-resources` drops the classes of embedded image when embedding element has classes of their own HOT 1
- Allow custom-style atttributes for inline elements in OpenDocument / ODT writer
- Large SVGs are rendered incorrectly in latex output HOT 4
- Conditionals evaluate truthiness HOT 7
- Bullet point format not preserved HOT 1
- The First Paragraph style of reference docx can only work on the first paragraph, and the following paragraphs cannot work HOT 3
- --from=html: Allow plain text rendering of links and images HOT 1
- Early macro substitution in `\ifstrequal` clauses
- Enable latex_macros for output writers HOT 6
- Latex math environment flalign not converted to markdown math HOT 3
- Djot line breaks don't split slides like markdown line breaks HOT 5
- markdown to manpage: Rendering text between ticks not highlighted HOT 1
- A title after a blockquote is not rendered well HOT 1
- Converting from RTF (using CJK characters) into Markdown causes CJK characters messed up HOT 10
- Jira: First Bulleted List in Table Breaks Output Table HOT 1
- Pandoc --version reports commitBuffer: invalid argument (cannot encode character '\248') on Windows if home folder includes non-ascii characters HOT 3
- While generating DOCX impossible to change header line to TOC "Table of Contents" to anything else. HOT 2
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.