Swig-template delete Whitespaces per default - swig-template

I am using Swig as the template engine in my project to create XML.
To make the XML output look nice I need to add a "-" everytime I use the template functions ({% -%}, {{ -}}, {# -#}).
It would be nice to be able to change the default behavior to always strip whitespace before and after. Is there a setting for this already?

No, there isn't.
The stripping is done in line 624 in parser.js:
https://github.com/paularmstrong/swig/blob/2e0e135ac04da5bf75f79cf8d4498094b3b49d35/lib/parser.js#L624
The variables stripNext and stripPrev are set to true only if a tag or a variable expression includes this -. If not stripping will not be done. There is no other way.

Related

Customize quoted strings in VS Code

The value side of attributes in HTML were very unreadable, too dark, making it especially hard to disseminate between class names in HTML, when using the dark theme on VS Code.
How do I change it to make reading more comfortable?
p.s. My "Tags" are very limited due to rep, but I'm so sure others have this question.
Here is how to accomplish this particular task.
Introducing [me to] a very useful tool: Inspect Editor Tokens and Scopes
Put cursor in, in this case, a quoted value string.
CNTL + SHIFT + P (open command palette).
Find "Developer: Inspect Editor Tokens and Scopes"
Note the textmate scope(s).
Use property: "editor.tokenColorCustomizations" → "textMateRules" to add new rule.
While I'm doing this directly on values in the JSON of settings - and changing quotes there at a high level, this also works with inheritance, so string.quoted.double.html would override the example shown in this screenshot (which applies to ALL double quoted strings), when editing HTML files. I find this useful for making my lint rules standout too.

Don't escape specific variable in ErlyDTL

ErlyDTL has an option auto_escape (which is set to true by default), which makes sure that all variables are escaped during rendering of the template.
Is there a way not to escape a specific variable?
Just found out this can be done with a safe filter. Like this:
{{var|safe}}
More information: https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#safe

Maintaining GREP variables through find and replace

I've recently taken on a project of document conversion to HTML. That is, a client gives me a .DOC file, and I need to convert the contents to one long HTML file - no styling, no CSS, just clean HTML with paragraph tags, header tags tags, etc.
I found an application that does a pretty good job of automating the first part of it. The problem is that I need to do some advanced find and replace based on strings using variables.
For instance, I have footnotes that were converted properly. They're currently displayed as superscript numbers with the
I'd like to change how the footnote is displayed. Instead of a superscript number 6 for the 6th footnote, I'd like it to show (Note 6)
To do that on the entire document (hundreds of footnotes), I'm wondering if I can do something like:
FIND:
<sup><a name="FN[0-9]" href="FNR[0-9]">[0-9]</a></sup>
REPLACE:
<a name="FN%1" href="FNR%2">(Note %3)</a>
The problem is, I can't find a Find and Replace tool that lets me maintain the variables in the replace area. All I get is the superscript 6 appearing as (Note %3), as well as every other footnote doing the same thing.
Anyone have any ideas on how I can accomplish my task efficiently?
In Perl it would look roughly like this on the command line (I have NOT tested this):
perl -i -p -e's{<sup><a name="(FN\d)" href="(FNR\d)">(\d)</a></sup>}{<a name="$1" href="$2">(Note $3)</a>}' filenames....
-i says "Edit this file in place", -p means "print each line after we do whatever is in the -e switch".
That's assuming you're only looking for a single digit where you have [0-9]. If you want to match FN427, then you change (FN\d) to (FN\d+), for example.
This also assumes that the HTML that are you parsing looks EXACTLY LIKE THAT. If you get some HTML that is <a href=... name=... (with the attributes in opposite order than you have) then it will break. In that case, you'll want to use an HTML parser.
I hope that gives you enough to start with.

Jenkins text parameter rebuild

I'm using the text parameter to get multi line parameters, and write them to file.
If I use the rebuild, the text parameter is loaded as a single line string (where newline is removed).
Does anyone have an idea on how to fix this? I guess the rebuild plugin is the problem...
The multi-line text parameter seems to be rather buggy. One workaround you may consider is to substitute newlines with some custom escape system and then convert the escape sequences back to newlines inside your build.
A more advanced solution would be to modify the plugin itself to convert the escape sequences into newlines and use that modified plugin in your Jenkins. I've done that sort of thing for Claim Plugin to display failed matrix jobs which it did not do on its own. If you decide to take this route I can walk you through the main steps.
I have just enhanced the plugin to add TextParameterValue.jelly
That works fine, since text and textarea are not that different except new lines just use StringParameterValue.jelly as template and use <f:textarea name="value" value="${it.value}" /> instead of <f:textbox name="value" value="${it.value}" />

How to prevent LaTeX from hyphenating words containing a dash?

I would like to globally prevent LaTeX from hyphenating 'Objective-C'. I am aware of the \hyphenation command, but I don't see how I can make use of it. If I pass 'Objective-C' to this command, the dash will be treated as a hint to hyphenate the word there.
One solution I found is wrapping Objective-C into an mbox each time I use it. However, the document I am writing contains this name a lot, and wrapping it into an mbox each time is ugly (as is defining a command and using this over and over again in the source code).
Why is defining a new command ugly? It's how \LaTeX\ defines itself.
\def\ObjectiveC{\mbox{Objective-C}}
Use \nobreakdash. That's what LyX produces when I insert a nonbreakingdash and convert it to tex.
As suggested here, you could define a command like this:
\newcommand\dash{\nobreakdash-\hspace{0pt}}
and use it like this
Consider the $n$\dash dimensional manifold ...
Also, you could use the babel package and use "~ as a protected hyphen. I'm not sure if using babel is advisable when writing in english, though.

Resources