Unverified Commit 8fad66a5 authored by Raniere Silva's avatar Raniere Silva Committed by GitHub
Browse files

Merge pull request #146 from rgaiacs/syntax-highlighting-example

Syntax highlighting example
parents 3928e3f6 1ee92191
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -74,5 +74,5 @@ exclude:
  - Makefile
  - bin

# Turn off built-in syntax highlighting.
highlighter: false
# Turn on built-in syntax highlighting.
highlighter: rouge
+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ is translated into:
</body>
</html>
~~~
{: .source}
{: .html}

> ## Back in the Day...
>
+63 −16
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ which is rendered as:
for thing in collection:
    do_something
~~~
{: .source}
{: .language-python}

The class specified at the bottom using an opening curly brace and colon,
the class identifier with a leading dot,
@@ -159,23 +159,70 @@ The [template]({{ site.template_repo }}) provides three styles for code blocks:
~~~
{: .error}

The following styles are all synonyms for `.source`;
please use them where possible to indicate the type of source being displayed,
in case we decide to adopt syntax highlighting at some point:
### Syntax Highlighting

The following styles like `.source`, but include syntax highlighting for the
specified language.
Please use them where possible to indicate the type of source being displayed,
and to make code easier to read.

`.language-bash`: Bash shell commands:

~~~
echo "Hello World"
~~~
{: .language-bash}

`.html`: HTML source:

~~~
<html>
<body>
<em>Hello World</em>
</body>
</html>
~~~
{: .html}

`.language-make`: Makefiles:

~~~
all:
    g++ main.cpp hello.cpp -o hello
~~~
{: .language-make}

`.language-matlab`: MATLAB source:

~~~
disp('Hello, world!')
~~~
{: .language-matlab}

`.language-python`: Python source:

~~~
print("Hello World")
~~~
{: .language-python}

`.language-r`: R source:

~~~
cat("Hello World")
~~~
{: .language-r}

`.language-sql`: SQL source:

~~~
CREATE PROCEDURE HelloWorld AS
PRINT 'Hello, world!'
RETURN (0)
~~~
{: .language-sql}

*   `.bash`: Bash shell commands
*   `.make`: Makefiles
*   `.matlab`: MATLAB source
*   `.python`: Python source
*   `.r`: R source
*   `.sql`: SQL source

> ## Why No Syntax Highlighting?
>
> We do not use syntax highlighting for code blocks
> because some learners' systems won't do it,
> or will do it differently than what they see on screen.
{: .callout}

## Special Blockquotes

+6 −6
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ each episode written in RMarkdown.
~~~
source("../bin/chunk-options.R")
~~~
{: .r}
{: .language-r}

The rest of the lesson should be written as a normal RMarkdown file. You can
include chunk for codes, just like you'd normally do.
@@ -44,7 +44,7 @@ Normal output:
~~~
1 + 1
~~~
{: .r}
{: .language-r}



@@ -59,7 +59,7 @@ Output with error message:
~~~
x[10]
~~~
{: .r}
{: .language-r}



@@ -76,7 +76,7 @@ library(ggplot2)
ggplot(diamonds, aes(x = carat,  y = price, color = cut)) +
    geom_point()
~~~
{: .r}
{: .language-r}

<img src="../fig/rmd-plot-example-1.png" title="plot of chunk plot-example" alt="plot of chunk plot-example" style="display: block; margin: auto;" />

@@ -93,7 +93,7 @@ instructions and solutions. For instance this:
> ~~~
> paste("This", "new", "template", "looks", "good")
> ~~~
> {: .r}
> {: .language-r}
>
> > ## Solution
> >
@@ -116,7 +116,7 @@ will generate this:
> ~~~
> paste("This", "new", "template", "looks", "good")
> ~~~
> {: .r}
> {: .language-r}
>
> > ## Solution
> >
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ For example, "to delete the cell press <kbd>D</kbd>" should be write as
~~~
to delete the cell press <kbd>D</kbd>
~~~
{: .html}

The table below covers most of the keyboard key labels.

@@ -79,5 +80,6 @@ For example, "press <kbd>Ctrl</kbd>+<kbd>X</kbd> to quit nano" should be write a
~~~
press <kbd>Ctrl</kbd>+<kbd>X</kbd> to quit nano.
~~~
{: .html}

{% include links.md %}
Loading