mmistakes / minimal-mistakes

:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.
https://mmistakes.github.io/minimal-mistakes/
MIT License
12.4k stars 25.56k forks source link

Make splash excerpt honor line breaks #1746

Closed jbshirk closed 6 years ago

jbshirk commented 6 years ago

Description

my landing page is thus:

---
layout: splash
classes: landing
author_profile: false
excerpt : |+
  We do **complete property services** 

  from design to installation and maintenance

  including beautiful landscapes  and water features 

and I see that the layout is defined thus:

---
layout: default

---

{% if page.header.overlay_color or page.header.overlay_image or page.header.image %}
  {% include page__hero.html %}
{% elsif page.header.video.id and page.header.video.provider %}
  {% include page__hero_video.html %}
{% endif %}

<div id="main" role="main">
  <article class="splash" itemscope itemtype="http://schema.org/CreativeWork">
    {% if page.title %}<meta itemprop="headline" content="{{ page.title | markdownify | strip_html | strip_newlines | escape_once }}">{% endif %}
    {% if page.excerpt %}<meta itemprop="description" content="{{ page.excerpt | markdownify | strip_html  | escape_once }}">{% endif %} 

Environment

theme version: 4.11.2 Jekyll version: 3.8.3 public git repository:
hosting with GitHub Pages: no Operating system you tested with: OSX 10.12.6


Expected behavior

The intention is for the \n\n to be interpreted as markdown line breaks. I've tried removing | strip_html - to no effect. I think I must be misusing this.

Steps to reproduce the behavior

Then provide a complete log by running bundle exec jekyll build --trace --verbose

  Logging at level: debug
