Skip to content

Commit

Permalink
escape brackets in generated pre parts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulf Wiger committed Oct 5, 2011
1 parent b5f1675 commit 813c322
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
10 changes: 5 additions & 5 deletions doc/edown_doclet.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ __Authors:__ Ulf Wiger ([`[email protected]`](mailto:ulf.wiger@erla



<pre>run(Command::<a href="#type-doclet_gen">doclet_gen()</a> | <a href="#type-doclet_toc">doclet_toc()</a>, Ctxt::<a href="#type-edoc_context">edoc_context()</a>) -> ok</pre>
<pre>run(Command::[doclet_gen()](#type-doclet_gen) | [doclet_toc()](#type-doclet_toc), Ctxt::[edoc_context()](#type-edoc_context)) -&gt; ok</pre>
<br></br>


Expand All @@ -43,8 +43,8 @@ Main doclet entry point.



Also see [`//edoc/edoc:layout/2`](http://www.erlang.org/doc/man/edoc.html#layout-2) for layout-related options, and
[`//edoc/edoc:get_doc/2`](http://www.erlang.org/doc/man/edoc.html#get_doc-2) for options related to reading source
Also see [`//edoc/edoc:layout/2`](/Users/uwiger/ETC/git/edoc/doc/edoc.md#layout-2) for layout-related options, and
[`//edoc/edoc:get_doc/2`](/Users/uwiger/ETC/git/edoc/doc/edoc.md#get_doc-2) for options related to reading source
files.

Options:
Expand Down Expand Up @@ -77,7 +77,7 @@ functions will also be included. The default value is <code>false</code>.



<dt><code>{overview, <a href="http://www.erlang.org/doc/man/edoc.html#type-filename">//edoc/edoc:filename()</a>}</code>
<dt><code>{overview, <a href="/Users/uwiger/ETC/git/edoc/doc/edoc.md#type-filename">//edoc/edoc:filename()</a>}</code>
</dt>


Expand Down Expand Up @@ -117,7 +117,7 @@ specified, no stylesheet reference will be generated.



<dt><code>{stylesheet_file, <a href="http://www.erlang.org/doc/man/edoc.html#type-filename">//edoc/edoc:filename()</a>}</code>
<dt><code>{stylesheet_file, <a href="/Users/uwiger/ETC/git/edoc/doc/edoc.md#type-filename">//edoc/edoc:filename()</a>}</code>
</dt>


Expand Down
6 changes: 3 additions & 3 deletions doc/edown_layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ the source file. The default value is <code>true</code>.



<dd>Specifies an <a href="http://www.erlang.org/doc/man/index.html" target="_top"><code>xmerl</code></a> callback module to be
used for exporting the documentation. See <a href="http://www.erlang.org/doc/man/xmerl.html#export_simple_content-2"><code>//xmerl/xmerl:export_simple_content/2</code></a> for details.
<dd>Specifies an <a href="/Users/uwiger/ETC/git/xmerl/doc/index.md" target="_top"><code>xmerl</code></a> callback module to be
used for exporting the documentation. See <a href="/Users/uwiger/ETC/git/xmerl/doc/xmerl.md#export_simple_content-2"><code>//xmerl/xmerl:export_simple_content/2</code></a> for details.
</dd>





__See also:__ [//edoc/edoc:layout/2](http://www.erlang.org/doc/man/edoc.html#layout-2), [edown_doclet:layout/2](edown_doclet.md#layout-2).<a name="overview-2"></a>
__See also:__ [//edoc/edoc:layout/2](/Users/uwiger/ETC/git/edoc/doc/edoc.md#layout-2), [edown_doclet:layout/2](edown_doclet.md#layout-2).<a name="overview-2"></a>

###overview/2##

Expand Down
4 changes: 2 additions & 2 deletions doc/edown_make.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@



<pre>from_script(Config::ConfigFile) -> ok | {error, Reason}</pre>
<pre>from_script(Config::ConfigFile) -&gt; ok | {error, Reason}</pre>
<br></br>


Expand All @@ -49,7 +49,7 @@ This function does not manage dependencies. It is simply a wrapper around



<pre>main(Args::[Config]) -> <a href="#type-no_return">no_return()</a></pre>
<pre>main(Args::[Config]) -&gt; [no_return()](#type-no_return)</pre>
<br></br>


Expand Down
10 changes: 5 additions & 5 deletions src/edown_layout.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%% limitations under the License.
%%==============================================================================
%% @author Ulf Wiger <[email protected]>
%% @copyright 2010 Erlang Solutions Ltd
%% @copyright 2010 Erlang Solutions Ltd
%% @end
%% =====================================================================

Expand Down Expand Up @@ -572,15 +572,15 @@ format_spec(Name, Type, Defs, #opts{pretty_printer = erl_pp}=Opts) ->
L = t_clause(Name, Type),
O = pp_clause(Name, Type),
{R, ".\n"} = etypef(L, O),
[{pre, R}]
[{pre_pre, R}]
catch _:_ ->
%% Example: "@spec ... -> record(a)"
format_spec(Name, Type, Defs, Opts#opts{pretty_printer=''})
end;
format_spec(Sep, Type, Defs, _Opts) ->
%% Very limited formatting.
Br = if Defs =:= [] -> br; true -> [] end,
[{pre, t_clause(Sep, Type)}, Br].
[{pre_pre, t_clause(Sep, Type)}, Br].

t_clause(Name, Type) ->
#xmlElement{content = [#xmlElement{name = 'fun', content = C}]} = Type,
Expand All @@ -599,13 +599,13 @@ format_type(Prefix, Name, Type, Last, #opts{pretty_printer = erl_pp}=Opts) ->
L = t_utype(Type),
O = pp_type(Name, Type),
{R, ".\n"} = etypef(L, O),
[{pre, Prefix ++ [" = "] ++ R ++ Last}]
[{pre_pre, Prefix ++ [" = "] ++ R ++ Last}]
catch _:_ ->
%% Example: "t() = record(a)."
format_type(Prefix, Name, Type, Last, Opts#opts{pretty_printer =''})
end;
format_type(Prefix, _Name, Type, Last, _Opts) ->
[{pre, Prefix ++ [" = "] ++ t_utype(Type) ++ Last}].
[{pre_pre, Prefix ++ [" = "] ++ t_utype(Type) ++ Last}].

pp_type(Prefix, Type) ->
Atom = list_to_atom(lists:duplicate(iolist_size(Prefix), $a)),
Expand Down
5 changes: 5 additions & 0 deletions src/edown_xmerl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ rstrip(Str) -> re:replace(Str, "\\s\$", []).
%% for an example. (By default, we always generate the end tag, to make
%% sure that the scope of a markup is not extended by mistake.)

'#element#'('pre_pre', Data, Attrs, Parents, E) ->
'#element#'(pre, escape_pre(Data), Attrs, Parents, E);
'#element#'('pre', Data, Attrs, Parents, E) ->
xmerl_html:'#element#'('pre', Data, Attrs, Parents, E);
'#element#'('div', Data, _, _Parents, _E) ->
Expand Down Expand Up @@ -99,6 +101,9 @@ elem(Tag, Data, Attrs, Parents, E) ->
md_elem(Tag, Data, Attrs, Parents, E)
end.

escape_pre(Data) ->
re:replace(re:replace(Data, "<", "\\&lt;", [global]), ">", "\\&gt;", [global]).

alias_for(Tag, Data, Attrs, Parents, E) ->
xmerl_html:'#element#'(Tag, Data, Attrs, Parents, E#xmlElement{name = Tag}).

Expand Down

0 comments on commit 813c322

Please sign in to comment.