Wgraph:Tutorial strings

From FollowTheScore
Jump to: navigation, search

A lot of properties expect arguments of type 'string', e.g. 'label'. Node identifiers are also strings.

String Quoting

  • Strings can be written as plain tokens without quotes if they do not contain spaces
  • Strings can be written as plain tokens with underscores instead of spaces; underscores are always converted to spaces
  • Strings can be quoted with single or double quotes
    • 'abc def' is the same as 'abc def"
  • within a 'single quoted string' you can use " (double quotes) without escaping
  • within a "double quoted string" you can use ' (single quotes) without escaping; this is useful if you want to use wiki markup syntax for italic and bold within a label
  • you can also use the '\' (backslash) for escaping; \n is newline etc.
  • even if strings are quoted, they will be trimmed (i.e. spaces and newlines will be removed from both ends). This is useful because template calls tend to introduce unwanted whitespaces into arguments. If you really want leading or trailing white space, use underscores. If you use the concatenation mechanism for strings and you want a space between the concatenated parts, you must terminate the first part with an underscore or start the second part with asn underscore. See the example below.

String concatenation

  • sequences of quoted strings with equal delimiter symbols will be concatenated (pasted) if they are separated by space or newline.
    • So, "ab cd" "ef" will give one string "ab cdef" (note that there is no space between d and e.
    • 'Ab_' 'cd' or "Ab " "cd" will result in "Ab cd"
    • whereas 'Ab ' "cd" are two separate string arguments
    • whereas Ab cd is the string "Ab" followed by a token named cd.


Line breaking, Labels

  • When used as node or edge labels strings are broken into lines.
  • Underscores in the label (as in all strings) are converted to spaces.
  • The character sequence '\n' will always trigger a linebreak
  • <br> and <p> will be transformed into line breaks
  • Apart from that, other "breakable characters" like space, dashs, semicolon, colon, comma and brackets are used for breaking.
  • strings will be broken at the first breakable character position which has a distance of at least 'textwidth' positions from the last line break
  • Within labels you can use wiki syntax for underlining, bold and italic. Double quotes around your label are necessary if you want to use single quotes (and spaces) within the label.

{{#wgraph: png | wgl |

 node A { label "This\n is a long text, which_is broken into_" "several lines" }

}}