after many search on google, it seems that my problem is not very well documented.
I am developping a symfony blog which contains maths. So I have tried to use mathjax. It works well but the problem is that the character '&' and '\\' are not send as it is in the web page (when I look in the source code of the firefox, the character are : '& amp;' and '& #92;').
The content is stored in the database and the characters in the database are correct.
Is there clean way to solve the problem ? Maybe by Mathjax side or Symfony side ?
I have tried to use raw twig filter but the character are still the same in the source code.
Thank you very much :)
EDIT:
I use knplabs/knp-markdown-bundle with the default filter to print the post content : post.content|markdown, and when I retire the |markdown the characters are correct but I have not the markdown conversion...
EDIT 2: Ok after a morning of search, I found what is my problem. Me, I parse the markdown into back end (php) and then javascript parse the html (markdown -> mathjax). But usually, all is done with javascript in this sense : mathjax -> markdown. like in this app : https://github.com/kerzol/markdown-mathjax.
So my new question is, is there a way to make mathjax reverse the markdown parser ?
I've found a answer on my own but it is not very elegant. What I want is to unparse the text between $ $ and $$ $$. So I've done that :
$html = $this->container->get('markdown.parser')
->transformMarkdown($post->getContent());
$html = str_replace('&', '&', $html);
$html = str_replace('\', '\\\\', $html);
$html = str_replace('<em>', '_', $html);
$html = str_replace('</em>', '_', $html);
$post->setContent($html);
and in the view :
{{ post.content|raw }}
It is working but this is not beautifull at all.
Related
I already have lines indented with Tabs inside my plugin file. But PHPCS still reports the following:
Tabs must be used to indent lines; spaces are not allowed
32 | ERROR | [x] Tabs must be used to indent lines; spaces are not allowed
| | (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
Command line sniff command is
$ phpcs --standard=phpcs.xml.dist cool-media.filter.php > phpcs_errors.txt
Sample code snippet:
function __construct() {
<TAB>$this->plugin = plugin_basename( __FILE__ );
<TAB>$this->taxonomy = 'category';
<TAB>$this->post_type = 'attachment';
<TAB>$this->text_domain = 'cool-media-filter';
<TAB>$this->taxonomy = apply_filters( 'cool_media_taxonomy', $this->taxonomy );
}
I don't know how to fix!
Editor: PHPStorm
Coding standard used in project: WordPress Core
Ruleset: https://github.com/Automattic/_s/blob/master/phpcs.xml.dist
Any suggestion would be helpful. I am new to Code Sniffer.
EDIT (Screenshot from code editor)
Although you might have pressed the tab key to get the indentation, I suspect that your editor is set to automatically replace that tab with spaces.
Check your editor's code standards settings, add in an .editorconfig file, and/or run phpcbf --standard=WordPress-Core cool-media.filter.php to autofix this issue (and any other issues).
During my theme translation process I am stuck in the middle badly, currently i am following strange issue. Here are my settings:
and here is in my code file I mean in my theme code:
<?php _e('kai'); echo __('ka'); echo _('kami saab');?>
<?php echo _('huh');?>
Sorry for that strange words, but its not the case by now. The problem is that its showing only two translate able strings like:
echo _('kami saab');
echo _('huh');
My problem is why other these are missing? And why not my this works at all?
<?php _e('kai', 'kami'); echo __('ka', 'kami');?>
Now why not this picking my lines in my translate able strings list? What's wrong with my code or settings ... ?
Okay, If you check your settings as shown in above screen shot, you are doing one minor mistake, which is that just remove function symbol from end of your provided keywords: For more details check below given Keywords:
_e
__
and all other code will remain same as it is, and your those strings will be showing translate able as well.
I'm trying to create a simple setup to load a template, insert some data and save as a new file. However I need some conditional formatting on some of the cells and when I get the newly created files the conditional formatting is missing. It's not being overridden by some other formatting, the rules are missing from the conditional formatting menu. I'm using PHP 5.2, PHPExcel 1.7.8 and Excel 2010.
<?php
class template {
static $objPHPExcel;
function __construct() {
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPExcel/IOFactory.php';
if (!file_exists("template.xlsx")) {
exit("template missing." . EOL);
}
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(false);
self::$objPHPExcel = $objReader->load("template.xlsx");
}
function insertdata($dataArray){ /* unused */ }
function save($name){
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
require_once '../Classes/PHPExcel/IOFactory.php';
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$objWriter = PHPExcel_IOFactory::createWriter(self::$objPHPExcel, 'Excel2007');
$objWriter->save($name);
echo date('H:i:s') , " File written to: ".$name , EOL;
}
$temp=new template();
$temp->save("savethis.xlsx");
I'm trying to preserve a Graded 2 color scale (Formatting based on cell values, Minimum is type Number=1, Maximum is type Number=10). The cell in question has a formula attached that references another sheet (all data has been saved correctly).
I have found that is is hopeless to read, modify and save an XLS/XLSX file getting the "auto filter", "Data Validation" and "Conditional Format" from the original file, the final solution I found is to make the template using the PHPExcel library.
Sadly, as it was stated on the other answer (https://stackoverflow.com/a/13172890/218418):
PHPExcel is not a library for "editing" workbook files: you're not using PHPExcel to change a file, you're changing a PHPExcel object that can be loaded from a file, and can subsequently be written to a file.
I'm amused that something like "editing" an Excel file using a template with just data validation, conditional formating and auto filter is not possible, but I understand.
This is an old thread, but I recently ran into the same issue. It seems like PHPSpreadsheet (the new incarnation of PHPExcel) supports creating spreadsheets with conditional formatting, but when I tried to read an existing spreadsheet and then write it out to a new file, the conditional formatting was broken.
I'm planning to use xlsx-populate instead - it's nodeJS rather than PHP, but it seems to be better at writing Excel files while maintaining features of the spreadsheet (like conditional formatting) that it doesn't understand.
In my case, I have a need to populate one sheet of a large, complex spreadsheet. Values from that sheet are used in calculations and conditional formatting on other sheets, which I don't need to modify directly.
With xlsx-populate, I was able to open the spreadsheet, populate it, and save it without breaking the formatting.
I'm trying to learn Drupal modules. Can someone tell me what the '#' symbol is? I dont remember coming across it in PHP. (Its tricky to search for it cos as far as I can tell, you cant google for symbols). Can I convert it into a normal PHP variable, modify it and finally put it back into an # thing within the PHP of the .module file?
UPDATE: e.g.:
$error['msg'] = t("We're sorry. We have now only #qty of the ....
in file...
http://drupal.org/project/uc_out_of_stock
While that is the case in general PHP, it is used differently in Drupal within the t() function.
You can properly use placeholders in your text (which should be wrapped in t() for translation purposes on i18n capabilities) by putting a # , ! or % in front.
! = insert as is
# = run text through check_plain
% = html escape text
More info on the API page
In PHP the # symbol suppresses error messages.
There's plenty about it in the manual. When in doubt that's the place to go.
http://us3.php.net/manual/en/language.operators.errorcontrol.php
I recently switched from Aptana2 to version3.0.3, and the first thing i did was to install the sdomcl. file to get jQuery code assist.It works fine for jQuery, but there is no code assist for many keywords.For exymple there is no support for var,while,throw,try,break,case,catch etc.
Also there is no function, instead intellisense sugests Function.
The second problem is that i am constantly getting this warning '<' + '/' +letter not allowed here when typing something valid like this:
confirmDiv =$("")-sorry for this,but it wont let me type what i want, basically i am just creating a new div with the correct syntax.
Could it be something with Html Tidy?Anyways, big thanks in advance!
Aptana Studio 3.0.4 includes code assist for JavaScript keywords.
I've read that for Javascript the slashes / must be escaped with backslashes \ as it says here
Doing so the warning dissapears ;)