Comments (14)
<pre lang="*">...</pre>
isn't the pattern it is looking for, it sniffs out the following:
<pre class="brush: bash;">
gem uninstall json
gem install json --platform=ruby -v 1.4.6
</pre>
SyntaxHighligher doesn't use <pre lang="*">
as far as I know, just the <pre class="brush:*">
syntax.
from goodbye-syntax-highlighter.
Thats right - I´ve choosen the Plugin http://wordpress.org/extend/plugins/wp-syntax/ formerly. Is it a grest problem to include an upgrade from WP-Syntax to GSH? I would be grateful.
from goodbye-syntax-highlighter.
Sure, that would be possible, though I'm not familiar with the languages that are supported.
Do you think it should be something rolled into GSH or should I start a new plugin, e.g. goodbye-wp-syntax?
from goodbye-syntax-highlighter.
I think it would be nice if GSH will be replace all Syntax Highlight WP-Plugins :). WP-Syntax supports all GeSHi-Languages (http://qbnz.com/highlighter/).
from goodbye-syntax-highlighter.
My only thought on a separate project is that GeSHi supports a ton of languages (as does highlight.js), and the language name doesn't always match up (e.g. csharp --> cs, though that is the same for GeSHi and SH to highlight.js). Having a separate plugin could help to keep the mappings clean. That said, I guess you are right; it would be nice to just have one project.
I suppose the <pre lang="XXX">
pattern isn't that far off from <pre class="brush: XXX;">
. It probably would just be safe to look for both patterns out of the gate, and then add any enhancements that may arise from that change. I won't go deep into mappings for the first release (as I didn't even do that for SH), but it should be a good start.
from goodbye-syntax-highlighter.
Ok, initial version is checked in. Give it a try. I tested a couple of snippets and it seems to work as expected, but I'd like you to try it on your blog. If you say everything looks good, I'll release it.
from goodbye-syntax-highlighter.
@controlcde, have you had a chance to try out the plugin?
from goodbye-syntax-highlighter.
Well, I´m busy right now but I´ve to give a little tests. All in all: It works - i think so.
But I´ve some notes:
- Is it right, that I´ve to install wp-highlight.js before GSH will working?
- The resulting code doesn´t look like SyntaxHighlighter :(. No line numbers, no highlighting.
- Maybe I´m using a special typo but it seams so that GSH can´t detect the ending tag. And if I write
....
Some text and than more
....
The text between will not shown in the same style like text before the block.
from goodbye-syntax-highlighter.
If you could give me a hint how I could insert my code (more than one line) into this comment field without interpretation of GFM I will do this :)
from goodbye-syntax-highlighter.
- You are correct, you need wp-highlight.js to be installed. That will convert the
<pre><code>
blocks into formatted code. You don't need the wp-highlight plugin specifically, you could just use your own implementation using hightlight.js directly. - hightlight.js doesn't support line numbers, nor line highlighting. You can read more about it in the docs. There is a branch that supports line numbers, but I haven't tried it out, plus GSH currently just strips that stuff out when outputting the new code blocks.
- Not sure what you mean... To get code to be inserted you can either indent each line by 4 spaces or use a block that starts with ``` LANGUAGE and ends with the three back-ticks. You can see an example of this by clicking the GFM link that is at the top of the comment editor, or on this page.
from goodbye-syntax-highlighter.
thanks, and to 3. I hope now you could see my example :)
<pre class="brush: bash">
echo "#!/bin/bash" > /usr/local/bin/mute-on.sh
echo "osascript -e 'set volume with output muted'" >> /usr/local/bin/mute-on.sh
echo "#!/bin/bash" > /usr/local/bin/mute-on.sh
echo "osascript -e 'set volume with output muted'" >> /usr/local/bin/mute-on.sh
</pre>
Then more text
<pre class="brush: bash">
sudo chmod u+x /usr/local/bin/mute-on.sh
sudo chmod u+x /usr/local/bin/mute-off.sh
</pre>
and some more text
<pre class="brush: bash">
defaults read com.apple.loginwindow LoginHook
defaults read com.apple.loginwindow LogoutHook
</pre>
finally: text
<pre class="brush: bash;">
defaults write com.apple.loginwindow LogoutHook /usr/local/bin/mute-on.sh
defaults write com.apple.loginwindow LoginHook /usr/local/bin/mute-off.sh
</pre>
I think it´s a strange behavior, isn´t it?!
from goodbye-syntax-highlighter.
First, you are missing a semicolon after your brush declaration in the first 2 <pre>
tags.
That said, this is a problem. I modified the regular expression so it grabs everything between the <pre>
and the last </pre>
(e.g. (.*)
). That doesn't work. I originally had it picking up everything except the start of a tag (e.g ([^<]*)
), but that causes other problems like not capturing HTML code snippets.
Do you have any ideas? I was thinking of capturing everything between the <pre>
and </pre>
except for a nested </pre>
, but I'm struggling with the regular expression to do that.
from goodbye-syntax-highlighter.
Try the latest version. I'm not 100% satisfied with the regular expression that I wrote. It requires line breaks after the <pre...>
and before the </pre>
. It should pick up tags now and your example should work.
from goodbye-syntax-highlighter.
I rolled the regular expression back to what was originally there ([^<]*)
.
XML/HTML inside a <pre>
block should really be escaped, so the old expression seems to work as expected.
from goodbye-syntax-highlighter.
Related Issues (2)
- Problem with `\` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.