Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about comments #170

Open
borkdude opened this issue Jan 18, 2018 · 4 comments
Open

Question about comments #170

borkdude opened this issue Jan 18, 2018 · 4 comments

Comments

@borkdude
Copy link
Contributor

borkdude commented Jan 18, 2018

I have a template like:

PMID- {{pmid}}
OWN - {{own}}
{# STAT- In-Process #}

The line with the comment {# STAT- In-Process #} gets rendered as a newline. Can I prevent this while still keeping it at its own line?

@yogthos
Copy link
Owner

yogthos commented Jan 18, 2018

Unfortunately not, it's something I've been wanting to add for a while. This feature would require updating the read-tag-content function to be smarter to consume the new line if it follows the tag. This should happen only in a case where the line consists of just the tag itself.

@yogthos
Copy link
Owner

yogthos commented Jan 18, 2018

I guess the requirement would be as follows. If a tag is on a blank line, and it does not produce output, then it should be removed. So, you'd have to check that the only content before the tag and after the last new line character consists of spaces, and the type of tag that was created. A better place to handle that might be here.

@aviflax
Copy link
Contributor

aviflax commented Mar 4, 2020

FWIW, Shopify’s template system, Liquid (with which I’m familiar because it’s built in to Jekyll), has a more explicit but less elegant mechanism:

In Liquid, you can include a hyphen in your tag syntax {{-, -}}, {%-, and -%} to strip whitespace from the left or right side of a rendered tag.

I’d love to see some solution to this ship with the library.

For now, FWIW, I’m running my output through this naive, brittle, hacky function:

(defn reduce-whitespace
  [s]
  (str/replace s #"\n\s+\n" "\n"))

@yogthos
Copy link
Owner

yogthos commented Mar 4, 2020

Using a hyphen to indicate that the whitespace around the tag should be stripped out actually doesn't sound terrible. I wouldn't have time to look at this in the near future, but I would be open to a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants