Comments (12)
Interesting, I'm not sure where that preserve option comes from, then,
because I've seen it around Refinery before... thanks for highlighting this
I am in the process of integrating a syntax highlighter and noticed that
line breaks and whitespace was not preserved on the index page of the blog.
I was mainly concerned for the content within "pre" and "code" tags. The
show page seemed to render fine.I traced it back to the teaser helper:
def blog_post_teaser(post)
if post.respond_to?(:custom_teaser) && post.custom_teaser.present?
post.custom_teaser.html_safe
else
truncate(post.body, {
:length => RefinerySetting.find_or_set(:blog_post_teaser_length,
250),
:preserve_html_tags => true
}).html_safe
end
endIt seems that the truncate method is not preserving html properly. I had a
look at the rails api and I couldn't find a method to support the
:preserve_html_tags being passed. In addition, the truncate method states
in the documentation
that it does not preserve valid html.Does the blog use another custom truncate method to preserve tags? Is this
a valid option? Perhaps something like this would be better?Thanks!
Reply to this email directly or view it on GitHub:
https://github.com/resolve/refinerycms-blog/issues/98
from refinerycms-blog.
Refinery uses this plugin https://github.com/hgimenez/truncate_html and here's Refinery helper https://github.com/resolve/refinerycms/blob/master/core/lib/refinery/helpers/html_truncation_helper.rb which uses that plugin.
from refinerycms-blog.
I believe that might be the same one I found earlier. Any idea why
whitespace and line breaks are removed?
On Thu, Jul 7, 2011 at 2:22 PM, ugisozols <
[email protected]>wrote:
Refinery uses this plugin https://github.com/hgimenez/truncate_html and
here's Refinery helper
https://github.com/resolve/refinerycms/blob/master/core/lib/refinery/helpers/html_truncation_helper.rbwhich uses that plugin.Reply to this email directly or view it on GitHub:
https://github.com/resolve/refinerycms-blog/issues/98#issuecomment-1524859
from refinerycms-blog.
By taking a quick look at truncate_html specs https://github.com/hgimenez/truncate_html/blob/master/spec/truncate_html/html_string_spec.rb#L10-16 it's clear that removing continuous whitespace is intended behavior.
Dunno about line breaks as I haven't looked any further yet.
from refinerycms-blog.
@joemsak @ugisozols @astjohn status?
from refinerycms-blog.
@parndt, as ugisozois has pointed out, whitespace is intentionally removed by the truncate_html gem. This effectively breaks the ability to use code and pre blocks.
For my own personal use, I have since disabled the teaser functionality. Either refinerycms-blog will have to roll it's own solution, or the gem will have to perhaps add an option to preserve whitespace. Unfortunately, I don't have time at the moment to contribute.
from refinerycms-blog.
I haven't looked into this issue any further... should I?
from refinerycms-blog.
@ugisozols sure if you like, the best option might be to contribute a patch to truncate_html that allows an option for preserving whitespace.
from refinerycms-blog.
Any failing test would do too
from refinerycms-blog.
@astjohn how do you disable teasers?
from refinerycms-blog.
@budu, Unfortunately, it's been a while and I have moved away from refinery. At the time, I believe I ended up removing anything that would have rendered them while I customized the views. Not ideal.
from refinerycms-blog.
I think an acceptable workaround is to enter content into the custom_teaser
field :-)
from refinerycms-blog.
Related Issues (20)
- Error when trying to upgrade HOT 1
- Friendly urls are not generated on save HOT 8
- 'refinery_settings' already exists HOT 2
- Compatibility with Rails 5.2 HOT 4
- Updating to jquery-ui v6 HOT 1
- Upgrading to version 4 resulted in list of authors to no longer be available from the Posts form
- Log production HOT 5
- Installation breaks base install of refinerycms HOT 8
- Bundle take too loog time to work. HOT 4
- refinerycms-wymeditor not work HOT 2
- Don't release the version >= 4.0.0
- Fix N + 1 for Refinery::Blog::Post.live HOT 5
- [Bug: feature/refinery-5] Can no visit the posts management page
- Travis CI fails with job exceeded max time limit HOT 1
- query-ui/widgets/autocomplete not found HOT 3
- Disable RSS Feed HOT 2
- Failing to install HOT 3
- uninitialized constant Refinery::Application (NameError)
- Dependabot can't resolve your Ruby dependency files
- is this gem still maintained?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refinerycms-blog.