Current section
Files
Jump to
Current section
Files
src/lorem_ipsum@generator.erl
-module(lorem_ipsum@generator).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/lorem_ipsum/generator.gleam").
-export([generate/1, words/1, sentences/1, paragraphs/1]).
-file("src/lorem_ipsum/generator.gleam", 37).
-spec generate_words(lorem_ipsum@options:options()) -> binary().
generate_words(Options) ->
{options, Count, _, _, _, _, _, _, _, Words} = Options,
Word_count = erlang:length(Words),
case (Word_count =:= 0) orelse (Count =< 0) of
true ->
<<""/utf8>>;
false ->
_pipe = gleam@int:range(0, Count, [], fun gleam@list:prepend/2),
_pipe@1 = lists:reverse(_pipe),
_pipe@2 = gleam@list:map(
_pipe@1,
fun(I) ->
Index = lorem_ipsum@sequence:pseudo_index(I, Word_count),
Word = case lorem_ipsum@sequence:list_index(Words, Index) of
{ok, W} ->
W;
{error, _} ->
<<""/utf8>>
end,
Word
end
),
gleam@string:join(_pipe@2, <<" "/utf8>>)
end.
-file("src/lorem_ipsum/generator.gleam", 162).
-spec wrap_paragraphs_html(binary()) -> binary().
wrap_paragraphs_html(Text) ->
_pipe = Text,
_pipe@1 = gleam@string:split(_pipe, <<"\n"/utf8>>),
_pipe@2 = gleam@list:map(
_pipe@1,
fun(P) -> <<<<"<p>"/utf8, P/binary>>/binary, "</p>"/utf8>> end
),
gleam@string:join(_pipe@2, <<"\n"/utf8>>).
-file("src/lorem_ipsum/generator.gleam", 154).
-spec wrap_html(lorem_ipsum@options:options(), binary()) -> binary().
wrap_html(Options, Text) ->
case Options of
{options, _, paragraphs, _, _, _, _, _, _, _} ->
wrap_paragraphs_html(Text);
{options, _, sentences, _, _, _, _, _, _, _} ->
<<<<"<p>"/utf8, Text/binary>>/binary, "</p>"/utf8>>;
{options, _, words, _, _, _, _, _, _, _} ->
<<<<"<span>"/utf8, Text/binary>>/binary, "</span>"/utf8>>
end.
-file("src/lorem_ipsum/generator.gleam", 169).
-spec capitalise_first(binary()) -> binary().
capitalise_first(Text) ->
case gleam@string:to_graphemes(Text) of
[] ->
<<""/utf8>>;
[First | Rest] ->
<<(string:uppercase(First))/binary,
(gleam@string:join(Rest, <<""/utf8>>))/binary>>
end.
-file("src/lorem_ipsum/generator.gleam", 59).
-spec generate_sentences(lorem_ipsum@options:options()) -> binary().
generate_sentences(Options) ->
{options, Count, _, _, _, _, Min_words, Max_words, _, _} = Options,
case Count =< 0 of
true ->
<<""/utf8>>;
false ->
_pipe = gleam@int:range(0, Count, [], fun gleam@list:prepend/2),
_pipe@1 = lists:reverse(_pipe),
_pipe@4 = gleam@list:map(
_pipe@1,
fun(I) ->
Length = lorem_ipsum@sequence:bounded(
I,
Min_words,
Max_words
),
Sentence_options = case Options of
{options,
_,
_,
Format,
Paragraph_lower_bound,
Paragraph_upper_bound,
_,
_,
Suffix,
Words} ->
{options,
Length,
words,
Format,
Paragraph_lower_bound,
Paragraph_upper_bound,
Min_words,
Max_words,
Suffix,
Words}
end,
Sentence = begin
_pipe@2 = Sentence_options,
_pipe@3 = generate_words(_pipe@2),
capitalise_first(_pipe@3)
end,
<<Sentence/binary, "."/utf8>>
end
),
gleam@string:join(_pipe@4, <<" "/utf8>>)
end.
-file("src/lorem_ipsum/generator.gleam", 108).
-spec generate_paragraphs(lorem_ipsum@options:options()) -> binary().
generate_paragraphs(Options) ->
{options, Count, _, _, Min_sentences, Max_sentences, _, _, _, _} = Options,
case Count =< 0 of
true ->
<<""/utf8>>;
false ->
_pipe = gleam@int:range(0, Count, [], fun gleam@list:prepend/2),
_pipe@1 = lists:reverse(_pipe),
_pipe@2 = gleam@list:map(
_pipe@1,
fun(I) ->
Length = lorem_ipsum@sequence:bounded(
I,
Min_sentences,
Max_sentences
),
Paragraph_options = case Options of
{options,
_,
_,
Format,
_,
_,
Min_words,
Max_words,
Suffix,
Words} ->
{options,
Length,
sentences,
Format,
Min_sentences,
Max_sentences,
Min_words,
Max_words,
Suffix,
Words}
end,
generate_sentences(Paragraph_options)
end
),
gleam@string:join(_pipe@2, case Options of
{options, _, _, _, _, _, _, _, Suffix@1, _} ->
Suffix@1
end)
end.
-file("src/lorem_ipsum/generator.gleam", 7).
-spec generate(lorem_ipsum@options:options()) -> binary().
generate(Options) ->
Text = case Options of
{options, _, words, _, _, _, _, _, _, _} ->
generate_words(Options);
{options, _, sentences, _, _, _, _, _, _, _} ->
generate_sentences(Options);
{options, _, paragraphs, _, _, _, _, _, _, _} ->
generate_paragraphs(Options)
end,
Formatter = case Options of
{options, _, _, plain, _, _, _, _, _, _} ->
fun(X) -> X end;
{options, _, _, html, _, _, _, _, _, _} ->
fun(X@1) -> wrap_html(Options, X@1) end
end,
Formatter(Text).
-file("src/lorem_ipsum/generator.gleam", 22).
-spec words(integer()) -> binary().
words(Count) ->
_pipe = lorem_ipsum@options:with_count_and_units(
{options,
1,
sentences,
plain,
3,
7,
5,
15,
<<"\n"/utf8>>,
[<<"lorem"/utf8>>,
<<"ipsum"/utf8>>,
<<"dolor"/utf8>>,
<<"sit"/utf8>>,
<<"amet"/utf8>>,
<<"consectetur"/utf8>>,
<<"adipiscing"/utf8>>,
<<"elit"/utf8>>,
<<"sed"/utf8>>,
<<"do"/utf8>>,
<<"eiusmod"/utf8>>,
<<"tempor"/utf8>>,
<<"incididunt"/utf8>>,
<<"ut"/utf8>>,
<<"labore"/utf8>>,
<<"et"/utf8>>,
<<"dolore"/utf8>>,
<<"magna"/utf8>>,
<<"aliqua"/utf8>>,
<<"ut"/utf8>>,
<<"enim"/utf8>>,
<<"ad"/utf8>>,
<<"minim"/utf8>>,
<<"veniam"/utf8>>,
<<"quis"/utf8>>,
<<"nostrud"/utf8>>,
<<"exercitation"/utf8>>,
<<"ullamco"/utf8>>,
<<"laboris"/utf8>>,
<<"nisi"/utf8>>,
<<"ut"/utf8>>,
<<"aliquip"/utf8>>,
<<"ex"/utf8>>,
<<"ea"/utf8>>,
<<"commodo"/utf8>>,
<<"consequat"/utf8>>,
<<"duis"/utf8>>,
<<"aute"/utf8>>,
<<"irure"/utf8>>,
<<"dolor"/utf8>>,
<<"in"/utf8>>,
<<"reprehenderit"/utf8>>,
<<"in"/utf8>>,
<<"voluptate"/utf8>>,
<<"velit"/utf8>>,
<<"esse"/utf8>>,
<<"cillum"/utf8>>,
<<"dolore"/utf8>>,
<<"eu"/utf8>>,
<<"fugiat"/utf8>>,
<<"nulla"/utf8>>,
<<"pariatur"/utf8>>,
<<"excepteur"/utf8>>,
<<"sint"/utf8>>,
<<"occaecat"/utf8>>,
<<"cupidatat"/utf8>>,
<<"non"/utf8>>,
<<"proident"/utf8>>,
<<"sunt"/utf8>>,
<<"in"/utf8>>,
<<"culpa"/utf8>>,
<<"qui"/utf8>>,
<<"officia"/utf8>>,
<<"deserunt"/utf8>>,
<<"mollit"/utf8>>,
<<"anim"/utf8>>,
<<"id"/utf8>>,
<<"est"/utf8>>,
<<"laborum"/utf8>>]},
Count,
words
),
generate(_pipe).
-file("src/lorem_ipsum/generator.gleam", 27).
-spec sentences(integer()) -> binary().
sentences(Count) ->
_pipe = lorem_ipsum@options:with_count_and_units(
{options,
1,
sentences,
plain,
3,
7,
5,
15,
<<"\n"/utf8>>,
[<<"lorem"/utf8>>,
<<"ipsum"/utf8>>,
<<"dolor"/utf8>>,
<<"sit"/utf8>>,
<<"amet"/utf8>>,
<<"consectetur"/utf8>>,
<<"adipiscing"/utf8>>,
<<"elit"/utf8>>,
<<"sed"/utf8>>,
<<"do"/utf8>>,
<<"eiusmod"/utf8>>,
<<"tempor"/utf8>>,
<<"incididunt"/utf8>>,
<<"ut"/utf8>>,
<<"labore"/utf8>>,
<<"et"/utf8>>,
<<"dolore"/utf8>>,
<<"magna"/utf8>>,
<<"aliqua"/utf8>>,
<<"ut"/utf8>>,
<<"enim"/utf8>>,
<<"ad"/utf8>>,
<<"minim"/utf8>>,
<<"veniam"/utf8>>,
<<"quis"/utf8>>,
<<"nostrud"/utf8>>,
<<"exercitation"/utf8>>,
<<"ullamco"/utf8>>,
<<"laboris"/utf8>>,
<<"nisi"/utf8>>,
<<"ut"/utf8>>,
<<"aliquip"/utf8>>,
<<"ex"/utf8>>,
<<"ea"/utf8>>,
<<"commodo"/utf8>>,
<<"consequat"/utf8>>,
<<"duis"/utf8>>,
<<"aute"/utf8>>,
<<"irure"/utf8>>,
<<"dolor"/utf8>>,
<<"in"/utf8>>,
<<"reprehenderit"/utf8>>,
<<"in"/utf8>>,
<<"voluptate"/utf8>>,
<<"velit"/utf8>>,
<<"esse"/utf8>>,
<<"cillum"/utf8>>,
<<"dolore"/utf8>>,
<<"eu"/utf8>>,
<<"fugiat"/utf8>>,
<<"nulla"/utf8>>,
<<"pariatur"/utf8>>,
<<"excepteur"/utf8>>,
<<"sint"/utf8>>,
<<"occaecat"/utf8>>,
<<"cupidatat"/utf8>>,
<<"non"/utf8>>,
<<"proident"/utf8>>,
<<"sunt"/utf8>>,
<<"in"/utf8>>,
<<"culpa"/utf8>>,
<<"qui"/utf8>>,
<<"officia"/utf8>>,
<<"deserunt"/utf8>>,
<<"mollit"/utf8>>,
<<"anim"/utf8>>,
<<"id"/utf8>>,
<<"est"/utf8>>,
<<"laborum"/utf8>>]},
Count,
sentences
),
generate(_pipe).
-file("src/lorem_ipsum/generator.gleam", 32).
-spec paragraphs(integer()) -> binary().
paragraphs(Count) ->
_pipe = lorem_ipsum@options:with_count_and_units(
{options,
1,
sentences,
plain,
3,
7,
5,
15,
<<"\n"/utf8>>,
[<<"lorem"/utf8>>,
<<"ipsum"/utf8>>,
<<"dolor"/utf8>>,
<<"sit"/utf8>>,
<<"amet"/utf8>>,
<<"consectetur"/utf8>>,
<<"adipiscing"/utf8>>,
<<"elit"/utf8>>,
<<"sed"/utf8>>,
<<"do"/utf8>>,
<<"eiusmod"/utf8>>,
<<"tempor"/utf8>>,
<<"incididunt"/utf8>>,
<<"ut"/utf8>>,
<<"labore"/utf8>>,
<<"et"/utf8>>,
<<"dolore"/utf8>>,
<<"magna"/utf8>>,
<<"aliqua"/utf8>>,
<<"ut"/utf8>>,
<<"enim"/utf8>>,
<<"ad"/utf8>>,
<<"minim"/utf8>>,
<<"veniam"/utf8>>,
<<"quis"/utf8>>,
<<"nostrud"/utf8>>,
<<"exercitation"/utf8>>,
<<"ullamco"/utf8>>,
<<"laboris"/utf8>>,
<<"nisi"/utf8>>,
<<"ut"/utf8>>,
<<"aliquip"/utf8>>,
<<"ex"/utf8>>,
<<"ea"/utf8>>,
<<"commodo"/utf8>>,
<<"consequat"/utf8>>,
<<"duis"/utf8>>,
<<"aute"/utf8>>,
<<"irure"/utf8>>,
<<"dolor"/utf8>>,
<<"in"/utf8>>,
<<"reprehenderit"/utf8>>,
<<"in"/utf8>>,
<<"voluptate"/utf8>>,
<<"velit"/utf8>>,
<<"esse"/utf8>>,
<<"cillum"/utf8>>,
<<"dolore"/utf8>>,
<<"eu"/utf8>>,
<<"fugiat"/utf8>>,
<<"nulla"/utf8>>,
<<"pariatur"/utf8>>,
<<"excepteur"/utf8>>,
<<"sint"/utf8>>,
<<"occaecat"/utf8>>,
<<"cupidatat"/utf8>>,
<<"non"/utf8>>,
<<"proident"/utf8>>,
<<"sunt"/utf8>>,
<<"in"/utf8>>,
<<"culpa"/utf8>>,
<<"qui"/utf8>>,
<<"officia"/utf8>>,
<<"deserunt"/utf8>>,
<<"mollit"/utf8>>,
<<"anim"/utf8>>,
<<"id"/utf8>>,
<<"est"/utf8>>,
<<"laborum"/utf8>>]},
Count,
paragraphs
),
generate(_pipe).