All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.liftweb.markdown.Decorator.scala Maven / Gradle / Ivy

The newest version!
package net.liftweb.markdown

/*
 * Copyright 2013 WorldWide Conferencing, LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Based on https://github.com/chenkelmann/actuarius originally developed by
 * Christoph Henkelmann http://henkelmann.eu/
 */

/**
 * This trait influences the behavior of the Markdown output of inline and block parsers
 * and the complete transformer.
 * Mix in this trait and override methods to change the behavior and override the "deco()" method
 * in the respective parser/transformer to return
 * your modified instances to change the output they create.
 *
 * Inline element decoration methods always get passed the spanned text, so you have to
 * prepend and append the opening/closing tags. For block elements there is always a method
 * for the opening and closing tags. This is to make block
 * processing more efficient to prevent unnecessary String building of whole blocks just to
 * add tags. (The block building uses a StringBuilder internally and just appends the returned tags)
 *
 * If you want line breaks after opening/closing block level tags, you have to add the newline yourself.
 */

trait Decorator {
    /**
     * The string used to ident one level. Defaults to the empty string
     */
    def indentation() = ""
    /**
     * If true, inline xml tags and verbatim xml blocks are allowed,
     * otherwise they are escaped and included as plain text
     */
    def allowVerbatimXml():Boolean = true
    /** used to print out manual line breaks (default: 
) */ def decorateBreak():String = "
" /** used to print out inline code (default: ...) */ def decorateCode(code:String):String = "" + code + "" /** used to print out emphasized text (default ...) */ def decorateEmphasis(text:String):String = "" + text + "" /** Used to print out strong text (default: ... */ def decorateStrong(text:String):String = "" + text + "" /** Used to print link elements (default: "" + text + "" case Some(t) => "" + text + "" } /** Used to print image elements (default: "\""" case Some(t) => "\""" } /**used to print a horizontal ruler defaults to "
\n" */ def decorateRuler():String = "
\n" /** used to print the beginning of a header, defaults to "" */ def decorateHeaderOpen(headerNo:Int):String = "" /** used to print the end of a header, defaults to "" */ def decorateHeaderClose(headerNo:Int):String = "\n" /** used to print the beginning of a code block, defaults to "
"*/
    def decorateCodeBlockOpen():String = "
"
    /** used to print the end of a code block, defaults to "
\n" */ def decorateCodeBlockClose():String = "
\n" /** used to print the beginning of a paragraph, defaults to "

" */ def decorateParagraphOpen():String = "

" /** used to print the end of a paragraph, defaults to "

\n" */ def decorateParagraphClose():String = "

\n" /** used to print the beginning of a blockquote, defaults to "
" */ def decorateBlockQuoteOpen():String = "
" /** used to print the end of a blockquote, defaults to "
\n" */ def decorateBlockQuoteClose():String = "
\n" /** used to print the beginning of a list item, defaults to "
  • " */ def decorateItemOpen():String = "
  • " /** used to print the end of a list item, defaults to "
  • " */ def decorateItemClose():String = "\n" /** used to print the beginning of an unordered list, defaults to "
      \n" */ def decorateUListOpen():String = "
        \n" /** used to print the end of an unordered list, defaults to "
      \n" */ def decorateUListClose():String = "
    \n" /** used to print the beginning of an ordered list, defaults to
      \n */ def decorateOListOpen():String = "
        \n" /** used to print the end of an ordered list, defaults to
      \n */ def decorateOListClose():String = "
    \n" } /** * Default instance of Decorator with the standard Markdown behavior */ object Decorator extends Decorator { }




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy