Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,4 +1,13 @@
{{omit from|BBC BASIC}}
A here document (or "heredoc") is a way of specifying a text block, preserving the line breaks, indentation and other whitespace within the text. Depending on the language being used a here document is constructed using a command followed by "<<" (or some other symbol) followed by a token string. The text block will then start on the next line, and will be followed by the chosen token at the beginning of the following line, which is used to mark the end of the textblock.
{{omit from|Déjà Vu}}
{{omit from|Gambas}}
{{omit from|GW-BASIC}}
{{omit from|MATLAB|MATLAB has no multiline string literal functionality}}
A here document (or "heredoc") is a way of specifying a text block, preserving the line breaks, indentation and other whitespace within the text.
Depending on the language being used a here document is constructed using a command followed by "<<" (or some other symbol) followed by a token string.
The text block will then start on the next line, and will be followed by the chosen token at the beginning of the following line, which is used to mark the end of the textblock.
The task is to demonstrate the use of here documents within the language.

View file

@ -0,0 +1,3 @@
---
category:
- Syntax elements

View file

@ -0,0 +1,18 @@
#include <iostream> // Only for cout to demonstrate
int main()
{
std::cout <<
R"EOF( A raw string begins with R, then a double-quote ("), then an optional
identifier (here I've used "EOF"), then an opening parenthesis ('('). If you
use an identifier, it cannot be longer than 16 characters, and it cannot
contain a space, either opening or closing parentheses, a backslash, a tab, a
vertical tab, a form feed, or a newline.
It ends with a closing parenthesis (')'), the identifer (if you used one),
and a double-quote.
All characters are okay in a raw string, no escape sequences are necessary
or recognized, and all whitespace is preserved.
)EOF";
}

View file

@ -0,0 +1,8 @@
" a multiline
string\n(with escape sequences: \u{greek-capital-letter-sigma})
"
"""this is "easier".."""
HEREDOC: EOF
this
is not \n escaped at all
EOF

View file

@ -0,0 +1,27 @@
object temp {
val MemoriesOfHolland=
"""Thinking of Holland
|I see broad rivers
|slowly chuntering
|through endless lowlands,
|rows of implausibly
|airy poplars
|standing like tall plumes
|against the horizon;
|and sunk in the unbounded
|vastness of space
|homesteads and boweries
|dotted across the land,
|copses, villages,
|couchant towers,
|churches and elm-trees,
|bound in one great unity.
|There the sky hangs low,
|and steadily the sun
|is smothered in a greyly
|iridescent smirr,
|and in every province
|the voice of water
|with its lapping disasters
|is feared and hearkened.""".stripMargin
}

View file

@ -2,10 +2,12 @@ set hereDocExample {
In Tcl, the {curly brace} notation is strictly a here-document style notation
as it permits arbitrary content inside it *except* for an unbalanced brace.
That is typically not a problem as seen in reality, as almost all content that
might be placed in a here-doc is either brace-free or balanced. The content
of the braces is not interpreted at all; no substitutions are performed on it.
might be placed in a here-doc is either brace-free or balanced.
The content of the braces is not interpreted at all;
no substitutions are performed on it.
The sole exception is that there is limited processing of backslashes; a single
backslash at the end of a line causes the end-of-line plus all whitespace at
the start of the next line to be compressed to a single space.
The sole exception is that there is limited processing of backslashes;
a single backslash at the end of a line causes the end-of-line
plus all whitespace at the start of the next line
to be compressed to a single space.
}

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<![CDATA[
This text is in a CDATA section. In here, it's okay to include <, >, &, ", and '
without any special treatment.
The section is terminated by a three-character sequence consisting of two right
brackets ("]]") followed by a greater-than (">"). If this sequence appears in
your text, a workaround is to drop out of the CDATA section, output part of the
terminator, then start a new CDATA section and output the rest. Let's do this
now:
]]>]]<![CDATA[>
Newlines and spacing are retained as well, as long as they're evaluated in a
context that bothers preserving them. Whether or not the spaces before and after
the CDATA section are also preserved may be application-dependent.
]]>
</xsl:template>
</xsl:stylesheet>