Commit 11956ad7 authored by Kaushal Modi's avatar Kaushal Modi

Add test case for whitespace chomping not working inside shortcodes

parent a3b7226c
......@@ -316,6 +316,48 @@ CLOSED: [2018-02-13 Tue 10:31]
:PROPERTIES:
:EXPORT_HUGO_SECTION: bugs
:END:
** DONE Whitespace chomping inside shortcodes :chomp:whitespace:shortcode:
CLOSED: [2018-04-23 Mon 08:46]
:PROPERTIES:
:EXPORT_FILE_NAME: whitespace-chomping-in-shortcodes
:END:
#+begin_description
Use of whitespace chomping braces in shortcodes.
#+end_description
[[https://discourse.gohugo.io/t/using-inner-still-adds-newlines/11679][Ref]]
*** Shortcode definition (=inner-chomp=)
#+include: ../layouts/shortcodes/inner-chomp.html :src go-html-template
*** Shortcode use
#+begin_src md
{{< inner-chomp >}}
Hello
{{< /inner-chomp >}}
#+end_src
{{< inner-chomp >}}
Hello
{{< /inner-chomp >}}
*** Expected HTML
#+begin_src html
<div>Hello</div>
#+end_src
*** Observed HTML
/View the source of this page and search for "Hello"./
#+begin_src html
<div>
Hello
</div>
#+end_src
*** Workaround
The workaround is to put the opening/closing shortcode identifiers on
the same line.
#+begin_src md
{{< inner-chomp >}}Workaround{{< /inner-chomp >}}
#+end_src
/View the source of this page and search for "Workaround"./
{{< inner-chomp >}}Workaround{{< /inner-chomp >}}
** DONE HTML entities in code blocks
CLOSED: [2017-12-21 Thu 11:35]
:PROPERTIES:
......
+++
title = "Whitespace chomping inside shortcodes"
author = ["Kaushal Modi"]
description = "Use of whitespace chomping braces in shortcodes."
date = 2018-04-23T08:46:00-04:00
tags = ["chomp", "whitespace", "shortcode"]
draft = false
creator = "Emacs 27.0.50 (Org mode 9.1.11 + ox-hugo)"
+++
[Ref](https://discourse.gohugo.io/t/using-inner-still-adds-newlines/11679)
## Shortcode definition (`inner-chomp`) {#shortcode-definition--inner-chomp}
```go-html-template
<div>{{- .Inner -}}</div>
```
## Shortcode use {#shortcode-use}
```md
{{</* inner-chomp */>}}
Hello
{{</* /inner-chomp */>}}
```
{{< inner-chomp >}}
Hello
{{< /inner-chomp >}}
## Expected HTML {#expected-html}
```html
<div>Hello</div>
```
## Observed HTML {#observed-html}
_View the source of this page and search for "Hello"._
```html
<div>
Hello
</div>
```
## Workaround {#workaround}
The workaround is to put the opening/closing shortcode identifiers on
the same line.
```md
{{</* inner-chomp */>}}Workaround{{</* /inner-chomp */>}}
```
_View the source of this page and search for "Workaround"._
{{< inner-chomp >}}Workaround{{< /inner-chomp >}}
<div>{{- .Inner -}}</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment