An example post about code insertion into posts.
Testing code snippet highlight
The following example shows how to highlight a piece of code throughout the use of pygments:
Code highlighting with redcarpet
Another snippet rendered with the most common Github code syntax:
def strip_nonascii(self, s):
"""This method remove non-ascii chars from argument"""
return ud.normalize('NFKD', unicode(s) ).encode('ascii','ignore')
@db_commit
def create_users_table(self, cursor):
""" Check the existence of the users log table, otherwise create it """
pass
package astrac.akka.askretry
import akka.actor._
import akka.util.Timeout
import akka.pattern.ask
import scala.concurrent.duration._
import scala.concurrent.Future
object RetryingActor {
case class Ask[T](target: ActorRef, message: T, rate: FiniteDuration,
maxAttempts: Int)
case object Retry
case class RetryException(attempts: Int) extends Exception(s"Cannot retry
after $attempts attempts")
def props[T] = Props[RetryingActor]
}
Check the markdown of this example in order to fully comprehend the correct syntax.
Here you can find more detailed information.