Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.1k views
in Q2A Core by
edited by

When I creating my post to ask something , sometimes it may consists of programming script but those scripts are showing row wise. Its really an ugly look. That is the code part when I typed on wysiwyg editor it will showing each row wise. How can shown the whole code in an single code background.

The screenshot is shown below

 

I added the particular cose snippet to my editor and saved but still it not showing correctly. The screen shot below



Thanks

Q2A version: version 1.6.3

2 Answers

0 votes
by
edited by

It looks like you are "block quoting" the single rows of the query separately.

function qa_db_install_tables()
{
foreach ($missingtables as $rawname => $definition) {
qa_db_query_sub(qa_db_create_table_sql($rawname, $definition));
foreach ($definitions as $table => $definition) {
$missingcolumns=qa_db_missing_columns($table, $definition);
 
}

You should block quote the query as a whole : select ALL the query and then block quote it  :

function qa_db_install_tables()
{
 
foreach ($missingtables as $rawname => $definition) {
qa_db_query_sub(qa_db_create_table_sql($rawname, $definition));
 
 
 
foreach ($definitions as $table => $definition) {
$missingcolumns=qa_db_missing_columns($table, $definition);
 
}
 
EDIT :
another example
 
$inipath = php_ini_loaded_file();
 
    if ($inipath) {
 
        echo 'Loaded php.ini: ' . $inipath;
 
    } else {
 
        echo 'A php.ini file is not loaded';
 
    }
 
 
by
No still it shown row wise. But I felt there is a space between the script which makes this effect. So I just eliminated the space between each row(single space only allowed). Is there any other way to avoid this effect because its not easy to eliminate every space in between the rows. Please help
Thanks
by
What do you mean with "space between the script" ?
Some extra CRs ?
have a look at the 2nd query in my answer.
I've edited it adding some extra CRs between the 2 foreach instructions.
I've still a unique block highlighted.
---> select ALL the code
by
Your above code not showing in a script background. It showing like a bold text. I dont know the reason.
In my case This is my example script which is still shown as separately row wise.

$inipath = php_ini_loaded_file();

    if ($inipath) {

        echo 'Loaded php.ini: ' . $inipath;

    } else {

        echo 'A php.ini file is not loaded';

    }
please check it.
Thanks
by
I've edited again my answer adding your code snippet
by
yes @maxjtechno . here its working well. But in my site no surprises found. Is there any setting needed on WYSIWYG editor. Now feeling confused.
Please check my question because I've edited my post for showing the same code snippet not showing correctly for me.

 Or Is there any setting needed to change on WYSIWYG editor.

Thanks
by
I am using WYSIWYG Editor v1.1.1 [[Wrapper for CKEditor WYSIWYG rich text editor]]
by
Yes, me too....
Did you customize it or added some extra options to its config.js ?
You can try also here with a default 1.1.1 installation of the wysiwyg plugin :
http://demo.question2answer.org/
by
Yes tested and I found something. That is it may be the effect of css. Because I am using bootstrap .In my bootstrap has already uses an different style for the class "blockquote". In q2a site also uses the same class with different styles. I think this may the issue . But in previous the row style[ without using block quote] which I have inspected with fire bug it shows pre tag of each row, this is real unknown factor.

Please check and give reply
many thanks
by
The troubleshooting should be done on your customization directly
0 votes
by
If you are going to display code in your site then you should just install the markdown plugin: https://github.com/svivian/q2a-markdown-editor

It is close to the editor of stackoverflow: 4 spaces = a line of code
by
Is there any option to activate code line on WYSIWYG editor. Because the http://www.question2answer.org/qa uses WYSIWYG editor and showing the code correctly. But in my site not only showing such issues. May I know which WYSIWYG editor version currently q2a uses.
by
This site uses the default setup... but this is not a site focused on coding. Using <blockquotes> to display code is really awful. You could try some plugins for the ckeditor:
http://ckeditor.com/addon/syntaxhighlight
http://ckeditor.com/addon/codemirror

But the markdown editor is a much better option, IMO.

You could also try this one: http://www.question2answer.org/qa/37512

I'm not 100% what the editor is as I haven't tried it.
by
Yes exactly you are right the all display style for code coming from  <blockquotes>.
I am going to install markdown editor. Is the markdown editor compatiable to q2a version 1.6.3.???

Many thanks :)
by
Yes it is... and even with 1.7alpha1, according to my tests.
...