PardallMarkdown.Content.HtmlUtils (PardallMarkdown v0.4.4) View Source
Link to this section Summary
Functions
Extract text from paragraphs </p>
of a HTML html
string,
and assemble a string up until it reaches expected_length
length.
Link to this section Functions
Extract text from paragraphs </p>
of a HTML html
string,
and assemble a string up until it reaches expected_length
length.
If the generated string length matches expected_length
, an ellipsis
will be appended to it. If the generated string is smaller than expected_length
,
then no ellipsis is added.
If no text could be extracted from the input html, returns nil.
Examples
iex> PardallMarkdown.Content.HtmlUtils.generate_summary_from_html("<h1>Post Title</h1><main><article><div><p>So, <a href='link'>a description</a> will be generated from it. Even a <span>nested span</span>.</p></div></article></main><p>As you can see, this a long paragraph outside.</p>This is <a name='anchor'>an anchor</a>.")
"So, a description will be generated from it. Even a nested span. As you can see, this a long paragraph outside."
iex> PardallMarkdown.Content.HtmlUtils.generate_summary_from_html("<h1>Post Title</h1><main><article><div><p>So, <a href='link'>a description</a> will be generated from it. Even a <span>nested span</span>.</p><p>Another paragraph?</p><p>Another paragraph 2?</p><p>Another paragraph 3?</p><p>As you can see, this a very long paragraph. As you can see, this a very long paragraph.</p></div></article></main>")
"So, a description will be generated from it. Even a nested span. Another paragraph? Another paragraph 2? Another paragraph 3? As you can see, this a very long..."