PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/scalate-wikitext/src/main/scala/org/fusesource/scalate/wikitext/ScalateConfluenceLanguage.scala

http://github.com/scalate/scalate
Scala | 57 lines | 22 code | 7 blank | 28 comment | 0 complexity | c136c1d588f6fcb01dcc680648fd65cd MD5 | raw file
 1/**
 2 * Copyright (C) 2009-2011 the original author or authors.
 3 * See the notice.md file distributed with this work for additional
 4 * information regarding copyright ownership.
 5 *
 6 * Licensed under the Apache License, Version 2.0 (the "License");
 7 * you may not use this file except in compliance with the License.
 8 * You may obtain a copy of the License at
 9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18package org.fusesource.scalate.wikitext
19
20import org.eclipse.mylyn.wikitext.core.parser.markup.Block
21import org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage
22import java.{ util => ju }
23import collection.JavaConverters._
24
25/**
26 * Registry of language extensions
27 */
28object ConfluenceLanguageExtensions {
29  var extensions: List[Block] = List()
30}
31
32/**
33 * Adds extensions to the Confluence language such as support for a 'pygmentize' macro
34 *
35 * The pygmentize macro will use the pygmentize command line tool to syntax highlight the code within the block
36 *
37 * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
38 */
39class ScalateConfluenceLanguage extends ConfluenceLanguage {
40
41  override def addStandardBlocks(blocks: ju.List[Block], paragraphBreakingBlocks: ju.List[Block]) = {
42    super.addStandardBlocks(blocks, paragraphBreakingBlocks)
43
44    blocks.addAll(ConfluenceLanguageExtensions.extensions.asJava)
45
46    List(new PygmentsBlock, new SnippetBlock,
47      new HtmlBlock, new DivBlock,
48      new SectionBlock, new ColumnBlock,
49      new CenterBlock,
50
51      // tags
52      new AttributesTag, new IncludeTag, new ChildrenTag).foreach { b =>
53        blocks.add(b)
54        paragraphBreakingBlocks.add(b)
55      }
56  }
57}