Jump to content

Typographer


Mike Rockett
 Share

Recommended Posts

Thanks Macrura :)

I actually see that I'm going to need to bump PHP Typography to 6.x first, which means I'll land up bumping the module version to 0.5 for a little testing. Looks like there's been a cleanup and some new features added, as well as a bunch of hyphenation languages. Will open an issue for that shortly.

Link to comment
Share on other sites

  • 2 months later...

Hi,

I currently updating my website, and run with problem with Typographer. I use version 0.4.0 on local 7.0.30-0ubuntu0.16.04.1

Strangely I have this problem only in my home page (other pages seems to work), so I guess it's a specific setting but no idea which one. Can you see it?

Thanks!

Mel

image.thumb.png.37385d3f2ca779974653e30c16f8d596.png

Link to comment
Share on other sites

Hi @Mike Rockett

Sorry, I forgot to mention. I updated last week to the last dev version 3.105. It should be related to either PW version or PHP version, since on my production website, with the same settings and same data, it works fine.

I was able to delimited to a specific part :

Spoiler

$abstracts = $pages->find("template=publication, categ_publi=1108, limit=4, sort=-year, sort=-date_sort"); // abstract

foreach($abstracts as $c) { 
			$congres[$c->congress] = $c;
	}
	
		<h4 class='title is-4'>
	  	<span class='icon is-medium'><i class='fa fa-globe fa-fw' aria-hidden='true'></i></span>  
		{$abstracts->first()->categ_publi->title}s</h4>
			<div class='columns'>";
				foreach($congres as $c) {
					$content .= "<div class='column'><div class='box'>
					<div class='title is-6'><a href='{$c->url}'>{$c->congress}</a></div>
					<div class='columns is-multiline is-inline-mobile is-centered'>
						<div class='column'>
						<span class='icon'><i class='fa fa-calendar fa-fw' aria-hidden='true'></i></span>
						<p class='is-inline-mobile'>{$c->congress_date} {$c->year}</p>
						</div>
						<div class='column'>
						<span class='icon'><i class='fa fa-map-marker fa-fw' aria-hidden='true'></i></span>
						<p class='is-inline-mobile'>{$c->congress_location}</p>
						</div>
					</div></div></div>";
				} 

 

I received error for the "congress field". I tried to change the data or even empty, but it didn't change the error. Even deleting "<div class='title is-6'><a href='{$c->url}'>{$c->congress}</a></div>" doesn't help. Everywhere else in the website where it uses this field, I get the same error.

Thanks!

