Hi again.
I read in documentation about the <!--more-->
:
Alternatively, you may add the
<!--more-->
summary divider where you want to split the article. Content prior to the summary divider will be used as that content’s summary, and stored into the.Summary
variable with all HTML formatting intact.
Well… seems like that isn’t completely exact.
First, it wont work with shortcodes. Like example, {{% figure parameters %}}
. If you use Markdown in title
or caption
parameter, it will simply ignore the format.
I needed to customize the figure
shortcode for really preserve the HTML formatting, using the markdownify
function:
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link" }}<a href="{{.}}">{{ end }}
<img alt="{{ with .Get "alt" }}{{.}}{{ end }}" src="{{ .Get "src" }}" />
{{ if .Get "link" }}</a>{{ end }}
{{ if or (.Get "title") (.Get "caption") }}
<figcaption>
{{ with .Get "title" }}<p class="title">{{.|markdownify}}</p>{{ end }}
{{ with .Get "caption" }}<div class="caption">{{.|markdownify}}</div>{{ end }}
</figcaption>
{{ end }}
</figure>
(not just because of that: I’m used to reStructuredText figure directive and wanted to achieved something similar [still on it]).
With that, I get my markdown in this shortcode correctly parsed almost always. Almost, because there is the second and main problem: “divided” markup.
I mean, like example, the use of reference links.
I like them, because the text seems more clear and tidy to me.
But when you write something like:
Bla bla bla bla [this is a link][this is their label]
bla bla bla [^1]
<!--more-->
[this is their label]: http://this-is-the-url.domain
[^1]: Text of the footnote
Well: you get a summary without your wanted HTML :(.
And yes: you can avoid this (even if is ugly) using normal links in the summary part, yeah.
But then, you notice the footnote is also broken. And this hasn’t an easy solution like the links problem. Well: you can also place the divider just before the footnote. But that’s you giving up your writing freedom, right?
I don’t know how hugo
works, but, if you want to create summaries retaining the HTML formating for real, shouldn’t you first convert markdown to HTML and, only after that, get the excerpt you want for summary?
The Markdown generates the right HTML (except the shortcode part, you still will need the markdownify
function) in full pages, so it seems that hugo
first get the excerpt and, later, converts it to HTML. And, because of that, you get this kind of markup broken.
It’s just me or this is a general problem?
Should I report a bug issue about this?
At the time being, I’m just trying to avoid this problems with the mentioned workarounds, but it doesn’t feel good >_<.
Thanks for your time!
hugo version
:
Hugo Static Site Generator v0.13 BuildDate: 2015-04-20T21:17:06+02:00