Code Blocks
Hello,
Could you also add support for twig code blocks? I ask because I use a static site generator called PieCrust which is like Jekyll except for it's highlighting it uses twig variables as such
{% geshi 'css' %}
{% endgeshi %}
It does not currently support MMD or Discount formats.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Brett on 26 Sep, 2013 02:09 PM
You can use a custom processor to handle this. I do similar with my blog previews to handle special formatting:
http://brettterpstra.com/2013/01/04/previewing-jekyll-posts-with-marked/
Twig isn't a widely requested feature (you're the first), so don't hold out too much hope that it will find its way in as a feature in the near future. A little scripting will do the trick, though.
-Brett
2 Posted by Joseph Crawford on 26 Sep, 2013 02:15 PM
Thanks I will look into the scripting to see how it can be accomplished :) Thanks for releasing version 2 much better than 1 :)
3 Posted by Joseph Crawford on 26 Sep, 2013 02:50 PM
Any possibility you could help with this, I am not too familiar with Ruby but this regex works in online testers when tested against the following code, however run as a preprocessor it is not doing anything.
Support Staff 4 Posted by Brett on 26 Sep, 2013 03:20 PM
Do you have YAML headers in your documents? Lines 6 and 7 are looking for two
---
lines and removing them. If you don't have any, it's getting an error when it tries to pick from the array. If you remove that section, you might have better luck. Let me know if that helps.5 Posted by Joseph Crawford on 26 Sep, 2013 03:21 PM
Hello Brett,
Yes the file does in-fact have a YAML header.
6 Posted by Joseph Crawford on 26 Sep, 2013 03:22 PM
Oh and verbatim is there in this case but it's not always present.
Support Staff 7 Posted by Brett on 26 Sep, 2013 03:26 PM
Can you upload a complete document (including headers) for me to test?
Support Staff 8 Posted by Brett on 26 Sep, 2013 03:30 PM
Oh, I see. You're using interpolation outside of a string in the last line. Change it to just:
The regex needs some tweaking with more optionals if things like
verbatim
won't always be there, but making that change gets it to work with your sample code.9 Posted by Joseph Crawford on 26 Sep, 2013 03:31 PM
Sure I have attached a page from my site
Support Staff 10 Posted by Brett on 26 Sep, 2013 03:56 PM
See if you can work with this: http://ckyp.us/UAY2
You have an error in your syntax in the example post, line 82 has a double
endgeshi
and noendverbatim
. With that fixed the above script is working for me, at least for the code block portion.Are you using Marked 1 or 2?
11 Posted by Joseph Crawford on 26 Sep, 2013 04:13 PM
Brett,
That does not appear to work for me: https://www.dropbox.com/s/hr8wvnjzqetqyr9/Screenshot%202013-09-26%2012.12.07.png
I modified my preprocessor file, then saved it and modified the md file and saved it, the preview did not update.
12 Posted by Joseph Crawford on 26 Sep, 2013 04:37 PM
I am using Marked 2 just bought it this morning when I saw the PRMac hit my inbox :)
Support Staff 13 Posted by Brett on 26 Sep, 2013 05:33 PM
what do you get if you run:
on the command line?
14 Posted by Joseph Crawford on 26 Sep, 2013 05:41 PM
Hello Brett,
I had a permission issue as the file was not chmod 755. I fixed that and on the console I get the document html output with the geshi stuff replaced.
However in Marked2 I still get the geshi blocks in the preview which is odd…
Thanks,
Joseph Crawford
Support Staff 15 Posted by Brett on 26 Sep, 2013 05:45 PM
Just for giggles, chmod it to 777 and see what it does.
-Brett
16 Posted by Joseph Crawford on 26 Sep, 2013 05:50 PM
Brett,
chmod to 777 did not help the issue. What I did find is that nothing was changing so I quit Marked2 and then re-opened it.
Now it shows a blank white page for the preview of the document. If I go to settings and remove the pre-processor the content comes back.
I don't think it actually loaded the processor until i restarted the app. However now I am left with a blank white preview.
Thanks,
Joseph Crawford
Support Staff 17 Posted by Brett on 26 Sep, 2013 06:56 PM
I'll need to test this all locally to figure out what's going on. Custom processors can be finicky. Can you post:
- the script you're currently using as the processor
- a screenshot of your Behavior settings
- the markdown file you're testing with
I'll take a look.
-Brett
18 Posted by Joseph Crawford on 26 Sep, 2013 07:19 PM
I posted the files, but they are not showing up. Please let me know if they end up posting or not.
19 Posted by Joseph Crawford on 26 Sep, 2013 07:20 PM
Files
Support Staff 20 Posted by Brett on 26 Sep, 2013 07:48 PM
If you set your settings like this: http://ckyp.us/7u77
And use the attached script, you should be able to get going with it. Let me know.
21 Posted by Joseph Crawford on 26 Sep, 2013 08:07 PM
Brett,
That's working except for instances which contain YAML such as this
{% geshi 'markdown' line_numbers class='codeblock' %}
---
title: Index
date: 2013-08-12 18:36
---
A new page.
{% endgeshi %}
It actually kinda messes with the mark-up. If you look at the sample document I provided this appears on line 48
however if you check the preview it appears the Marked is chopping out lines 48-72 from the resulting document.
For these blocks I wish to keep the entire body in place without stripping the yaml from there, etc.
Thanks,
Joseph Crawford
Support Staff 22 Posted by Brett on 26 Sep, 2013 08:26 PM
It's not Marked doing the chopping, it's the script. Still needs some refining.
-Brett
23 Posted by Joseph Crawford on 26 Sep, 2013 10:15 PM
I've got the code fixed so that it will do the replacements and it works on the command line but in Marked they all still show as twig blocks.
24 Posted by Joseph Crawford on 29 Sep, 2013 04:42 AM
Any ideas why it would just load a blank white screen? It's working just fine n the console it replaces everything properly, but in Marked it is not showing a preview at all. Is there a log I can check to see what is going on?
Thanks,
Joseph Crawford
25 Posted by Joseph Crawford on 29 Sep, 2013 05:19 AM
Brett,
As you can see it's working just fine here: http://ideone.com/AVUOve
however it does not appear that Marked likes it, for some reason it's still showing the template tags
Thanks,
Joseph Crawford