How to interpolate variable into markdown codeblock in Pluto.jl? - julia

In Pluto if I try to include an interpolated value in the markdown string, it renders the string without interpolating the value.
I'd like the string to render as: My variable's value is: 10

Markdown itself isn't intended to interpolate variables. You may use Markdown.parse instead of md"" literal. This allows the string to interpolate the variables before passing to the Markdown parser.
Markdown.parse("""
My variable's value is: `$x`.
""")

Related

In ruamel how to start a string with '*' with no quotes like any other string

yaml = ruamel.yaml.YAML()
yaml.indent(mapping=4)
test_yaml_file = open("test.yaml")
test_file = yaml.load(test_yaml_file)
# test = LiteralScalarString('*clvm')
test = "*testing"
test_file['test_perf'] = test
with open("test.yaml", 'w') as changed_file:
yaml.dump(test_file, changed_file)
In this the expected output was
test_perf: *testing
but the output has been
test_perf: '*testing'
how to achieve this using ruamel?
Your scalar starts with a *, which is used in YAML to indicate an alias node. To prevent *testing to be interpreted as an alias during loading (even though the corresponding anchor (&testing) is not specified in the document), the scalar must be quoted or represented as a literal or folded block scalar.
So there is no way to prevent the quotes from happening apart from choosing to represent the scalar as literal or folded block scalar (where you don't get the quotes, but do get the | resp. >)
You should not worry about these quotes, because after loading you'll again have the string *testing and not something that all of a sudden has extra (unwanted) quotes).
There are other characters that have special meaning in YAML (&, !, etc.) and when indicated at the beginning of a scalar cause the scalar to be quoted. What the dump routine actually does is dump the string and read it back and if that results in a different value, the dumper knows that quoting is needed. This also works with strings like 2022-01-28, which when read back result in a date, such strings get quoted automatically when dumped as well (same for strings that look like floats, integers, true/false values).

How to translate TextMeshPro-StyleTags to the actual RichText in Unity?

I have the following string in TextMeshPro: "<style=Title>This is a Title (...)".
I would like to translate the StyleTag to the defined Opening Tags.
For this example it would translate the string above to the following: "<size=125%><align=center>This is a Title (...)".
How can I do this?
You can get the OpeningTags to a StyleTag by calling the following function: TMP_StyleSheet.GetStyle("[StyleName]").styleOpeningDefinition (with TMP_StyleSheet being a reference to the used TMP-StyleSheet).
So a possible solution is to extract the StyleName from your string (e.g. "(...text) <style=Example> (text...)" would become "Example") and feed it to the function above. Regular Expressions can help to extract the StyleName from your string. Then replace the whole tag with whatever the function returns (e.g. "<size=125%>"). (Note: It returns Null if the tag does not exist). Then do the same with the closing tag.

getNodeSet by attribute values

I'm parsing xml with R's getNodeSet function by attribute value with the following code:
getNodeSet(doc, "/body//*[#attribution='HM'][#*='checkmark'][#*='underline']")
The code above returns node content that includes all three of the above values (effectively, 'HM' And 'checkmark' And 'underline').
I'd like the function to return nodes in which the first value remains constant, but for which additional values are EITHER/OR (effectively, 'HM' AND 'checkmark' OR 'underline').
Grateful for any help.
The solution is to combine the type attribute values to be OR'd within a single set of square brackets, and supply 'or' without quotes:
getNodeSet(doc, "/body//*[#attribution='HM'][#*='underline' or #*='checkmark']")

How to include multiple \Sexpr values within LaTeX math mode tags?

As part of my work, I am expected to show calculation steps with sample values. To do this, I usually just replace the variable names with \Sexpr{} to add in the values. For some reason \Sexpr{} escapes math mode and breaks some of my tags. For instance, this works well:
$r_{pump} = \sqrt{(x_{pump} - x_{obs})^{2} + (y_{pump} - y_{obs})^{2}}$
It results in all values being correctly placed under the square root tag like this:
However, when I try to include \Sexpr{} tags to incorporate values like this...
$\sqrt{(\Sexpr{x[1]}(m) - \Sexpr{x[2]}(m))^{2} + (\Sexpr{y[1]}(m) - \Sexpr{y[2]}(m))^{2}}$
...I get results that look like this:
This happens when I try to include \Sexpr{} in a \frac{}{} tag as well.
Am I applying math mode ($\Stuff$) incorrectly?

Using asp how to create formatted currency with commas?

Using asp. Trying to format a decimal number to add commas. Are there simple to use functions or techniques in asp to go from a decimal value to currency format with commas?
Examples:
DecimalValue = 3439.01 CurrencyValue = " 3,439.01"
DecimalValue = 3843838.38 CurrencyValue = "3,843,838.00"
use the vbscript function FormatCurrency
complete syntax is:
FormatCurrency(Expression[,NumDigAfterDec[,
IncLeadingDig[,UseParForNegNum[,GroupDig]]]])
example:
FormatCurrency(20000)
output = $20,000.00
example of setting number of decimals:
FormatCurrency(20000,5)
output = $20,000.00000
To expand on Carlton Jenke's answer, there are 2 functions you can use for this (you mentioned formatting as a currency in the question title but don't include currency symbols in the body of the question):
formatnumber returns an expression formatted as a number.
formatcurrency returns an expression formatted as a currency value
using the currency symbol defined in the system control panel.
Both functions take the same arguments, those being:
Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit
[,UseParensForNegativeNumbers [,GroupDigits]]]]
Expression is the only required argument, that being the number
you wish to format.
NumDigitsAfterDecimal is a numeric value specifying how many
decimal places you want to round to. The default value is -1, which
indicates that the computer's regional settings should be used.
IncludeLeadingDigit is a tristate constant (see below) which
specifies whether or not you want to include a leading zero for
values between -1 and 1.
UseParensForNegativeNumbers is another tristate constant which
specifies whether or not you want negative values to be enclosed in
parentheses, rather than using a minus symbol.
GroupDigits, which is the argument you're after, is also a
tristate constant and is used to specify whether or not you want to
group numbers using the system's group delimiter.
The tristate constants takes one of the following for the value:
-2 is the default and indicates that the default value from the computer's regional setting should be used.
-1 is true.
0 is false.

Resources