2013-04-15 11 views
7

Blogum için Github'da Jekyll ve Markdown kullanıyorum. Sayfamdaki kod etiketlerini nasıl ekleyebilirim? Ben bazı kod okuyucularına gösterilecek sayfamda oturana ama jekyll bunları sevmez eklemek için <pre> etiketleri kullanabilirsiniz düşünüyordumBlogum için Github'da Jekyll ve Markdown kullanıyorum. Sayfamdaki kod etiketlerini nasıl ekleyebilirim?

örnek ..

Birisi bana bunu yapabilecek bir iyi biçimlendirme etiketi söyleyebilir misiniz Bu kodu denerseniz sayfamda

kodu eklemek için bu kullanmak:

<pre> 
    <code class="ruby"> 
git clone --mirror [email protected]:project project 

cd project 

git remote add github [email protected]:username/project.git 


In cron Job 

cd /pathto/project && git fetch -q && git push -q --mirror github 
    </code> 
</pre> 

bu hatayı olsun

enter image description here

Benim _config.xml

# This is the default format. 
# For more see: https://github.com/mojombo/jekyll/wiki/Permalinks 
permalink: /:categories/:year/:month/:day/:title 

exclude: [".rvmrc", ".rbenv-version", "README.md", "Rakefile", "changelog.md"] 
auto: true 
pygments: true 

# Themes are encouraged to use these universal variables 
# so be sure to set them if your theme uses them. 
# 
title : xxxx 
tagline :xxxx 
author : 
    name : xxx 
    email : jxxx 
    github : xxx 
    twitter : xx 

# The production_url is only used when full-domain names are needed 
# such as sitemap.txt 
# Most places will/should use BASE_PATH to make the urls 
# 
# If you have set a CNAME (pages.github.com) set your custom domain here. 
# Else if you are pushing to username.github.com, replace with your username. 
# Finally if you are pushing to a GitHub project page, include the project name at the end. 
# 
production_url : http://johnathanmarksmith.com 

# All Jekyll-Bootstrap specific configurations are namespaced into this hash 
# 
JB : 
    version : 0.3.0 

    # All links will be namespaced by BASE_PATH if defined. 
    # Links in your website should always be prefixed with {{BASE_PATH}} 
    # however this value will be dynamically changed depending on your deployment situation. 
    # 
    # CNAME (http://yourcustomdomain.com) 
    # DO NOT SET BASE_PATH 
    # (urls will be prefixed with "/" and work relatively) 
    # 
    # GitHub Pages (http://username.github.com) 
    # DO NOT SET BASE_PATH 
    # (urls will be prefixed with "/" and work relatively) 
    # 
    # GitHub Project Pages (http://username.github.com/project-name) 
    # 
    # A GitHub Project site exists in the `gh-pages` branch of one of your repositories. 
    # REQUIRED! Set BASE_PATH to: http://username.github.com/project-name 
    # 
    # CAUTION: 
    # - When in Localhost, your site will run from root "/" regardless of BASE_PATH 
    # - Only the following values are falsy: ["", null, false] 
    # - When setting BASE_PATH it must be a valid url. 
    #  This means always setting the protocol (http|https) or prefixing with "/" 
    BASE_PATH : false 

    # By default, the asset_path is automatically defined relative to BASE_PATH plus the enabled theme. 
    # ex: [BASE_PATH]/assets/themes/[THEME-NAME] 
    # 
    # Override this by defining an absolute path to assets here. 
    # ex: 
    # http://s3.amazonaws.com/yoursite/themes/watermelon 
    # /assets 
    # 
    ASSET_PATH : false 

    # These paths are to the main pages Jekyll-Bootstrap ships with. 
    # Some JB helpers refer to these paths; change them here if needed. 
    # 
    archive_path: /archive.html 
    categories_path : /categories.html 
    tags_path : /tags.html 
    atom_path : /atom.xml 
    rss_path : /rss.xml 

    # Settings for comments helper 
    # Set 'provider' to the comment provider you want to use. 
    # Set 'provider' to false to turn commenting off globally. 
    # 
    comments : 
    provider : disqus 
    disqus : 
     short_name : jekyllbootstrap 
    livefyre : 
     site_id : 123 
    intensedebate : 
     account : 123abc 
    facebook : 
     appid : 123 
     num_posts: 5 
     width: 580 
     colorscheme: light 

    # Settings for analytics helper 
    # Set 'provider' to the analytics provider you want to use. 
    # Set 'provider' to false to turn analytics off globally. 
    #   
    analytics : 
    provider : google 
    google : 
     tracking_id : 'UA-123-12' 
    getclicky : 
     site_id : 
    mixpanel : 
     token : '_MIXPANEL_TOKEN_' 

    # Settings for sharing helper. 
    # Sharing is for things like tweet, plusone, like, reddit buttons etc. 
    # Set 'provider' to the sharing provider you want to use. 
    # Set 'provider' to false to turn sharing off globally. 
    # 
    sharing : 
    provider : false 

    # Settings for all other include helpers can be defined by creating 
    # a hash with key named for the given helper. ex: 
    # 
    # pages_list : 
    #  provider : "custom" 
    # 
    # Setting any helper's provider to 'custom' will bypass the helper code 
    # and include your custom code. Your custom file must be defined at: 
    # ./_includes/custom/[HELPER] 
    # where [HELPER] is the name of the helper you are overriding. 
+0

Bu yardım: http://stackoverflow.com/questions/8648390/syntax-highlighting-markdown-code-blocks-in-jekyll-without-using-liquid-tags? –

+0

hayır Yukarıdaki hatayı alıyorum .. güncelleştirilmiş bilgilerle birlikte soruya bakın – SJS

+0

Eğer varsa, _config.yml dosyanızı göndermeniz gerekecek. Repo'unuza bir bağlantı sağlayabiliyorsanız, bu da yardımcı olacaktır. –

cevap

3

.md veya .markdown, sonra standart Markdown sözdizimini kullanmak istersiniz:

block 
of 
code 

Jekyll redcarpet, Maruku veya RDiscount gibi Markdown ayrıştırıcı kullanır ve nasıl tanımlamaz: 4 boşluklarla her bir satır

block code girintisi için `içi code` Bu gibi inline code kullanımı ters tırnakların için, İçeriğinizi biçimlendirmelisiniz, bu sizin yazdığınız içerik türüne göre belirlenir, bu durumda, Markdown.

http://daringfireball.net/projects/markdown/syntax#code

Ayrıca dizimi {% highlight %} Sıvı sözdizimi etiketini kullanarak vurgulama içine görünebilir::

https://github.com/mojombo/jekyll/wiki/Liquid-Extensions#code-highlighting

Umut yardımcı olur Yani bakmak için yer code için Markdown sözdizimi belgelerdir!

3

Bu nasıl efendim hakkında size kastediyoruz "sayfa" Bir Markdown dosya uzantısı yani ise

~~~ ruby 
# This is a test. 
def foo 
    puts 'foo' 
end 
~~~ 

ref

+0

isteğinize göre _config.yml eklentisini ekledim. Alternatif olarak (ve bence daha yaygındır) '' 'karakterleri yerine üç tane backticks ekleyin. – IQAndreas

İlgili konular