Skip to content

Commit

Permalink
support syntax highlighting in code blocks (see README)
Browse files Browse the repository at this point in the history
  • Loading branch information
uwiger committed May 24, 2013
1 parent 30a9f78 commit 1f6954c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@ Example:

The conversion function will fetch the current branch name from git,
and fail if it cannot do so.
Github customizations
=====================
`pre` tags are converted into github "fenced" code blocks, i.e.

```
```...'''
```

. If language-specific syntax highlighting is desired,
this can be achieved by adding a 'lang' attribute, e.g.

```
<pre lang="erlang">
incr(X) ->
%% This should be formatted with Erlang syntax highlighting
X + 1.
</pre>
```

which should format like this:

```erlang

incr(X) ->
%% This should be formatted with Erlang syntax highlighting
X + 1.

```

Rebar customizations
====================
Expand Down
28 changes: 28 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@ Example:

The conversion function will fetch the current branch name from git,
and fail if it cannot do so.
Github customizations
=====================
`pre` tags are converted into github "fenced" code blocks, i.e.

```
```...'''
```

. If language-specific syntax highlighting is desired,
this can be achieved by adding a 'lang' attribute, e.g.

```
<pre lang="erlang">
incr(X) ->
%% This should be formatted with Erlang syntax highlighting
X + 1.
</pre>
```

which should format like this:

```erlang

incr(X) ->
%% This should be formatted with Erlang syntax highlighting
X + 1.

```

Rebar customizations
====================
Expand Down
21 changes: 21 additions & 0 deletions doc/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ Example:
The conversion function will fetch the current branch name from git,
and fail if it cannot do so.

Github customizations
=====================
`pre' tags are converted into github "fenced" code blocks, i.e.
<pre>&#96;&#96;&#96;...'''</pre>. If language-specific syntax highlighting is desired,
this can be achieved by adding a 'lang' attribute, e.g.

<pre>&lt;pre lang="erlang"&gt;
incr(X) ->
%% This should be formatted with Erlang syntax highlighting
X + 1.
&lt;/pre&gt;</pre>

which should format like this:

<pre lang="erlang">
incr(X) ->
%% This should be formatted with Erlang syntax highlighting
X + 1.
</pre>


Rebar customizations
====================
A set of escripts can be found under
Expand Down
6 changes: 5 additions & 1 deletion src/edown_xmerl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ md_elem(Tag, Data, Attrs, Parents, E) ->
%% would have written it and markdown rendering will take
%% care of entity escaping so that a code block describing
%% XML or HTML will get rendered properly.
["\n```\n", Data, "\n```\n"];
Lang = case lists:keyfind(lang, #xmlAttribute.name, Attrs) of
#xmlAttribute{value = Lang1} -> Lang1;
false -> ""
end,
["\n```", Lang, "\n", Data, "\n```\n"];
_ ->
["\n",
xmerl_lib:start_tag(Tag,Attrs),
Expand Down

0 comments on commit 1f6954c

Please sign in to comment.