Improve markup determination logic

Sets Page.markup earlier (as early as possible, when the page is
loaded). Sets it once and only once, removing many redundant calls
to determineMarkupType().

This kills a sleeping bug that was avoided by the parts of the
code depending on this value making those redundant calls.
This commit is contained in:
Vas Sudanagunta 2018-05-04 20:17:16 -04:00 committed by Bjørn Erik Pedersen
parent 00e36a4164
commit 2fb9af59c1
2 changed files with 12 additions and 16 deletions

View file

@ -314,7 +314,8 @@ func renderShortcode(
if sc.doMarkup {
newInner := p.s.ContentSpec.RenderBytes(&helpers.RenderingContext{
Content: []byte(inner), PageFmt: p.determineMarkupType(),
Content: []byte(inner),
PageFmt: p.Markup,
Cfg: p.Language(),
DocumentID: p.UniqueID(),
DocumentName: p.Path(),
@ -333,7 +334,7 @@ func renderShortcode(
// substitutions in <div>HUGOSHORTCODE-1</div> which prevents the
// generation, but means that you cant use shortcodes inside of
// markdown structures itself (e.g., `[foo]({{% ref foo.md %}})`).
switch p.determineMarkupType() {
switch p.Markup {
case "unknown", "markdown":
if match, _ := regexp.MatchString(innerNewlineRegexp, inner); !match {
cleaner, err := regexp.Compile(innerCleanupRegexp)