Superscript characters in Prestashop 1.7 product name - html

One of the products in my website has a superscript character in the product name. Since Prestashop does not allow HTML tags inside product names, I need to find a way to display the superscript character correctly in the product page.
While searching around, I found somebody with a similar problem: https://www.prestashop.com/forums/topic/543339-how-to-make-superscript-format-%C2%AE-symbol-in-category-name-and-product-name/. They seemed to resolve the issue by modifying a line of code in the product.tpl file of their theme:
<h1 itemprop="name">{$product->name|escape:'html':'UTF-8'|replace:'character':'<sup>character</sup>'}</h1>
I tried this solution, but instead of replacing only the one character with its superscript version, the theme displays the entire string as plain text, including the sup tags. Cleared the cache, set to force recompile template files, nothing.
Clearly the "replace" command does work, but I can't figure out why the sup tags don't. Does anybody know a way to solve this problem?

Use the unicode equivalent of the superscript digits instead.
See https://unicode-table.com/en/sets/superscript-and-subscript-numbers/

Related

Store arbitrary characters in Semantic MediaWiki

I'm trying to store some text containing html tags into properties, which doesn't work. I created a form for a property with the data type 'text' and a template. Saving the form writes the text into the template, but it can't get displayed, as it contains illegal characters, as I guess.
What I'm trying to do:
I need a form to enter data, containing html tags and special
characters
I'd like to be able to use a query to find all those pages
and show that text using a template I provide to the ask query.
I also tried to use the free text option, but then I can't retrieve it using the ask query.
What would be the best, or at least a working solution to this?
Thanks a lot
storing text with html tags is a bit tricky in SemanticMediaWiki
The reason is the invention of the StripMarkers UNIQ/QINU by the MediaWiki developers.
When parsing the content of page with html tags in it the parsing is sort of "postponed". This technical detail unfortunately makes it hard for extension developers like the SMW developers to solve the issue of handling such content. Also it makes it hard for lay people to follow the discussion on how to solve the problem
Here are two examples of SMW Issues that are marked as "closed". This state of affairs means that by following the configuration hints in the issue your problem should be solved. If not please ask a question on the SMW issue list or even initiate the reopening of the issues.
https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/794
https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/3707
On my wiki we ran into this and resolved it by replacing special characters (we had issues with [ ] =, but the same problem happens with to < > tags too) with alternate unicode characters using the regex extension and a template before setting the property with {{#set:}}. If you want to display the formatted text on the wiki directly then call that parameter separately without replacing the unicode characters.
When you want to display the property, you can then run the reverse replacement with regex before displaying your now intact code (using the template result format to allow you to perform the operation on the output of the query).
To switch to special characters you can create this template
{{#regex:{{#regex:{{#regex:{{#regex:{{#regex:{{{1|}}}|/=/|꞊}}|/\[/|[}}|/\]/|]}}|/>/|≽}}|/</|≼}}
And to switch back you can use this as a template
{{#regex:{{#regex:{{#regex:{{#regex:{{#regex:{{{1|}}}|/꞊/|=}}|/[/|[}}|/]/|]}}|/≽/|>}}|/≼/|<}}

How to delete anchor tags with Latin text from all posts in WordPress?

I have a WordPress site in Persian language. It is hacked and there are some advertisement links in every post in site.
I want to remove all of these links from my site. The only pattern I can find in these links is that they contain English characters.
I need a sql command like this:
update wp_posts set post_content =
replace(post_content,'Text to find','text to replace with');
But I need it to target anchor links with English characters inside them.
I also need to run it on ACF field, too.
If you can do this in PHP (easier), you can use:
preg_replace('/[^\x{0600}–\x{06FF}\x{0750}-\x{077F}\x{08A0}–\x{08FF}\x{FB50}–\x{FDFF}\x{FE70}–\x{FEFF}\x{10E60}–\x{10E7F}\x{1EE00}—\x{1EEFF}]/u', '', $my_content_from_db);
(I assume you're removing everything that's not Farsi and that translates to everything that's not part of the Arabic Unicode character set.)
(I also assume that you're capable of pulling all the posts from the DB, modifying them and writing them back to the DB. If not I can edit this answer with some more information.)
If you must do it in SQL, perhaps try the library in this answer with the same regex.
Beware that this will remove everything that's not in Arabic script. People use words in foreign languages (in your case, possibly ones with non-Arabic characters) within text sometimes. These would get removed.

Custom google font error in HTML

I have a blog where I use custom fonts from Google Fonts in each and every text of the <body> element, but whenever there is an inverted comma or a double inverted comma in my text, it is not shown as it should be - it is replaced by an unknown character.
I had even looked into the font and there is the character support for the inverted commas.
I don't think this has anything to do with your font.
If you look at the source code you will see the characters already are broken there:
This rather is a problem of your encoding. Your site is UTF-8, but the characters seem to be non-UTF-8. You either need to use UTF-8 characters or change the encoding of your site. (1st option is preferable)
If you change the site encoding to Windows-1252 (which is automatically suggested by Chrome based on the content) everything seems fine:
The question is how did you create this text? Maybe in Word and then copy and pasted? Or is your blog backend not UTF-8?
Also note there are two different characters: ’vs ´.
It's a special character. Please check below example
if you want to write "Don't" than you have to use "don’t"
if you want to write in double quote "highly sought users" than you have to use “highly sought users”
I hope this will help you.
Usually the special characters appears when you copy the text from other sources like MS word. This can be solved by manually entering inverted commas while entering or modifying in the database.

Some characters don't appear properly in code tags

so my problem is that symbols like '>'an '&' appear as their respective character codes in the code tag. I have tried typing them out manually and then adding the tag, the other way around as well and it didn't help.
So what should I do so that '>' appears as the symbol when in the code tag?
Please refer to this table. Some characters have HTML codes as they have special meanings if typed as they are. You should use their HTML names (which you can see in the referenced table) in order for them to be rendered correctly.

Shortened HTML text and malformed tags

In my web application I intend to shorten a lengthy string of HTML formatted text if it is more than 300 characters long and then display the 300 characters and a Read More link on the page.
The issue I came across is when the 300 character limit is reached inside an HTML tag, example: (look for HERE)
<a hreHERE="somewhere">link</a>
<a hre="somewhere">liHEREnk</a>
When this happens, the entire page could become ill-formatted because everything after the HERE in the previous example is removed and the HTML tag is kept open.
I thinking of using CSS to hide any overflow beyond a certain limit and create the "Read More" link if the text is beyond a certain number, but this would entail me including all the text on the page.
I've also thought about splitting the text at . to ensure that it's split at the end of a sentence, but that would mean I would include more characters than I needed.
Is there a better way to accomplish this?
Note: I have not specified a server side language because this is more of a general question, but I'm using ASP.NET/C# .
Extract the plaintext from the HTML, and display that. There are libraries (like the HTML Agility Pack for .NET) that make this easy, and it's not too hard to do it yourself with an XML parser. Trying to fix a truncated HTML snippet is a losing cause.
One option I can think of is to cut it off at 300 characters and make sure the last index of '<' is less than the last index of '>'. If it is, truncate the string right before the last instance of '>', then use a library like tidy html to fix tags that are orphaned (like the </a> in the example).
There are problems with this though. One thing being if there are 300 chars worth of nothing but HTML - your summary will be displayed as empty.
If you do not need the html to be displayed it's far easier to simply extract the plain text and use that instead.
EDIT: Added using something like tidy html for orphaned tags. Original answer only solved cutting thing mid-tag, rather than within an opening/closing tag.