Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-11-29 15:40:08

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Excerpts with a leading space

I’m using this code to populate the meta description in <head>:

<meta name=“description” content=”<txp:if_individual_article><txp:if_excerpt><txp:rah_replace from=”<p>,</p>” to=”,”><txp:excerpt /></txp:rah_replace></txp:if_excerpt></txp:if_individual_article>” />

…and it outputs the (Textiled) excerpt with a leading space, regardless of whether there’s a leading space in the excerpt or not, like this:

<meta name=“description” content=” This is an excerpt”>

The space appears before the <p> tag, which I’ve zapped with rah_replace. If I disable Textile for excerpts, the leading space disappears and I don’t need to use rah_replace. On the grounds that I can’t enable Textile for body and disable it for excerpt (or can I?), I figure rah_replace can save the day. I’ve tried the following code to zap the leading space before the <p> (note the extra space before <p>):

<meta name=“description” content=”<txp:if_individual_article><txp:if_excerpt><txp:rah_replace from=” <p>,</p>” to=”,”><txp:excerpt /></txp:rah_replace></txp:if_excerpt></txp:if_individual_article>” />

…but that doesn’t pick up the leading space and this happens:

<meta name=“description” content=” <p>This is an excerpt”>

I understand Textile formatting can be circumvented by starting the paragraph with a leading space, but I don’t have one in this case.

Yours confused-ly,
Uncle Pete

Offline

#2 2012-11-29 15:48:12

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: Excerpts with a leading space

OK, so I can enable Textile for body and disable it for excerptupm_textile_toggle is where it’s at. My question about the leading space still stands — anomaly, intended behaviour or something else?

Last edited by gaekwad (2012-11-29 15:48:53)

Offline

#3 2012-11-29 17:03:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,172
Website GitHub Mastodon Twitter

Re: Excerpts with a leading space

You can also start the excerpt with a space which cancels the <p> tag. Also v4.5+ provides the possibility of non textiled excerpt

Last edited by colak (2012-11-29 17:04:57)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2012-11-29 17:05:12

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: Excerpts with a leading space

colak wrote:

You can also start the excerpt with a space which cancels the <p> tag

Thanks, Yiannis. Do you have any idea where the space might be coming from if I don’t start the excerpt with a space?

Offline

#5 2012-11-29 17:37:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,795
Website GitHub

Re: Excerpts with a leading space

gaekwad wrote:

Do you have any idea where the space might be coming from if I don’t start the excerpt with a space?

Hmmm, doesn’t for me if I turn Leave text untouched on for Excerpts (under Advanced options on the Write panel – shouldn’t need a plugin for this unless I’ve missed something). But with it being Textiled then yes, there’s a tab character before the opening <p> tag. Try zapping that character instead of a space.

However, if you use an opening space then it seems you’re damned in this context because the opening space that you use to disable Textile gets included in the content. Not good. Erm, yeah, ummm, not sure sound of feet rapidly disappearing into the distance

Last edited by Bloke (2012-11-29 18:30:38)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2012-11-29 18:40:13

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Excerpts with a leading space

gaekwad wrote:

OK, so I can enable Textile for body and disable it for excerptupm_textile_toggle is where it’s at.

You can do that without the plugin, under Advanced Options…

Offline

#7 2012-11-29 19:02:55

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Excerpts with a leading space

To be honest I would get too bothered about meta description, it’s going the way of meta keywords (I.e. redundant). I’m not including it at all any more.

If you’re using HTML5 doctype then I’d recommend learning about semantics and microdata instead. Google loves the microdata (since they helped create it).

Schema.org is a good place to start.

Offline

#8 2012-11-29 19:43:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,795
Website GitHub

Re: Excerpts with a leading space

philwareham wrote:

To be honest I would get too bothered about meta description, it’s going the way of meta keywords

True, but it doesn’t solve the annoying Textile tab-at-the-start thing. Never figured out why that’s there. Might see if I can debug it later if I get half an hour spare, but if it’s a feature of Textile instead of (as I suspect) the way Txp uses it, then it’ll need to be raised as an issue on the Textile development git repo. Will report here if I find anything either way.

Last edited by Bloke (2012-11-29 19:43:51)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2012-11-29 20:14:29

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Excerpts with a leading space

@bloke

If you’re looking into that space, the comments also take some weird spacing as noted in textpattern issue 303

Might be related, or at least fixable in the same way.

Offline

#10 2012-11-30 08:27:00

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Excerpts with a leading space

That indentation is a Textile feature. Certain block-level tags including paragraphs and lists are indented by tab characters.

During the development the indentation has gotten bit random tho, I have to admit. Not all blocks are indented, some spawn different amount of newlines and newlines do stack up, and where indentation is present, it isn’t inherited.

Anyhow, removing those tab characters doesn’t take more than search-n-replacing ‘\t’ from Textile’s source.

Offline

#11 2012-11-30 08:31:26

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Excerpts with a leading space

Does it need an issue raised on the Textile GitHub repo?

Offline

#12 2012-11-30 08:35:21

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Excerpts with a leading space

I don’t think it as a real issue, but if you want the behavior changed, then I would say yes. Textile is where the change would have to be made.

Last edited by Gocom (2012-11-30 08:35:55)

Offline

Board footer

Powered by FluxBB