module CodeRay module Encoders class HTML class CSS attr :stylesheet def CSS.load_stylesheet style = nil CodeRay::Styles[style] end def initialize style = :default @classes = Hash.new style = CSS.load_stylesheet style @stylesheet = [ style::CSS_MAIN_STYLES, style::TOKEN_COLORS.gsub(/^(?!$)/, '.CodeRay ') ].join("\n") parse style::TOKEN_COLORS end def [] *styles cl = @classes[styles.first] return '' unless cl style = '' 1.upto(styles.size) do |offset| break if style = cl[styles[offset .. -1]] end raise 'Style not found: %p' % [styles] if $DEBUG and style.empty? return style end private CSS_CLASS_PATTERN = / ( (?: # $1 = classes \s* \. [-\w]+ )+ ) \s* \{ \s* ( [^\}]+ )? # $2 = style \s* \} \s* | ( . ) # $3 = error /mx def parse stylesheet stylesheet.scan CSS_CLASS_PATTERN do |classes, style, error| raise "CSS parse error: '#{error.inspect}' not recognized" if error styles = classes.scan(/[-\w]+/) cl = styles.pop @classes[cl] ||= Hash.new @classes[cl][styles] = style.to_s.strip end end end end end end if $0 == __FILE__ require 'pp' pp CodeRay::Encoders::HTML::CSS.new end icSideFloats Apache XML Graphics FOP: https://github.com/apache/xmlgraphics-fopwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/test/java/org/apache/fop/visual/RedirectorLineHandler.java
blob: d77870397a4bda036b1f6ec89aa88724074251ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

/* $Id$ */

package org.apache.fop.visual;

/**
 * This interface is used to redirect output from an external application elsewhere.
 */
public interface RedirectorLineHandler {

    /**
     * Called before the first handleLine() call.
     */
    void notifyStart();

    /**
     * Called for each line of output to be processed.
     * @param line a line of application output
     */
    void handleLine(String line);
    
    /**
     * Called after the last handleLine() call.
     */
    void notifyEnd();
}