Custom Processor Arguments without setting its state
As you mention in the documentation, we can set per-document custom (pre)processor settings as a JSON array to pass additional arguments to the processor. A la:
Custom Processor: [true, "-o", "html"]
Is it possible to set parameters to be passed to the processor without forcing the processor to be on or off in the document, and then they are just ignored if the custom processor is off? For example, something like
Custom Processor: [NULL, "-o", "html"]
I like to be able to enable and disable the custom processor with the indicator button in the Marked pane, but when I am passing arguments in the document, the state is not affected by clicking the indicator, and I can only enable or disable the processor by editing the document.
Obviously this isn't a huge dealbreaker if it isn't possible. It would just mean I'd have to write a more complex processor script to dig into the document content manually, or just not have the clicky button. But it could be a nice thing to have.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Brett on 26 Mar, 2020 12:51 PM
The way I have it implemented at this time will not allow a JSON string
to be anything other than true or false in the first argument. I can see
the utility of what you're asking, so I'll take a look at modifying that
in the future.
No option for the immediate present, though.
-Brett
2 Posted by connor on 26 Mar, 2020 02:28 PM
No worries! It's definitely easy to work around with a more intelligent
processor script. Thanks!
3 Posted by connor on 30 Mar, 2020 03:43 PM
So, either I'm a little bit insane, you snuck in an app update without me noticing, or there's a ghost in my computer, but Marked is now exhibiting almost this behavior? Except in a way that I think is a bug. Example document:
If I open this document in Marked, the Custom Preprocessor is off by default, and the toggle button remains clickable. If I toggle the Custom Preprocessor on, it passes along the JSON arguments, but the first argument of
true
orfalse
appears to be ignored.As nice as it is that my prayers have been answered by a bug, I don't think this is the optimal behavior.
Thanks!
Support Staff 4 Posted by Brett on 30 Mar, 2020 04:22 PM
I'll be honest, I think you're the first person in Marked's history to even explore the JSON option here, so it hasn't received much attention. I'll look into it.
- Brett
5 Posted by connor on 30 Mar, 2020 05:04 PM
Ha! Should I be writing a more intelligent script in something other than bash? Probably, but I'm still a baby script writer so the JSON arguments make for a good baby step to parsing YAML headers myself in python. Someday I'll get there!
Support Staff 6 Posted by Brett on 30 Mar, 2020 05:26 PM
There are lots of ways you can branch logic using variables and content parsing, whether in yaml blocks or otherwise. Just depends on your scripting language of choice. Give me an idea what you're trying to do, I might have suggestions.
That said, I do want to improve the JSON arguments feature if I'm going to offer it, no point implementing something half-baked.
- Brett
7 Posted by connor on 30 Mar, 2020 07:24 PM
I am yet another devoted fan of pandoc, primarily via R Markdown documents. Most of the time I'm just writing in RStudio, but if what I'm writing is all words and no code, RStudio is more than I need, but I still want to use R to compile the documents via pandoc. What I probably should do (which I only now thought about doing, so thanks for the prompting) is just write an executable R script and have THAT be the preprocessor rather than trying to reinvent the wheel with my own bash script…
In essence, I am trying to do an end around adding my own items to the Export drawer via a Preprocessor. I don't feel strongly about setting a custom processor to preview the exact output in Marked, both because all I really care about is the text content rather than the formatting, and because more often than not I want a LaTeX PDF or a Word document rather than HTML, and I prefer to generate those documents cleanly via pandoc rather than attached to a Marked template routed through HTML.
8 Posted by connor on 31 Mar, 2020 12:27 AM
Wow I just wrote an R script directly to do this and it is much better. Putting it here for posterity just in case someone else stumbles upon this thread, but I guess what I would underscore as my takeaway from this exercise is a feature request to be able to customize the contents of the Export Drawer. This really belongs there, and the preprocessor is just a workaround.
The R processor, if it's of interest: