Parcourir la source

Add support for code highlight

Maxime Vidori il y a 9 ans
Parent
commit
8fbf969101
4 fichiers modifiés avec 152 ajouts et 244 suppressions
  1. 1 3
      content/blog/2015-04-14-pytest-fixture.md
  2. 1 1
      pelicanconf.py
  3. 33 35
      theme/static/css/main.css
  4. 117 205
      theme/static/css/pygment.css

+ 1 - 3
content/blog/2015-04-14-pytest-fixture.md

@@ -2,9 +2,6 @@ Title: Pytest Fixture
 Category: tuto
 Tags: python, dev
 
-[TOC]
-
-# toto
 I am a huge fan of python (one of the best language in my toolbox). And
 when it comes to tests, [pytest](http://pytest.org/) is *THE* library to use.
 
@@ -14,6 +11,7 @@ some of my snippets.
 First one the app fixture:
 
 ```python
+
 @pytest.fixture(autouse=True)
 def app():
     """Load flask in testing mode"""

+ 1 - 1
pelicanconf.py

@@ -45,6 +45,6 @@ TOC = {
     'TOC_RUN': 'true'
 }
 
-MD_EXTENSIONS = (['attr_list'])
+MD_EXTENSIONS = ['attr_list', 'codehilite(css_class=highlight)', 'extra']
 # Uncomment following line if you want document-relative URLs when developing
 #RELATIVE_URLS = True

+ 33 - 35
theme/static/css/main.css

@@ -40,7 +40,7 @@ h1, h2, h3, h4, h5, h6 {
 	line-height: 1.1;
     font-family: 'Oswald', arial, serif;
 }
-	
+
 hr { border: 2px solid #EEEEEE; }
 
 /* Anchors */
@@ -59,7 +59,7 @@ a:hover, a:active {
 h1 a:hover {
     background-color: inherit
 }
-	
+
 /* Paragraphs */
 div.line-block,
 p { margin-top: 1em;
@@ -100,8 +100,6 @@ dl {margin: 0 0 1.5em 0;}
 dt {font-weight: bold;}
 dd {margin-left: 1.5em;}
 
-pre{background-color:  rgb(238, 238, 238); padding: 10px; margin: 10px; overflow: auto;}
-
 /* Quotes */
 blockquote {
     margin: 20px;
@@ -120,7 +118,7 @@ div.note {
 
 /* Tables */
 table {margin: .5em auto 1.5em auto; width: 98%;}
-	
+
 	/* Thead */
 	thead th {padding: .5em .4em; text-align: left;}
 	thead td {}
@@ -128,14 +126,14 @@ table {margin: .5em auto 1.5em auto; width: 98%;}
 	/* Tbody */
 	tbody td {padding: .5em .4em;}
 	tbody th {}
-	
+
 	tbody .alt td {}
 	tbody .alt th {}
-	
+
 	/* Tfoot */
 	tfoot th {}
 	tfoot td {}
-	
+
 /* HTML5 tags */
 header, section, footer,
 aside, nav, article, figure {
@@ -175,7 +173,7 @@ img.left, figure.left {float: left; margin: 0 2em 2em 0;}
 			#banner #logo img {
 				width: 230px;
 			}
-		
+
 		/* Main Nav */
 		#banner nav {
 			display: inline-block;
@@ -191,10 +189,10 @@ img.left, figure.left {float: left; margin: 0 2em 2em 0;}
 			right: 0;
 			top: 50%;
 		}
-		
+
 		#banner nav ul {list-style: none; margin: 0 auto; width: 840px;}
 		#banner nav li {float: left; display: inline; margin: 0 5px;}
-		
+
 		#banner nav a:link, #banner nav a:visited {
 			color: #fff;
 			display: inline-block;
@@ -205,7 +203,7 @@ img.left, figure.left {float: left; margin: 0 2em 2em 0;}
 			text-transform: lowercase;
 			font-variant: small-caps;
 		}
-		
+
 		/* #banner nav a:active, */
 		#banner nav .active a:link, #banner nav .active a:visited {
 			border: 1px solid #FFF;
@@ -290,7 +288,7 @@ div#side-content {
 	overflow: hidden;
 	padding: 20px;
 	width: 760px;
-	
+
 	border-radius: 10px;
 	-moz-border-radius: 10px;
 	-webkit-border-radius: 10px;
@@ -318,7 +316,7 @@ div#side-content {
 	margin-bottom: 2em;
 	overflow: hidden;
 	padding: 20px 20px;
-	width: 70%;	
+	width: 70%;
 	border-radius: 10px;
 	-moz-border-radius: 10px;
 	-webkit-border-radius: 10px;
@@ -358,21 +356,21 @@ div#side-content {
 		float: left;
 		width: 615px;
 	}
-	
+
 	#extras .blogroll li {float: left; margin: 0 20px 0 0; width: 185px;}
-	
+
 	/* Social */
 	#extras .social {
 		float: right;
 		width: 175px;
 	}
-	
+
 	#extras div[class='social'] a {
 		background-repeat: no-repeat;
 		background-position: 3px 6px;
 		padding-left: 25px;
 	}
-	
+
 		/* Icons */
 		.social a[href*='about.me'] {background-image: url('../images/icons/aboutme.png');}
 		.social a[href*='bitbucket.org'] {background-image: url('../images/icons/bitbucket.png');}
@@ -412,7 +410,7 @@ div#side-content {
 	padding: 20px;
 	text-align: left;
 	width: 760px;
-	
+
 	border-radius: 10px;
 	-moz-border-radius: 10px;
 	-webkit-border-radius: 10px;
@@ -435,7 +433,7 @@ div#side-content {
 /* Blog */
 .hentry {
 	display: block;
-	clear: both; 	
+	clear: both;
 	border-bottom: 1px solid #eee;
 	padding: 1.5em 0;
 }
@@ -444,10 +442,10 @@ li:last-child .hentry, #content > .hentry {border: 0; margin: 0;}
 .hentry img{display : none ;}
 
 .entry-title {
-	font-size: 3em; 
+	font-size: 3em;
 	font-family: Lato;
 	font-weight: 300;
-	margin-bottom: 60px; 
+	margin-bottom: 60px;
 	margin-top: 30px;
 	text-align: center;
 }
@@ -473,7 +471,7 @@ li:last-child .hentry, #content > .hentry {border: 0; margin: 0;}
 	/* Blog Index */
 	#posts-list {list-style: none; margin: 0;}
 	#posts-list .hentry {padding-left: 10px; position: relative;}
-	
+
 	#posts-list footer {
 		left: 10px;
 		position: relative;
@@ -481,7 +479,7 @@ li:last-child .hentry, #content > .hentry {border: 0; margin: 0;}
 		top: 0.5em;
 		width: 190px;
 	}
-	
+
 	/* About the Author */
 	#about-author {
 		background: #f9f9f9;
@@ -489,21 +487,21 @@ li:last-child .hentry, #content > .hentry {border: 0; margin: 0;}
 		font-style: normal;
 		margin: 2em 0;
 		padding: 10px 20px 15px 20px;
-		
+
 		border-radius: 5px;
 		-moz-border-radius: 5px;
 		-webkit-border-radius: 5px;
 	}
-	
+
 	#about-author strong {
 		color: #C64350;
 		clear: both;
 		display: block;
 		font-size: 1.429em;
 	}
-	
+
 	#about-author .photo {border: 1px solid #ddd; float: left; margin: 5px 1em 0 0;}
-	
+
 	/* Comments */
 	#comments-list {list-style: none; margin: 0 1em;}
 	#comments-list blockquote {
@@ -512,25 +510,25 @@ li:last-child .hentry, #content > .hentry {border: 0; margin: 0;}
 		font-style: normal;
 		margin: 0;
 		padding: 15px 20px;
-		
+
 		border-radius: 5px;
 		-moz-border-radius: 5px;
 		-webkit-border-radius: 5px;
 	}
 	#comments-list footer {color: #888; padding: .5em 1em 0 0; text-align: right;}
-	
+
 	#comments-list li:nth-child(2n) blockquote {background: #F5f5f5;}
-	
+
 	/* Add a Comment */
 	#add-comment label {clear: left; float: left; text-align: left; width: 150px;}
 	#add-comment input[type='text'],
 	#add-comment input[type='email'],
 	#add-comment input[type='url'] {float: left; width: 200px;}
-	
+
 	#add-comment textarea {float: left; height: 150px; width: 495px;}
-	
+
 	#add-comment p.req {clear: both; margin: 0 .5em 1em 0; text-align: right;}
-	
+
 	#add-comment input[type='submit'] {float: right; margin: 0 .5em;}
 	#add-comment * {margin-bottom: .5em;}
 
@@ -560,4 +558,4 @@ li:last-child .hentry, #content > .hentry {border: 0; margin: 0;}
 	display: block;
 	margin: auto;
 	margin-bottom: 20px;
-}
+}

+ 117 - 205
theme/static/css/pygment.css

@@ -1,205 +1,117 @@
-.hll {
-background-color:#eee;
-}
-.c {
-color:#408090;
-font-style:italic;
-}
-.err {
-border:1px solid #FF0000;
-}
-.k {
-color:#007020;
-font-weight:bold;
-}
-.o {
-color:#666666;
-}
-.cm {
-color:#408090;
-font-style:italic;
-}
-.cp {
-color:#007020;
-}
-.c1 {
-color:#408090;
-font-style:italic;
-}
-.cs {
-background-color:#FFF0F0;
-color:#408090;
-}
-.gd {
-color:#A00000;
-}
-.ge {
-font-style:italic;
-}
-.gr {
-color:#FF0000;
-}
-.gh {
-color:#000080;
-font-weight:bold;
-}
-.gi {
-color:#00A000;
-}
-.go {
-color:#303030;
-}
-.gp {
-color:#C65D09;
-font-weight:bold;
-}
-.gs {
-font-weight:bold;
-}
-.gu {
-color:#800080;
-font-weight:bold;
-}
-.gt {
-color:#0040D0;
-}
-.kc {
-color:#007020;
-font-weight:bold;
-}
-.kd {
-color:#007020;
-font-weight:bold;
-}
-.kn {
-color:#007020;
-font-weight:bold;
-}
-.kp {
-color:#007020;
-}
-.kr {
-color:#007020;
-font-weight:bold;
-}
-.kt {
-color:#902000;
-}
-.m {
-color:#208050;
-}
-.s {
-color:#4070A0;
-}
-.na {
-color:#4070A0;
-}
-.nb {
-color:#007020;
-}
-.nc {
-color:#0E84B5;
-font-weight:bold;
-}
-.no {
-color:#60ADD5;
-}
-.nd {
-color:#555555;
-font-weight:bold;
-}
-.ni {
-color:#D55537;
-font-weight:bold;
-}
-.ne {
-color:#007020;
-}
-.nf {
-color:#06287E;
-}
-.nl {
-color:#002070;
-font-weight:bold;
-}
-.nn {
-color:#0E84B5;
-font-weight:bold;
-}
-.nt {
-color:#062873;
-font-weight:bold;
-}
-.nv {
-color:#BB60D5;
-}
-.ow {
-color:#007020;
-font-weight:bold;
-}
-.w {
-color:#BBBBBB;
-}
-.mf {
-color:#208050;
-}
-.mh {
-color:#208050;
-}
-.mi {
-color:#208050;
-}
-.mo {
-color:#208050;
-}
-.sb {
-color:#4070A0;
-}
-.sc {
-color:#4070A0;
-}
-.sd {
-color:#4070A0;
-font-style:italic;
-}
-.s2 {
-color:#4070A0;
-}
-.se {
-color:#4070A0;
-font-weight:bold;
-}
-.sh {
-color:#4070A0;
-}
-.si {
-color:#70A0D0;
-font-style:italic;
-}
-.sx {
-color:#C65D09;
-}
-.sr {
-color:#235388;
-}
-.s1 {
-color:#4070A0;
-}
-.ss {
-color:#517918;
-}
-.bp {
-color:#007020;
-}
-.vc {
-color:#BB60D5;
-}
-.vg {
-color:#BB60D5;
-}
-.vi {
-color:#BB60D5;
-}
-.il {
-color:#208050;
-}
+pre {
+  padding: 5px;
+  margin: 0;
+  font-size: 12px;
+}
+
+code {
+  background-color: #fff;
+  font-size: 12px;
+  padding: 0 5px 0 5px;
+}
+
+table.highlighttable tr td {
+  vertical-align: middle;
+  padding: 0;
+}
+
+
+table.highlighttable {
+  border-collapse: collapse;
+  border-spacing: 0;
+}
+
+.linenos {
+  padding: 0;
+  background-color: #fff;
+  width: 1%;
+  white-space: nowrap;
+}
+
+.linenos pre {
+  display: inline-block;
+  border: 1px solid #d8d8d8;
+  border-right-width: 0;
+  color: #8e908c;
+}
+
+.linenos a {
+  color: #4d4d4c;
+  text-decoration: none;
+}
+
+.highlight  {
+  background: #fff;
+  color: #4d4d4c;
+  border: 1px solid #d8d8d8;
+  padding: 0;
+}
+
+.highlight pre {
+  padding-left: 10px;
+}
+
+.highlight .hll { background-color: #d6d6d6 }
+.highlight .c { color: #8e908c } /* Comment */
+.highlight .err { color: #c82829 } /* Error */
+.highlight .k { color: #8959a8 } /* Keyword */
+.highlight .l { color: #f5871f } /* Literal */
+.highlight .n { color: #4d4d4c } /* Name */
+.highlight .o { color: #3e999f } /* Operator */
+.highlight .p { color: #4d4d4c } /* Punctuation */
+.highlight .cm { color: #8e908c } /* Comment.Multiline */
+.highlight .cp { color: #8e908c } /* Comment.Preproc */
+.highlight .c1 { color: #8e908c } /* Comment.Single */
+.highlight .cs { color: #8e908c } /* Comment.Special */
+.highlight .gd { color: #c82829 } /* Generic.Deleted */
+.highlight .ge { font-style: italic } /* Generic.Emph */
+.highlight .gh { color: #4d4d4c; font-weight: bold } /* Generic.Heading */
+.highlight .gi { color: #718c00 } /* Generic.Inserted */
+.highlight .gp { color: #8e908c; font-weight: bold } /* Generic.Prompt */
+.highlight .gs { font-weight: bold } /* Generic.Strong */
+.highlight .gu { color: #3e999f; font-weight: bold } /* Generic.Subheading */
+.highlight .kc { color: #8959a8 } /* Keyword.Constant */
+.highlight .kd { color: #8959a8 } /* Keyword.Declaration */
+.highlight .kn { color: #3e999f } /* Keyword.Namespace */
+.highlight .kp { color: #8959a8 } /* Keyword.Pseudo */
+.highlight .kr { color: #8959a8 } /* Keyword.Reserved */
+.highlight .kt { color: #eab700 } /* Keyword.Type */
+.highlight .ld { color: #718c00 } /* Literal.Date */
+.highlight .m { color: #f5871f } /* Literal.Number */
+.highlight .s { color: #718c00 } /* Literal.String */
+.highlight .na { color: #4271ae } /* Name.Attribute */
+.highlight .nb { color: #4d4d4c } /* Name.Builtin */
+.highlight .nc { color: #eab700 } /* Name.Class */
+.highlight .no { color: #c82829 } /* Name.Constant */
+.highlight .nd { color: #3e999f } /* Name.Decorator */
+.highlight .ni { color: #4d4d4c } /* Name.Entity */
+.highlight .ne { color: #c82829 } /* Name.Exception */
+.highlight .nf { color: #4271ae } /* Name.Function */
+.highlight .nl { color: #4d4d4c } /* Name.Label */
+.highlight .nn { color: #eab700 } /* Name.Namespace */
+.highlight .nx { color: #4271ae } /* Name.Other */
+.highlight .py { color: #4d4d4c } /* Name.Property */
+.highlight .nt { color: #3e999f } /* Name.Tag */
+.highlight .nv { color: #c82829 } /* Name.Variable */
+.highlight .ow { color: #3e999f } /* Operator.Word */
+.highlight .w { color: #4d4d4c } /* Text.Whitespace */
+.highlight .mf { color: #f5871f } /* Literal.Number.Float */
+.highlight .mh { color: #f5871f } /* Literal.Number.Hex */
+.highlight .mi { color: #f5871f } /* Literal.Number.Integer */
+.highlight .mo { color: #f5871f } /* Literal.Number.Oct */
+.highlight .sb { color: #718c00 } /* Literal.String.Backtick */
+.highlight .sc { color: #4d4d4c } /* Literal.String.Char */
+.highlight .sd { color: #8e908c } /* Literal.String.Doc */
+.highlight .s2 { color: #718c00 } /* Literal.String.Double */
+.highlight .se { color: #f5871f } /* Literal.String.Escape */
+.highlight .sh { color: #718c00 } /* Literal.String.Heredoc */
+.highlight .si { color: #f5871f } /* Literal.String.Interpol */
+.highlight .sx { color: #718c00 } /* Literal.String.Other */
+.highlight .sr { color: #718c00 } /* Literal.String.Regex */
+.highlight .s1 { color: #718c00 } /* Literal.String.Single */
+.highlight .ss { color: #718c00 } /* Literal.String.Symbol */
+.highlight .bp { color: #4d4d4c } /* Name.Builtin.Pseudo */
+.highlight .vc { color: #c82829 } /* Name.Variable.Class */
+.highlight .vg { color: #c82829 } /* Name.Variable.Global */
+.highlight .vi { color: #c82829 } /* Name.Variable.Instance */
+.highlight .il { color: #f5871f } /* Literal.Number.Integer.Long */