EDIT: I refine more the issue by comparing my different fields, problematic or not. This field have some <sup></sup> (I export data from a other software, and it's difficult to remove them). Could it be the problem? It wasn't in previous version of PW.

Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...

Hi @Mike Rockett, first of all thanks for this wonderful module! Been using this for a while but never stopped by to say thanks.

I just sent two pull requests your way I'd love to get your take on.

The first one makes the module work well with multi-language sites by adding a hook for modifying the Typographer Settings instance.

The second one just updates the underlying php-typography package, while we're at it.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...
On 10/24/2020 at 2:28 PM, d'Hinnisdaël said:

Hi @Mike Rockett, first of all thanks for this wonderful module! Been using this for a while but never stopped by to say thanks.

I just sent two pull requests your way I'd love to get your take on.

The first one makes the module work well with multi-language sites by adding a hook for modifying the Typographer Settings instance.

The second one just updates the underlying php-typography package, while we're at it.

Hi Phillip – I'm so incredibly sorry for neglecting this. I noted in the merge requests that I'd get to it, and then never did. I'm going to go ahead and accept both and release, however I have no reliable way to test without configuring dev-environments for it. So if there are any issues, we can deal with them on an as-and-when-needed basis.  Edit: Managed to test.

On 4/17/2021 at 11:02 PM, Spiria said:

I have a strange problem which is also present with another fork of php-typography. All the letters are spaced... I had hope that your module would have not the same problem. It seems related to the locale.

Putting set_space_collapse to  false resolves the issue.

2097408623_CleanShot2021-04-17at13_55_55.png.2a4fa1e999ae279ab6f7207b1f5319f2.png

https://github.com/mundschenk-at/php-typography/issues/137

 

On 4/17/2021 at 11:27 PM, Spiria said:

I have however another stranger and more important problem in French. Every "ne" which is the negation in French, is replaced by "né"!!!

1629714648_CleanShot2021-04-17at17_24_27.png.714c3700bdf9bf5ddc599fe3b51d0c5a.png

979890819_CleanShot2021-04-17at17_26_27.png.a98645c078a5902a10337a59123e9a5c.png

Very strange. Seems like something that would need to be fixed in the underlying package. Updating to v6.6 now as part of the above merge request at least. ?

Edited by Mike Rockett
  • Like 2
Link to comment
Share on other sites

29 minutes ago, Mike Rockett said:

Very strange. Seems like something that would need to be fixed in the underlying package. Updating to v6.6 now as part of the above merge request at least. ?

In fact, switching the diacritic corrections to off in French resolved the problem. "ne" is set to be corrected into "né" when you are in English.

Link to comment
Share on other sites

Ok that seems to have been due to caching - the module system heavily caches frontend pages, which it shouldn't really be doing for pages that require authentication...

Anyways, I have a new problem now. It seems that PW no longer accepts projects that live outside GitHub (it used to, as the current module points to the GitLab repo). @ryan – would it be possible to allow non-GitHub repositories?

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

@Mike Rockett (& others), I think I must be missing something obvious here. Using the standard modules installer, I’ve installed Typographer 1.0.0 into my PW 3.0.179 installation (PHP 7.4.19), and configured many of its options. Two examples: smart quotes and smart ordinals.

Following the example of TextformatterMarkdownExtra (which I have working), I “get” the module:

$typ = $modules->get('TextformatterTypographer');

I then want Typographer to process the contents of a field “vsDetails” (in $item):

$details = $item->vsDetails;
$typ->format($details);
echo "<p class='news'>$details</p>";

All this seems to work without error, but $details is echoed unmodified: foot symbols used as apostrophes remain “'” and “2nd” remains unchanged (the “nd” is not superscripted).

The whole site is in debug mode; Tracy is installed (but I don’t really know how to use it yet). If I make other changes to the page, they’re immediately apparent, so I’m pretty sure caching isn’t an issue. (And just to be sure, I deleted the contents of /site/assets/cache/ )

I see that it’s possible to turn Typographer off for certain elements and classes; the text I’m feeding it is not from any of those, but I’m really not sure how it would know one way or the other. I’m taking this as another sign that I’m missing an important concept.

FWIW, I can run the TextformatterMarkdownExtra module on the same text in the same way, and it works perfectly.

Thanks for any help or pointers you can give!

Link to comment
Share on other sites

@ErikMH – Hi Erik,

The module wasn't intended to be used manually like that. Normally, you would apply the module as a formatter for the field in question by modifying the field's configuration. Under the hood, the formatValue method is called, which imports the vendor packages and runs the formatter. I guess if you wanted to, you could call this method manually, but you would need to pass in an instance of the current page and field. Here is the method signature that it uses:

public function formatValue(Page $page, Field $field, &$value);

The value is passed in by reference.

I guess I can see that there might be use-cases for calling the method outside of the PW field system, so I reckon I should add a method to format arbitrary strings without the page and field dependencies (which are not used anyway - it's just the method signature that PW uses for formatters).

  • Thanks 1
Link to comment
Share on other sites

1.1.0 released with support for formatting text outside of the field context. You can now use the following to format arbitrary text:

print $modules->get('TextformatterTypographer')->formatString($text);

Note that this new method does not use by-reference passing of the input text.

  • Like 2
Link to comment
Share on other sites

Thank you so much for your quick response, @Mike Rockett! Long-time developer here, but very very new to ProcessWire. I’d suspected I was calling the module in the wrong way — and clearly I was right! So, thank you for adding the new method, but in fact I’ll look into configuring the field to use it as a formatter; I’ll bet that’ll be more efficient in terms of caching (and using a reference!) than what I was trying to do!

I’m loving ProcessWire, but there’s a lot to learn....

  • Like 1
Link to comment
Share on other sites

  • 2 years later...

Hi @Mike Rockett I just tried installing this on a dev version of pw 3.0.220 and it seems the new module overhaul might have picked up strange behavior:

image.thumb.png.c4c9d4097bc824a539cc34bfce3c6b48.png

I mentioned this in a thread of Ryan's also as I'm not sure where the incompatability lies.

I also noted that php-typographer has advanced to v6.7.0 which includes some php 8.1 deprecation resolutions.

 

  • Like 1
Link to comment
Share on other sites

Changing line 40 in TextformatterTypographer.module.php

from:

  public function getModuleInfo()
  {
    return json_decode(file_get_contents(__DIR__ . '/TextformatterTypographer.info.json'), true);
  }


to:

  public static function getModuleInfo()
  {
    return json_decode(file_get_contents(__DIR__ . '/TextformatterTypographer.info.json'), true);
  }

resolved the installation issue.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...