In asciidoctor I can overwrite any attribute value given on the CLI via a document header value, when I append '#' to the value on the CLI.
Example: -a icontype=png# is overwritten by :icontype: svg in the doc header. Good.
Problem: Boolean attributes.
How would I UNSET a boolean attribute given on the CLI, like -a data-uri.
Use Case: My .adoc renderer should by default set data-uri, but I would like to switch it off sometimes via a document header attribute.
Is that possible?
Answer:
CLI: -a data-uri=#
Doc Header: :data-uri!:
(https://asciidoctor.org/docs/user-manual/#using-attributes-set-assign-and-reference)
Related
If I have these files:
text.md:
---
header-includes:
- \usepackage{pgf-pie}
---
\begin{tikzpicture}
\pie{50/, 50/}
\end{tikzpicture}
settings.yaml:
variables:
header-includes:
- \pagecolor{black}
and I compile them with pandoc with the command:
pandoc text.md -d settings -o text.pdf
...the header-includes value in the defaults file settings.yaml will overwrite the metadata block in text.md, thus failing to compile.
Is there a way to get pandoc to combine the two header-includes lists instead?
Combining these header-includes lists is not possible.
There are two reasons to this: One, the values from the defaults file always take precedence. In addition, if a name is used both as as a variable and in the metadata, then the variable will be used.
For additional info and discussions of this topic, see these pandoc GitHub issues:
Command-line options --css and --include-in-header override corresponding metadata fields instead of accumulating
Allow defaults to be folded into YAML metadata
A possible workaround would be to use a "new style" custom writer, as these provide write access to both metadata and variables:
function Writer (doc, opts)
local includes_tmpl = pandoc.template.compile('$header-includes$')
local vars = {['header-includes'] = opts.variables['header-includes'] or ''}
-- Write header-includes, once with variables, once without (thus
-- allowing metadata values to be used instead)
opts.variables['header-includes'] =
pandoc.write(doc, 'latex', {template=includes_tmpl, variables=vars}) ..
'\n' ..
pandoc.write(doc, 'latex', {template=includes_tmpl})
return pandoc.write(doc, 'latex', opts)
end
Note, however, that this currently requires the development version, so you'd need to use a nightly build. You'll also need to explicitly specify the template and PDF engine, e.g., --template=default.latex --pdf-engine=xelatex.
I was to set the baseURL of my cypress tests to be read from .env file.
I can't set it directly in the cypress.json file.
And when I try to use cy.visit(process.env.MYAPPURL), I get an this error
cy.visit() must be called with a url or an options object containing a
url as its 1st argument
you can leave cy.visit() empty but you just need to set this env CYPRESS_BASE_URL with the base url instead like this for example:
CYPRESS_BASE_URL=$VUE_APP_BASE_URL
check this for explanation https://docs.cypress.io/guides/guides/environment-variables
I need to POST the following curl command using Go
curl -X POST http://localhost:8001/routes/route_name -F "name=function" -F "config.file[1]=#my_file.lua"
I have been looking into multipart file upload examples, but I can't wrap my head around how to create a post with a nested field name (config.file is a config object with file as an array of strings) using CreateFormFile(key, val).
The problem I am having is according to the docs (https://pkg.go.dev/mime/multipart#Writer.WriteField) the WriteField API takes a field name and a value (path to file to post). I am not sure how to post a field name that is in a nested object e.g. CreateFormFile("config.file", filePath).
Anyone know how to convert the above curl command to Go using POST.
I have some configuration templates which use FMPP to generate the
real runtime config files based upon info in a csv and properties
file (defined in config.fmpp).
I want to be able to configure a second cluster server for the same task using the same set of templates and config.fmpp information. However, there are slight differences needed in the generated runtime config and I can do this if I know which server instance I am on ("serverA" or "serverB") using a standard fmpp variable like ${myserver}.
But there must only be one set of templates and FMPP config files so I need to somehow get the value of "myserver" from the runtime
environment in each server.
Some of the options I might have are:
pass value of myserver on the command line tool invocation (best way); or
get it from an environment variable.
Does anyone have an example of the code to do any of these and any suggestions of the best approach? Online reference would be great.
fmpp -S /home/me/sample-project/src -Param myserver:serverA
Environment settings:
fmpp v0.9.14
freemarker v2.3.19
Use the -D command line option (see --help):
-D, --data=<TDD> Creates shared data that all templates will see. <TDD> is the
Textual Data Definition, e.g.:
-D "properties(style.properties), onLine:true"
Note that paths like "style.properties" are relative to the
data root directory.
Like:
fmpp -S /home/me/sample-project/src -D myserver:serverA
Note that there's a space after the -D. (It's not like the java command line syntax, but rather like the standard GNU command line syntax.
This -D has nothing to do with Java's -D option.
The documentation shows onLine:true, but such Boolean values are legacy and no longer accepted. Use online:yes to parse Boolean values.
For example:
fmpp \
-S /path/ \
--verbose \
-D "online:yes"
Then, within the template:
<p>
online: ${online}
</p>
Will result in:
online: yes
The --verbose command-line parameter is useful to show any errors when parsing the template.
Pandoc allows you to include metadata at the beginning of a Markdown document using a header like
---
title: The Song That Never Ends
subtitle: It Goes On and On My Friends
author: Abraham Lincoln
lang: en_US
---
Is there any way to convey this information to Pandoc when the input format is not Markdown? I’m specifically interested in HTML input. I tried calling Pandoc with --from=html+yaml_metadata_block, but this didn’t seem to change the behavior at all—the YAML block is just interpreted as HTML.
(It is possible to include some metadata in the “percent format” shown in the “pandoc_title_block” section of the manual, but there doesn’t seem to be a way to give a separate title and subtitle with that syntax. It’s also possible to include the YAML header before the HTML and to force Pandoc to interpret the input as Markdown, but this seems hacky, and if you try to convert that to “real” Markdown then the output is full of HTML tags instead of Markdown formatting characters.)
You can use the --metadata (short -M) or --metadata-file options to supply metadata on the command line, for example:
pandoc -M title="The Song That Never Ends"
A simple solution would be to use Lua filters to augment the metadata read from the HTML file as described in the Lua filters doc. Below is an updated version:
-- file: additional-metadata.lua
function read_file_as_markdown_yaml (filename)
-- read metadata file into string
local metafile = io.open(filename, 'r')
local content = metafile:read('*a')
metafile:close()
-- get metadata
return pandoc.read(content, 'markdown').meta
end
function Meta (meta)
-- read YAML file and add its content to the metadata
local yaml_meta = read_file_as_markdown_yaml(meta.default_meta_file)
for k, v in pairs(yaml_meta) do
-- use YAML metadata as fallback
meta[k] = meta[k] or v
end
return meta
end
Use with
pandoc --lua-filter additional-metadata.lua \
--metadata default_meta_file:YOUR-FILE-HERE.yaml \
your-input-file.html