Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-10-17 17:58:48

mazso
Member
Registered: 2005-09-29
Posts: 25

Textile: change single/double openings/closings

In former version of Textpattern it was quite easy to change single/double openings/closings from “ to „ (just to give an example). Just modify in classTextile.php this part

<code>
$glyph_replace = array(‘$1’$2’, // single closing
‘‘’, // single opening
‘$1”’, // double closing
‘“’, // double opening
</code>

according to your needs.

In Textpattern 4.0.4. the code was a little bit modified. The above snippet now looks like this:

<code>
$glyph_replace = array(
‘$1’.$txt_apostrophe.’$2’, // apostrophe’s
‘$1’.$txt_apostrophe.’$2’, // back in ’88
‘$1’.$txt_quote_single_close, // single closing
$txt_quote_single_open, // single opening
‘$1’.$txt_quote_double_close, // double closing
$txt_quote_double_open, // double opening
</code>

This could be hacked in the above mentioned way: But I think it would be better to alter the $txt_qotes_… But where can I find them?

Mazso

(Edit: modified thread subject for clarity. -Mary)

Last edited by Mary (2006-10-18 03:12:20)

Offline

#2 2006-10-17 21:20:44

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Textile: change single/double openings/closings

The define() calls near the top.


Alex

Offline

#3 2006-10-18 07:07:24

mazso
Member
Registered: 2005-09-29
Posts: 25

Re: Textile: change single/double openings/closings

Oups. I should use alt+f.

Thank you, Zem.

Mazso

Offline

#4 2006-10-18 14:05:54

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Textile: change single/double openings/closings

If you have a working hack or hdiff exemple, I think that would be nice for a lot of people :)

Offline

#5 2006-10-18 15:06:19

mazso
Member
Registered: 2005-09-29
Posts: 25

Re: Textile: change single/double openings/closings

Sure, Jeremie,

Textile uses english (or american) openings and closings. Thats ist much better then the inch-sign (“), you can often see on webpages.

The english openings looking like this:

“Did you see ‘American Splendour’? It’s a great movie.”

The german typography goes like this

„Did you see ‚American Splendour‘? It’s a great movie.“

There are other versions for french and so on but the principle to alter the openings remains the same:

Open the classTextile.php in textpattern/lib

In version 4.0.4. you will find this starting with line #196

<code>
define('txt_quote_single_open', '‘'); define(‘txt_quote_single_close’, ‘’’);
define('txt_quote_double_open', '“'); define(‘txt_quote_double_close’, ‘”’);
</txp:code>

Oups: I didn’t want to display the glyphs but the HTML-entities. The ‘ for example ist number #8216

Change them to:

<code>@
define('txt_quote_single_open', '‚'); define(‘txt_quote_single_close’, ‘‘’);
define('txt_quote_double_open', '„'); define(‘txt_quote_double_close’, ‘“’);
@</code>

There is another thing I hacked at the classTextile.php. I wanted to replace the acronym-element – AFAIK it will be dropped in future version of XHTML/HTML – with abbr. And it should work on two-letter-words and on small-letter-words.

You have to change these two lines:

<code>
‘/\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/’, // 3+ uppercase
.
.
.
<acronym title=”$2”>$1</acronym>
</code>

to

<code>
‘/\b([a-zA-Z][a-zA-Z0-9]{1,})\b(?:[(]([^)]*)[)])/’, // abbr
.
.
.
<abbr title=”$2”>$1</abbr>
</code>

Mazso

Last edited by mazso (2006-10-18 15:18:41)

Offline

#6 2006-10-21 06:48:17

wordgasm
Member
Registered: 2006-05-17
Posts: 83
Website

Re: Textile: change single/double openings/closings

is it possible to not to have them " and ' translated into “quotation marks” and ‘apostrophes’ throughout all the articles?

Offline

#7 2006-10-21 08:07:21

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Textile: change single/double openings/closings

Open up textpattern/lib/classTextile.php, scroll to line 191, and replace these:

@define('txt_quote_single_open',  '&#8216;');
@define('txt_quote_single_close', '&#8217;');
@define('txt_quote_double_open',  '&#8220;');
@define('txt_quote_double_close', '&#8221;');
@define('txt_apostrophe',         '&#8217;');
@define('txt_ellipsis',           '&#8230;');

with these:

@define('txt_quote_single_open',  "'");
@define('txt_quote_single_close', "'");
@define('txt_quote_double_open',  '"');
@define('txt_quote_double_close', '"');
@define('txt_apostrophe',  "'");
@define('txt_ellipsis', '...');

(I added ellipsis because of your related thread.)

Offline

#8 2006-10-21 17:59:14

wordgasm
Member
Registered: 2006-05-17
Posts: 83
Website

Re: Textile: change single/double openings/closings

thank you mary.:) Just in case someone wants to do the same

I changed those on line 191 of classtextile.php to this:

<pre>
<code>
define('txt_quote_single_open', '&apos;'); define(‘txt_quote_single_close’, ‘&apos;’);
define('txt_quote_double_open', '&quot;'); define(‘txt_quote_double_close’, ‘&quot;’);
define('txt_apostrophe', '&apos;'); define(‘txt_ellipsis’, ‘&period;&period;&period;’);
</code>
</pre>

And ran this on the SQL database:

<pre>
<code>
UPDATE textpattern SET Body_html = REPLACE;
UPDATE textpattern SET Body_html = REPLACE;
UPDATE textpattern SET Body_html = REPLACE;
UPDATE textpattern SET Body_html = REPLACE;
UPDATE textpattern SET Body_html = REPLACE;
</code>
</pre>

Offline

Board footer

Powered by FluxBB