Configuration file: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_config.yml
             Theme: minimal-mistakes-jekyll
      Theme source: /Users/joe/.rvm/gems/ruby-2.4.2/gems/minimal-mistakes-jekyll-4.11.2
         Requiring: jekyll-paginate
         Requiring: jekyll-sitemap
         Requiring: jekyll-gist
         Requiring: jekyll-feed
         Requiring: jekyll-data
         Requiring: jemoji
         Requiring: jekyll-paginate
         Requiring: jekyll-sitemap
         Requiring: jekyll-gist
         Requiring: jekyll-feed
         Requiring: jemoji
            Source: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com
       Destination: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       EntryFilter: excluded /docs
       EntryFilter: excluded /Gemfile
       EntryFilter: excluded /Gemfile.lock
       EntryFilter: excluded /LICENSE.txt
       EntryFilter: excluded /package.json
       EntryFilter: excluded /Rakefile
       EntryFilter: excluded /README.md
       EntryFilter: excluded /test
       EntryFilter: excluded /assets/images/DAquaTerra Full Page Ad.pdf
       EntryFilter: excluded /assets/js/plugins
       EntryFilter: excluded /assets/js/vendor
             Theme: Ignoring assets/css/main.scss in theme due to existing file with that path in site.
             Theme: Ignoring assets/js/lunr/lunr-en.js in theme due to existing file with that path in site.
             Theme: Ignoring assets/js/lunr/lunr-gr.js in theme due to existing file with that path in site.
             Theme: Ignoring assets/js/lunr/lunr-store.js in theme due to existing file with that path in site.
             Theme: Ignoring /assets/js/lunr/lunr.js in theme due to existing file with that path in site.
             Theme: Ignoring /assets/js/lunr/lunr.min.js in theme due to existing file with that path in site.
             Theme: Ignoring /assets/js/main.min.js in theme due to existing file with that path in site.

           Reading: Theme Data Files...
                    /Users/joe/.rvm/gems/ruby-2.4.2/gems/minimal-mistakes-jekyll-4.11.2/_data/navigation.yml
                    /Users/joe/.rvm/gems/ruby-2.4.2/gems/minimal-mistakes-jekyll-4.11.2/_data/ui-text.yml

           Merging: Theme Data Hash...
                    use --show-data with --verbose to output merged Data Hash.

        Generating: JekyllFeed::Generator finished in 0.021005 seconds.
        Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination.
        Generating: Jekyll::Paginate::Pagination finished in 0.000424 seconds.
        Generating: Jekyll::JekyllSitemap finished in 0.001158 seconds.
         Rendering: about-authors.md
  Pre-Render Hooks: about-authors.md
  Rendering Markup: about-authors.md
  Rendering Layout: about-authors.md
     Layout source: site
         Rendering: about-feature-rows-table.md
  Pre-Render Hooks: about-feature-rows-table.md
  Rendering Liquid: about-feature-rows-table.md
  Rendering Markup: about-feature-rows-table.md
  Rendering Layout: about-feature-rows-table.md
     Layout source: site
         Rendering: about-feature-rows.md
  Pre-Render Hooks: about-feature-rows.md
  Rendering Liquid: about-feature-rows.md
  Rendering Markup: about-feature-rows.md
  Rendering Layout: about-feature-rows.md
     Layout source: site
         Rendering: about-feature.md
  Pre-Render Hooks: about-feature.md
  Rendering Liquid: about-feature.md
  Rendering Markup: about-feature.md
  Rendering Layout: about-feature.md
     Layout source: site
         Rendering: about-gallery.md
  Pre-Render Hooks: about-gallery.md
  Rendering Liquid: about-gallery.md
  Rendering Markup: about-gallery.md
  Rendering Layout: about-gallery.md
     Layout source: site
         Rendering: about-images.md
  Pre-Render Hooks: about-images.md
  Rendering Liquid: about-images.md
  Rendering Markup: about-images.md
  Rendering Layout: about-images.md
     Layout source: site
         Rendering: about-img.md
  Pre-Render Hooks: about-img.md
  Rendering Markup: about-img.md
  Rendering Layout: about-img.md
     Layout source: site
         Rendering: about-sidebar.md
  Pre-Render Hooks: about-sidebar.md
  Rendering Markup: about-sidebar.md
  Rendering Layout: about-sidebar.md
         Rendering: contact.md
  Pre-Render Hooks: contact.md
  Rendering Markup: contact.md
  Rendering Layout: contact.md
         Rendering: index.md
  Pre-Render Hooks: index.md
  Rendering Liquid: index.md
  Rendering Markup: index.md
  Rendering Layout: index.md
     Layout source: site
         Rendering: assets/js/lunr/lunr-en.js
  Pre-Render Hooks: assets/js/lunr/lunr-en.js
  Rendering Liquid: assets/js/lunr/lunr-en.js
  Rendering Markup: assets/js/lunr/lunr-en.js
  Rendering Layout: assets/js/lunr/lunr-en.js
         Rendering: assets/js/lunr/lunr-gr.js
  Pre-Render Hooks: assets/js/lunr/lunr-gr.js
  Rendering Liquid: assets/js/lunr/lunr-gr.js
  Rendering Markup: assets/js/lunr/lunr-gr.js
  Rendering Layout: assets/js/lunr/lunr-gr.js
         Rendering: assets/js/lunr/lunr-store.js
  Pre-Render Hooks: assets/js/lunr/lunr-store.js
  Rendering Liquid: assets/js/lunr/lunr-store.js
  Rendering Markup: assets/js/lunr/lunr-store.js
  Rendering Layout: assets/js/lunr/lunr-store.js
         Rendering: assets/css/main.scss
  Pre-Render Hooks: assets/css/main.scss
  Rendering Liquid: assets/css/main.scss
  Rendering Markup: assets/css/main.scss
         Rendering: portfolio-archive.md
  Pre-Render Hooks: portfolio-archive.md
  Rendering Markup: portfolio-archive.md
  Rendering Layout: portfolio-archive.md
     Layout source: site
         Rendering: feed.xml
  Pre-Render Hooks: feed.xml
  Rendering Liquid: feed.xml
  Rendering Markup: feed.xml
  Rendering Layout: feed.xml
         Rendering: sitemap.xml
  Pre-Render Hooks: sitemap.xml
  Rendering Liquid: sitemap.xml
  Rendering Markup: sitemap.xml
  Rendering Layout: sitemap.xml
         Rendering: robots.txt
  Pre-Render Hooks: robots.txt
  Rendering Liquid: robots.txt
  Rendering Markup: robots.txt
  Rendering Layout: robots.txt
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/about-authors/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/about-feature-rows-table/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/about-feature-rows/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/about-feature/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/about-gallery/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/about-images/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/about-img/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/about-sidebar/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/contact/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/assets/js/lunr/lunr-en.js
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/assets/js/lunr/lunr-gr.js
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/assets/js/lunr/lunr-store.js
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/assets/css/main.css
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/portfolio/index.html
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/feed.xml
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/sitemap.xml
           Writing: /Users/joe/Sites/GitHub/jekyll/DAquaTerra.com/_site/robots.txt
                    done in 7.014 seconds.

Screenshots can also be included if they help illustrate a behavior.

screen shot 2018-07-12 at 6 58 37 pm

mmistakes commented 6 years ago

If you open up /_includes/page__hero.html there's this line:

<p class="page__lead">{{ page.excerpt | markdownify | remove: "<p>" | remove: "</p>" }}</p>

What's going on is page.excerpt is inserted inside of a paragraph tag and Kramdown is interpreting the line breaks as new paragraphs... which are then removed with the two filters.

So what you can do is change that wrapping <p class="page__lead">...</p> to maybe <div class="page__lead">...</div> and take out the | remove: "<p>" | remove: "</p>" filters.

A simpler way would be to do what I did with the doc site's splash page and use <br>s to force breaks.

excerpt: |
  We do **complete property services** 
  <br>
  from design to installation and maintenance
  <br>
  including beautiful landscapes and water features 
jbshirk commented 6 years ago

Super! Thank you very much!

jbshirk commented 6 years ago

Note for posterity:

I took the second option to avoid munging the functionality of other splash pages. I found that I had to also take away the plus after the pipe. This works exactly as desired:

excerpt : |
  We provide **complete** property services <br />

  including beautiful landscapes and water features <br />

  <ul class="page__lead"> <li>Design</li><li>Installation</li><li>Maintenance</li></ul>
mmistakes commented 6 years ago

Yeah I noticed your +, I took it out in my code above. excerpt: > also seems to work instead of the pipe.