Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"data[c]" in c code showed as "data1" #26

Closed
hpt opened this issue Oct 15, 2013 · 9 comments
Closed

"data[c]" in c code showed as "data1" #26

hpt opened this issue Oct 15, 2013 · 9 comments

Comments

@hpt
Copy link

hpt commented Oct 15, 2013

Hello,

When trying to highlight c language code with syntaxhighlighter, the "data[c]" is showed as "data1". Something like this:

[code lang="c"]

char data[100];
int cpp;

for (c=0;c<100;c++)
data[c]="a";
[/code]

will be showed as this:

c

@Viper007Bond
Copy link
Collaborator

@hpt
Copy link
Author

hpt commented Oct 23, 2013

Could you help me on this? It's strange. Why I always get "1" for "[c]" or "[cpp]" or "[php]" in the source code highlighting here?

@Viper007Bond
Copy link
Collaborator

Can you provide a URL to where this is happening for you? It's hard to debug without seeing it for myself.

@hpt
Copy link
Author

hpt commented Oct 24, 2013

Please see https://96.126.98.8/blog/?p=1837

@Viper007Bond
Copy link
Collaborator

Check out the HTML source code of the page -- the "data1" there as well so the issue is NOT with the highlighting package.

The problem is either with my plugin or another plugin you have enabled. I recommend you start by disabling all other plugins that you have active (except mine) to see if that resolves the issue.

You can also check the database to see what the post_content value is for the post. Is "data1" there too?

@hpt
Copy link
Author

hpt commented Oct 26, 2013

Thanks. I have disabled all other plugins besides yours, but the problem wasn't fixed. And I also checked the post_content value, it looks like this, it's "data[c]" there:

[c]
int data[100];
int c

for (c=0;c<=100;c++)
data[c]=c;

for (c=0;c<=100;c++)
printf("%d\n",data[c]);
[/c]

@hpt
Copy link
Author

hpt commented Oct 26, 2013

The "<" and '"' in pervious comment are both converted to html's "&" format in the post_content.

@Viper007Bond
Copy link
Collaborator

I just realized what's going on. You're using the shortcode [c] to wrap your code and yet you have [c] in your code itself which is confusing WordPress's shortcode parser.

Try doing this instead:

[code lang="c"] your code here [/code]

@hpt
Copy link
Author

hpt commented Oct 30, 2013

I have tested surrounding my code with [code lang="c"] and [/code]. But [c] is still showed as 1. In the mean time, I have disabled other plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants