New upstream version 1.3
Emmanuel Bourg
6 years ago
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | ||
2 | <!-- | |
3 | Licensed to the Apache Software Foundation (ASF) under one | |
4 | or more contributor license agreements. See the NOTICE file | |
5 | distributed with this work for additional information | |
6 | regarding copyright ownership. The ASF licenses this file | |
7 | to you under the Apache License, Version 2.0 (the | |
8 | "License"); you may not use this file except in compliance | |
9 | with the License. You may obtain a copy of the License at | |
10 | ||
11 | http://www.apache.org/licenses/LICENSE-2.0 | |
12 | ||
13 | Unless required by applicable law or agreed to in writing, | |
14 | software distributed under the License is distributed on an | |
15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | KIND, either express or implied. See the License for the | |
17 | specific language governing permissions and limitations | |
18 | under the License. | |
19 | --> | |
20 | ||
21 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
22 | <modelVersion>4.0.0</modelVersion> | |
23 | ||
24 | <parent> | |
25 | <groupId>org.apache.maven.doxia</groupId> | |
26 | <artifactId>doxia</artifactId> | |
27 | <version>1.2</version> | |
28 | <relativePath>../pom.xml</relativePath> | |
29 | </parent> | |
30 | ||
31 | <artifactId>doxia-book</artifactId> | |
32 | <name>Doxia :: Book Component</name> | |
33 | <description>A component to write books like user manuals and guides in any format supported by Doxia.</description> | |
34 | <url>http://maven.apache.org/doxia/doxia/doxia-book/</url> | |
35 | ||
36 | <dependencies> | |
37 | <!-- doxia core --> | |
38 | <dependency> | |
39 | <groupId>org.apache.maven.doxia</groupId> | |
40 | <artifactId>doxia-core</artifactId> | |
41 | </dependency> | |
42 | <dependency> | |
43 | <groupId>org.apache.maven.doxia</groupId> | |
44 | <artifactId>doxia-sink-api</artifactId> | |
45 | </dependency> | |
46 | ||
47 | <!-- doxia modules ordered --> | |
48 | <dependency> | |
49 | <groupId>org.apache.maven.doxia</groupId> | |
50 | <artifactId>doxia-module-apt</artifactId> | |
51 | </dependency> | |
52 | <dependency> | |
53 | <groupId>org.apache.maven.doxia</groupId> | |
54 | <artifactId>doxia-module-docbook-simple</artifactId> | |
55 | </dependency> | |
56 | <dependency> | |
57 | <groupId>org.apache.maven.doxia</groupId> | |
58 | <artifactId>doxia-module-itext</artifactId> | |
59 | </dependency> | |
60 | <dependency> | |
61 | <groupId>org.apache.maven.doxia</groupId> | |
62 | <artifactId>doxia-module-latex</artifactId> | |
63 | </dependency> | |
64 | <dependency> | |
65 | <groupId>org.apache.maven.doxia</groupId> | |
66 | <artifactId>doxia-module-xdoc</artifactId> | |
67 | </dependency> | |
68 | <dependency> | |
69 | <groupId>org.apache.maven.doxia</groupId> | |
70 | <artifactId>doxia-module-xhtml</artifactId> | |
71 | </dependency> | |
72 | ||
73 | <!-- plexus --> | |
74 | <dependency> | |
75 | <groupId>org.codehaus.plexus</groupId> | |
76 | <artifactId>plexus-container-default</artifactId> | |
77 | </dependency> | |
78 | <dependency> | |
79 | <groupId>org.codehaus.plexus</groupId> | |
80 | <artifactId>plexus-i18n</artifactId> | |
81 | <version>1.0-beta-6</version> | |
82 | </dependency> | |
83 | <dependency> | |
84 | <groupId>org.codehaus.plexus</groupId> | |
85 | <artifactId>plexus-utils</artifactId> | |
86 | </dependency> | |
87 | ||
88 | <!-- test --> | |
89 | <dependency> | |
90 | <groupId>org.apache.maven.doxia</groupId> | |
91 | <artifactId>doxia-core</artifactId> | |
92 | <type>test-jar</type> | |
93 | <scope>test</scope> | |
94 | </dependency> | |
95 | </dependencies> | |
96 | ||
97 | <build> | |
98 | <plugins> | |
99 | <plugin> | |
100 | <groupId>org.codehaus.modello</groupId> | |
101 | <artifactId>modello-maven-plugin</artifactId> | |
102 | <configuration> | |
103 | <models> | |
104 | <model>src/main/modello/book.mdo</model> | |
105 | </models> | |
106 | <version>1.0.0</version> | |
107 | </configuration> | |
108 | <executions> | |
109 | <execution> | |
110 | <id>site-docs</id> | |
111 | <phase>pre-site</phase> | |
112 | <goals> | |
113 | <goal>xdoc</goal> | |
114 | <goal>xsd</goal> | |
115 | </goals> | |
116 | </execution> | |
117 | <execution> | |
118 | <id>descriptor</id> | |
119 | <phase>generate-sources</phase> | |
120 | <goals> | |
121 | <goal>java</goal> | |
122 | <goal>xpp3-reader</goal> | |
123 | <goal>xsd</goal> | |
124 | </goals> | |
125 | </execution> | |
126 | </executions> | |
127 | </plugin> | |
128 | <plugin> | |
129 | <groupId>org.apache.maven.plugins</groupId> | |
130 | <artifactId>maven-surefire-plugin</artifactId> | |
131 | <configuration> | |
132 | <!-- To be sure that JVM will implement AWT in software --> | |
133 | <systemProperties> | |
134 | <property> | |
135 | <name>java.awt.headless</name> | |
136 | <value>true</value> | |
137 | </property> | |
138 | </systemProperties> | |
139 | </configuration> | |
140 | </plugin> | |
141 | </plugins> | |
142 | </build> | |
143 | ||
144 | <profiles> | |
145 | <profile> | |
146 | <id>reporting</id> | |
147 | <reporting> | |
148 | <plugins> | |
149 | <plugin> | |
150 | <groupId>org.codehaus.mojo</groupId> | |
151 | <artifactId>l10n-maven-plugin</artifactId> | |
152 | <version>1.0-alpha-2</version> | |
153 | <configuration> | |
154 | <locales> | |
155 | <locale>en</locale> | |
156 | <locale>fr</locale> | |
157 | </locales> | |
158 | </configuration> | |
159 | </plugin> | |
160 | </plugins> | |
161 | </reporting> | |
162 | </profile> | |
163 | </profiles> | |
164 | </project>⏎ |
0 | package org.apache.maven.doxia.book; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.model.BookModel; | |
22 | ||
23 | import java.io.File; | |
24 | import java.util.List; | |
25 | import java.util.Locale; | |
26 | ||
27 | /** | |
28 | * An interface to create books in different output formats from a book descriptor. | |
29 | * | |
30 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
31 | * @version $Id: BookDoxia.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
32 | */ | |
33 | public interface BookDoxia | |
34 | { | |
35 | /** The plexus lookup role. */ | |
36 | String ROLE = BookDoxia.class.getName(); | |
37 | ||
38 | /** | |
39 | * Load a BookModel from a descriptor file. | |
40 | * | |
41 | * @param bookDescriptor the book descriptor file. | |
42 | * @return BookModel | |
43 | * @throws org.apache.maven.doxia.book.BookDoxiaException if the model cannot be loaded. | |
44 | */ | |
45 | BookModel loadBook( File bookDescriptor ) | |
46 | throws BookDoxiaException; | |
47 | ||
48 | /** | |
49 | * Creates a book from a BookModel using the {@link Locale#getDefault()} and UTF-8 as default encoding. | |
50 | * | |
51 | * @param book the BookModel. | |
52 | * @param bookRendererId the id of the output format. | |
53 | * @param files a list of source files. | |
54 | * @param outputDirectory the output directory. | |
55 | * @throws org.apache.maven.doxia.book.BookDoxiaException if the model cannot be loaded. | |
56 | * @see #renderBook(BookModel, String, List, File, Locale, String, String) | |
57 | * @see Locale#getDefault() | |
58 | */ | |
59 | void renderBook( BookModel book, String bookRendererId, List<File> files, File outputDirectory ) | |
60 | throws BookDoxiaException; | |
61 | ||
62 | /** | |
63 | * Creates a book from a BookModel. | |
64 | * | |
65 | * @param book the BookModel. | |
66 | * @param bookRendererId the id of the output format. | |
67 | * @param files a list of source files. | |
68 | * @param outputDirectory the output directory. | |
69 | * @param locale the wanted locale. | |
70 | * @param inputEncoding the input encoding when processing <code>files</code>. | |
71 | * @param outputEncoding the output encoding when writing files in <code>ouputDirectory</code>. | |
72 | * @throws org.apache.maven.doxia.book.BookDoxiaException if the model cannot be loaded. | |
73 | * @since 1.1 | |
74 | */ | |
75 | void renderBook( BookModel book, String bookRendererId, List<File> files, File outputDirectory, Locale locale, | |
76 | String inputEncoding, String outputEncoding ) | |
77 | throws BookDoxiaException; | |
78 | } |
0 | package org.apache.maven.doxia.book; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | /** | |
22 | * Wraps an exception when rendering books. | |
23 | * | |
24 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
25 | * @version $Id: BookDoxiaException.java 740275 2009-02-03 11:17:28Z vsiveton $ | |
26 | */ | |
27 | public class BookDoxiaException | |
28 | extends Exception | |
29 | { | |
30 | /** serialVersionUID */ | |
31 | private static final long serialVersionUID = 87146681585045106L; | |
32 | ||
33 | /** | |
34 | * Construct a new BookDoxiaException with the specified detail message. | |
35 | * | |
36 | * @param message The detailed message. This can later be retrieved by the Throwable.getMessage() method. | |
37 | */ | |
38 | public BookDoxiaException( String message ) | |
39 | { | |
40 | super( message ); | |
41 | } | |
42 | ||
43 | /** | |
44 | * Construct a new BookDoxiaException with the specified detail message and cause. | |
45 | * | |
46 | * @param message The detailed message. This can later be retrieved by the Throwable.getMessage() method. | |
47 | * @param cause the cause. This can be retrieved later by the Throwable.getCause() method | |
48 | * (a null value is permitted, and indicates that the cause is nonexistent or unknown). | |
49 | */ | |
50 | public BookDoxiaException( String message, Throwable cause ) | |
51 | { | |
52 | super( message, cause ); | |
53 | } | |
54 | } |
0 | package org.apache.maven.doxia.book; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.context.BookContext; | |
22 | import org.apache.maven.doxia.book.model.BookModel; | |
23 | import org.apache.maven.doxia.book.services.indexer.BookIndexer; | |
24 | import org.apache.maven.doxia.book.services.io.BookIo; | |
25 | import org.apache.maven.doxia.book.services.renderer.BookRenderer; | |
26 | import org.apache.maven.doxia.book.services.validation.BookValidator; | |
27 | import org.apache.maven.doxia.book.services.validation.ValidationResult; | |
28 | import org.codehaus.plexus.logging.AbstractLogEnabled; | |
29 | ||
30 | import java.io.File; | |
31 | import java.util.Collections; | |
32 | import java.util.List; | |
33 | import java.util.Locale; | |
34 | import java.util.Map; | |
35 | import java.util.Set; | |
36 | ||
37 | /** | |
38 | * Default implementation of BookDoxia. | |
39 | * | |
40 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
41 | * @version $Id: DefaultBookDoxia.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
42 | * @plexus.component | |
43 | */ | |
44 | public class DefaultBookDoxia | |
45 | extends AbstractLogEnabled | |
46 | implements BookDoxia | |
47 | { | |
48 | /** | |
49 | * @plexus.requirement | |
50 | */ | |
51 | private BookIo bookIo; | |
52 | ||
53 | /** | |
54 | * @plexus.requirement | |
55 | */ | |
56 | private BookValidator bookValidator; | |
57 | ||
58 | /** | |
59 | * @plexus.requirement | |
60 | */ | |
61 | private BookIndexer bookIndexer; | |
62 | ||
63 | /** | |
64 | * @plexus.requirement role="org.apache.maven.doxia.book.services.renderer.BookRenderer" | |
65 | */ | |
66 | private Map<String, BookRenderer> bookRenderers; | |
67 | ||
68 | // ---------------------------------------------------------------------- | |
69 | // BookDoxia Implementation | |
70 | // ---------------------------------------------------------------------- | |
71 | ||
72 | /** {@inheritDoc} */ | |
73 | public BookModel loadBook( File bookDescriptor ) | |
74 | throws BookDoxiaException | |
75 | { | |
76 | return bookIo.readBook( bookDescriptor ); | |
77 | } | |
78 | ||
79 | /** {@inheritDoc} */ | |
80 | public void renderBook( BookModel book, String bookRendererId, List<File> files, File outputDirectory ) | |
81 | throws BookDoxiaException | |
82 | { | |
83 | renderBook( book, bookRendererId, files, outputDirectory, Locale.getDefault(), "UTF-8", "UTF-8" ); | |
84 | } | |
85 | ||
86 | /** {@inheritDoc} */ | |
87 | public void renderBook( BookModel book, String bookRendererId, List<File> files, File outputDirectory, | |
88 | Locale locale, String inputEncoding, String outputEncoding ) | |
89 | throws BookDoxiaException | |
90 | { | |
91 | // ---------------------------------------------------------------------- | |
92 | // | |
93 | // ---------------------------------------------------------------------- | |
94 | ||
95 | ValidationResult validationResult = bookValidator.validateBook( book ); | |
96 | ||
97 | if ( !validationResult.isAllOk() ) | |
98 | { | |
99 | throw new InvalidBookDescriptorException( validationResult ); | |
100 | } | |
101 | ||
102 | // ---------------------------------------------------------------------- | |
103 | // Create and initialize the context | |
104 | // ---------------------------------------------------------------------- | |
105 | ||
106 | BookContext context = new BookContext(); | |
107 | ||
108 | context.setBook( book ); | |
109 | ||
110 | context.setOutputDirectory( outputDirectory ); | |
111 | ||
112 | context.setLocale( locale ); | |
113 | ||
114 | context.setInputEncoding( inputEncoding ); | |
115 | ||
116 | context.setOutputEncoding( outputEncoding ); | |
117 | ||
118 | // ----------------------------------------------------------------------- | |
119 | // | |
120 | // ----------------------------------------------------------------------- | |
121 | ||
122 | bookIo.loadFiles( context, files ); | |
123 | ||
124 | // ---------------------------------------------------------------------- | |
125 | // Generate indexes | |
126 | // ---------------------------------------------------------------------- | |
127 | ||
128 | bookIndexer.indexBook( book, context ); | |
129 | ||
130 | // ---------------------------------------------------------------------- | |
131 | // Render the book | |
132 | // ---------------------------------------------------------------------- | |
133 | ||
134 | BookRenderer bookRenderer = bookRenderers.get( bookRendererId ); | |
135 | ||
136 | if ( bookRenderer == null ) | |
137 | { | |
138 | throw new BookDoxiaException( "No such book renderer '" + bookRendererId + "'." ); | |
139 | } | |
140 | ||
141 | bookRenderer.renderBook( context ); | |
142 | } | |
143 | ||
144 | /** | |
145 | * Returns a Set of ids of the BookRenderers that are available in this BookDoxia. | |
146 | * | |
147 | * @return Set | |
148 | */ | |
149 | public Set<String> getAvailableBookRenderers() | |
150 | { | |
151 | return Collections.unmodifiableSet( bookRenderers.keySet() ); | |
152 | } | |
153 | ||
154 | } |
+0
-61
0 | package org.apache.maven.doxia.book; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.services.validation.ValidationResult; | |
22 | ||
23 | /** | |
24 | * Indicates that the book descriptor file could not be parsed correctly. | |
25 | * | |
26 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
27 | * @version $Id: InvalidBookDescriptorException.java 769433 2009-04-28 15:26:55Z ltheussl $ | |
28 | */ | |
29 | public class InvalidBookDescriptorException | |
30 | extends BookDoxiaException | |
31 | { | |
32 | ||
33 | /** serialVersionUID */ | |
34 | private static final long serialVersionUID = -5706648416915909753L; | |
35 | ||
36 | /** ValidationResult. */ | |
37 | private ValidationResult validationResult; | |
38 | ||
39 | /** | |
40 | * Construct a new InvalidBookDescriptorException and stores the given ValidationResult. | |
41 | * | |
42 | * @param validationResult The ValidationResult to store. | |
43 | */ | |
44 | public InvalidBookDescriptorException( ValidationResult validationResult ) | |
45 | { | |
46 | super( "Invalid book descriptor." ); | |
47 | ||
48 | this.validationResult = validationResult; | |
49 | } | |
50 | ||
51 | /** | |
52 | * Return the ValidationResult. | |
53 | * | |
54 | * @return the ValidationResult associated with this Exception. | |
55 | */ | |
56 | public ValidationResult getValidationResult() | |
57 | { | |
58 | return validationResult; | |
59 | } | |
60 | } |
0 | package org.apache.maven.doxia.book.context; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.model.BookModel; | |
22 | ||
23 | import java.io.File; | |
24 | import java.util.Locale; | |
25 | import java.util.Map; | |
26 | import java.util.HashMap; | |
27 | ||
28 | /** | |
29 | * Context to render a book. | |
30 | * | |
31 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
32 | * @version $Id: BookContext.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
33 | */ | |
34 | public class BookContext | |
35 | { | |
36 | /** The BookModel of this context. */ | |
37 | private BookModel book; | |
38 | ||
39 | /** The files. */ | |
40 | private Map<String, BookContext.BookFile> files; | |
41 | ||
42 | /** The output directory. */ | |
43 | private File outputDirectory; | |
44 | ||
45 | /** The BookIndex of this context. */ | |
46 | private BookIndex index; | |
47 | ||
48 | /** The Locale used to generate the navigation. */ | |
49 | private Locale locale; | |
50 | ||
51 | /** The input encoding used to read Doxia file. */ | |
52 | private String inputEncoding; | |
53 | ||
54 | /** The output encoding used to write the renderer files. */ | |
55 | private String outputEncoding; | |
56 | ||
57 | // ---------------------------------------------------------------------- | |
58 | // | |
59 | // ---------------------------------------------------------------------- | |
60 | ||
61 | /** Represents a BookFile. */ | |
62 | public static class BookFile | |
63 | { | |
64 | /** The file. */ | |
65 | private File file; | |
66 | ||
67 | /** The id of the parser. */ | |
68 | private String parserId; | |
69 | ||
70 | /** | |
71 | * Constructor. | |
72 | * | |
73 | * @param file the file. | |
74 | * @param parserId the parser id. | |
75 | */ | |
76 | public BookFile( File file, String parserId ) | |
77 | { | |
78 | this.file = file; | |
79 | this.parserId = parserId; | |
80 | } | |
81 | ||
82 | /** | |
83 | * Return the file of this BookFile. | |
84 | * | |
85 | * @return File. | |
86 | */ | |
87 | public File getFile() | |
88 | { | |
89 | return file; | |
90 | } | |
91 | ||
92 | /** | |
93 | * Return the parserId of this BookFile. | |
94 | * | |
95 | * @return String. | |
96 | */ | |
97 | public String getParserId() | |
98 | { | |
99 | return parserId; | |
100 | } | |
101 | } | |
102 | ||
103 | // ---------------------------------------------------------------------- | |
104 | // Accessors | |
105 | // ---------------------------------------------------------------------- | |
106 | ||
107 | /** | |
108 | * Return the BookModel of this BookContext. | |
109 | * | |
110 | * @return BookModel. | |
111 | */ | |
112 | public BookModel getBook() | |
113 | { | |
114 | return book; | |
115 | } | |
116 | ||
117 | /** | |
118 | * Set the BookModel of this BookContext. | |
119 | * | |
120 | * @param book the BookModel. | |
121 | */ | |
122 | public void setBook( BookModel book ) | |
123 | { | |
124 | this.book = book; | |
125 | } | |
126 | ||
127 | /** | |
128 | * Return the files of this BookContext. | |
129 | * | |
130 | * @return Map. A new HashMap is constructed if the current Map is null. | |
131 | */ | |
132 | public Map<String, BookContext.BookFile> getFiles() | |
133 | { | |
134 | if ( files == null ) | |
135 | { | |
136 | files = new HashMap<String, BookContext.BookFile>(); | |
137 | } | |
138 | ||
139 | return files; | |
140 | } | |
141 | ||
142 | /** | |
143 | * Set the files of this BookContext. | |
144 | * | |
145 | * @param files the Map of files. | |
146 | */ | |
147 | public void setFiles( Map<String, BookContext.BookFile> files ) | |
148 | { | |
149 | this.files = files; | |
150 | } | |
151 | ||
152 | /** | |
153 | * Return the outputDirectory of this BookContext. | |
154 | * | |
155 | * @return File. | |
156 | */ | |
157 | public File getOutputDirectory() | |
158 | { | |
159 | return outputDirectory; | |
160 | } | |
161 | ||
162 | /** | |
163 | * Set the outputDirectory of this BookContext. | |
164 | * | |
165 | * @param outputDirectory the output directory. | |
166 | */ | |
167 | public void setOutputDirectory( File outputDirectory ) | |
168 | { | |
169 | this.outputDirectory = outputDirectory; | |
170 | } | |
171 | ||
172 | /** | |
173 | * Return the index of this BookContext. | |
174 | * | |
175 | * @return BookIndex. | |
176 | */ | |
177 | public BookIndex getIndex() | |
178 | { | |
179 | return index; | |
180 | } | |
181 | ||
182 | /** | |
183 | * Set the index of this BookContext. | |
184 | * | |
185 | * @param index the index to set. | |
186 | */ | |
187 | public void setIndex( BookIndex index ) | |
188 | { | |
189 | this.index = index; | |
190 | } | |
191 | ||
192 | /** | |
193 | * <p>Getter for the field <code>locale</code>.</p> | |
194 | * | |
195 | * @return the locale | |
196 | * @since 1.1 | |
197 | */ | |
198 | public Locale getLocale() | |
199 | { | |
200 | return locale; | |
201 | } | |
202 | ||
203 | /** | |
204 | * <p>Setter for the field <code>locale</code>.</p> | |
205 | * | |
206 | * @param locale the locale to set | |
207 | * @since 1.1 | |
208 | */ | |
209 | public void setLocale( Locale locale ) | |
210 | { | |
211 | this.locale = locale; | |
212 | } | |
213 | ||
214 | /** | |
215 | * <p>Getter for the field <code>inputEncoding</code>.</p> | |
216 | * | |
217 | * @return the inputEncoding | |
218 | * @since 1.1 | |
219 | */ | |
220 | public String getInputEncoding() | |
221 | { | |
222 | return inputEncoding; | |
223 | } | |
224 | ||
225 | /** | |
226 | * <p>Setter for the field <code>inputEncoding</code>.</p> | |
227 | * | |
228 | * @param inputEncoding the inputEncoding to set | |
229 | * @since 1.1 | |
230 | */ | |
231 | public void setInputEncoding( String inputEncoding ) | |
232 | { | |
233 | this.inputEncoding = inputEncoding; | |
234 | } | |
235 | ||
236 | /** | |
237 | * <p>Getter for the field <code>outputEncoding</code>.</p> | |
238 | * | |
239 | * @return the outputEncoding | |
240 | * @since 1.1 | |
241 | */ | |
242 | public String getOutputEncoding() | |
243 | { | |
244 | return outputEncoding; | |
245 | } | |
246 | ||
247 | /** | |
248 | * <p>Setter for the field <code>outputEncoding</code>.</p> | |
249 | * | |
250 | * @param outputEncoding the outputEncoding to set | |
251 | * @since 1.1 | |
252 | */ | |
253 | public void setOutputEncoding( String outputEncoding ) | |
254 | { | |
255 | this.outputEncoding = outputEncoding; | |
256 | } | |
257 | } |
0 | package org.apache.maven.doxia.book.context; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.index.IndexEntry; | |
22 | ||
23 | /** | |
24 | * <p>BookIndex class.</p> | |
25 | * | |
26 | * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugstøl</a> | |
27 | * @version $Id: BookIndex.java 746976 2009-02-23 12:15:38Z vsiveton $ | |
28 | */ | |
29 | public class BookIndex | |
30 | extends IndexEntry | |
31 | { | |
32 | /** | |
33 | * Constructs a new BookIndex. | |
34 | */ | |
35 | public BookIndex() | |
36 | { | |
37 | super( "book" ); | |
38 | } | |
39 | } |
+0
-46
0 | package org.apache.maven.doxia.book.services.indexer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.model.BookModel; | |
22 | import org.apache.maven.doxia.book.context.BookContext; | |
23 | import org.apache.maven.doxia.book.BookDoxiaException; | |
24 | ||
25 | /** | |
26 | * Index a book. | |
27 | * | |
28 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
29 | * @version $Id: BookIndexer.java 746976 2009-02-23 12:15:38Z vsiveton $ | |
30 | */ | |
31 | public interface BookIndexer | |
32 | { | |
33 | /** The plexus lookup role. */ | |
34 | String ROLE = BookIndexer.class.getName(); | |
35 | ||
36 | /** | |
37 | * Index a book. | |
38 | * | |
39 | * @param book the book to index. | |
40 | * @param bookContext the BookContext. | |
41 | * @throws org.apache.maven.doxia.book.BookDoxiaException if the book cannot be indexed. | |
42 | */ | |
43 | void indexBook( BookModel book, BookContext bookContext ) | |
44 | throws BookDoxiaException; | |
45 | } |
+0
-147
0 | package org.apache.maven.doxia.book.services.indexer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.FileNotFoundException; | |
22 | import java.io.FileReader; | |
23 | ||
24 | import org.apache.maven.doxia.Doxia; | |
25 | import org.apache.maven.doxia.book.BookDoxiaException; | |
26 | import org.apache.maven.doxia.book.context.BookContext; | |
27 | import org.apache.maven.doxia.book.context.BookIndex; | |
28 | import org.apache.maven.doxia.book.model.BookModel; | |
29 | import org.apache.maven.doxia.book.model.Chapter; | |
30 | import org.apache.maven.doxia.book.model.Section; | |
31 | import org.apache.maven.doxia.index.IndexEntry; | |
32 | import org.apache.maven.doxia.index.IndexingSink; | |
33 | import org.apache.maven.doxia.parser.ParseException; | |
34 | import org.apache.maven.doxia.parser.manager.ParserNotFoundException; | |
35 | import org.codehaus.plexus.logging.AbstractLogEnabled; | |
36 | ||
37 | /** | |
38 | * Default implementation of BookIndexer. | |
39 | * | |
40 | * @plexus.component | |
41 | * | |
42 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
43 | * @version $Id: DefaultBookIndexer.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
44 | */ | |
45 | public class DefaultBookIndexer | |
46 | extends AbstractLogEnabled | |
47 | implements BookIndexer | |
48 | { | |
49 | /** | |
50 | * @plexus.requirement | |
51 | */ | |
52 | private Doxia doxia; | |
53 | ||
54 | // ---------------------------------------------------------------------- | |
55 | // BookIndexer Implementation | |
56 | // ---------------------------------------------------------------------- | |
57 | ||
58 | /** {@inheritDoc} */ | |
59 | public void indexBook( BookModel book, BookContext bookContext ) | |
60 | throws BookDoxiaException | |
61 | { | |
62 | BookIndex index = new BookIndex(); | |
63 | ||
64 | for ( Chapter chapter : book.getChapters() ) | |
65 | { | |
66 | indexChapter( bookContext, index, chapter ); | |
67 | } | |
68 | ||
69 | bookContext.setIndex( index ); | |
70 | } | |
71 | ||
72 | // ---------------------------------------------------------------------- | |
73 | // Private | |
74 | // ---------------------------------------------------------------------- | |
75 | ||
76 | /** | |
77 | * Index a chapter. | |
78 | * | |
79 | * @param context the BookContext. | |
80 | * @param bookEntry the IndexEntry. | |
81 | * @param chapter the Chapter to index. | |
82 | * @throws BookDoxiaException if the chapter cannot be indexed. | |
83 | */ | |
84 | private void indexChapter( BookContext context, IndexEntry bookEntry, Chapter chapter ) | |
85 | throws BookDoxiaException | |
86 | { | |
87 | IndexEntry chapterEntry = new IndexEntry( bookEntry, chapter.getId( ) ); | |
88 | ||
89 | chapterEntry.setTitle( chapter.getTitle() ); | |
90 | ||
91 | for ( Section section : chapter.getSections() ) | |
92 | { | |
93 | indexSection( context, chapterEntry, section ); | |
94 | } | |
95 | } | |
96 | ||
97 | /** | |
98 | * Index a section. | |
99 | * | |
100 | * @param bookContext the BookContext. | |
101 | * @param chapterEntry the IndexEntry. | |
102 | * @param section the Section to index. | |
103 | * @throws BookDoxiaException if the section cannot be indexed. | |
104 | */ | |
105 | private void indexSection( BookContext bookContext, IndexEntry chapterEntry, Section section ) | |
106 | throws BookDoxiaException | |
107 | { | |
108 | BookContext.BookFile bookFile = (BookContext.BookFile) bookContext.getFiles().get( section.getId() ); | |
109 | ||
110 | if ( bookFile == null ) | |
111 | { | |
112 | throw new BookDoxiaException( "No document that matches section with id=" | |
113 | + section.getId() + "." ); | |
114 | } | |
115 | ||
116 | // ---------------------------------------------------------------------- | |
117 | // | |
118 | // ---------------------------------------------------------------------- | |
119 | ||
120 | IndexEntry sectionEntry = new IndexEntry( chapterEntry, section.getId() ); | |
121 | ||
122 | IndexingSink sink = new IndexingSink( sectionEntry ); | |
123 | ||
124 | try | |
125 | { | |
126 | doxia.parse( new FileReader( bookFile.getFile() ), bookFile.getParserId(), sink ); | |
127 | } | |
128 | catch ( ParserNotFoundException e ) | |
129 | { | |
130 | throw new BookDoxiaException( "Parser not found: " | |
131 | + bookFile.getParserId() + ".", e ); | |
132 | } | |
133 | catch ( ParseException e ) | |
134 | { | |
135 | throw new BookDoxiaException( "Error while parsing document: " | |
136 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
137 | } | |
138 | catch ( FileNotFoundException e ) | |
139 | { | |
140 | throw new BookDoxiaException( "Could not find document: " | |
141 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
142 | } | |
143 | ||
144 | sectionEntry.setTitle( sink.getTitle() ); | |
145 | } | |
146 | } |
0 | package org.apache.maven.doxia.book.services.io; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.model.BookModel; | |
22 | import org.apache.maven.doxia.book.BookDoxiaException; | |
23 | import org.apache.maven.doxia.book.context.BookContext; | |
24 | ||
25 | import java.io.File; | |
26 | import java.util.List; | |
27 | ||
28 | /** | |
29 | * Common book-related IO methods. | |
30 | * | |
31 | * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugstøl</a> | |
32 | * @version $Id: BookIo.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
33 | */ | |
34 | public interface BookIo | |
35 | { | |
36 | /** The plexus lookup role. */ | |
37 | String ROLE = BookIo.class.getName(); | |
38 | ||
39 | /** | |
40 | * Read a BookModel from a descriptor file. | |
41 | * | |
42 | * @param bookDescriptor the book descriptor file. | |
43 | * @return BookModel | |
44 | * @throws org.apache.maven.doxia.book.BookDoxiaException if the model cannot be read. | |
45 | */ | |
46 | BookModel readBook( File bookDescriptor ) | |
47 | throws BookDoxiaException; | |
48 | ||
49 | /** | |
50 | * Loads files in a given context. | |
51 | * | |
52 | * @param context the BookContext. | |
53 | * @param files a list of files. | |
54 | */ | |
55 | void loadFiles( BookContext context, List<File> files ); | |
56 | } |
+0
-144
0 | package org.apache.maven.doxia.book.services.io; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.model.io.xpp3.BookModelXpp3Reader; | |
22 | import org.apache.maven.doxia.book.model.BookModel; | |
23 | import org.apache.maven.doxia.book.BookDoxiaException; | |
24 | import org.apache.maven.doxia.book.context.BookContext; | |
25 | import org.apache.maven.doxia.module.site.SiteModule; | |
26 | import org.apache.maven.doxia.module.site.manager.SiteModuleManager; | |
27 | import org.codehaus.plexus.util.IOUtil; | |
28 | import org.codehaus.plexus.util.ReaderFactory; | |
29 | import org.codehaus.plexus.util.xml.pull.XmlPullParserException; | |
30 | import org.codehaus.plexus.logging.AbstractLogEnabled; | |
31 | ||
32 | import java.io.IOException; | |
33 | import java.io.File; | |
34 | import java.io.Reader; | |
35 | import java.util.Collection; | |
36 | import java.util.Map; | |
37 | import java.util.TreeMap; | |
38 | import java.util.List; | |
39 | ||
40 | /** | |
41 | * <p>DefaultBookIo class.</p> | |
42 | * | |
43 | * @plexus.component | |
44 | * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugstøl</a> | |
45 | * @version $Id: DefaultBookIo.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
46 | */ | |
47 | public class DefaultBookIo | |
48 | extends AbstractLogEnabled | |
49 | implements BookIo | |
50 | { | |
51 | /** | |
52 | * @plexus.requirement | |
53 | */ | |
54 | private SiteModuleManager siteModuleManager; | |
55 | ||
56 | // ----------------------------------------------------------------------- | |
57 | // DefaultBookIo Implementation | |
58 | // ----------------------------------------------------------------------- | |
59 | ||
60 | /** {@inheritDoc} */ | |
61 | public BookModel readBook( File bookDescriptor ) | |
62 | throws BookDoxiaException | |
63 | { | |
64 | Reader reader = null; | |
65 | try | |
66 | { | |
67 | reader = ReaderFactory.newXmlReader( bookDescriptor ); | |
68 | return new BookModelXpp3Reader().read( reader, true ); | |
69 | } | |
70 | catch ( IOException e ) | |
71 | { | |
72 | throw new BookDoxiaException( "Error while reading book descriptor.", e ); | |
73 | } | |
74 | catch ( XmlPullParserException e ) | |
75 | { | |
76 | throw new BookDoxiaException( "Error while reading book descriptor.", e ); | |
77 | } | |
78 | finally | |
79 | { | |
80 | IOUtil.close( reader ); | |
81 | } | |
82 | } | |
83 | ||
84 | /** {@inheritDoc} */ | |
85 | public void loadFiles( BookContext context, List<File> files ) | |
86 | { | |
87 | // ---------------------------------------------------------------------- | |
88 | // Find all the files, map the file names to ids | |
89 | // ---------------------------------------------------------------------- | |
90 | ||
91 | Collection<SiteModule> siteModules = siteModuleManager.getSiteModules(); | |
92 | ||
93 | for ( SiteModule siteModule : siteModules ) | |
94 | { | |
95 | String extension = siteModule.getExtension(); | |
96 | ||
97 | String sourceDirectory = File.separator + siteModule.getSourceDirectory() + File.separator; | |
98 | ||
99 | String parserId = siteModule.getParserId(); | |
100 | ||
101 | for ( File file : files ) | |
102 | { | |
103 | String name = file.getName(); | |
104 | ||
105 | String path = file.getAbsolutePath(); | |
106 | ||
107 | // first check if the file path contains one of the recognized source dir identifiers | |
108 | // (there's trouble if a pathname contains 2 identifiers), then match file extensions (not unique). | |
109 | ||
110 | if ( path.indexOf( sourceDirectory ) != -1 ) | |
111 | { | |
112 | name = name.substring( 0, name.length() - extension.length() - 1 ); | |
113 | ||
114 | context.getFiles().put( name, new BookContext.BookFile( file, parserId ) ); | |
115 | } | |
116 | else if ( name.endsWith( extension ) ) | |
117 | { | |
118 | name = name.substring( 0, name.length() - extension.length() - 1 ); | |
119 | ||
120 | // don't overwrite if it's there already | |
121 | if ( !context.getFiles().containsKey( name ) ) | |
122 | { | |
123 | context.getFiles().put( name, new BookContext.BookFile( file, parserId ) ); | |
124 | } | |
125 | } | |
126 | } | |
127 | } | |
128 | ||
129 | if ( getLogger().isDebugEnabled() ) | |
130 | { | |
131 | getLogger().debug( "Dumping document <-> id mapping:" ); | |
132 | ||
133 | Map<String, BookContext.BookFile> map = new TreeMap<String, BookContext.BookFile>( context.getFiles() ); | |
134 | ||
135 | for ( Map.Entry<String, BookContext.BookFile> entry : map.entrySet() ) | |
136 | { | |
137 | BookContext.BookFile file = entry.getValue(); | |
138 | ||
139 | getLogger().debug( " " + entry.getKey() + "=" + file.getFile() + ", parser: " + file.getParserId() ); | |
140 | } | |
141 | } | |
142 | } | |
143 | } |
+0
-338
0 | package org.apache.maven.doxia.book.services.renderer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.File; | |
22 | import java.io.FileNotFoundException; | |
23 | import java.io.IOException; | |
24 | import java.io.Reader; | |
25 | import java.io.Writer; | |
26 | import java.text.DateFormat; | |
27 | import java.util.Date; | |
28 | ||
29 | import org.apache.maven.doxia.Doxia; | |
30 | import org.apache.maven.doxia.book.BookDoxiaException; | |
31 | import org.apache.maven.doxia.book.context.BookContext; | |
32 | import org.apache.maven.doxia.book.model.BookModel; | |
33 | import org.apache.maven.doxia.book.model.Chapter; | |
34 | import org.apache.maven.doxia.book.model.Section; | |
35 | import org.apache.maven.doxia.module.itext.ITextSinkFactory; | |
36 | import org.apache.maven.doxia.parser.ParseException; | |
37 | import org.apache.maven.doxia.parser.manager.ParserNotFoundException; | |
38 | import org.apache.maven.doxia.sink.Sink; | |
39 | import org.codehaus.plexus.logging.AbstractLogEnabled; | |
40 | import org.codehaus.plexus.util.IOUtil; | |
41 | import org.codehaus.plexus.util.ReaderFactory; | |
42 | import org.codehaus.plexus.util.StringUtils; | |
43 | import org.codehaus.plexus.util.WriterFactory; | |
44 | import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; | |
45 | ||
46 | /** | |
47 | * Base class for <code>iText</code> renderer. | |
48 | * | |
49 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
50 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
51 | * @version $Id: AbstractITextBookRenderer.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
52 | */ | |
53 | public abstract class AbstractITextBookRenderer | |
54 | extends AbstractLogEnabled | |
55 | implements BookRenderer | |
56 | { | |
57 | /** | |
58 | * @plexus.requirement | |
59 | */ | |
60 | private Doxia doxia; | |
61 | ||
62 | // ---------------------------------------------------------------------- | |
63 | // BookRenderer Implementation | |
64 | // ---------------------------------------------------------------------- | |
65 | ||
66 | /** {@inheritDoc} */ | |
67 | public void renderBook( BookContext context ) | |
68 | throws BookDoxiaException | |
69 | { | |
70 | BookModel book = context.getBook(); | |
71 | ||
72 | if ( !context.getOutputDirectory().exists() ) | |
73 | { | |
74 | if ( !context.getOutputDirectory().mkdirs() ) | |
75 | { | |
76 | throw new BookDoxiaException( "Could not make directory: " | |
77 | + context.getOutputDirectory().getAbsolutePath() + "." ); | |
78 | } | |
79 | } | |
80 | ||
81 | File bookFile = new File( context.getOutputDirectory(), book.getId() + ".xml" ); | |
82 | ||
83 | Writer fileWriter; | |
84 | try | |
85 | { | |
86 | fileWriter = WriterFactory.newXmlWriter( bookFile ); | |
87 | } | |
88 | catch ( IOException e ) | |
89 | { | |
90 | throw new BookDoxiaException( "Error while opening file.", e ); | |
91 | } | |
92 | ||
93 | // ---------------------------------------------------------------------- | |
94 | // Create the XML File | |
95 | // ---------------------------------------------------------------------- | |
96 | ||
97 | PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter( fileWriter, "UTF-8", null ); | |
98 | writer.startElement( "itext" ); | |
99 | writer.addAttribute( "creationdate", DateFormat.getDateTimeInstance().format( new Date() ) ); | |
100 | writer.addAttribute( "producer", "Doxia iText" ); | |
101 | ||
102 | // writer.startElement( "paragraph" ); | |
103 | // writer.addAttribute( "leading", "18.0" ); | |
104 | // writer.addAttribute( "font", "unknown" ); | |
105 | // writer.addAttribute( "align", "Default" ); | |
106 | // writer.writeText( "Please visit my" + System.getProperty( "line.separator" ) ); | |
107 | // | |
108 | // writer.startElement( "anchor" ); | |
109 | // writer.addAttribute( "leading", "18.0" ); | |
110 | // writer.addAttribute( "font", "Helvetica" ); | |
111 | // writer.addAttribute( "size", "12.0" ); | |
112 | // writer.addAttribute( "fontstyle", "normal, underline" ); | |
113 | // writer.addAttribute( "red", "0" ); | |
114 | // writer.addAttribute( "green", "0" ); | |
115 | // writer.addAttribute( "blue", "255" ); | |
116 | // writer.addAttribute( "name", "top" ); | |
117 | // writer.addAttribute( "reference", "http://www.lowagie.com/iText/" ); | |
118 | // | |
119 | // writer.startElement( "chunk" ); | |
120 | // writer.addAttribute( "font", "Helvetica" ); | |
121 | // writer.addAttribute( "size", "12.0" ); | |
122 | // writer.addAttribute( "fontstyle", "normal, underline" ); | |
123 | // writer.addAttribute( "red", "0" ); | |
124 | // writer.addAttribute( "green", "0" ); | |
125 | // writer.addAttribute( "blue", "255" ); | |
126 | // writer.writeText( "website (external reference)" ); | |
127 | // writer.endElement(); | |
128 | // | |
129 | // writer.endElement(); // anchor | |
130 | // | |
131 | // writer.endElement(); // paragraph | |
132 | ||
133 | // TODO: Write out TOC | |
134 | ||
135 | System.setProperty( "itext.basedir", bookFile.getParentFile().getAbsolutePath() ); | |
136 | Sink sink = new ITextSinkFactory().createSink( writer ); | |
137 | ||
138 | try | |
139 | { | |
140 | for ( Chapter chapter : book.getChapters() ) | |
141 | { | |
142 | renderChapter( sink, writer, chapter, context ); | |
143 | } | |
144 | ||
145 | writer.endElement(); // itext | |
146 | } | |
147 | finally | |
148 | { | |
149 | sink.flush(); | |
150 | sink.close(); | |
151 | ||
152 | IOUtil.close( fileWriter ); | |
153 | System.getProperties().remove( "itext.basedir" ); | |
154 | } | |
155 | ||
156 | // ---------------------------------------------------------------------- | |
157 | // Render the XML to PDF | |
158 | // ---------------------------------------------------------------------- | |
159 | File outputFile = new File( context.getOutputDirectory(), book.getId() + "." + getOutputExtension() ); | |
160 | try | |
161 | { | |
162 | renderXML( bookFile, outputFile ); | |
163 | } | |
164 | catch ( IOException e ) | |
165 | { | |
166 | throw new BookDoxiaException( "Error while rendering file", e ); | |
167 | } | |
168 | } | |
169 | ||
170 | /** | |
171 | * Get the output extension supported. | |
172 | * | |
173 | * @return the ouput extension supported. | |
174 | */ | |
175 | public abstract String getOutputExtension(); | |
176 | ||
177 | /** | |
178 | * Generate an ouput file with the iText framework. | |
179 | * | |
180 | * @param iTextFile the input file. | |
181 | * @param iTextOutput the output file. | |
182 | * @throws java.io.IOException if any. | |
183 | */ | |
184 | public abstract void renderXML( File iTextFile, File iTextOutput ) | |
185 | throws IOException; | |
186 | ||
187 | // ---------------------------------------------------------------------- | |
188 | // Private | |
189 | // ---------------------------------------------------------------------- | |
190 | ||
191 | /** | |
192 | * Write a chapter. | |
193 | * | |
194 | * @param writer the writer. | |
195 | * @param chapter the Chapter. | |
196 | * @param context the BookContext. | |
197 | * @throws BookDoxiaException if the chapter cannot be written. | |
198 | */ | |
199 | private void renderChapter( Sink sink, PrettyPrintXMLWriter writer, Chapter chapter, BookContext context ) | |
200 | throws BookDoxiaException | |
201 | { | |
202 | writer.startElement( "chapter" ); | |
203 | writer.addAttribute( "numberdepth", "1" ); | |
204 | writer.addAttribute( "depth", "1" ); | |
205 | writer.addAttribute( "indent", "1" ); | |
206 | ||
207 | startTitle( writer, "36.0", "Helvetica", "24.0", "normal", "255", "0", "0" ); | |
208 | chunk( writer, chapter.getTitle(), "Helvetica", "24.0", "normal", "255", "0", "0" ); | |
209 | writer.endElement(); // title | |
210 | ||
211 | // writer.startElement( "sectioncontent" ); | |
212 | for ( Section section : chapter.getSections() ) | |
213 | { | |
214 | renderSection( sink, writer, section, context ); | |
215 | } | |
216 | // writer.endElement(); // sectioncontent | |
217 | ||
218 | writer.endElement(); // chapter | |
219 | } | |
220 | ||
221 | /** | |
222 | * Write a section. | |
223 | * | |
224 | * @param writer the writer. | |
225 | * @param section the Section. | |
226 | * @param context the BookContext. | |
227 | * @throws BookDoxiaException if the section cannot be written. | |
228 | */ | |
229 | private void renderSection( Sink sink, PrettyPrintXMLWriter writer, Section section, BookContext context ) | |
230 | throws BookDoxiaException | |
231 | { | |
232 | // writer.startElement( "section" ); | |
233 | ||
234 | // ---------------------------------------------------------------------- | |
235 | // | |
236 | // ---------------------------------------------------------------------- | |
237 | ||
238 | BookContext.BookFile bookFile = (BookContext.BookFile) context.getFiles().get( section.getId() ); | |
239 | ||
240 | if ( bookFile == null ) | |
241 | { | |
242 | throw new BookDoxiaException( "No document that matches section with id=" + section.getId() + "." ); | |
243 | } | |
244 | ||
245 | // ---------------------------------------------------------------------- | |
246 | // | |
247 | // ---------------------------------------------------------------------- | |
248 | ||
249 | Reader reader = null; | |
250 | try | |
251 | { | |
252 | reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); | |
253 | doxia.parse( reader, bookFile.getParserId(), sink ); | |
254 | } | |
255 | catch ( ParserNotFoundException e ) | |
256 | { | |
257 | throw new BookDoxiaException( "Parser not found: " + bookFile.getParserId() + ".", e ); | |
258 | } | |
259 | catch ( ParseException e ) | |
260 | { | |
261 | throw new BookDoxiaException( | |
262 | "Error while parsing document: " + bookFile.getFile().getAbsolutePath() + ".", | |
263 | e ); | |
264 | } | |
265 | catch ( FileNotFoundException e ) | |
266 | { | |
267 | throw new BookDoxiaException( "Could not find document: " + bookFile.getFile().getAbsolutePath() + ".", e ); | |
268 | } | |
269 | catch ( IOException e ) | |
270 | { | |
271 | throw new BookDoxiaException( "Error while rendering book: " | |
272 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
273 | } | |
274 | finally | |
275 | { | |
276 | IOUtil.close( reader ); | |
277 | } | |
278 | } | |
279 | ||
280 | /** | |
281 | * Start a title. | |
282 | * | |
283 | * @param writer the writer. | |
284 | * @param leading leading. | |
285 | * @param font the font. | |
286 | * @param size the size. | |
287 | * @param fontstyle the fontstyle. | |
288 | * @param red red. | |
289 | * @param green green. | |
290 | * @param blue blue. | |
291 | */ | |
292 | private void startTitle( PrettyPrintXMLWriter writer, String leading, String font, String size, String fontstyle, | |
293 | String red, String green, String blue ) | |
294 | { | |
295 | writer.startElement( "title" ); | |
296 | writer.addAttribute( "leading", leading ); | |
297 | writer.addAttribute( "font", font ); | |
298 | writer.addAttribute( "size", size ); | |
299 | writer.addAttribute( "fontstyle", fontstyle ); | |
300 | writer.addAttribute( "red", red ); | |
301 | writer.addAttribute( "green", green ); | |
302 | writer.addAttribute( "blue", blue ); | |
303 | } | |
304 | ||
305 | /** | |
306 | * Write a chunk. | |
307 | * | |
308 | * @param writer the writer. | |
309 | * @param title the title. | |
310 | * @param font the font. | |
311 | * @param size the size. | |
312 | * @param fontstyle the fontstyle. | |
313 | * @param red red. | |
314 | * @param green green. | |
315 | * @param blue blue. | |
316 | */ | |
317 | private void chunk( PrettyPrintXMLWriter writer, String title, String font, String size, String fontstyle, | |
318 | String red, String green, String blue ) | |
319 | { | |
320 | writer.startElement( "chunk" ); | |
321 | writer.addAttribute( "font", font ); | |
322 | writer.addAttribute( "size", size ); | |
323 | writer.addAttribute( "fontstyle", fontstyle ); | |
324 | writer.addAttribute( "red", red ); | |
325 | writer.addAttribute( "green", green ); | |
326 | writer.addAttribute( "blue", blue ); | |
327 | if ( StringUtils.isNotEmpty( title ) ) | |
328 | { | |
329 | writer.writeText( title ); | |
330 | } | |
331 | else | |
332 | { | |
333 | writer.writeText( "<Missing title>" ); | |
334 | } | |
335 | writer.endElement(); // chunk | |
336 | } | |
337 | } |
+0
-44
0 | package org.apache.maven.doxia.book.services.renderer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.context.BookContext; | |
22 | import org.apache.maven.doxia.book.BookDoxiaException; | |
23 | ||
24 | /** | |
25 | * Render a book. | |
26 | * | |
27 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
28 | * @version $Id: BookRenderer.java 746976 2009-02-23 12:15:38Z vsiveton $ | |
29 | */ | |
30 | public interface BookRenderer | |
31 | { | |
32 | /** The plexus lookup role. */ | |
33 | String ROLE = BookRenderer.class.getName(); | |
34 | ||
35 | /** | |
36 | * Render a book. | |
37 | * | |
38 | * @param context the BookContext. | |
39 | * @throws org.apache.maven.doxia.book.BookDoxiaException if the book cannot be rendered. | |
40 | */ | |
41 | void renderBook( BookContext context ) | |
42 | throws BookDoxiaException; | |
43 | } |
+0
-223
0 | package org.apache.maven.doxia.book.services.renderer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.File; | |
22 | import java.io.FileNotFoundException; | |
23 | import java.io.IOException; | |
24 | import java.io.Reader; | |
25 | import java.io.Writer; | |
26 | ||
27 | import org.apache.maven.doxia.Doxia; | |
28 | import org.apache.maven.doxia.book.BookDoxiaException; | |
29 | import org.apache.maven.doxia.book.context.BookContext; | |
30 | import org.apache.maven.doxia.book.model.BookModel; | |
31 | import org.apache.maven.doxia.book.model.Chapter; | |
32 | import org.apache.maven.doxia.book.model.Section; | |
33 | import org.apache.maven.doxia.book.services.renderer.docbook.DocBookBookSink; | |
34 | import org.apache.maven.doxia.parser.ParseException; | |
35 | import org.apache.maven.doxia.parser.manager.ParserNotFoundException; | |
36 | import org.apache.maven.doxia.sink.Sink; | |
37 | import org.codehaus.plexus.logging.AbstractLogEnabled; | |
38 | import org.codehaus.plexus.util.IOUtil; | |
39 | import org.codehaus.plexus.util.ReaderFactory; | |
40 | import org.codehaus.plexus.util.StringUtils; | |
41 | import org.codehaus.plexus.util.WriterFactory; | |
42 | ||
43 | /** | |
44 | * An implementation of <code>BookRenderer</code> for docbook | |
45 | * | |
46 | * @plexus.component role-hint="doc-book" | |
47 | * @author Eric Redmond | |
48 | * @version $Id: DocbookBookRenderer.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
49 | */ | |
50 | public class DocbookBookRenderer | |
51 | extends AbstractLogEnabled | |
52 | implements BookRenderer | |
53 | { | |
54 | /** | |
55 | * @plexus.requirement | |
56 | */ | |
57 | private Doxia doxia; | |
58 | ||
59 | // ---------------------------------------------------------------------- | |
60 | // BookRenderer Implementation | |
61 | // ---------------------------------------------------------------------- | |
62 | ||
63 | /** {@inheritDoc} */ | |
64 | public void renderBook( BookContext context ) | |
65 | throws BookDoxiaException | |
66 | { | |
67 | BookModel book = context.getBook(); | |
68 | ||
69 | if ( !context.getOutputDirectory().exists() ) | |
70 | { | |
71 | if ( !context.getOutputDirectory().mkdirs() ) | |
72 | { | |
73 | throw new BookDoxiaException( "Could not make directory: " | |
74 | + context.getOutputDirectory().getAbsolutePath() + "." ); | |
75 | } | |
76 | } | |
77 | ||
78 | File bookFile = new File( context.getOutputDirectory(), book.getId() + ".xml" ); | |
79 | ||
80 | Writer fileWriter; | |
81 | try | |
82 | { | |
83 | fileWriter = WriterFactory.newXmlWriter( bookFile ); | |
84 | } | |
85 | catch ( IOException e ) | |
86 | { | |
87 | throw new BookDoxiaException( "Error while opening file.", e ); | |
88 | } | |
89 | ||
90 | // ---------------------------------------------------------------------- | |
91 | // Create the Dockbook File | |
92 | // ---------------------------------------------------------------------- | |
93 | ||
94 | // TODO: Write out TOC? | |
95 | ||
96 | DocBookBookSink sink = new DocBookBookSink( fileWriter ); | |
97 | ||
98 | try | |
99 | { | |
100 | sink.book(); | |
101 | ||
102 | // TODO: symmetrize bookHead? | |
103 | ||
104 | if ( StringUtils.isNotEmpty( book.getTitle() ) ) | |
105 | { | |
106 | sink.bookTitle(); | |
107 | sink.text( book.getTitle() ); | |
108 | sink.bookTitle_(); | |
109 | } | |
110 | ||
111 | if ( StringUtils.isNotEmpty( book.getDate() ) ) | |
112 | { | |
113 | sink.bookDate(); | |
114 | sink.text( book.getDate() ); | |
115 | sink.bookDate_(); | |
116 | } | |
117 | ||
118 | if ( StringUtils.isNotEmpty( book.getAuthor() ) ) | |
119 | { | |
120 | sink.bookAuthor(); | |
121 | sink.text( book.getAuthor() ); | |
122 | sink.bookAuthor_(); | |
123 | } | |
124 | ||
125 | sink.bookHead_(); | |
126 | ||
127 | for ( Chapter chapter : book.getChapters() ) | |
128 | { | |
129 | sink.chapter(); | |
130 | ||
131 | if ( StringUtils.isNotEmpty( chapter.getTitle() ) ) | |
132 | { | |
133 | sink.chapterTitle(); | |
134 | sink.text( chapter.getTitle() ); | |
135 | sink.chapterTitle_(); | |
136 | } | |
137 | ||
138 | renderChapter( chapter, context, sink ); | |
139 | ||
140 | sink.chapter_(); | |
141 | } | |
142 | ||
143 | sink.book_(); | |
144 | } | |
145 | finally | |
146 | { | |
147 | sink.flush(); | |
148 | ||
149 | sink.close(); | |
150 | ||
151 | IOUtil.close( fileWriter ); | |
152 | } | |
153 | } | |
154 | ||
155 | /** | |
156 | * Write a chapter. | |
157 | * | |
158 | * @param writer the writer. | |
159 | * @param chapter the Chapter. | |
160 | * @param context the BookContext. | |
161 | * @param sink a Sink. | |
162 | * @throws BookDoxiaException if the chapter cannot be written. | |
163 | */ | |
164 | private void renderChapter( Chapter chapter, BookContext context, Sink sink ) | |
165 | throws BookDoxiaException | |
166 | { | |
167 | for ( Section section : chapter.getSections() ) | |
168 | { | |
169 | renderSection( section, context, sink ); | |
170 | } | |
171 | } | |
172 | ||
173 | /** | |
174 | * Write a section. | |
175 | * | |
176 | * @param writer the writer. | |
177 | * @param section the Section. | |
178 | * @param context the BookContext. | |
179 | * @param sink a Sink. | |
180 | * @throws BookDoxiaException if the section cannot be written. | |
181 | */ | |
182 | private void renderSection( Section section, BookContext context, Sink sink ) | |
183 | throws BookDoxiaException | |
184 | { | |
185 | BookContext.BookFile bookFile = (BookContext.BookFile) context.getFiles().get( section.getId() ); | |
186 | ||
187 | if ( bookFile == null ) | |
188 | { | |
189 | throw new BookDoxiaException( "No document that matches section with id=" + section.getId() + "." ); | |
190 | } | |
191 | ||
192 | Reader reader = null; | |
193 | try | |
194 | { | |
195 | reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); | |
196 | doxia.parse( reader, bookFile.getParserId(), sink ); | |
197 | } | |
198 | catch ( ParserNotFoundException e ) | |
199 | { | |
200 | throw new BookDoxiaException( "Parser not found: " + bookFile.getParserId() + ".", e ); | |
201 | } | |
202 | catch ( ParseException e ) | |
203 | { | |
204 | throw new BookDoxiaException( | |
205 | "Error while parsing document: " + bookFile.getFile().getAbsolutePath() + ".", | |
206 | e ); | |
207 | } | |
208 | catch ( FileNotFoundException e ) | |
209 | { | |
210 | throw new BookDoxiaException( "Could not find document: " + bookFile.getFile().getAbsolutePath() + ".", e ); | |
211 | } | |
212 | catch ( IOException e ) | |
213 | { | |
214 | throw new BookDoxiaException( "Error while rendering book: " | |
215 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
216 | } | |
217 | finally | |
218 | { | |
219 | IOUtil.close( reader ); | |
220 | } | |
221 | } | |
222 | } |
+0
-246
0 | package org.apache.maven.doxia.book.services.renderer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.BookDoxiaException; | |
22 | import org.apache.maven.doxia.book.services.renderer.latex.LatexBookSink; | |
23 | import org.apache.maven.doxia.book.context.BookContext; | |
24 | import org.apache.maven.doxia.book.model.BookModel; | |
25 | import org.apache.maven.doxia.book.model.Chapter; | |
26 | import org.apache.maven.doxia.book.model.Section; | |
27 | import org.apache.maven.doxia.parser.manager.ParserNotFoundException; | |
28 | import org.apache.maven.doxia.parser.ParseException; | |
29 | import org.apache.maven.doxia.Doxia; | |
30 | import org.codehaus.plexus.util.ReaderFactory; | |
31 | import org.codehaus.plexus.util.StringUtils; | |
32 | import org.codehaus.plexus.util.IOUtil; | |
33 | import org.codehaus.plexus.util.WriterFactory; | |
34 | ||
35 | import java.io.File; | |
36 | import java.io.FileWriter; | |
37 | import java.io.IOException; | |
38 | import java.io.PrintWriter; | |
39 | import java.io.FileNotFoundException; | |
40 | import java.io.Reader; | |
41 | import java.io.Writer; | |
42 | import java.util.Map; | |
43 | import java.util.HashMap; | |
44 | ||
45 | /** | |
46 | * <p>LatexBookRenderer class.</p> | |
47 | * | |
48 | * @plexus.component role-hint="latex" | |
49 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
50 | * @version $Id: LatexBookRenderer.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
51 | */ | |
52 | public class LatexBookRenderer | |
53 | implements BookRenderer | |
54 | { | |
55 | /** | |
56 | * @plexus.requirement | |
57 | */ | |
58 | private Doxia doxia; | |
59 | ||
60 | // ---------------------------------------------------------------------- | |
61 | // BookRenderer Implementatino | |
62 | // ---------------------------------------------------------------------- | |
63 | ||
64 | /** {@inheritDoc} */ | |
65 | public void renderBook( BookContext context ) | |
66 | throws BookDoxiaException | |
67 | { | |
68 | BookModel book = context.getBook(); | |
69 | ||
70 | if ( !context.getOutputDirectory().exists() ) | |
71 | { | |
72 | if ( !context.getOutputDirectory().mkdirs() ) | |
73 | { | |
74 | throw new BookDoxiaException( | |
75 | "Could not make directory: " + context.getOutputDirectory().getAbsolutePath() + "." ); | |
76 | } | |
77 | } | |
78 | ||
79 | File bookFile = new File( context.getOutputDirectory(), book.getId() + ".tex" ); | |
80 | ||
81 | FileWriter fileWriter = null; | |
82 | ||
83 | try | |
84 | { | |
85 | fileWriter = new FileWriter( bookFile ); | |
86 | ||
87 | PrintWriter writer = new PrintWriter( fileWriter ); | |
88 | ||
89 | writeBook( book, context, writer ); | |
90 | } | |
91 | catch ( IOException e ) | |
92 | { | |
93 | throw new BookDoxiaException( "Error while opening file.", e ); | |
94 | } | |
95 | finally | |
96 | { | |
97 | IOUtil.close( fileWriter ); | |
98 | } | |
99 | } | |
100 | ||
101 | // ---------------------------------------------------------------------- | |
102 | // Private | |
103 | // ---------------------------------------------------------------------- | |
104 | ||
105 | /** SectionInfo: id and title. */ | |
106 | static class SectionInfo | |
107 | { | |
108 | /** id. */ | |
109 | String id; | |
110 | ||
111 | /** title. */ | |
112 | String title; | |
113 | } | |
114 | ||
115 | /** | |
116 | * Write a book. | |
117 | * | |
118 | * @param book the BookModel to write. | |
119 | * @param context the BookContext. | |
120 | * @param writer the writer to use. | |
121 | * @throws IOException if any. | |
122 | * @throws BookDoxiaException if the section cannot be written. | |
123 | */ | |
124 | private void writeBook( BookModel book, BookContext context, PrintWriter writer ) | |
125 | throws IOException, BookDoxiaException | |
126 | { | |
127 | // ---------------------------------------------------------------------- | |
128 | // Process all the section documents and collect their names | |
129 | // ---------------------------------------------------------------------- | |
130 | ||
131 | Map<String, SectionInfo> sectionInfos = new HashMap<String, SectionInfo>(); | |
132 | ||
133 | for ( Chapter chapter : book.getChapters() ) | |
134 | { | |
135 | for ( Section section : chapter.getSections() ) | |
136 | { | |
137 | SectionInfo info = writeSection( section, context ); | |
138 | ||
139 | sectionInfos.put( info.id, info ); | |
140 | } | |
141 | } | |
142 | ||
143 | // ---------------------------------------------------------------------- | |
144 | // Write the main .tex file | |
145 | // ---------------------------------------------------------------------- | |
146 | ||
147 | writer.println( "\\documentclass{book}" ); | |
148 | writer.println( "\\title{" + book.getTitle() + "}" ); | |
149 | ||
150 | if ( StringUtils.isNotEmpty( book.getAuthor() ) ) | |
151 | { | |
152 | writer.println( "\\author{" + book.getAuthor() + "}" ); | |
153 | } | |
154 | ||
155 | if ( StringUtils.isNotEmpty( book.getDate() ) ) | |
156 | { | |
157 | writer.println( "\\date{" + book.getDate() + "}" ); | |
158 | } | |
159 | ||
160 | LatexBookSink sink = new LatexBookSink( writer ); | |
161 | sink.defaultBookPreamble(); | |
162 | ||
163 | writer.println( "\\begin{document}" ); | |
164 | writer.println( "\\maketitle" ); | |
165 | writer.println( "\\tableofcontents" ); | |
166 | // writer.println( "\\listoffigures" ); | |
167 | ||
168 | for ( Chapter chapter : book.getChapters() ) | |
169 | { | |
170 | writer.println( "\\chapter{" + chapter.getTitle() + "}" ); | |
171 | ||
172 | for ( Section section : chapter.getSections() ) | |
173 | { | |
174 | SectionInfo info = sectionInfos.get( section.getId() ); | |
175 | ||
176 | writer.println( "\\input{" + info.id + "}" ); | |
177 | } | |
178 | } | |
179 | ||
180 | writer.println( "\\end{document}" ); | |
181 | } | |
182 | ||
183 | /** | |
184 | * Write a section. | |
185 | * | |
186 | * @param section the Section to write. | |
187 | * @param context the BookContext. | |
188 | * @return SectionInfo | |
189 | * @throws IOException if any. | |
190 | * @throws BookDoxiaException if the section cannot be written. | |
191 | */ | |
192 | private SectionInfo writeSection( Section section, BookContext context ) | |
193 | throws IOException, BookDoxiaException | |
194 | { | |
195 | File file = new File( context.getOutputDirectory(), ( section.getId() + ".tex" ) ); | |
196 | ||
197 | Writer writer = WriterFactory.newWriter( file, context.getOutputEncoding() ); | |
198 | ||
199 | LatexBookSink sink = new LatexBookSink( writer ); | |
200 | ||
201 | BookContext.BookFile bookFile = (BookContext.BookFile) context.getFiles().get( section.getId() ); | |
202 | ||
203 | if ( bookFile == null ) | |
204 | { | |
205 | throw new BookDoxiaException( "No document that matches section with id=" | |
206 | + section.getId() + "." ); | |
207 | } | |
208 | ||
209 | Reader reader = null; | |
210 | try | |
211 | { | |
212 | reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); | |
213 | doxia.parse( reader, bookFile.getParserId(), sink ); | |
214 | } | |
215 | catch ( ParserNotFoundException e ) | |
216 | { | |
217 | throw new BookDoxiaException( "Parser not found: " | |
218 | + bookFile.getParserId() + ".", e ); | |
219 | } | |
220 | catch ( ParseException e ) | |
221 | { | |
222 | throw new BookDoxiaException( "Error while parsing document: " | |
223 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
224 | } | |
225 | catch ( FileNotFoundException e ) | |
226 | { | |
227 | throw new BookDoxiaException( "Could not find document: " | |
228 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
229 | } | |
230 | finally | |
231 | { | |
232 | sink.flush(); | |
233 | sink.close(); | |
234 | ||
235 | IOUtil.close( reader ); | |
236 | IOUtil.close( writer ); | |
237 | } | |
238 | ||
239 | SectionInfo info = new SectionInfo(); | |
240 | info.id = section.getId(); | |
241 | info.title = sink.getTitle(); | |
242 | ||
243 | return info; | |
244 | } | |
245 | } |
+0
-52
0 | package org.apache.maven.doxia.book.services.renderer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.File; | |
22 | import java.io.FileInputStream; | |
23 | import java.io.FileOutputStream; | |
24 | import java.io.IOException; | |
25 | ||
26 | import org.apache.maven.doxia.module.itext.ITextUtil; | |
27 | ||
28 | /** | |
29 | * PDF book renderer with the <code>iText</code> framework. | |
30 | * | |
31 | * @plexus.component role-hint="pdf" | |
32 | * | |
33 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
34 | * @version $Id: PdfBookRenderer.java 638290 2008-03-18 09:45:22Z bentmann $ | |
35 | */ | |
36 | public class PdfBookRenderer | |
37 | extends AbstractITextBookRenderer | |
38 | { | |
39 | /** {@inheritDoc} */ | |
40 | public String getOutputExtension() | |
41 | { | |
42 | return "pdf"; | |
43 | } | |
44 | ||
45 | /** {@inheritDoc} */ | |
46 | public void renderXML( File iTextFile, File iTextOutput ) | |
47 | throws IOException | |
48 | { | |
49 | ITextUtil.writePdf( new FileInputStream( iTextFile ), new FileOutputStream( iTextOutput ) ); | |
50 | } | |
51 | } |
+0
-52
0 | package org.apache.maven.doxia.book.services.renderer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.File; | |
22 | import java.io.FileInputStream; | |
23 | import java.io.FileOutputStream; | |
24 | import java.io.IOException; | |
25 | ||
26 | import org.apache.maven.doxia.module.itext.ITextUtil; | |
27 | ||
28 | /** | |
29 | * RTF book renderer with the <code>iText</code> framework. | |
30 | * | |
31 | * @plexus.component role-hint="rtf" | |
32 | * | |
33 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
34 | * @version $Id: RtfBookRenderer.java 638290 2008-03-18 09:45:22Z bentmann $ | |
35 | */ | |
36 | public class RtfBookRenderer | |
37 | extends AbstractITextBookRenderer | |
38 | { | |
39 | /** {@inheritDoc} */ | |
40 | public String getOutputExtension() | |
41 | { | |
42 | return "rtf"; | |
43 | } | |
44 | ||
45 | /** {@inheritDoc} */ | |
46 | public void renderXML( File iTextFile, File iTextOutput ) | |
47 | throws IOException | |
48 | { | |
49 | ITextUtil.writeRtf( new FileInputStream( iTextFile ), new FileOutputStream( iTextOutput ) ); | |
50 | } | |
51 | } |
+0
-208
0 | package org.apache.maven.doxia.book.services.renderer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.Doxia; | |
22 | import org.apache.maven.doxia.book.context.BookContext; | |
23 | import org.apache.maven.doxia.book.BookDoxiaException; | |
24 | import org.apache.maven.doxia.book.model.BookModel; | |
25 | import org.apache.maven.doxia.book.model.Chapter; | |
26 | import org.apache.maven.doxia.book.model.Section; | |
27 | import org.apache.maven.doxia.book.services.renderer.xhtml.XhtmlBookSink; | |
28 | import org.apache.maven.doxia.sink.render.RenderingContext; | |
29 | import org.apache.maven.doxia.parser.manager.ParserNotFoundException; | |
30 | import org.apache.maven.doxia.parser.ParseException; | |
31 | import org.codehaus.plexus.logging.AbstractLogEnabled; | |
32 | import org.codehaus.plexus.util.IOUtil; | |
33 | import org.codehaus.plexus.util.ReaderFactory; | |
34 | ||
35 | import java.io.File; | |
36 | import java.io.FileNotFoundException; | |
37 | import java.io.FileWriter; | |
38 | import java.io.IOException; | |
39 | import java.io.Reader; | |
40 | import java.io.Writer; | |
41 | ||
42 | /** | |
43 | * <p>XHtmlBookRenderer class.</p> | |
44 | * | |
45 | * @plexus.component role-hint="xhtml" | |
46 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
47 | * @version $Id: XHtmlBookRenderer.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
48 | */ | |
49 | public class XHtmlBookRenderer | |
50 | extends AbstractLogEnabled | |
51 | implements BookRenderer | |
52 | { | |
53 | /** | |
54 | * @plexus.requirement | |
55 | */ | |
56 | private Doxia doxia; | |
57 | ||
58 | // ---------------------------------------------------------------------- | |
59 | // BookRenderer Implementation | |
60 | // ---------------------------------------------------------------------- | |
61 | ||
62 | /** {@inheritDoc} */ | |
63 | public void renderBook( BookContext context ) | |
64 | throws BookDoxiaException | |
65 | { | |
66 | BookModel book = context.getBook(); | |
67 | ||
68 | if ( !context.getOutputDirectory().exists() ) | |
69 | { | |
70 | if ( !context.getOutputDirectory().mkdirs() ) | |
71 | { | |
72 | throw new BookDoxiaException( "Could not make directory: " | |
73 | + context.getOutputDirectory().getAbsolutePath() + "." ); | |
74 | } | |
75 | } | |
76 | ||
77 | File bookFile = new File( context.getOutputDirectory(), book.getId() + ".xhtml" ); | |
78 | ||
79 | Writer fileWriter; | |
80 | ||
81 | try | |
82 | { | |
83 | fileWriter = new FileWriter( bookFile ); | |
84 | } | |
85 | catch ( IOException e ) | |
86 | { | |
87 | throw new BookDoxiaException( "Error while opening file.", e ); | |
88 | } | |
89 | ||
90 | XhtmlBookSink sink = new XhtmlBookSink( fileWriter, | |
91 | new RenderingContext( context.getOutputDirectory(), bookFile.getAbsolutePath() ) ); | |
92 | ||
93 | try | |
94 | { | |
95 | sink.bookHead(); | |
96 | sink.bookTitle(); | |
97 | sink.text( context.getBook().getTitle() ); | |
98 | sink.bookTitle_(); | |
99 | sink.bookAuthor(); | |
100 | sink.text( context.getBook().getAuthor() ); | |
101 | sink.bookAuthor_(); | |
102 | sink.bookDate(); | |
103 | sink.text( context.getBook().getDate() ); | |
104 | sink.bookDate_(); | |
105 | sink.bookHead_(); | |
106 | sink.bookBody(); | |
107 | ||
108 | int chapterNumber = 1; | |
109 | ||
110 | for ( Chapter chapter : book.getChapters() ) | |
111 | { | |
112 | sink.sectionTitle(); | |
113 | sink.text( Integer.toString( chapterNumber ) + ". " + chapter.getTitle() ); | |
114 | sink.sectionTitle_(); | |
115 | ||
116 | renderChapter( sink, chapter, context ); | |
117 | ||
118 | chapterNumber++; | |
119 | } | |
120 | ||
121 | sink.bookBody_(); | |
122 | } | |
123 | finally | |
124 | { | |
125 | sink.flush(); | |
126 | ||
127 | sink.close(); | |
128 | ||
129 | IOUtil.close( fileWriter ); | |
130 | } | |
131 | } | |
132 | ||
133 | // ---------------------------------------------------------------------- | |
134 | // Private | |
135 | // ---------------------------------------------------------------------- | |
136 | ||
137 | /** | |
138 | * Write a chapter. | |
139 | * | |
140 | * @param sink the XhtmlBookSink. | |
141 | * @param chapter the Chapter. | |
142 | * @param context the BookContext. | |
143 | * @throws BookDoxiaException if the chapter cannot be written. | |
144 | */ | |
145 | private void renderChapter( XhtmlBookSink sink, Chapter chapter, BookContext context ) | |
146 | throws BookDoxiaException | |
147 | { | |
148 | for ( Section section : chapter.getSections() ) | |
149 | { | |
150 | renderSection( sink, section, context ); | |
151 | } | |
152 | } | |
153 | ||
154 | /** | |
155 | * Write a section. | |
156 | * | |
157 | * @param sink the XhtmlBookSink. | |
158 | * @param section the Section. | |
159 | * @param context the BookContext. | |
160 | * @throws BookDoxiaException if the section cannot be written. | |
161 | */ | |
162 | private void renderSection( XhtmlBookSink sink, Section section, BookContext context ) | |
163 | throws BookDoxiaException | |
164 | { | |
165 | sink.section2(); | |
166 | ||
167 | BookContext.BookFile bookFile = context.getFiles().get( section.getId() ); | |
168 | ||
169 | if ( bookFile == null ) | |
170 | { | |
171 | throw new BookDoxiaException( "No document that matches section with id=" + section.getId() + "." ); | |
172 | } | |
173 | ||
174 | Reader reader = null; | |
175 | try | |
176 | { | |
177 | reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); | |
178 | doxia.parse( reader, bookFile.getParserId(), sink ); | |
179 | } | |
180 | catch ( ParserNotFoundException e ) | |
181 | { | |
182 | throw new BookDoxiaException( "Parser not found: " | |
183 | + bookFile.getParserId() + ".", e ); | |
184 | } | |
185 | catch ( ParseException e ) | |
186 | { | |
187 | throw new BookDoxiaException( "Error while parsing document: " | |
188 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
189 | } | |
190 | catch ( FileNotFoundException e ) | |
191 | { | |
192 | throw new BookDoxiaException( "Could not find document: " | |
193 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
194 | } | |
195 | catch ( IOException e ) | |
196 | { | |
197 | throw new BookDoxiaException( "Error while rendering book: " | |
198 | + bookFile.getFile().getAbsolutePath() + ".", e ); | |
199 | } | |
200 | finally | |
201 | { | |
202 | IOUtil.close( reader ); | |
203 | } | |
204 | ||
205 | sink.section2_(); | |
206 | } | |
207 | } |
+0
-445
0 | package org.apache.maven.doxia.book.services.renderer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.File; | |
22 | import java.io.FileNotFoundException; | |
23 | import java.io.IOException; | |
24 | import java.io.Reader; | |
25 | import java.io.Writer; | |
26 | import java.util.Iterator; | |
27 | import java.util.Locale; | |
28 | ||
29 | import org.apache.maven.doxia.Doxia; | |
30 | import org.apache.maven.doxia.book.BookDoxiaException; | |
31 | import org.apache.maven.doxia.book.context.BookContext; | |
32 | import org.apache.maven.doxia.book.model.BookModel; | |
33 | import org.apache.maven.doxia.book.model.Chapter; | |
34 | import org.apache.maven.doxia.book.model.Section; | |
35 | import org.apache.maven.doxia.book.services.renderer.xdoc.ChapterXdocBookSink; | |
36 | import org.apache.maven.doxia.book.services.renderer.xdoc.IndexXdocBookSink; | |
37 | import org.apache.maven.doxia.book.services.renderer.xdoc.SectionXdocBookSink; | |
38 | import org.apache.maven.doxia.index.IndexEntry; | |
39 | import org.apache.maven.doxia.module.xdoc.XdocSink; | |
40 | import org.apache.maven.doxia.parser.ParseException; | |
41 | import org.apache.maven.doxia.parser.manager.ParserNotFoundException; | |
42 | import org.apache.maven.doxia.util.HtmlTools; | |
43 | import org.codehaus.plexus.i18n.I18N; | |
44 | import org.codehaus.plexus.logging.AbstractLogEnabled; | |
45 | import org.codehaus.plexus.util.IOUtil; | |
46 | import org.codehaus.plexus.util.ReaderFactory; | |
47 | import org.codehaus.plexus.util.StringUtils; | |
48 | import org.codehaus.plexus.util.WriterFactory; | |
49 | ||
50 | /** | |
51 | * An implementation of <code>BookRenderer</code> for Xdoc | |
52 | * | |
53 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
54 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
55 | * @version $Id: XdocBookRenderer.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
56 | * @plexus.component role-hint="xdoc" | |
57 | */ | |
58 | public class XdocBookRenderer | |
59 | extends AbstractLogEnabled | |
60 | implements BookRenderer | |
61 | { | |
62 | /** | |
63 | * @plexus.requirement | |
64 | */ | |
65 | private Doxia doxia; | |
66 | ||
67 | /** | |
68 | * @plexus.requirement | |
69 | */ | |
70 | private I18N i18n; | |
71 | ||
72 | // ---------------------------------------------------------------------- | |
73 | // BookRenderer Implementation | |
74 | // ---------------------------------------------------------------------- | |
75 | ||
76 | /** {@inheritDoc} */ | |
77 | public void renderBook( BookContext context ) | |
78 | throws BookDoxiaException | |
79 | { | |
80 | BookModel book = context.getBook(); | |
81 | ||
82 | if ( !context.getOutputDirectory().exists() ) | |
83 | { | |
84 | if ( !context.getOutputDirectory().mkdirs() ) | |
85 | { | |
86 | throw new BookDoxiaException( "Could not make directory: " | |
87 | + context.getOutputDirectory().getAbsolutePath() + "." ); | |
88 | } | |
89 | } | |
90 | ||
91 | renderBook( book, context ); | |
92 | } | |
93 | ||
94 | // ----------------------------------------------------------------------- | |
95 | // Protected | |
96 | // ----------------------------------------------------------------------- | |
97 | ||
98 | /** | |
99 | * Gets a trimmed String for the given key from the resource bundle defined by Plexus. | |
100 | * | |
101 | * @param locale the locale used | |
102 | * @param key the key for the desired string | |
103 | * @return the string for the given key and the given locale | |
104 | */ | |
105 | protected String getString( Locale locale, String key ) | |
106 | { | |
107 | if ( StringUtils.isEmpty( key ) ) | |
108 | { | |
109 | throw new IllegalArgumentException( "The key cannot be empty" ); | |
110 | } | |
111 | ||
112 | return i18n.getString( "book-renderer", locale, key ).trim(); | |
113 | } | |
114 | ||
115 | // ----------------------------------------------------------------------- | |
116 | // Private | |
117 | // ----------------------------------------------------------------------- | |
118 | ||
119 | /** | |
120 | * Render the book, ie the book index and all chapter index and pages | |
121 | * | |
122 | * @param book the BookModel. | |
123 | * @param context the BookContext. | |
124 | * @throws BookDoxiaException if any | |
125 | */ | |
126 | private void renderBook( BookModel book, BookContext context ) | |
127 | throws BookDoxiaException | |
128 | { | |
129 | // ----------------------------------------------------------------------- | |
130 | // Render the book index.xml page | |
131 | // ----------------------------------------------------------------------- | |
132 | ||
133 | File index = new File( context.getOutputDirectory(), "index.xml" ); | |
134 | ||
135 | try | |
136 | { | |
137 | writeBookIndex( index, book, context ); | |
138 | } | |
139 | catch ( IOException e ) | |
140 | { | |
141 | throw new BookDoxiaException( "Error while rendering index page to: '" | |
142 | + index.getAbsolutePath() + "'.", e ); | |
143 | } | |
144 | ||
145 | // ----------------------------------------------------------------------- | |
146 | // Render all the chapter pages | |
147 | // ----------------------------------------------------------------------- | |
148 | ||
149 | Iterator<IndexEntry> ii = context.getIndex().getChildEntries().iterator(); | |
150 | ||
151 | for ( Chapter chapter : book.getChapters() ) | |
152 | { | |
153 | renderChapter( chapter, context, ii.next() ); | |
154 | } | |
155 | } | |
156 | ||
157 | /** | |
158 | * Write the book index, ie a TOC. | |
159 | * | |
160 | * @param index the File. | |
161 | * @param book the BookModel. | |
162 | * @param context the BookContext. | |
163 | * @throws IOException if any | |
164 | */ | |
165 | private void writeBookIndex( File index, BookModel book, BookContext context ) | |
166 | throws IOException | |
167 | { | |
168 | Writer writer = WriterFactory.newXmlWriter( index ); | |
169 | ||
170 | XdocSink sink = new IndexXdocBookSink( writer, context.getIndex().getFirstEntry(), i18n, context.getLocale() ); | |
171 | ||
172 | try | |
173 | { | |
174 | // ----------------------------------------------------------------------- | |
175 | // Head | |
176 | // ----------------------------------------------------------------------- | |
177 | ||
178 | sink.head(); | |
179 | ||
180 | sink.title(); | |
181 | sink.text( book.getTitle() + " - " + getString( context.getLocale(), "toc" ) ); | |
182 | sink.title_(); | |
183 | ||
184 | sink.head_(); | |
185 | ||
186 | // ----------------------------------------------------------------------- | |
187 | // Body | |
188 | // ----------------------------------------------------------------------- | |
189 | ||
190 | sink.body(); | |
191 | ||
192 | sink.section1(); | |
193 | sink.sectionTitle1(); | |
194 | sink.text( book.getTitle() + " - " + getString( context.getLocale(), "toc" ) ); | |
195 | sink.sectionTitle1_(); | |
196 | ||
197 | sink.list(); | |
198 | for ( IndexEntry entry : context.getIndex().getChildEntries() ) | |
199 | { | |
200 | writeChapterIndexForBookIndex( sink, entry ); | |
201 | } | |
202 | sink.list_(); | |
203 | ||
204 | sink.section1_(); | |
205 | ||
206 | sink.body_(); | |
207 | } | |
208 | finally | |
209 | { | |
210 | sink.flush(); | |
211 | ||
212 | sink.close(); | |
213 | ||
214 | IOUtil.close( writer ); | |
215 | } | |
216 | } | |
217 | ||
218 | /** | |
219 | * Write the chapter index for the book index. | |
220 | * | |
221 | * @param sink the XdocSink. | |
222 | * @param chapterEntry the chapter IndexEntry. | |
223 | */ | |
224 | private void writeChapterIndexForBookIndex( XdocSink sink, IndexEntry chapterEntry ) | |
225 | { | |
226 | sink.listItem(); | |
227 | sink.link( chapterEntry.getId() + ".html" ); | |
228 | sink.text( chapterEntry.getTitle() ); | |
229 | sink.link_(); | |
230 | ||
231 | sink.list(); | |
232 | for ( IndexEntry sectionIndex : chapterEntry.getChildEntries() ) | |
233 | { | |
234 | writeSectionIndexForBookIndex( sink, sectionIndex ); | |
235 | } | |
236 | sink.list_(); | |
237 | ||
238 | sink.listItem_(); | |
239 | } | |
240 | ||
241 | /** | |
242 | * Write the section index for the book index. | |
243 | * | |
244 | * @param sink the XdocSink. | |
245 | * @param sectionIndex the section IndexEntry. | |
246 | */ | |
247 | private void writeSectionIndexForBookIndex( XdocSink sink, IndexEntry sectionIndex ) | |
248 | { | |
249 | sink.listItem(); | |
250 | sink.link( sectionIndex.getId() + ".html" ); | |
251 | sink.text( sectionIndex.getTitle() ); | |
252 | sink.link_(); | |
253 | ||
254 | sink.list(); | |
255 | for ( IndexEntry subsectionIndex : sectionIndex.getChildEntries() ) | |
256 | { | |
257 | writeSubsectionIndexForBookIndex( sink, sectionIndex, subsectionIndex ); | |
258 | } | |
259 | sink.list_(); | |
260 | ||
261 | sink.listItem_(); | |
262 | } | |
263 | ||
264 | /** | |
265 | * Write subsection index for the book index. | |
266 | * | |
267 | * @param sink the XdocSink. | |
268 | * @param sectionIndex the section IndexEntry. | |
269 | * @param subsectionIndex the subsection IndexEntry. | |
270 | */ | |
271 | private void writeSubsectionIndexForBookIndex( XdocSink sink, IndexEntry sectionIndex, IndexEntry subsectionIndex ) | |
272 | { | |
273 | sink.listItem(); | |
274 | sink.link( sectionIndex.getId() + ".html#" + HtmlTools.encodeId( subsectionIndex.getId() ) ); | |
275 | sink.text( subsectionIndex.getTitle() ); | |
276 | sink.link_(); | |
277 | sink.listItem_(); | |
278 | } | |
279 | ||
280 | // ----------------------------------------------------------------------- | |
281 | // Rendering | |
282 | // ----------------------------------------------------------------------- | |
283 | ||
284 | /** | |
285 | * Render the chapter index and all section pages. | |
286 | * | |
287 | * @param chapter the Chapter. | |
288 | * @param context the BookContext. | |
289 | * @param chapterIndex the IndexEntry. | |
290 | * @throws BookDoxiaException if any | |
291 | */ | |
292 | private void renderChapter( Chapter chapter, BookContext context, IndexEntry chapterIndex ) | |
293 | throws BookDoxiaException | |
294 | { | |
295 | // ----------------------------------------------------------------------- | |
296 | // Render the chapter index page | |
297 | // ----------------------------------------------------------------------- | |
298 | ||
299 | File index = new File( context.getOutputDirectory(), chapter.getId() + ".xml" ); | |
300 | ||
301 | try | |
302 | { | |
303 | writeChapterIndex( index, chapter, chapterIndex, context ); | |
304 | } | |
305 | catch ( IOException e ) | |
306 | { | |
307 | throw new BookDoxiaException( "Error while rendering index page to: '" | |
308 | + index.getAbsolutePath() + "'.", e ); | |
309 | } | |
310 | ||
311 | // ----------------------------------------------------------------------- | |
312 | // Render all section pages | |
313 | // ----------------------------------------------------------------------- | |
314 | ||
315 | Iterator<IndexEntry> ii = chapterIndex.getChildEntries().iterator(); | |
316 | ||
317 | for ( Section section : chapter.getSections() ) | |
318 | { | |
319 | renderSection( context, section, ii.next() ); | |
320 | } | |
321 | } | |
322 | ||
323 | /** | |
324 | * Write a chapter index | |
325 | * | |
326 | * @param index the File. | |
327 | * @param context the context. | |
328 | * @param chapter the Chapter. | |
329 | * @param chapterIndex the IndexEntry. | |
330 | * @throws IOException if any. | |
331 | */ | |
332 | private void writeChapterIndex( File index, Chapter chapter, IndexEntry chapterIndex, BookContext context ) | |
333 | throws IOException | |
334 | { | |
335 | Writer writer = WriterFactory.newXmlWriter( index ); | |
336 | ||
337 | ChapterXdocBookSink sink = new ChapterXdocBookSink( writer, chapterIndex, i18n, context.getLocale() ); | |
338 | ||
339 | try | |
340 | { | |
341 | // ----------------------------------------------------------------------- | |
342 | // Head | |
343 | // ----------------------------------------------------------------------- | |
344 | ||
345 | sink.head(); | |
346 | ||
347 | sink.title(); | |
348 | sink.text( chapter.getTitle() ); | |
349 | sink.title_(); | |
350 | ||
351 | sink.head_(); | |
352 | ||
353 | // ----------------------------------------------------------------------- | |
354 | // Body | |
355 | // ----------------------------------------------------------------------- | |
356 | ||
357 | sink.body(); | |
358 | ||
359 | sink.section1(); | |
360 | sink.sectionTitle1(); | |
361 | sink.text( chapter.getTitle() ); | |
362 | sink.sectionTitle1_(); | |
363 | ||
364 | sink.list(); | |
365 | for ( IndexEntry sectionIndex : chapterIndex.getChildEntries() ) | |
366 | { | |
367 | writeSectionIndexForBookIndex( sink, sectionIndex ); | |
368 | } | |
369 | sink.list_(); | |
370 | ||
371 | sink.section1_(); | |
372 | ||
373 | sink.body_(); | |
374 | } | |
375 | finally | |
376 | { | |
377 | sink.flush(); | |
378 | ||
379 | sink.close(); | |
380 | ||
381 | IOUtil.close( writer ); | |
382 | } | |
383 | } | |
384 | ||
385 | /** | |
386 | * Render all section pages. | |
387 | * | |
388 | * @param context the BookContext. | |
389 | * @param section the Section. | |
390 | * @param sectionIndex the IndexEntry. | |
391 | * @throws BookDoxiaException if any. | |
392 | */ | |
393 | private void renderSection( BookContext context, Section section, IndexEntry sectionIndex ) | |
394 | throws BookDoxiaException | |
395 | { | |
396 | try | |
397 | { | |
398 | Writer writer = WriterFactory.newXmlWriter( new File( context.getOutputDirectory() | |
399 | + "/" + section.getId() + ".xml" ) ); | |
400 | ||
401 | SectionXdocBookSink sink = new SectionXdocBookSink( writer, sectionIndex, i18n, context.getLocale() ); | |
402 | ||
403 | BookContext.BookFile bookFile = (BookContext.BookFile) context.getFiles().get( section.getId() ); | |
404 | ||
405 | if ( bookFile == null ) | |
406 | { | |
407 | throw new BookDoxiaException( "No document that matches section with id=" + section.getId() + "." ); | |
408 | } | |
409 | ||
410 | Reader reader = null; | |
411 | try | |
412 | { | |
413 | reader = ReaderFactory.newReader( bookFile.getFile(), context.getInputEncoding() ); | |
414 | doxia.parse( reader, bookFile.getParserId(), sink ); | |
415 | } | |
416 | catch ( ParserNotFoundException e ) | |
417 | { | |
418 | throw new BookDoxiaException( "Parser not found: " + bookFile.getParserId() + ".", e ); | |
419 | } | |
420 | catch ( ParseException e ) | |
421 | { | |
422 | throw new BookDoxiaException( "Error while parsing document: " + bookFile.getFile().getAbsolutePath() | |
423 | + ".", e ); | |
424 | } | |
425 | catch ( FileNotFoundException e ) | |
426 | { | |
427 | throw new BookDoxiaException( "Could not find document: " + bookFile.getFile().getAbsolutePath() + ".", | |
428 | e ); | |
429 | } | |
430 | finally | |
431 | { | |
432 | sink.flush(); | |
433 | sink.close(); | |
434 | ||
435 | IOUtil.close( reader ); | |
436 | IOUtil.close( writer ); | |
437 | } | |
438 | } | |
439 | catch ( IOException e ) | |
440 | { | |
441 | throw new BookDoxiaException( "Error while rendering book.", e ); | |
442 | } | |
443 | } | |
444 | } |
+0
-270
0 | package org.apache.maven.doxia.book.services.renderer.docbook; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.Writer; | |
22 | ||
23 | import javax.swing.text.MutableAttributeSet; | |
24 | import javax.swing.text.html.HTML.Tag; | |
25 | ||
26 | import org.apache.maven.doxia.module.docbook.DocBookSink; | |
27 | ||
28 | /** | |
29 | * An Docbook Sink that doesn't write out head or body elements for every section of a book, and has some convenience | |
30 | * methods relating to the construction of a Doxia Book. | |
31 | * | |
32 | * @author Dave Syer | |
33 | * @version $Id: DocBookBookSink.java 808201 2009-08-26 22:04:43Z vsiveton $ | |
34 | * @since 1.1 | |
35 | */ | |
36 | public class DocBookBookSink | |
37 | extends DocBookSink | |
38 | { | |
39 | /** Indicates if we're inside a head. */ | |
40 | private boolean hasHead = false; | |
41 | ||
42 | /** | |
43 | * Construct a new DocBookSink. | |
44 | * | |
45 | * @param out the writer for the sink. | |
46 | */ | |
47 | public DocBookBookSink( Writer out ) | |
48 | { | |
49 | super( out ); | |
50 | ||
51 | setSystemId( "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" ); | |
52 | setPublicId( "-//OASIS//DTD DocBook V4.4//EN" ); | |
53 | } | |
54 | ||
55 | // ---------------------------------------------------------------------- | |
56 | // | |
57 | // ---------------------------------------------------------------------- | |
58 | ||
59 | /** | |
60 | * {@inheritDoc} | |
61 | * | |
62 | * Does nothing because we don't want the header from each document to crop up in the middle of a book. | |
63 | */ | |
64 | public void head() | |
65 | { | |
66 | // noop | |
67 | } | |
68 | ||
69 | /** | |
70 | * {@inheritDoc} | |
71 | * | |
72 | * Does nothing because we don't want the header from each document to crop up in the middle of a book. | |
73 | */ | |
74 | public void head_() | |
75 | { | |
76 | // noop | |
77 | } | |
78 | ||
79 | /** | |
80 | * {@inheritDoc} | |
81 | * | |
82 | * Marks the skip flag to true so that this element's text is not emitted by the base class. | |
83 | */ | |
84 | public void title() | |
85 | { | |
86 | setSkip( true ); | |
87 | } | |
88 | ||
89 | /** | |
90 | * {@inheritDoc} | |
91 | * | |
92 | * Marks the skip flag to false so that rendering can resume. | |
93 | */ | |
94 | public void title_() | |
95 | { | |
96 | setSkip( false ); | |
97 | } | |
98 | ||
99 | /** | |
100 | * {@inheritDoc} | |
101 | * | |
102 | * Marks the skip flag to true so that this element's text is not emitted by the base class. | |
103 | */ | |
104 | public void author() | |
105 | { | |
106 | setSkip( true ); | |
107 | } | |
108 | ||
109 | /** | |
110 | * {@inheritDoc} | |
111 | * | |
112 | * Marks the skip flag to false so that rendering can resume. | |
113 | */ | |
114 | public void author_() | |
115 | { | |
116 | setSkip( false ); | |
117 | } | |
118 | ||
119 | /** | |
120 | * {@inheritDoc} | |
121 | * | |
122 | * Does nothing because we don't want the header from each document to crop up in the middle of a book. | |
123 | */ | |
124 | public void body() | |
125 | { | |
126 | // noop | |
127 | } | |
128 | ||
129 | /** | |
130 | * {@inheritDoc} | |
131 | * | |
132 | * Does nothing because we don't want the header from each document to crop up in the middle of a book. | |
133 | */ | |
134 | public void body_() | |
135 | { | |
136 | // noop | |
137 | } | |
138 | ||
139 | /** | |
140 | * Emit the start tag for the book. | |
141 | * | |
142 | * @see org.apache.maven.doxia.module.docbook.DocbookMarkup#BOOK_TAG | |
143 | */ | |
144 | public void book() | |
145 | { | |
146 | init(); | |
147 | ||
148 | MutableAttributeSet att = writeXmlHeader( "book" ); | |
149 | ||
150 | writeStartTag( BOOK_TAG, att ); | |
151 | ||
152 | } | |
153 | ||
154 | /** | |
155 | * Emit the end tag for the book. | |
156 | * | |
157 | * @see org.apache.maven.doxia.module.docbook.DocbookMarkup#BOOK_TAG | |
158 | */ | |
159 | public void book_() | |
160 | { | |
161 | writeEndTag( BOOK_TAG ); | |
162 | flush(); | |
163 | } | |
164 | ||
165 | /** If no header matter has yet been encountered emit the book info start tag. */ | |
166 | private void bookHead() | |
167 | { | |
168 | if ( !hasHead ) | |
169 | { | |
170 | writeStartTag( BOOKINFO_TAG ); | |
171 | hasHead = true; | |
172 | } | |
173 | } | |
174 | ||
175 | /** | |
176 | * If some header matter has been encountered emit the book info end tag. | |
177 | */ | |
178 | public void bookHead_() | |
179 | { | |
180 | if ( hasHead ) | |
181 | { | |
182 | writeEndTag( BOOKINFO_TAG ); | |
183 | hasHead = false; | |
184 | } | |
185 | } | |
186 | ||
187 | /** | |
188 | * Emit the title start tag for the whole book. | |
189 | */ | |
190 | public void bookTitle() | |
191 | { | |
192 | bookHead(); | |
193 | writeStartTag( Tag.TITLE ); | |
194 | } | |
195 | ||
196 | /** | |
197 | * Emit the title end tag for the whole book. | |
198 | */ | |
199 | public void bookTitle_() | |
200 | { | |
201 | super.title_(); | |
202 | } | |
203 | ||
204 | /** | |
205 | * Emit the author start tag for the whole book. | |
206 | */ | |
207 | public void bookAuthor() | |
208 | { | |
209 | bookHead(); | |
210 | super.author(); | |
211 | } | |
212 | ||
213 | /** | |
214 | * Emit the author end tag for the whole book. | |
215 | */ | |
216 | public void bookAuthor_() | |
217 | { | |
218 | super.author_(); | |
219 | } | |
220 | ||
221 | /** | |
222 | * Emit the date start tag for the whole book. | |
223 | */ | |
224 | public void bookDate() | |
225 | { | |
226 | bookHead(); | |
227 | super.date(); | |
228 | } | |
229 | ||
230 | /** | |
231 | * Emit the date end tag for the whole book. | |
232 | */ | |
233 | public void bookDate_() | |
234 | { | |
235 | super.date_(); | |
236 | } | |
237 | ||
238 | /** | |
239 | * Emit the chapter start tag. | |
240 | */ | |
241 | public void chapter() | |
242 | { | |
243 | writeStartTag( CHAPTER_TAG ); | |
244 | } | |
245 | ||
246 | /** | |
247 | * Emit the chapter end tag. | |
248 | */ | |
249 | public void chapter_() | |
250 | { | |
251 | writeEndTag( CHAPTER_TAG ); | |
252 | } | |
253 | ||
254 | /** | |
255 | * Emit the chapter title start tag. | |
256 | */ | |
257 | public void chapterTitle() | |
258 | { | |
259 | writeStartTag( Tag.TITLE ); | |
260 | } | |
261 | ||
262 | /** | |
263 | * Emit the chapter title end tag. | |
264 | */ | |
265 | public void chapterTitle_() | |
266 | { | |
267 | writeEndTag( Tag.TITLE ); | |
268 | } | |
269 | } |
+0
-124
0 | package org.apache.maven.doxia.book.services.renderer.latex; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.module.latex.LatexSink; | |
22 | ||
23 | import java.io.Writer; | |
24 | ||
25 | /** | |
26 | * <p>LatexBookSink class.</p> | |
27 | * | |
28 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
29 | * @version $Id: LatexBookSink.java 769433 2009-04-28 15:26:55Z ltheussl $ | |
30 | */ | |
31 | public class LatexBookSink | |
32 | extends LatexSink | |
33 | { | |
34 | /** text. */ | |
35 | private String txt; | |
36 | ||
37 | /** title. */ | |
38 | private String title; | |
39 | ||
40 | // ---------------------------------------------------------------------- | |
41 | // | |
42 | // ---------------------------------------------------------------------- | |
43 | ||
44 | /** | |
45 | * Construct a new LatexBookSink which is a LatexSink with the given writer, | |
46 | * null sinkCommands, null preamble and fragmentDocument = true. | |
47 | * | |
48 | * @param out the writer for the sink. | |
49 | */ | |
50 | public LatexBookSink( Writer out ) | |
51 | { | |
52 | super( out, null, null, true ); | |
53 | } | |
54 | ||
55 | // ---------------------------------------------------------------------- | |
56 | // | |
57 | // ---------------------------------------------------------------------- | |
58 | ||
59 | /** {@inheritDoc} */ | |
60 | protected String getDocumentStart() | |
61 | { | |
62 | return ""; | |
63 | // return "\\documentclass{book}"; | |
64 | } | |
65 | ||
66 | /** {@inheritDoc} */ | |
67 | protected String getDocumentBegin() | |
68 | { | |
69 | return null; | |
70 | } | |
71 | ||
72 | // ---------------------------------------------------------------------- | |
73 | // | |
74 | // ---------------------------------------------------------------------- | |
75 | ||
76 | /** {@inheritDoc} */ | |
77 | public void text( String text ) | |
78 | { | |
79 | this.txt = text; | |
80 | ||
81 | super.text( text ); | |
82 | } | |
83 | ||
84 | /** {@inheritDoc} */ | |
85 | public void title_() | |
86 | { | |
87 | super.title_(); | |
88 | ||
89 | this.title = txt; | |
90 | } | |
91 | ||
92 | // ---------------------------------------------------------------------- | |
93 | // | |
94 | // ---------------------------------------------------------------------- | |
95 | ||
96 | /** | |
97 | * Return the title. | |
98 | * | |
99 | * @return String. | |
100 | */ | |
101 | public String getTitle() | |
102 | { | |
103 | return title; | |
104 | } | |
105 | ||
106 | // ---------------------------------------------------------------------- | |
107 | // | |
108 | // ---------------------------------------------------------------------- | |
109 | ||
110 | /** | |
111 | * Writes the default LaTeX commands and preamble in the main book file. | |
112 | * | |
113 | * @since 1.1 | |
114 | */ | |
115 | public void defaultBookPreamble() | |
116 | { | |
117 | markup( defaultSinkCommands() ); | |
118 | markup( defaultPreamble() ); | |
119 | flush(); | |
120 | } | |
121 | ||
122 | ||
123 | } |
+0
-126
0 | package org.apache.maven.doxia.book.services.renderer.xdoc; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.Writer; | |
22 | import java.util.Locale; | |
23 | ||
24 | import org.apache.maven.doxia.module.xdoc.XdocSink; | |
25 | ||
26 | import org.codehaus.plexus.i18n.I18N; | |
27 | import org.codehaus.plexus.util.StringUtils; | |
28 | ||
29 | /** | |
30 | * Abstract <code>XdocSink</code> implementation for book. | |
31 | * | |
32 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
33 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
34 | * @version $Id: AbstractXdocBookSink.java 808201 2009-08-26 22:04:43Z vsiveton $ | |
35 | */ | |
36 | public abstract class AbstractXdocBookSink | |
37 | extends XdocSink | |
38 | { | |
39 | /** I18N for localized messages. */ | |
40 | private final I18N i18n; | |
41 | ||
42 | /** The wanted locale */ | |
43 | private final Locale locale; | |
44 | ||
45 | /** | |
46 | * Default constructor. | |
47 | * | |
48 | * @param out a Writer. | |
49 | * @param i18n I18N. | |
50 | * @param locale the wanted locale. | |
51 | */ | |
52 | public AbstractXdocBookSink( Writer out, I18N i18n, Locale locale ) | |
53 | { | |
54 | super( out ); | |
55 | ||
56 | this.i18n = i18n; | |
57 | this.locale = locale; | |
58 | } | |
59 | ||
60 | /** {@inheritDoc} */ | |
61 | public void date_() | |
62 | { | |
63 | // nop | |
64 | } | |
65 | ||
66 | /** {@inheritDoc} */ | |
67 | public void body() | |
68 | { | |
69 | writeStartTag( BODY ); | |
70 | ||
71 | write( "<section name=\"\">" ); | |
72 | ||
73 | navigationPanel(); | |
74 | horizontalRule(); | |
75 | ||
76 | write( "</section>" ); | |
77 | } | |
78 | ||
79 | /** {@inheritDoc} */ | |
80 | public void body_() | |
81 | { | |
82 | write( "<section name=\"\">" ); | |
83 | ||
84 | horizontalRule(); | |
85 | ||
86 | navigationPanel(); | |
87 | ||
88 | write( "</section>" ); | |
89 | ||
90 | writeEndTag( BODY ); | |
91 | ||
92 | writeEndTag( DOCUMENT_TAG ); | |
93 | ||
94 | flush(); | |
95 | ||
96 | close(); | |
97 | ||
98 | init(); | |
99 | } | |
100 | ||
101 | // ----------------------------------------------------------------------- | |
102 | // Protected | |
103 | // ----------------------------------------------------------------------- | |
104 | ||
105 | /** | |
106 | * Gets a trimmed String for the given key from the resource bundle defined by Plexus. | |
107 | * | |
108 | * @param key the key for the desired string | |
109 | * @return the string for the given key | |
110 | */ | |
111 | protected String getString( String key ) | |
112 | { | |
113 | if ( StringUtils.isEmpty( key ) ) | |
114 | { | |
115 | throw new IllegalArgumentException( "The key cannot be empty" ); | |
116 | } | |
117 | ||
118 | return i18n.getString( "book-renderer", locale, key ).trim(); | |
119 | } | |
120 | ||
121 | /** | |
122 | * Add a navigation panel. | |
123 | */ | |
124 | protected abstract void navigationPanel(); | |
125 | } |
+0
-151
0 | package org.apache.maven.doxia.book.services.renderer.xdoc; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.Writer; | |
22 | import java.util.Locale; | |
23 | ||
24 | import org.apache.maven.doxia.index.IndexEntry; | |
25 | import org.codehaus.plexus.i18n.I18N; | |
26 | ||
27 | /** | |
28 | * A <code>XdocSink</code> implementation for chapter in a book. | |
29 | * | |
30 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
31 | * @version $Id: ChapterXdocBookSink.java 782330 2009-06-07 05:55:26Z ltheussl $ | |
32 | */ | |
33 | public class ChapterXdocBookSink | |
34 | extends AbstractXdocBookSink | |
35 | { | |
36 | /** the chapter IndexEntry. */ | |
37 | private final IndexEntry chapterIndex; | |
38 | ||
39 | /** | |
40 | * Default constructor. | |
41 | * | |
42 | * @param out the Writer. | |
43 | * @param chapterIndex the chapter IndexEntry. | |
44 | * @param i18n I18N. | |
45 | * @param locale wanted locale. | |
46 | */ | |
47 | public ChapterXdocBookSink( Writer out, IndexEntry chapterIndex, I18N i18n, Locale locale ) | |
48 | { | |
49 | super( out, i18n, locale ); | |
50 | ||
51 | this.chapterIndex = chapterIndex; | |
52 | } | |
53 | ||
54 | /** {@inheritDoc} */ | |
55 | protected void navigationPanel() | |
56 | { | |
57 | write( "<!--Navigation Panel-->" ); | |
58 | ||
59 | write( "<table width=\"100%\" align=\"center\">" ); | |
60 | write( "<tr>" ); | |
61 | ||
62 | // ----------------------------------------------------------------------- | |
63 | // Prev | |
64 | // ----------------------------------------------------------------------- | |
65 | ||
66 | IndexEntry prevChapter = chapterIndex.getPrevEntry(); | |
67 | ||
68 | write( "<td><div align=\"left\">" ); | |
69 | ||
70 | previous( prevChapter ); | |
71 | ||
72 | write( "</div></td>" ); | |
73 | ||
74 | // ----------------------------------------------------------------------- | |
75 | // Parent | |
76 | // ----------------------------------------------------------------------- | |
77 | ||
78 | write( "<td><div align=\"center\">" ); | |
79 | up(); | |
80 | write( "</div></td>" ); | |
81 | ||
82 | // ----------------------------------------------------------------------- | |
83 | // Next | |
84 | // ----------------------------------------------------------------------- | |
85 | ||
86 | write( "<td><div align=\"right\">" ); | |
87 | ||
88 | next(); | |
89 | ||
90 | write( "</div></td>" ); | |
91 | ||
92 | write( "</tr>" ); | |
93 | write( "</table>" ); | |
94 | ||
95 | write( "<!--End of Navigation Panel-->" ); | |
96 | } | |
97 | ||
98 | /** | |
99 | * Add previous link. | |
100 | * | |
101 | * @param prevChapter the previous IndexEntry. | |
102 | */ | |
103 | protected void previous( IndexEntry prevChapter ) | |
104 | { | |
105 | if ( prevChapter != null ) | |
106 | { | |
107 | IndexEntry lastEntry = prevChapter.getLastEntry(); | |
108 | if ( lastEntry == null ) | |
109 | { | |
110 | write( "<i>Start of book</i>" ); | |
111 | } | |
112 | else | |
113 | { | |
114 | write( getString( "previous" ) + ": <a href=\"" + lastEntry.getId() + ".html\">" ); | |
115 | content( lastEntry.getTitle() ); | |
116 | write( "</a>" ); | |
117 | } | |
118 | } | |
119 | else | |
120 | { | |
121 | write( getString( "previous" ) + ":<a href=\"index.html\">" + getString( "toc" ) + "</a>" ); | |
122 | } | |
123 | } | |
124 | ||
125 | /** | |
126 | * Add parent/up link. | |
127 | */ | |
128 | protected void up() | |
129 | { | |
130 | write( getString( "up" ) + ": <a href=\"index.html\">" + getString( "toc" ) + "</a>" ); | |
131 | } | |
132 | ||
133 | /** | |
134 | * Add next link | |
135 | */ | |
136 | protected void next() | |
137 | { | |
138 | IndexEntry firstEntry = chapterIndex.getFirstEntry(); | |
139 | if ( firstEntry == null ) | |
140 | { | |
141 | write( "<i>End of book</i>" ); | |
142 | } | |
143 | else | |
144 | { | |
145 | write( getString( "next" ) + ": <a href=\"" + firstEntry.getId() + ".html\">" ); | |
146 | content( firstEntry.getTitle() ); | |
147 | write( "</a>" ); | |
148 | } | |
149 | } | |
150 | } |
+0
-84
0 | package org.apache.maven.doxia.book.services.renderer.xdoc; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.Writer; | |
22 | import java.util.Locale; | |
23 | ||
24 | import org.apache.maven.doxia.index.IndexEntry; | |
25 | import org.codehaus.plexus.i18n.I18N; | |
26 | ||
27 | /** | |
28 | * A <code>XdocSink</code> implementation for index book. | |
29 | * | |
30 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
31 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
32 | * @version $Id: IndexXdocBookSink.java 782330 2009-06-07 05:55:26Z ltheussl $ | |
33 | */ | |
34 | public class IndexXdocBookSink | |
35 | extends AbstractXdocBookSink | |
36 | { | |
37 | /** the first IndexEntry. */ | |
38 | private final IndexEntry firstEntry; | |
39 | ||
40 | /** | |
41 | * Default constructor. | |
42 | * | |
43 | * @param out the Writer. | |
44 | * @param firstEntry the first IndexEntry. | |
45 | * @param i18n I18N. | |
46 | * @param locale wanted locale. | |
47 | */ | |
48 | public IndexXdocBookSink( Writer out, IndexEntry firstEntry, I18N i18n, Locale locale ) | |
49 | { | |
50 | super( out, i18n, locale ); | |
51 | ||
52 | this.firstEntry = firstEntry; | |
53 | } | |
54 | ||
55 | /** {@inheritDoc} */ | |
56 | protected void navigationPanel() | |
57 | { | |
58 | write( "<!--Navigation Panel-->" ); | |
59 | ||
60 | write( "<table width=\"100%\" align=\"center\">" ); | |
61 | write( "<tr>" ); | |
62 | ||
63 | // ----------------------------------------------------------------------- | |
64 | // Next | |
65 | // ----------------------------------------------------------------------- | |
66 | ||
67 | if ( firstEntry != null ) | |
68 | { | |
69 | write( "<td><div align=\"right\">" ); | |
70 | ||
71 | write( getString( "next" ) + ": <a href=\"" + firstEntry.getId() + ".html\">" ); | |
72 | content( firstEntry.getTitle() ); | |
73 | write( "</a>" ); | |
74 | ||
75 | write( "</div></td>" ); | |
76 | } | |
77 | ||
78 | write( "</tr>" ); | |
79 | write( "</table>" ); | |
80 | ||
81 | write( "<!--End of Navigation Panel-->" ); | |
82 | } | |
83 | } |
+0
-166
0 | package org.apache.maven.doxia.book.services.renderer.xdoc; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.Writer; | |
22 | import java.util.Locale; | |
23 | ||
24 | import org.apache.maven.doxia.index.IndexEntry; | |
25 | import org.codehaus.plexus.i18n.I18N; | |
26 | ||
27 | /** | |
28 | * A <code>XdocSink</code> implementation for section in a book | |
29 | * | |
30 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
31 | * @version $Id: SectionXdocBookSink.java 782330 2009-06-07 05:55:26Z ltheussl $ | |
32 | */ | |
33 | public class SectionXdocBookSink | |
34 | extends AbstractXdocBookSink | |
35 | { | |
36 | /** indexEntry. */ | |
37 | private final IndexEntry indexEntry; | |
38 | ||
39 | /** | |
40 | * Default constructor. | |
41 | * | |
42 | * @param out the Writer to use. | |
43 | * @param indexEntry the IndexEntry. | |
44 | * @param i18n the I18N. | |
45 | * @param locale wanted locale. | |
46 | */ | |
47 | public SectionXdocBookSink( Writer out, IndexEntry indexEntry, I18N i18n, Locale locale ) | |
48 | { | |
49 | super( out, i18n, locale ); | |
50 | ||
51 | this.indexEntry = indexEntry; | |
52 | } | |
53 | ||
54 | /** {@inheritDoc} */ | |
55 | protected void navigationPanel() | |
56 | { | |
57 | write( "<!--Navigation Panel-->" ); | |
58 | ||
59 | write( "<table width=\"100%\" align=\"center\" border=\"0\">" ); | |
60 | write( "<tr>" ); | |
61 | ||
62 | IndexEntry parent = indexEntry.getParent(); | |
63 | ||
64 | // ----------------------------------------------------------------------- | |
65 | // Prev | |
66 | // ----------------------------------------------------------------------- | |
67 | ||
68 | IndexEntry prevEntry = indexEntry.getPrevEntry(); | |
69 | ||
70 | write( "<td align=\"left\">" ); | |
71 | ||
72 | previous( parent, prevEntry ); | |
73 | ||
74 | write( "</td>" ); | |
75 | ||
76 | // ----------------------------------------------------------------------- | |
77 | // Parent | |
78 | // ----------------------------------------------------------------------- | |
79 | ||
80 | write( "<td align=\"center\">" ); | |
81 | up( parent ); | |
82 | write( "</td>" ); | |
83 | ||
84 | // ----------------------------------------------------------------------- | |
85 | // Next | |
86 | // ----------------------------------------------------------------------- | |
87 | ||
88 | IndexEntry nextEntry = indexEntry.getNextEntry(); | |
89 | ||
90 | write( "<td align=\"right\">" ); | |
91 | ||
92 | next( parent, nextEntry ); | |
93 | ||
94 | write( "</td>" ); | |
95 | ||
96 | write( "</tr>" ); | |
97 | write( "</table>" ); | |
98 | ||
99 | write( "<!--End of Navigation Panel-->" ); | |
100 | } | |
101 | ||
102 | /** | |
103 | * Add previous link. | |
104 | * | |
105 | * @param parent the parent IndexEntry. | |
106 | * @param prevEntry the previous IndexEntry. | |
107 | */ | |
108 | protected void previous( IndexEntry parent, IndexEntry prevEntry ) | |
109 | { | |
110 | if ( prevEntry != null ) | |
111 | { | |
112 | write( getString( "previous" ) + ": <a href=\"" + prevEntry.getId() + ".html\">" ); | |
113 | content( prevEntry.getTitle() ); | |
114 | write( "</a>" ); | |
115 | } | |
116 | else | |
117 | { | |
118 | write( getString( "previous" ) + ": <a href=\"" + parent.getId() + ".html\">" ); | |
119 | content( parent.getTitle() ); | |
120 | write( "</a>" ); | |
121 | } | |
122 | } | |
123 | ||
124 | /** | |
125 | * Add parent/up link. | |
126 | * | |
127 | * @param parent the parent IndexEntry. | |
128 | * @see org.apache.maven.doxia.book.services.renderer.xdoc.ChapterXdocBookSink#up() | |
129 | */ | |
130 | protected void up( IndexEntry parent ) | |
131 | { | |
132 | write( getString( "up" ) + ": <a href=\"" + parent.getId() + ".html\">" + parent.getTitle() + "</a>" ); | |
133 | } | |
134 | ||
135 | /** | |
136 | * Add next link. | |
137 | * | |
138 | * @param parent the parent IndexEntry. | |
139 | * @param nextEntry the next IndexEntry. | |
140 | */ | |
141 | protected void next( IndexEntry parent, IndexEntry nextEntry ) | |
142 | { | |
143 | if ( nextEntry != null ) | |
144 | { | |
145 | write( getString( "next" ) + ": <a href=\"" + nextEntry.getId() + ".html\">" ); | |
146 | content( nextEntry.getTitle() ); | |
147 | write( "</a>" ); | |
148 | } | |
149 | else | |
150 | { | |
151 | IndexEntry nextChapter = parent.getNextEntry(); | |
152 | ||
153 | if ( nextChapter == null ) | |
154 | { | |
155 | write( "<i>End of book</i>" ); | |
156 | } | |
157 | else | |
158 | { | |
159 | write( getString( "next" ) + ": <a href=\"" + nextChapter.getId() + ".html\">" ); | |
160 | content( nextChapter.getTitle() ); | |
161 | write( "</a>" ); | |
162 | } | |
163 | } | |
164 | } | |
165 | } |
+0
-248
0 | package org.apache.maven.doxia.book.services.renderer.xhtml; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.module.xhtml.XhtmlSink; | |
22 | import org.apache.maven.doxia.sink.render.RenderingContext; | |
23 | import org.codehaus.plexus.util.StringUtils; | |
24 | ||
25 | import java.io.Writer; | |
26 | ||
27 | /** | |
28 | * An Xhtml Sink that doesn't write out head or body elements. | |
29 | * | |
30 | * @author ltheussl | |
31 | * @version $Id: XhtmlBookSink.java 808201 2009-08-26 22:04:43Z vsiveton $ | |
32 | */ | |
33 | public class XhtmlBookSink | |
34 | extends XhtmlSink | |
35 | { | |
36 | private RenderingContext renderingContext; | |
37 | ||
38 | /** | |
39 | * Construct a new XhtmlBookSink. | |
40 | * | |
41 | * @param out the writer for the sink. | |
42 | * @param context the RenderingContext. | |
43 | */ | |
44 | public XhtmlBookSink( Writer out, RenderingContext context ) | |
45 | { | |
46 | super( out ); | |
47 | this.renderingContext = context; | |
48 | } | |
49 | ||
50 | // ---------------------------------------------------------------------- | |
51 | // | |
52 | // ---------------------------------------------------------------------- | |
53 | ||
54 | /** | |
55 | * {@inheritDoc} | |
56 | * | |
57 | * Does nothing. | |
58 | */ | |
59 | public void head() | |
60 | { | |
61 | init(); | |
62 | ||
63 | setHeadFlag( true ); | |
64 | } | |
65 | ||
66 | /** | |
67 | * {@inheritDoc} | |
68 | * | |
69 | * Does nothing. | |
70 | */ | |
71 | public void head_() | |
72 | { | |
73 | setHeadFlag( false ); | |
74 | } | |
75 | ||
76 | /** | |
77 | * {@inheritDoc} | |
78 | * | |
79 | * Does nothing. | |
80 | */ | |
81 | public void title() | |
82 | { | |
83 | // noop | |
84 | } | |
85 | ||
86 | /** | |
87 | * {@inheritDoc} | |
88 | * | |
89 | * Does nothing. | |
90 | */ | |
91 | public void title_() | |
92 | { | |
93 | resetTextBuffer(); | |
94 | } | |
95 | ||
96 | /** | |
97 | * {@inheritDoc} | |
98 | * | |
99 | * Does nothing. | |
100 | */ | |
101 | public void author_() | |
102 | { | |
103 | resetTextBuffer(); | |
104 | } | |
105 | ||
106 | /** | |
107 | * {@inheritDoc} | |
108 | * | |
109 | * Does nothing. | |
110 | */ | |
111 | public void date_() | |
112 | { | |
113 | resetTextBuffer(); | |
114 | } | |
115 | ||
116 | /** | |
117 | * {@inheritDoc} | |
118 | * | |
119 | * Does nothing. | |
120 | */ | |
121 | public void body() | |
122 | { | |
123 | // noop | |
124 | } | |
125 | ||
126 | /** | |
127 | * {@inheritDoc} | |
128 | * | |
129 | * Does nothing. | |
130 | */ | |
131 | public void body_() | |
132 | { | |
133 | // noop | |
134 | } | |
135 | ||
136 | /** | |
137 | * Calls super.head(). | |
138 | */ | |
139 | public void bookHead() | |
140 | { | |
141 | super.head(); | |
142 | } | |
143 | ||
144 | /** | |
145 | * Calls super.head_(). | |
146 | */ | |
147 | public void bookHead_() | |
148 | { | |
149 | super.head_(); | |
150 | } | |
151 | ||
152 | /** | |
153 | * Calls super.title(). | |
154 | */ | |
155 | public void bookTitle() | |
156 | { | |
157 | super.title(); | |
158 | } | |
159 | ||
160 | /** | |
161 | * Calls super.title_(). | |
162 | */ | |
163 | public void bookTitle_() | |
164 | { | |
165 | super.title_(); | |
166 | } | |
167 | ||
168 | /** | |
169 | * Calls super.author(). | |
170 | */ | |
171 | public void bookAuthor() | |
172 | { | |
173 | super.author(); | |
174 | } | |
175 | ||
176 | /** | |
177 | * Calls super.author_(). | |
178 | */ | |
179 | public void bookAuthor_() | |
180 | { | |
181 | super.author_(); | |
182 | } | |
183 | ||
184 | /** | |
185 | * Calls super.date(). | |
186 | */ | |
187 | public void bookDate() | |
188 | { | |
189 | super.date(); | |
190 | } | |
191 | ||
192 | /** | |
193 | * Calls super.date_(). | |
194 | */ | |
195 | public void bookDate_() | |
196 | { | |
197 | super.date_(); | |
198 | } | |
199 | ||
200 | /** | |
201 | * Calls super.body(). | |
202 | */ | |
203 | public void bookBody() | |
204 | { | |
205 | super.body(); | |
206 | } | |
207 | ||
208 | /** | |
209 | * Calls super.body_(). | |
210 | */ | |
211 | public void bookBody_() | |
212 | { | |
213 | super.body_(); | |
214 | } | |
215 | ||
216 | /** {@inheritDoc} */ | |
217 | public void sectionTitle() | |
218 | { | |
219 | writeStartTag( H1 ); | |
220 | } | |
221 | ||
222 | /** {@inheritDoc} */ | |
223 | public void sectionTitle_() | |
224 | { | |
225 | writeEndTag( H1 ); | |
226 | } | |
227 | ||
228 | /** {@inheritDoc} */ | |
229 | protected void write( String text ) | |
230 | { | |
231 | if ( renderingContext != null ) | |
232 | { | |
233 | String relativePathToBasedir = renderingContext.getRelativePath(); | |
234 | ||
235 | if ( relativePathToBasedir == null ) | |
236 | { | |
237 | text = StringUtils.replace( text, "$relativePath", "." ); | |
238 | } | |
239 | else | |
240 | { | |
241 | text = StringUtils.replace( text, "$relativePath", relativePathToBasedir ); | |
242 | } | |
243 | } | |
244 | ||
245 | super.write( text ); | |
246 | } | |
247 | } |
+0
-42
0 | package org.apache.maven.doxia.book.services.validation; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.model.BookModel; | |
22 | ||
23 | /** | |
24 | * Ensure a BookModel is valid. | |
25 | * | |
26 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
27 | * @version $Id: BookValidator.java 638290 2008-03-18 09:45:22Z bentmann $ | |
28 | */ | |
29 | public interface BookValidator | |
30 | { | |
31 | /** The plexus lookup role. */ | |
32 | String ROLE = BookValidator.class.getName(); | |
33 | ||
34 | /** | |
35 | * Validate a BookModel. | |
36 | * | |
37 | * @param book the BookModel to validate. | |
38 | * @return ValidationResult | |
39 | */ | |
40 | ValidationResult validateBook( BookModel book ); | |
41 | } |
+0
-104
0 | package org.apache.maven.doxia.book.services.validation; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.codehaus.plexus.logging.AbstractLogEnabled; | |
22 | import org.codehaus.plexus.util.StringUtils; | |
23 | import org.apache.maven.doxia.book.model.BookModel; | |
24 | import org.apache.maven.doxia.book.model.Chapter; | |
25 | ||
26 | /** | |
27 | * Default implementation of BookValidator. | |
28 | * | |
29 | * @plexus.component | |
30 | * | |
31 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
32 | * @version $Id: DefaultBookValidator.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
33 | */ | |
34 | public class DefaultBookValidator | |
35 | extends AbstractLogEnabled | |
36 | implements BookValidator | |
37 | { | |
38 | // ---------------------------------------------------------------------- | |
39 | // BookValidator Implementation | |
40 | // ---------------------------------------------------------------------- | |
41 | ||
42 | /** {@inheritDoc} */ | |
43 | public ValidationResult validateBook( BookModel book ) | |
44 | { | |
45 | ValidationResult result = new ValidationResult(); | |
46 | ||
47 | if ( StringUtils.isEmpty( book.getId() ) ) | |
48 | { | |
49 | result.getErrors().add( "Book is missing id." ); | |
50 | } | |
51 | ||
52 | if ( StringUtils.isEmpty( book.getTitle() ) ) | |
53 | { | |
54 | result.getErrors().add( "Book is missing title." ); | |
55 | } | |
56 | ||
57 | if ( book.getChapters().size() == 0 ) | |
58 | { | |
59 | result.getErrors().add( "The book must have at least one chaper" ); | |
60 | } | |
61 | else | |
62 | { | |
63 | for ( Chapter chapter : book.getChapters() ) | |
64 | { | |
65 | validateChapter( result, chapter ); | |
66 | ||
67 | // TODO: Validate the chapter id | |
68 | } | |
69 | } | |
70 | ||
71 | return result; | |
72 | } | |
73 | ||
74 | // ---------------------------------------------------------------------- | |
75 | // Private | |
76 | // ---------------------------------------------------------------------- | |
77 | ||
78 | /** | |
79 | * Validate a Chapter. | |
80 | * | |
81 | * @param result the ValidationResult to receive the results. | |
82 | * @param chapter the chapter to validate. | |
83 | */ | |
84 | private void validateChapter( ValidationResult result, Chapter chapter ) | |
85 | { | |
86 | if ( StringUtils.isEmpty( chapter.getId() ) ) | |
87 | { | |
88 | result.getErrors().add( "Each chapter has to have an id." ); | |
89 | ||
90 | return; | |
91 | } | |
92 | ||
93 | if ( StringUtils.isEmpty( chapter.getTitle() ) ) | |
94 | { | |
95 | result.getErrors().add( "Missing title. Chapter id: " + chapter.getId() ); | |
96 | } | |
97 | ||
98 | if ( chapter.getSections().size() == 0 ) | |
99 | { | |
100 | result.getErrors().add( "Chapter doesn't have any sections. Chapter id: " + chapter.getId() ); | |
101 | } | |
102 | } | |
103 | } |
+0
-78
0 | package org.apache.maven.doxia.book.services.validation; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.util.List; | |
22 | import java.util.ArrayList; | |
23 | ||
24 | /** | |
25 | * Encapsulates the result of a validation. | |
26 | * | |
27 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
28 | * @version $Id: ValidationResult.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
29 | */ | |
30 | public class ValidationResult | |
31 | { | |
32 | /** List of errors. */ | |
33 | private List<String> errors; | |
34 | ||
35 | /** List of warnings. */ | |
36 | private List<String> warnings; | |
37 | ||
38 | /** | |
39 | * Checks if there were any errors or warnings. | |
40 | * | |
41 | * @return True if there were no errors or warnings. | |
42 | */ | |
43 | public boolean isAllOk() | |
44 | { | |
45 | return getErrors().size() == 0 && getWarnings().size() == 0; | |
46 | } | |
47 | ||
48 | /** | |
49 | * Return the list of errors. | |
50 | * | |
51 | * @return List. A new ArrayList is constructed if the current List is null. | |
52 | */ | |
53 | public List<String> getErrors() | |
54 | { | |
55 | if ( errors == null ) | |
56 | { | |
57 | errors = new ArrayList<String>(); | |
58 | } | |
59 | ||
60 | return errors; | |
61 | } | |
62 | ||
63 | /** | |
64 | * Return the list of warnings. | |
65 | * | |
66 | * @return List. A new ArrayList is constructed if the current List is null. | |
67 | */ | |
68 | public List<String> getWarnings() | |
69 | { | |
70 | if ( warnings == null ) | |
71 | { | |
72 | warnings = new ArrayList<String>(); | |
73 | } | |
74 | ||
75 | return warnings; | |
76 | } | |
77 | } |
0 | <?xml version="1.0"?> | |
1 | ||
2 | <!-- | |
3 | Licensed to the Apache Software Foundation (ASF) under one | |
4 | or more contributor license agreements. See the NOTICE file | |
5 | distributed with this work for additional information | |
6 | regarding copyright ownership. The ASF licenses this file | |
7 | to you under the Apache License, Version 2.0 (the | |
8 | "License"); you may not use this file except in compliance | |
9 | with the License. You may obtain a copy of the License at | |
10 | ||
11 | http://www.apache.org/licenses/LICENSE-2.0 | |
12 | ||
13 | Unless required by applicable law or agreed to in writing, | |
14 | software distributed under the License is distributed on an | |
15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | KIND, either express or implied. See the License for the | |
17 | specific language governing permissions and limitations | |
18 | under the License. | |
19 | --> | |
20 | ||
21 | <model xmlns="http://modello.codehaus.org/MODELLO/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://modello.codehaus.org/MODELLO/1.0.0 http://modello.codehaus.org/xsd/modello-1.0.0.xsd" | |
22 | xml.namespace="http://maven.apache.org/BOOK/${version}"> | |
23 | <id>book</id> | |
24 | <name>BookModel</name> | |
25 | <description> | |
26 | <![CDATA[ | |
27 | <p> | |
28 | This descriptor specifies the metadatas and the content for a book. | |
29 | </p> | |
30 | <p> | |
31 | A book is defined by a collection of chapters, a chapter by a | |
32 | collection of sections, a section by a file. | |
33 | </p> | |
34 | <p>An XSD is available at:</p> | |
35 | <ul> | |
36 | <li><a href="http://maven.apache.org/xsd/book-1.0.0.xsd">http://maven.apache.org/xsd/book-1.0.0.xsd</a>.</li> | |
37 | </ul> | |
38 | ]]> | |
39 | </description> | |
40 | <defaults> | |
41 | <default> | |
42 | <key>package</key> | |
43 | <value>org.apache.maven.doxia.book.model</value> | |
44 | </default> | |
45 | </defaults> | |
46 | <classes> | |
47 | <class rootElement="true" xml.tagName="book"> | |
48 | <name>BookModel</name> | |
49 | <description> | |
50 | Describes the book layout and packaging. | |
51 | </description> | |
52 | <version>1.0.0</version> | |
53 | <fields> | |
54 | <field> | |
55 | <name>id</name> | |
56 | <version>1.0.0</version> | |
57 | <type>String</type> | |
58 | <identifier>true</identifier> | |
59 | <description> | |
60 | Specifies the id of this book. This is a symbolic name for a | |
61 | particular book from this project. | |
62 | </description> | |
63 | </field> | |
64 | <field> | |
65 | <name>title</name> | |
66 | <version>1.0.0</version> | |
67 | <type>String</type> | |
68 | <description> | |
69 | Specifies the title of this book. | |
70 | </description> | |
71 | </field> | |
72 | <field> | |
73 | <name>author</name> | |
74 | <version>1.0.0</version> | |
75 | <type>String</type> | |
76 | <description> | |
77 | Specifies the author of this book. | |
78 | </description> | |
79 | </field> | |
80 | <field> | |
81 | <name>date</name> | |
82 | <version>1.0.0</version> | |
83 | <type>String</type> | |
84 | <description> | |
85 | Specifies the date of this book. | |
86 | </description> | |
87 | </field> | |
88 | <field> | |
89 | <name>chapters</name> | |
90 | <version>1.0.0</version> | |
91 | <description> | |
92 | Specifies a collection of chapters. | |
93 | </description> | |
94 | <association> | |
95 | <type>Chapter</type> | |
96 | <multiplicity>*</multiplicity> | |
97 | </association> | |
98 | </field> | |
99 | <!-- | |
100 | <field> | |
101 | <name>bannerLeft</name> | |
102 | <description>Banner logo on the masthead of the site to the left.</description> | |
103 | <version>1.0.0</version> | |
104 | <association> | |
105 | <type>Banner</type> | |
106 | </association> | |
107 | <identifier>true</identifier> | |
108 | </field> | |
109 | <field> | |
110 | <name>bannerRight</name> | |
111 | <description>Banner logo on the masthead of the site to the right.</description> | |
112 | <version>1.0.0</version> | |
113 | <association> | |
114 | <type>Banner</type> | |
115 | </association> | |
116 | <identifier>true</identifier> | |
117 | </field> | |
118 | <field> | |
119 | <name>publishDate</name> | |
120 | <description>Modify the date published display properties.</description> | |
121 | <version>1.0.0</version> | |
122 | <association> | |
123 | <type>PublishDate</type> | |
124 | </association> | |
125 | <identifier>true</identifier> | |
126 | </field> | |
127 | <field> | |
128 | <name>version</name> | |
129 | <description>Modify the version display properties.</description> | |
130 | <version>1.0.0</version> | |
131 | <association> | |
132 | <type>Version</type> | |
133 | </association> | |
134 | <identifier>true</identifier> | |
135 | </field> | |
136 | <field> | |
137 | <name>poweredBy</name> | |
138 | <description>Powered by logos.</description> | |
139 | <version>1.0.0</version> | |
140 | <association xml.tagName="logo"> | |
141 | <type>Logo</type> | |
142 | <multiplicity>*</multiplicity> | |
143 | </association> | |
144 | <identifier>true</identifier> | |
145 | </field> | |
146 | <field> | |
147 | <name>skin</name> | |
148 | <description>The artifact containing the skin for the site</description> | |
149 | <version>1.0.0</version> | |
150 | <association> | |
151 | <type>Skin</type> | |
152 | </association> | |
153 | <identifier>true</identifier> | |
154 | </field> | |
155 | <field> | |
156 | <name>body</name> | |
157 | <description>The main site content decoration.</description> | |
158 | <version>1.0.0</version> | |
159 | <association> | |
160 | <type>Body</type> | |
161 | </association> | |
162 | <identifier>true</identifier> | |
163 | </field> | |
164 | <field> | |
165 | <name>custom</name> | |
166 | <description>Custom configuration for use with customised velocity templates.</description> | |
167 | <version>1.0.0</version> | |
168 | <type>DOM</type> | |
169 | <identifier>true</identifier> | |
170 | </field> | |
171 | --> | |
172 | </fields> | |
173 | </class> | |
174 | <class> | |
175 | <name>Chapter</name> | |
176 | <version>1.0.0</version> | |
177 | <fields> | |
178 | <field> | |
179 | <name>id</name> | |
180 | <version>1.0.0</version> | |
181 | <type>String</type> | |
182 | <identifier>true</identifier> | |
183 | <description> | |
184 | Specifies the id of this chapter. This is a symbolic name for a | |
185 | particular chapter. | |
186 | </description> | |
187 | </field> | |
188 | <field> | |
189 | <name>title</name> | |
190 | <version>1.0.0</version> | |
191 | <type>String</type> | |
192 | <description> | |
193 | Specifies the title of this chapter. | |
194 | </description> | |
195 | </field> | |
196 | <field> | |
197 | <name>sections</name> | |
198 | <version>1.0.0</version> | |
199 | <description> | |
200 | Specifies a collection of sections. | |
201 | </description> | |
202 | <association> | |
203 | <type>Section</type> | |
204 | <multiplicity>*</multiplicity> | |
205 | </association> | |
206 | </field> | |
207 | </fields> | |
208 | </class> | |
209 | <class> | |
210 | <name>Section</name> | |
211 | <version>1.0.0</version> | |
212 | <fields> | |
213 | <field> | |
214 | <name>id</name> | |
215 | <version>1.0.0</version> | |
216 | <type>String</type> | |
217 | <identifier>true</identifier> | |
218 | <description> | |
219 | Specifies the id of this section. This is a symbolic name for a | |
220 | particular section. | |
221 | </description> | |
222 | </field> | |
223 | <field> | |
224 | <name>title</name> | |
225 | <version>1.0.0</version> | |
226 | <type>String</type> | |
227 | <description> | |
228 | Specifies the title of this section. | |
229 | </description> | |
230 | </field> | |
231 | <field> | |
232 | <name>file</name> | |
233 | <version>1.0.0</version> | |
234 | <type>String</type> | |
235 | <description> | |
236 | Specifies the file of this section. | |
237 | </description> | |
238 | </field> | |
239 | </fields> | |
240 | </class> | |
241 | <!-- | |
242 | <class> | |
243 | <name>Banner</name> | |
244 | <description>A banner logo on the masthead of the site.</description> | |
245 | <version>1.0.0</version> | |
246 | <fields> | |
247 | <field> | |
248 | <name>name</name> | |
249 | <version>1.0.0</version> | |
250 | <description>Description of the banner.</description> | |
251 | <type>String</type> | |
252 | <identifier>true</identifier> | |
253 | </field> | |
254 | <field> | |
255 | <name>src</name> | |
256 | <version>1.0.0</version> | |
257 | <description>The href of an image for the banner</description> | |
258 | <type>String</type> | |
259 | <identifier>true</identifier> | |
260 | </field> | |
261 | <field> | |
262 | <name>alt</name> | |
263 | <version>1.0.0</version> | |
264 | <description>Alt description for the banner image.</description> | |
265 | <type>String</type> | |
266 | <identifier>true</identifier> | |
267 | </field> | |
268 | <field> | |
269 | <name>href</name> | |
270 | <version>1.0.0</version> | |
271 | <description>The href of a link to use for the banner</description> | |
272 | <type>String</type> | |
273 | <identifier>true</identifier> | |
274 | </field> | |
275 | </fields> | |
276 | </class> | |
277 | <class> | |
278 | <name>PublishDate</name> | |
279 | <description>Modify display properties for date published.</description> | |
280 | <version>1.0.0</version> | |
281 | <fields> | |
282 | <field xml.attribute="true"> | |
283 | <name>position</name> | |
284 | <description>Where to place the date published (left, right, navigation-top, navigation-bottom, | |
285 | bottom).</description> | |
286 | <version>1.0.0</version> | |
287 | <type>String</type> | |
288 | <identifier>true</identifier> | |
289 | </field> | |
290 | <field xml.attribute="true"> | |
291 | <name>format</name> | |
292 | <description>Date format to use. The default is MM/dd/yyyy.</description> | |
293 | <version>1.0.0</version> | |
294 | <type>String</type> | |
295 | <identifier>true</identifier> | |
296 | </field> | |
297 | </fields> | |
298 | </class> | |
299 | <class> | |
300 | <name>Version</name> | |
301 | <description>Modify display properties for version.</description> | |
302 | <version>1.0.0</version> | |
303 | <fields> | |
304 | <field xml.attribute="true"> | |
305 | <name>position</name> | |
306 | <description>Where to place the date published (left, right, navigation-top, navigation-bottom, | |
307 | bottom).</description> | |
308 | <version>1.0.0</version> | |
309 | <type>String</type> | |
310 | <identifier>true</identifier> | |
311 | </field> | |
312 | </fields> | |
313 | </class> | |
314 | <class> | |
315 | <name>Logo</name> | |
316 | <description>Logo.</description> | |
317 | <version>1.0.0</version> | |
318 | <superClass>LinkItem</superClass> | |
319 | <fields> | |
320 | <field xml.attribute="true"> | |
321 | <name>img</name> | |
322 | <description>Logo image href.</description> | |
323 | <version>1.0.0</version> | |
324 | <type>String</type> | |
325 | <identifier>true</identifier> | |
326 | </field> | |
327 | </fields> | |
328 | </class> | |
329 | <class> | |
330 | <name>Body</name> | |
331 | <description>The main content decoration.</description> | |
332 | <version>1.0.0</version> | |
333 | <fields> | |
334 | <field> | |
335 | <name>head</name> | |
336 | <description>Additional content to include in the HEAD block of the generated pages.</description> | |
337 | <version>1.0.0</version> | |
338 | <type>DOM</type> | |
339 | <identifier>true</identifier> | |
340 | </field> | |
341 | <field> | |
342 | <name>links</name> | |
343 | <description>A list of links to display in the navigation.</description> | |
344 | <version>1.0.0</version> | |
345 | <association xml.tagName="item"> | |
346 | <type>LinkItem</type> | |
347 | <multiplicity>*</multiplicity> | |
348 | </association> | |
349 | <identifier>true</identifier> | |
350 | </field> | |
351 | <field> | |
352 | <name>breadcrumbs</name> | |
353 | <description>A list of breadcrumbs to display in the navigation.</description> | |
354 | <version>1.0.0</version> | |
355 | <association xml.tagName="item"> | |
356 | <type>LinkItem</type> | |
357 | <multiplicity>*</multiplicity> | |
358 | <identifier>true</identifier> | |
359 | </association> | |
360 | <identifier>true</identifier> | |
361 | </field> | |
362 | <field> | |
363 | <name>menus</name> | |
364 | <description>Menus to include in the navigation.</description> | |
365 | <version>1.0.0</version> | |
366 | <association xml.itemsStyle="flat"> | |
367 | <type>Menu</type> | |
368 | <multiplicity>*</multiplicity> | |
369 | </association> | |
370 | <identifier>true</identifier> | |
371 | </field> | |
372 | </fields> | |
373 | </class> | |
374 | <class> | |
375 | <name>LinkItem</name> | |
376 | <description>A link in the navigation.</description> | |
377 | <version>1.0.0</version> | |
378 | <fields> | |
379 | <field xml.attribute="true"> | |
380 | <name>name</name> | |
381 | <description>The name to use for the link.</description> | |
382 | <version>1.0.0</version> | |
383 | <type>String</type> | |
384 | <identifier>true</identifier> | |
385 | </field> | |
386 | <field xml.attribute="true"> | |
387 | <name>href</name> | |
388 | <description>The href to use for the link.</description> | |
389 | <version>1.0.0</version> | |
390 | <type>String</type> | |
391 | <identifier>true</identifier> | |
392 | </field> | |
393 | </fields> | |
394 | </class> | |
395 | <class> | |
396 | <name>Menu</name> | |
397 | <description>A menu in the navigation.</description> | |
398 | <version>1.0.0</version> | |
399 | <fields> | |
400 | <field xml.attribute="true"> | |
401 | <name>name</name> | |
402 | <description>The name to use for the menu.</description> | |
403 | <version>1.0.0</version> | |
404 | <type>String</type> | |
405 | <identifier>true</identifier> | |
406 | </field> | |
407 | <field xml.attribute="true"> | |
408 | <name>inherit</name> | |
409 | <description>The way in which the menu is inherited.</description> | |
410 | <version>1.0.0</version> | |
411 | <type>String</type> | |
412 | <identifier>true</identifier> | |
413 | </field> | |
414 | <field xml.attribute="true"> | |
415 | <name>inheritAsRef</name> | |
416 | <description>If this is a reference, setting inheritAsRef means that it will be populated in the project, | |
417 | whereas if it is false it is populated in the parent and then inherited.</description> | |
418 | <version>1.0.0</version> | |
419 | <type>boolean</type> | |
420 | </field> | |
421 | <field xml.attribute="true"> | |
422 | <name>ref</name> | |
423 | <description><![CDATA[A reference to a pre-defined menu, such as a <code>reports</code>, <code>modules</code> | |
424 | or <code>parentProject</code>.]]></description> | |
425 | <version>1.0.0</version> | |
426 | <type>String</type> | |
427 | <identifier>true</identifier> | |
428 | </field> | |
429 | <field xml.attribute="true"> | |
430 | <name>img</name> | |
431 | <description>Image href.</description> | |
432 | <version>1.0.0</version> | |
433 | <type>String</type> | |
434 | <identifier>true</identifier> | |
435 | </field> | |
436 | <field> | |
437 | <name>items</name> | |
438 | <description>Menu item.</description> | |
439 | <version>1.0.0</version> | |
440 | <association xml.itemsStyle="flat"> | |
441 | <type>MenuItem</type> | |
442 | <multiplicity>*</multiplicity> | |
443 | </association> | |
444 | <identifier>true</identifier> | |
445 | </field> | |
446 | </fields> | |
447 | </class> | |
448 | <class> | |
449 | <name>MenuItem</name> | |
450 | <description>A menu item.</description> | |
451 | <version>1.0.0</version> | |
452 | <superClass>LinkItem</superClass> | |
453 | <fields> | |
454 | <field> | |
455 | <name>description</name> | |
456 | <description>A description of the menu item. This is used on any summary pages for a menu.</description> | |
457 | <version>1.0.0</version> | |
458 | <type>String</type> | |
459 | <identifier>true</identifier> | |
460 | </field> | |
461 | <field xml.attribute="true"> | |
462 | <name>collapse</name> | |
463 | <description>Whether the item is collapsed by default when it has children elements.</description> | |
464 | <version>1.0.0</version> | |
465 | <type>boolean</type> | |
466 | <identifier>true</identifier> | |
467 | </field> | |
468 | <field xml.attribute="true"> | |
469 | <name>ref</name> | |
470 | <description><![CDATA[A reference to a pre-defined menu item, such as a report (specified by the report goal | |
471 | name). Any elements explicitly given override those from the pre-defined reference.]]></description> | |
472 | <version>1.0.0</version> | |
473 | <type>String</type> | |
474 | <identifier>true</identifier> | |
475 | </field> | |
476 | <field> | |
477 | <name>items</name> | |
478 | <description>Menu item.</description> | |
479 | <version>1.0.0</version> | |
480 | <association xml.itemsStyle="flat"> | |
481 | <type>MenuItem</type> | |
482 | <multiplicity>*</multiplicity> | |
483 | </association> | |
484 | <identifier>true</identifier> | |
485 | </field> | |
486 | </fields> | |
487 | </class> | |
488 | <class> | |
489 | <name>Skin</name> | |
490 | <description>An skin artifact declaration</description> | |
491 | <version>1.0.0</version> | |
492 | <fields> | |
493 | <field> | |
494 | <name>groupId</name> | |
495 | <description>The group ID</description> | |
496 | <version>1.0.0</version> | |
497 | <type>String</type> | |
498 | <required>true</required> | |
499 | <identifier>true</identifier> | |
500 | </field> | |
501 | <field> | |
502 | <name>artifactId</name> | |
503 | <description>The artifact ID</description> | |
504 | <version>1.0.0</version> | |
505 | <type>String</type> | |
506 | <required>true</required> | |
507 | <identifier>true</identifier> | |
508 | </field> | |
509 | <field> | |
510 | <name>version</name> | |
511 | <description>The version</description> | |
512 | <version>1.0.0</version> | |
513 | <type>String</type> | |
514 | <identifier>true</identifier> | |
515 | </field> | |
516 | </fields> | |
517 | <codeSegments> | |
518 | <codeSegment> | |
519 | <version>1.0.0</version> | |
520 | <code> | |
521 | <![CDATA[ | |
522 | public static Skin getDefaultSkin() | |
523 | { | |
524 | Skin skin = new Skin(); | |
525 | skin.setGroupId( "org.apache.maven.skins" ); | |
526 | skin.setArtifactId( "maven-default-skin" ); | |
527 | return skin; | |
528 | } | |
529 | ]]> | |
530 | </code> | |
531 | </codeSegment> | |
532 | </codeSegments> | |
533 | </class> | |
534 | --> | |
535 | </classes> | |
536 | </model> |
0 | # Licensed to the Apache Software Foundation (ASF) under one | |
1 | # or more contributor license agreements. See the NOTICE file | |
2 | # distributed with this work for additional information | |
3 | # regarding copyright ownership. The ASF licenses this file | |
4 | # to you under the Apache License, Version 2.0 (the | |
5 | # "License"); you may not use this file except in compliance | |
6 | # with the License. You may obtain a copy of the License at | |
7 | # | |
8 | # http://www.apache.org/licenses/LICENSE-2.0 | |
9 | # | |
10 | # Unless required by applicable law or agreed to in writing, | |
11 | # software distributed under the License is distributed on an | |
12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
13 | # KIND, either express or implied. See the License for the | |
14 | # specific language governing permissions and limitations | |
15 | # under the License. | |
16 | ||
17 | toc=Table Of Content | |
18 | previous=Previous | |
19 | up=Up | |
20 | next=Next |
0 | # Licensed to the Apache Software Foundation (ASF) under one | |
1 | # or more contributor license agreements. See the NOTICE file | |
2 | # distributed with this work for additional information | |
3 | # regarding copyright ownership. The ASF licenses this file | |
4 | # to you under the Apache License, Version 2.0 (the | |
5 | # "License"); you may not use this file except in compliance | |
6 | # with the License. You may obtain a copy of the License at | |
7 | # | |
8 | # http://www.apache.org/licenses/LICENSE-2.0 | |
9 | # | |
10 | # Unless required by applicable law or agreed to in writing, | |
11 | # software distributed under the License is distributed on an | |
12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
13 | # KIND, either express or implied. See the License for the | |
14 | # specific language governing permissions and limitations | |
15 | # under the License. | |
16 | ||
17 | # NOTE: | |
18 | # This bundle is intentionally empty because English strings are provided by the base bundle via the parent chain. It | |
19 | # must be provided nevertheless such that a request for locale "en" will not errorneously pick up the bundle for the | |
20 | # JVM's default locale (which need not be "en"). See the method javadoc about | |
21 | # ResourceBundle.getBundle(String, Locale, ClassLoader) | |
22 | # for a full description of the lookup strategy. |
0 | # Licensed to the Apache Software Foundation (ASF) under one | |
1 | # or more contributor license agreements. See the NOTICE file | |
2 | # distributed with this work for additional information | |
3 | # regarding copyright ownership. The ASF licenses this file | |
4 | # to you under the Apache License, Version 2.0 (the | |
5 | # "License"); you may not use this file except in compliance | |
6 | # with the License. You may obtain a copy of the License at | |
7 | # | |
8 | # http://www.apache.org/licenses/LICENSE-2.0 | |
9 | # | |
10 | # Unless required by applicable law or agreed to in writing, | |
11 | # software distributed under the License is distributed on an | |
12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
13 | # KIND, either express or implied. See the License for the | |
14 | # specific language governing permissions and limitations | |
15 | # under the License. | |
16 | ||
17 | toc=Table des matières | |
18 | previous=Précédent | |
19 | up=Haut | |
20 | next=Suivant |
0 | ----- | |
1 | Writing Books in Doxia | |
2 | ----- | |
3 | Lukas Theussl | |
4 | ----- | |
5 | ||
6 | Introduction | |
7 | ||
8 | Doxia allows you to write books like user manuals and guides in any format supported by Doxia. Combined with the | |
9 | Doxia Book Maven you are able to include the manuals directly in your generated site with links to the off-line | |
10 | friendly formats like XDoc, PDF, RTF and LaTeX. | |
11 | ||
12 | * How It Works | |
13 | ||
14 | The only thing you need in addition to the content files itself is a simple book descriptor which is used to specify | |
15 | the ordering of the sections and the names for the chapters. | |
16 | ||
17 | See {{{./book.html}The Book Descriptor Reference}} for a reference to the descriptor. A sample is given on the | |
18 | main Doxia {{{http://maven.apache.org/doxia/book/index.html}site}}. | |
19 |
0 | ----- | |
1 | Usage | |
2 | ----- | |
3 | Lukas Theussl | |
4 | ----- | |
5 | ||
6 | Usage | |
7 | ||
8 | Below is a simple example to illustrate how to use it. | |
9 | ||
10 | +------------------------------------------------------ | |
11 | BookDoxia doxia = (BookDoxia) lookup( BookDoxia.ROLE ); | |
12 | ||
13 | // load the book descriptor | |
14 | File book1 = new File( "book-1.xml" ); | |
15 | ||
16 | BookModel book = doxia.loadBook( book1 ); | |
17 | ||
18 | // files to include | |
19 | List files = FileUtils.getFiles( new File( "src/resources/book/" ), "**/*.apt, **/*.xml", "" ); | |
20 | ||
21 | // render books in different formats | |
22 | doxia.renderBook( book, "pdf", files, new File( "target/itext/" ) ); | |
23 | doxia.renderBook( book, "xhtml", files, new File( "target/xhtml/" ) ); | |
24 | doxia.renderBook( book, "xdoc", files, new File( "target/xdoc/" ) ); | |
25 | doxia.renderBook( book, "latex", files, new File( "target/latex/" ) ); | |
26 | doxia.renderBook( book, "doc-book", files, new File( "target/doc-book/" ) ); | |
27 | doxia.renderBook( book, "rtf", files, new File( "target/rtf/" ) ); | |
28 | +------------------------------------------------------ | |
29 | ||
30 | See the {{{./apidocs/index.html}Javadocs}} for more details. |
0 | ----- | |
1 | Using Schema Book 1.0 | |
2 | ----- | |
3 | Vincent Siveton | |
4 | ------ | |
5 | 2009-01-28 | |
6 | ------ | |
7 | ||
8 | ~~ Licensed to the Apache Software Foundation (ASF) under one | |
9 | ~~ or more contributor license agreements. See the NOTICE file | |
10 | ~~ distributed with this work for additional information | |
11 | ~~ regarding copyright ownership. The ASF licenses this file | |
12 | ~~ to you under the Apache License, Version 2.0 (the | |
13 | ~~ "License"); you may not use this file except in compliance | |
14 | ~~ with the License. You may obtain a copy of the License at | |
15 | ~~ | |
16 | ~~ http://www.apache.org/licenses/LICENSE-2.0 | |
17 | ~~ | |
18 | ~~ Unless required by applicable law or agreed to in writing, | |
19 | ~~ software distributed under the License is distributed on an | |
20 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
21 | ~~ KIND, either express or implied. See the License for the | |
22 | ~~ specific language governing permissions and limitations | |
23 | ~~ under the License. | |
24 | ||
25 | ~~ NOTE: For help with the syntax of this file, see: | |
26 | ~~ http://maven.apache.org/doxia/references/apt-format.html | |
27 | ||
28 | Using Schema Book 1.0 | |
29 | ||
30 | The Decoration XSD is located {{{http://maven.apache.org/xsd/book-1.0.0.xsd}here}}. | |
31 | ||
32 | Your favorite IDE probably supports XSD schema's for .xml files. You need to specify the following: | |
33 | ||
34 | +-----+ | |
35 | <book xmlns="http://maven.apache.org/BOOK/1.0.0" | |
36 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
37 | xsi:schemaLocation="http://maven.apache.org/BOOK/1.0.0 http://maven.apache.org/xsd/book-1.0.0.xsd"> | |
38 | ... | |
39 | </book> | |
40 | +-----+ |
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | ||
2 | <!-- | |
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | --> | |
22 | ||
23 | <project xmlns="http://maven.apache.org/DECORATION/1.0.0" | |
24 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
25 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 file:../../../../doxia-sitetools/doxia-decoration-model/target/generated-site/xsd/decoration-1.0.0.xsd"> | |
26 | ||
27 | <body> | |
28 | ||
29 | <menu ref="parent"/> | |
30 | ||
31 | <menu name="About Doxia :: Book Components"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="Usage" href="usage.html"/> | |
34 | <!--<item name="FAQ" href="faq.html"/>--> | |
35 | </menu> | |
36 | ||
37 | <menu name="Schema Book 1.0"> | |
38 | <item name="Reference of Schema Book" href="book.html"/> | |
39 | <item name="Using Schema Book" href="using-book-xsd.html"/> | |
40 | </menu> | |
41 | ||
42 | <menu ref="reports"/> | |
43 | ||
44 | </body> | |
45 | ||
46 | </project> |
0 | package org.apache.maven.doxia.book; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.codehaus.plexus.PlexusTestCase; | |
22 | import org.codehaus.plexus.util.FileUtils; | |
23 | import org.codehaus.plexus.util.StringUtils; | |
24 | import org.apache.maven.doxia.book.model.BookModel; | |
25 | ||
26 | import java.io.File; | |
27 | import java.util.List; | |
28 | ||
29 | /** | |
30 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
31 | * @version $Id: BookRendererTest.java 707844 2008-10-25 13:41:29Z vsiveton $ | |
32 | */ | |
33 | public class BookRendererTest | |
34 | extends PlexusTestCase | |
35 | { | |
36 | public void testBasic() | |
37 | throws Exception | |
38 | { | |
39 | BookDoxia doxia = (BookDoxia) lookup( BookDoxia.ROLE ); | |
40 | ||
41 | File book1 = getTestFile( "src/test/resources/book-1.xml" ); | |
42 | ||
43 | List files = FileUtils.getFiles( getTestFile( "src/test/resources/book-1" ), "**/*.apt, **/*.xml", "" ); | |
44 | ||
45 | BookModel book = doxia.loadBook( book1 ); | |
46 | ||
47 | doxia.renderBook( book, "pdf", files, getTestFile( "target/test-output/itext" ) ); | |
48 | doxia.renderBook( book, "xhtml", files, getTestFile( "target/test-output/xhtml" ) ); | |
49 | doxia.renderBook( book, "xdoc", files, getTestFile( "target/test-output/xdoc" ) ); | |
50 | doxia.renderBook( book, "latex", files, getTestFile( "target/test-output/latex" ) ); | |
51 | doxia.renderBook( book, "doc-book", files, getTestFile( "target/test-output/doc-book" ) ); | |
52 | doxia.renderBook( book, "rtf", files, getTestFile( "target/test-output/rtf" ) ); | |
53 | ||
54 | assertCorrectDocbook(); | |
55 | } | |
56 | ||
57 | /** | |
58 | * Regression test for the docbook output. | |
59 | */ | |
60 | private void assertCorrectDocbook() | |
61 | throws Exception | |
62 | { | |
63 | String expected = | |
64 | FileUtils.fileRead( getTestFile( "src/test/resources/expected/doc-book/plexus-user-guide.xml" ) ); | |
65 | expected = StringUtils.deleteWhitespace( expected ); | |
66 | ||
67 | String actual = | |
68 | FileUtils.fileRead( getTestFile( "target/test-output/doc-book/plexus-user-guide.xml" ) ); | |
69 | actual = StringUtils.deleteWhitespace( actual ); | |
70 | ||
71 | assertEquals( "Wrong docbook output!", | |
72 | StringUtils.replace( expected, "\r", "" ), StringUtils.replace( actual, "\r", "" ) ); | |
73 | } | |
74 | } |
+0
-118
0 | package org.apache.maven.doxia.book.services.indexer; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.context.BookContext; | |
22 | import org.apache.maven.doxia.book.model.BookModel; | |
23 | import org.apache.maven.doxia.book.services.io.BookIo; | |
24 | import org.apache.maven.doxia.index.IndexEntry; | |
25 | import org.apache.maven.doxia.util.HtmlTools; | |
26 | import org.codehaus.plexus.PlexusTestCase; | |
27 | import org.codehaus.plexus.util.FileUtils; | |
28 | ||
29 | /** | |
30 | * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugstøl</a> | |
31 | * @version $Id: BookIndexerTest.java 638290 2008-03-18 09:45:22Z bentmann $ | |
32 | */ | |
33 | public class BookIndexerTest | |
34 | extends PlexusTestCase | |
35 | { | |
36 | public void testBasic() | |
37 | throws Exception | |
38 | { | |
39 | BookIo io = (BookIo) lookup( BookIo.ROLE ); | |
40 | ||
41 | BookIndexer indexer = (BookIndexer) lookup( BookIndexer.ROLE ); | |
42 | ||
43 | BookModel book = io.readBook( getTestFile( "src/test/resources/book-1.xml" ) ); | |
44 | ||
45 | BookContext context = new BookContext(); | |
46 | ||
47 | io.loadFiles( context, FileUtils.getFiles( getTestFile( "src/test/resources/book-1" ), "*.apt", "" ) ); | |
48 | ||
49 | indexer.indexBook( book, context ); | |
50 | ||
51 | IndexEntry root = context.getIndex(); | |
52 | ||
53 | assertNotNull( root ); | |
54 | ||
55 | assertEquals( 2, root.getChildEntries().size() ); | |
56 | ||
57 | IndexEntry c1 = assertIndexEntry( root, 0, "Chapter 1", "chapter-1", 2 ); | |
58 | ||
59 | // ----------------------------------------------------------------------- | |
60 | // Section 1 | |
61 | // ----------------------------------------------------------------------- | |
62 | ||
63 | IndexEntry s1 = assertIndexEntry( c1, 0, "Section 1", "section-1", 5 ); | |
64 | ||
65 | IndexEntry ss1 = assertIndexEntry( s1, 0, "Subsection 1", "Subsection_1", 1 ); | |
66 | ||
67 | assertIndexEntry( ss1, 0, "Subsubsection 1", "Subsubsection_1", 0 ); | |
68 | ||
69 | assertIndexEntry( s1, 1, "Subsection 2", "Subsection_2", 0 ); | |
70 | ||
71 | assertIndexEntry( s1, 2, "Subsection 3", "Subsection_3", 0 ); | |
72 | ||
73 | assertIndexEntry( s1, 3, "Subsection 4", "Subsection_4", 0 ); | |
74 | ||
75 | // ----------------------------------------------------------------------- | |
76 | // Section 2 | |
77 | // ----------------------------------------------------------------------- | |
78 | ||
79 | IndexEntry s2 = assertIndexEntry( c1, 1, "Section 2", "section-2", 1 ); | |
80 | ||
81 | assertIndexEntry( s2, 0, "Section 1.10.32 of \"de Finibus Bonorum et Malorum\", written by Cicero in 45 BC", | |
82 | "Section_1.10.32_of_\"de_Finibus_Bonorum_et_Malorum\",_written_by_Cicero_in_45_BC", 0 ); | |
83 | ||
84 | // ----------------------------------------------------------------------- | |
85 | // Chapter 2 | |
86 | // ----------------------------------------------------------------------- | |
87 | ||
88 | IndexEntry c2 = assertIndexEntry( root, 1, "Chapter 2", "chapter-2", 2 ); | |
89 | ||
90 | IndexEntry s3 = assertIndexEntry( c2, 0, "Section 3", "section-3", 1 ); | |
91 | ||
92 | assertIndexEntry( s3, 0, "1914 translation by H. Rackham", "1914_translation_by_H._Rackham", 0 ); | |
93 | ||
94 | IndexEntry s4 = assertIndexEntry( c2, 1, "Section 4", "section-4", 1 ); | |
95 | ||
96 | assertIndexEntry( s4, 0, "Section 1.10.33 of \"de Finibus Bonorum et Malorum\", written by Cicero in 45 BC", | |
97 | "Section_1.10.33_of_\"de_Finibus_Bonorum_et_Malorum\",_written_by_Cicero_in_45_BC", 0 ); | |
98 | } | |
99 | ||
100 | private IndexEntry assertIndexEntry( IndexEntry parent, int childIndex, String title, String id, int childCount ) | |
101 | { | |
102 | assertTrue( "parent: " + parent.getId() + ", " + | |
103 | "required count: " + childCount + ", " + | |
104 | "actual count: " + parent.getChildEntries().size(), | |
105 | childIndex < parent.getChildEntries().size() ); | |
106 | ||
107 | IndexEntry indexEntry = (IndexEntry) parent.getChildEntries().get( childIndex ); | |
108 | ||
109 | assertEquals( title, indexEntry.getTitle() ); | |
110 | ||
111 | assertEquals( HtmlTools.encodeId( id ), indexEntry.getId() ); | |
112 | ||
113 | assertEquals( childCount, indexEntry.getChildEntries().size() ); | |
114 | ||
115 | return indexEntry; | |
116 | } | |
117 | } |
+0
-490
0 | package org.apache.maven.doxia.book.services.renderer.docbook; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.Writer; | |
22 | ||
23 | import java.util.Locale; | |
24 | ||
25 | import javax.swing.text.MutableAttributeSet; | |
26 | import javax.swing.text.SimpleAttributeSet; | |
27 | ||
28 | import org.apache.maven.doxia.module.docbook.DocBookSink; | |
29 | import org.apache.maven.doxia.sink.AbstractSinkTest; | |
30 | import org.apache.maven.doxia.sink.Sink; | |
31 | import org.apache.maven.doxia.sink.SinkUtils; | |
32 | ||
33 | import org.apache.maven.doxia.util.DoxiaUtils; | |
34 | import org.codehaus.plexus.util.FileUtils; | |
35 | ||
36 | /** | |
37 | * Test the book path of the DockBook sink | |
38 | * @author Dave Syer | |
39 | */ | |
40 | public class DocBookBookSinkTest extends AbstractSinkTest | |
41 | { | |
42 | /** {@inheritDoc} */ | |
43 | protected boolean isXmlSink() | |
44 | { | |
45 | return true; | |
46 | } | |
47 | ||
48 | /** {@inheritDoc} */ | |
49 | protected String outputExtension() | |
50 | { | |
51 | return "docbook"; | |
52 | } | |
53 | ||
54 | /** {@inheritDoc} */ | |
55 | protected Sink createSink( Writer writer ) | |
56 | { | |
57 | return new DocBookBookSink( writer ); | |
58 | } | |
59 | ||
60 | // | |
61 | // DocBookBookSink specific | |
62 | // | |
63 | ||
64 | /** | |
65 | * Checks that the sequence <code>[bookTitle(), text( title ), bookTitle_()]</code>, | |
66 | * invoked on the current sink, produces the same result as | |
67 | * {@link #getBookTitleBlock getBookTitleBlock}( title ). | |
68 | * NewLines are ignored. | |
69 | */ | |
70 | public void testBookTitle() | |
71 | { | |
72 | DocBookBookSink sink = (DocBookBookSink) getSink(); | |
73 | ||
74 | String title = "Grodek"; | |
75 | sink.bookTitle(); | |
76 | sink.text( title ); | |
77 | sink.bookTitle_(); | |
78 | sink.flush(); | |
79 | ||
80 | String actual = getSinkContent(); | |
81 | String expected = getBookTitleBlock( title ); | |
82 | ||
83 | assertEquals( "Wrong book title!", expected, actual ); | |
84 | } | |
85 | ||
86 | /** | |
87 | * Checks that the sequence <code>[bookAuthor(), text( author ), bookAuthor_()] | |
88 | * </code>, invoked on the current sink, produces the same result as | |
89 | * {@link #getBookAuthorBlock getBookAuthorBlock}( author ). | |
90 | * NewLines are ignored. | |
91 | */ | |
92 | public void testBookAuthor() | |
93 | { | |
94 | DocBookBookSink sink = (DocBookBookSink) getSink(); | |
95 | ||
96 | String author = "Georg Trakl"; | |
97 | sink.bookAuthor(); | |
98 | sink.text( author ); | |
99 | sink.bookAuthor_(); | |
100 | sink.flush(); | |
101 | ||
102 | String actual = getSinkContent(); | |
103 | String expected = getBookAuthorBlock( author ); | |
104 | ||
105 | assertEquals( "Wrong book author!", expected, actual ); | |
106 | } | |
107 | ||
108 | /** | |
109 | * Checks that the sequence <code>[bookDate(), text( date ), bookDate_()]</code>, | |
110 | * invoked on the current sink, produces the same result as | |
111 | * {@link #getBookDateBlock getBookDateBlock}( date ). NewLines are ignored. | |
112 | */ | |
113 | public void testBookDate() | |
114 | { | |
115 | DocBookBookSink sink = (DocBookBookSink) getSink(); | |
116 | ||
117 | String date = "1914"; | |
118 | sink.bookDate(); | |
119 | sink.text( date ); | |
120 | sink.bookDate_(); | |
121 | sink.flush(); | |
122 | ||
123 | String actual = getSinkContent(); | |
124 | String expected = getBookDateBlock( date ); | |
125 | ||
126 | assertEquals( "Wrong book date!", expected, actual ); | |
127 | } | |
128 | ||
129 | /** | |
130 | * Checks that the sequence <code>[bookHead(), bookHead_()]</code>, | |
131 | * invoked on the current sink, produces the same result as | |
132 | * {@link #getBookHeadBlock getBookHeadBlock()}. NewLines are ignored. | |
133 | */ | |
134 | public void testBookHead() | |
135 | { | |
136 | DocBookBookSink sink = (DocBookBookSink) getSink(); | |
137 | ||
138 | //sink.bookHead(); | |
139 | sink.bookHead_(); | |
140 | sink.flush(); | |
141 | ||
142 | String actual = getSinkContent(); | |
143 | String expected = getBookHeadBlock(); | |
144 | ||
145 | assertEquals( "Wrong book head!", expected, actual ); | |
146 | } | |
147 | ||
148 | /** | |
149 | * Checks that the sequence <code>[book(), book_()]</code>, | |
150 | * invoked on the current sink, produces the same result as | |
151 | * {@link #getBookBlock getBookBlock()}. NewLines are ignored. | |
152 | */ | |
153 | public void testBook() | |
154 | { | |
155 | DocBookBookSink sink = (DocBookBookSink) getSink(); | |
156 | ||
157 | sink.book(); | |
158 | sink.book_(); | |
159 | sink.flush(); | |
160 | ||
161 | String actual = getSinkContent(); | |
162 | String expected = getBookBlock(); | |
163 | ||
164 | assertEquals( "Wrong book body!", expected, actual ); | |
165 | } | |
166 | ||
167 | /** | |
168 | * Checks that the sequence <code>[chapterTitle(), text( title ), | |
169 | * chapterTitle_()]</code>, invoked on the current sink, produces | |
170 | * the same result as | |
171 | * {@link #getChapterTitleBlock getChapterTitleBlock}( title ). | |
172 | * NewLines are ignored. | |
173 | */ | |
174 | public void testChapterTitle() | |
175 | { | |
176 | DocBookBookSink sink = (DocBookBookSink) getSink(); | |
177 | ||
178 | String title = "Title"; | |
179 | sink.chapterTitle(); | |
180 | sink.text( title ); | |
181 | sink.chapterTitle_(); | |
182 | sink.flush(); | |
183 | ||
184 | String actual = getSinkContent(); | |
185 | String expected = getChapterTitleBlock( title ); | |
186 | ||
187 | assertEquals( "Wrong chapterTitle!", expected, actual ); | |
188 | } | |
189 | ||
190 | /** | |
191 | * Checks that the sequence <code>[chapter(), chapter_()]</code>, | |
192 | * invoked on the current sink, produces the same result as | |
193 | * {@link #getChapterBlock getChapterBlock}(). | |
194 | * NewLines are ignored. | |
195 | */ | |
196 | public void testChapter() | |
197 | { | |
198 | DocBookBookSink sink = (DocBookBookSink) getSink(); | |
199 | ||
200 | sink.chapter(); | |
201 | sink.chapter_(); | |
202 | sink.flush(); | |
203 | ||
204 | String actual = getSinkContent(); | |
205 | String expected = getChapterBlock(); | |
206 | ||
207 | assertEquals( "Wrong chapter block!", expected, actual ); | |
208 | } | |
209 | ||
210 | /** | |
211 | * Returns a title block generated by this sink. | |
212 | * @param title The title to use. | |
213 | * @return The result of invoking a title block on the current sink. | |
214 | * @see #testBookTitle() | |
215 | */ | |
216 | protected String getBookTitleBlock( String title ) | |
217 | { | |
218 | return "<bookinfo><title>" + title + "</title>"; | |
219 | } | |
220 | ||
221 | /** | |
222 | * Returns an author block generated by this sink. | |
223 | * @param author The author to use. | |
224 | * @return The result of invoking an author block on the current sink. | |
225 | * @see #testBookAuthor() | |
226 | */ | |
227 | protected String getBookAuthorBlock( String author ) | |
228 | { | |
229 | return "<bookinfo><corpauthor>" + author + "</corpauthor>"; | |
230 | } | |
231 | ||
232 | /** | |
233 | * Returns a date block generated by this sink. | |
234 | * @param date The date to use. | |
235 | * @return The result of invoking a date block on the current sink. | |
236 | * @see #testBookDate() | |
237 | */ | |
238 | protected String getBookDateBlock( String date ) | |
239 | { | |
240 | return "<bookinfo><date>" + date + "</date>"; | |
241 | } | |
242 | ||
243 | /** | |
244 | * Returns a head block generated by this sink. | |
245 | * @return The result of invoking a head block on the current sink. | |
246 | * @see #testBookHead() | |
247 | */ | |
248 | protected String getBookHeadBlock() | |
249 | { | |
250 | return ""; | |
251 | } | |
252 | ||
253 | /** | |
254 | * Returns a body block generated by this sink. | |
255 | * @return The result of invoking a body block on the current sink. | |
256 | * @see #testBook() | |
257 | */ | |
258 | protected String getBookBlock() | |
259 | { | |
260 | return "<?xml version=\"1.0\"?><!DOCTYPE book PUBLIC \"" + DocBookSink.DEFAULT_XML_PUBLIC_ID | |
261 | + "\" \"" + DocBookSink.DEFAULT_XML_SYSTEM_ID + "\"><book></book>"; | |
262 | } | |
263 | ||
264 | /** | |
265 | * Returns a SectionTitle block generated by this sink. | |
266 | * @param title The title to use. | |
267 | * @return The result of invoking a SectionTitle block on the current sink. | |
268 | * @see #testChapterTitle() | |
269 | */ | |
270 | protected String getChapterTitleBlock( String title ) | |
271 | { | |
272 | return "<title>" + title + "</title>"; | |
273 | } | |
274 | ||
275 | /** | |
276 | * Returns a Section1 block generated by this sink. | |
277 | * @param title The title to use. | |
278 | * @return The result of invoking a Section1 block on the current sink. | |
279 | * @see #testChapter() | |
280 | */ | |
281 | protected String getChapterBlock() | |
282 | { | |
283 | return "<chapter></chapter>"; | |
284 | } | |
285 | ||
286 | ||
287 | // | |
288 | // from DocBookSink | |
289 | // | |
290 | ||
291 | ||
292 | /** {@inheritDoc} */ | |
293 | protected String getTitleBlock( String title ) | |
294 | { | |
295 | return ""; | |
296 | } | |
297 | ||
298 | /** {@inheritDoc} */ | |
299 | protected String getAuthorBlock( String author ) | |
300 | { | |
301 | return ""; | |
302 | } | |
303 | ||
304 | /** {@inheritDoc} */ | |
305 | protected String getDateBlock( String date ) | |
306 | { | |
307 | return "<date>" + date + "</date>"; | |
308 | } | |
309 | ||
310 | /** {@inheritDoc} */ | |
311 | protected String getHeadBlock() | |
312 | { | |
313 | return ""; | |
314 | } | |
315 | ||
316 | /** {@inheritDoc} */ | |
317 | protected String getBodyBlock() | |
318 | { | |
319 | return ""; | |
320 | } | |
321 | ||
322 | /** {@inheritDoc} */ | |
323 | protected String getSectionTitleBlock( String title ) | |
324 | { | |
325 | return "<title>" + title + "</title>"; | |
326 | } | |
327 | ||
328 | /** {@inheritDoc} */ | |
329 | protected String getSection1Block( String title ) | |
330 | { | |
331 | return "<section><title>" + title + "</title></section>"; | |
332 | } | |
333 | ||
334 | /** {@inheritDoc} */ | |
335 | protected String getSection2Block( String title ) | |
336 | { | |
337 | return "<section><title>" + title + "</title></section>"; | |
338 | } | |
339 | ||
340 | /** {@inheritDoc} */ | |
341 | protected String getSection3Block( String title ) | |
342 | { | |
343 | return "<section><title>" + title + "</title></section>"; | |
344 | } | |
345 | ||
346 | /** {@inheritDoc} */ | |
347 | protected String getSection4Block( String title ) | |
348 | { | |
349 | return "<section><title>" + title + "</title></section>"; | |
350 | } | |
351 | ||
352 | /** {@inheritDoc} */ | |
353 | protected String getSection5Block( String title ) | |
354 | { | |
355 | return "<section><title>" + title + "</title></section>"; | |
356 | } | |
357 | ||
358 | /** {@inheritDoc} */ | |
359 | protected String getListBlock( String item ) | |
360 | { | |
361 | return "<itemizedlist><listitem><para>" + item + "</para></listitem></itemizedlist>"; | |
362 | } | |
363 | ||
364 | /** {@inheritDoc} */ | |
365 | protected String getNumberedListBlock( String item ) | |
366 | { | |
367 | return "<orderedlist numeration=\"lowerroman\"><listitem><para>" | |
368 | + item + "</para></listitem></orderedlist>"; | |
369 | } | |
370 | ||
371 | /** {@inheritDoc} */ | |
372 | protected String getDefinitionListBlock( String definum, String definition ) | |
373 | { | |
374 | return "<variablelist><varlistentry><term>" + definum | |
375 | + "</term><listitem><para>" + definition | |
376 | + "</para></listitem></varlistentry></variablelist>"; | |
377 | } | |
378 | ||
379 | /** {@inheritDoc} */ | |
380 | protected String getFigureBlock( String source, String caption ) | |
381 | { | |
382 | String format = FileUtils.extension( source ).toUpperCase( Locale.ENGLISH ); | |
383 | ||
384 | return "<mediaobject><imageobject>" | |
385 | + "<imagedata fileref=\"" + source + "\" format=\"" + format + "\" />" | |
386 | + "</imageobject><caption><para>" + caption + "</para></caption></mediaobject>"; | |
387 | } | |
388 | ||
389 | /** {@inheritDoc} */ | |
390 | protected String getTableBlock( String cell, String caption ) | |
391 | { | |
392 | // Using the same set ordering than the JVM | |
393 | MutableAttributeSet att = new SimpleAttributeSet(); | |
394 | att.addAttribute( "frame", "none" ); | |
395 | att.addAttribute( "rowsep", "0" ); | |
396 | att.addAttribute( "colsep", "0" ); | |
397 | ||
398 | return "<table" + SinkUtils.getAttributeString( att ) + "><title>" + caption | |
399 | + "</title><tgroup cols=\"1\"><colspec align=\"center\" /><tbody><row><entry>" | |
400 | + cell + "</entry></row></tbody></tgroup></table>"; | |
401 | } | |
402 | ||
403 | /** {@inheritDoc} */ | |
404 | protected String getParagraphBlock( String text ) | |
405 | { | |
406 | return "<para>" + text + "</para>"; | |
407 | } | |
408 | ||
409 | /** {@inheritDoc} */ | |
410 | protected String getVerbatimBlock( String text ) | |
411 | { | |
412 | return "<programlisting>" + text + "</programlisting>"; | |
413 | } | |
414 | ||
415 | /** {@inheritDoc} */ | |
416 | protected String getHorizontalRuleBlock() | |
417 | { | |
418 | return "<!-- HR -->"; | |
419 | } | |
420 | ||
421 | /** {@inheritDoc} */ | |
422 | protected String getPageBreakBlock() | |
423 | { | |
424 | return "<!-- PB -->"; | |
425 | } | |
426 | ||
427 | /** {@inheritDoc} */ | |
428 | protected String getAnchorBlock( String anchor ) | |
429 | { | |
430 | return "<anchor id=\"" + anchor + "\" />" + anchor + "<!-- anchor_end -->"; | |
431 | } | |
432 | ||
433 | /** {@inheritDoc} */ | |
434 | protected String getLinkBlock( String link, String text ) | |
435 | { | |
436 | String linkend = DoxiaUtils.isInternalLink( link ) ? link.substring( 1 ) : link; | |
437 | return "<link linkend=\"" + linkend + "\">" + text + "</link>"; | |
438 | } | |
439 | ||
440 | /** {@inheritDoc} */ | |
441 | protected String getItalicBlock( String text ) | |
442 | { | |
443 | return "<emphasis>" + text + "</emphasis>"; | |
444 | } | |
445 | ||
446 | /** {@inheritDoc} */ | |
447 | protected String getBoldBlock( String text ) | |
448 | { | |
449 | return "<emphasis role=\"bold\">" + text + "</emphasis>"; | |
450 | } | |
451 | ||
452 | /** {@inheritDoc} */ | |
453 | protected String getMonospacedBlock( String text ) | |
454 | { | |
455 | return "<literal>" + text + "</literal>"; | |
456 | } | |
457 | ||
458 | /** {@inheritDoc} */ | |
459 | protected String getLineBreakBlock() | |
460 | { | |
461 | return "<!-- LB -->"; | |
462 | } | |
463 | ||
464 | /** {@inheritDoc} */ | |
465 | protected String getNonBreakingSpaceBlock() | |
466 | { | |
467 | return " "; | |
468 | } | |
469 | ||
470 | /** {@inheritDoc} */ | |
471 | protected String getTextBlock( String text ) | |
472 | { | |
473 | // TODO: retreive those from the sink | |
474 | return "~,_=,_-,_+,_*,_[,_],_<,_>,_{,_},_\\"; | |
475 | } | |
476 | ||
477 | /** {@inheritDoc} */ | |
478 | protected String getRawTextBlock( String text ) | |
479 | { | |
480 | // TODO | |
481 | return ""; | |
482 | } | |
483 | ||
484 | /** {@inheritDoc} */ | |
485 | protected String getCommentBlock( String text ) | |
486 | { | |
487 | return "<!-- Simple comment with - - - - -->"; | |
488 | } | |
489 | } |
0 | ----- | |
1 | Section 1 | |
2 | ----- | |
3 | Trygve | |
4 | ----- | |
5 | ||
6 | Subsection 1 | |
7 | ||
8 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec sagittis malesuada nisi. Aliquam orci eros, vestibulum | |
9 | eu, placerat et, pretium sed, nisi. Proin consequat. Praesent faucibus sem id arcu hendrerit nonummy. Aliquam blandit | |
10 | accumsan pede. Vivamus aliquet lacinia nunc. Praesent dapibus orci eu magna. Cras nonummy, pede nec facilisis semper, | |
11 | sem nibh vestibulum massa, sed ornare tortor elit non lectus. Nullam mauris turpis, luctus et, vulputate vitae, commodo | |
12 | sit amet, purus. Fusce erat. Proin ullamcorper imperdiet est. Morbi sit amet dui. Fusce bibendum auctor augue. Sed leo | |
13 | sapien, vehicula ac, nonummy id, cursus at, nulla. Ut sed purus. | |
14 | ||
15 | * Subsubsection 1 | |
16 | ||
17 | Suspendisse sagittis metus nec leo. Suspendisse velit. Phasellus ipsum dolor, porttitor ut1, varius id, scelerisque | |
18 | vel, ligula. Aliquam tempor sem in pede tincidunt nonummy. Vestibulum et nulla. Nunc et dolor a risus porttitor tem | |
19 | pus. Sed felis arcu, consectetuer non, imperdiet sollicitudin, ullamcorper vitae, nulla. Vestibulum ante ipsum primis | |
20 | in faucibus. | |
21 | ||
22 | Subsection 2 | |
23 | ||
24 | Duis eget libero aliquet quam ultrices malesuada. Donec molestie dignissim nunc. Curabitur turpis. Suspendisse a nibh | |
25 | ut elit vulputate ultrices. Etiam nulla erat, nonummy vel, fringilla at, scelerisque non, ante. Suspendisse adipiscing | |
26 | rhoncus purus. Nulla in augue. Ut ac nisi eu nisi cursus elementum. Pellentesque habitant morbi tristique senectus et | |
27 | netus et malesuada fames ac turpis egestas. Donec et turpis. Donec nec mi. Mauris malesuada congue sem. Maecenas et | |
28 | urna in nisi sagittis facilisis. Cras nibh. Aliquam purus. Donec convallis congue libero. Nulla feugiat. Nulla massa | |
29 | libero, consectetuer ac, aliquet ac, consequat eu, purus. Pellentesque eleifend pretium augue. | |
30 | ||
31 | Subsection 3 | |
32 | ||
33 | Integer auctor, nisi ut convallis imperdiet, ligula diam sollicitudin dolor, porttitor mattis urna sapien at velit. | |
34 | Fusce vestibulum, neque nec malesuada tempor, tortor nisi accumsan purus, quis faucibus metus elit ac urna. Aliquam | |
35 | commodo velit vel ipsum. Donec blandit diam blandit eros. Aliquam pretium fermentum neque. Sed nec tellus eu orci | |
36 | ullamcorper facilisis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. | |
37 | Nulla sed leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Fusce | |
38 | suscipit. Sed sit amet diam ac ante tincidunt ornare. Sed sodales vestibulum quam. Fusce accumsan. Ut ut mi. | |
39 | ||
40 | Subsection 4 | |
41 | ||
42 | Maecenas tincidunt lobortis nunc. Phasellus euismod diam sit amet felis. Donec lorem metus, vulputate vitae, ornare | |
43 | vel, molestie sit amet, pede. In erat velit, adipiscing sed, varius in, interdum cursus, enim. Quisque dolor ante, | |
44 | tincidunt vel, congue eget, consectetuer id, nunc. Suspendisse hendrerit. Proin egestas, massa eget egestas | |
45 | ullamcorper, nisl elit gravida magna, vitae dignissim odio velit ut tortor. Fusce lobortis consequat nulla. | |
46 | Vestibulum pretium justo at metus. Sed lorem velit, elementum eget, pellentesque ac, ornare id, mi. Pellentesque vel | |
47 | ligula et erat dictum commodo. Integer malesuada lacus nec metus. Aliquam id purus ac neque mattis venenatis. Aenean | |
48 | lobortis accumsan massa. Donec dui ante, facilisis vel, hendrerit ut, vehicula in, eros. Suspendisse potenti. Sed | |
49 | fringilla. Suspendisse vel nibh. Sed sit amet lacus quis massa tincidunt elementum. Ut ut augue vitae ligula dapibus | |
50 | aliquam. | |
51 | ||
52 | Subsection 5 | |
53 | ||
54 | Fusce non eros non lectus venenatis bibendum. Nullam pharetra. Nunc commodo pede et metus. Pellentesque habitant morbi | |
55 | tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum imperdiet nisl nec nulla. Morbi congue | |
56 | dictum pede. Aliquam ligula. In pede nulla, varius a, blandit ut, pulvinar vitae, mauris. Suspendisse sit amet magna. | |
57 | Curabitur cursus placerat justo. Vivamus imperdiet magna commodo mi. Vestibulum eget metus quis sem sollicitudin | |
58 | consectetuer. Morbi metus augue, elementum rutrum, luctus quis, porttitor a, est. Phasellus quis sapien et augue | |
59 | adipiscing fermentum. Sed fermentum tristique dui. Vivamus aliquam, tortor at ultricies commodo, urna ipsum fringilla | |
60 | neque, sit amet congue purus enim a justo. |
0 | ----- | |
1 | Section 2 | |
2 | ----- | |
3 | Trygve | |
4 | ----- | |
5 | ||
6 | Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC | |
7 | ||
8 | Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, | |
9 | eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam | |
10 | voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione | |
11 | voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci | |
12 | velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim | |
13 | ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi | |
14 | consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, | |
15 | vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? |
0 | ----- | |
1 | Section 3 | |
2 | ----- | |
3 | Trygve | |
4 | ----- | |
5 | ||
6 | 1914 translation by H. Rackham | |
7 | ||
8 | But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will | |
9 | give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the | |
10 | master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but | |
11 | because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. | |
12 | Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because | |
13 | occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial | |
14 | example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who | |
15 | has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who | |
16 | avoids a pain that produces no resultant pleasure? |
0 | ----- | |
1 | Section 4 | |
2 | ----- | |
3 | Trygve | |
4 | ----- | |
5 | ||
6 | Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC | |
7 | ||
8 | At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque | |
9 | corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa | |
10 | qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita | |
11 | distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime | |
12 | placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut | |
13 | officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. | |
14 | Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut | |
15 | perferendis doloribus asperiores repellat. |
0 | <!-- | |
1 | Licensed to the Apache Software Foundation (ASF) under one | |
2 | or more contributor license agreements. See the NOTICE file | |
3 | distributed with this work for additional information | |
4 | regarding copyright ownership. The ASF licenses this file | |
5 | to you under the Apache License, Version 2.0 (the | |
6 | "License"); you may not use this file except in compliance | |
7 | with the License. You may obtain a copy of the License at | |
8 | ||
9 | http://www.apache.org/licenses/LICENSE-2.0 | |
10 | ||
11 | Unless required by applicable law or agreed to in writing, | |
12 | software distributed under the License is distributed on an | |
13 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | KIND, either express or implied. See the License for the | |
15 | specific language governing permissions and limitations | |
16 | under the License. | |
17 | --> | |
18 | ||
19 | <book xmlns="http://maven.apache.org/BOOK/1.0.0" | |
20 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
21 | xsi:schemaLocation="http://maven.apache.org/BOOK/1.0.0 ../../../target/generated-site/xsd/book-1.0.0.xsd"> | |
22 | <id>plexus-user-guide</id> | |
23 | <title>Test Book</title> | |
24 | <chapters> | |
25 | <chapter> | |
26 | <id>chapter-1</id> | |
27 | <title>Chapter 1</title> | |
28 | <sections> | |
29 | <section> | |
30 | <id>section-1</id> | |
31 | </section> | |
32 | <section> | |
33 | <id>section-2</id> | |
34 | </section> | |
35 | </sections> | |
36 | </chapter> | |
37 | <chapter> | |
38 | <id>chapter-2</id> | |
39 | <title>Chapter 2</title> | |
40 | <sections> | |
41 | <section> | |
42 | <id>section-3</id> | |
43 | </section> | |
44 | <section> | |
45 | <id>section-4</id> | |
46 | </section> | |
47 | </sections> | |
48 | </chapter> | |
49 | </chapters> | |
50 | </book> |
0 | <?xml version="1.0"?><!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.4//EN" | |
1 | "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> | |
2 | <book><bookinfo><title>Test Book</title> | |
3 | </bookinfo> | |
4 | <chapter><title>Chapter 1</title> | |
5 | <section><title>Subsection 1</title> | |
6 | <para>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec sagittis | |
7 | malesuada nisi. Aliquam orci eros, vestibulum eu, placerat et, pretium sed, | |
8 | nisi. Proin consequat. Praesent faucibus sem id arcu hendrerit nonummy. | |
9 | Aliquam blandit accumsan pede. Vivamus aliquet lacinia nunc. Praesent dapibus | |
10 | orci eu magna. Cras nonummy, pede nec facilisis semper, sem nibh vestibulum | |
11 | massa, sed ornare tortor elit non lectus. Nullam mauris turpis, luctus et, | |
12 | vulputate vitae, commodo sit amet, purus. Fusce erat. Proin ullamcorper | |
13 | imperdiet est. Morbi sit amet dui. Fusce bibendum auctor augue. Sed leo | |
14 | sapien, vehicula ac, nonummy id, cursus at, nulla. Ut sed purus.</para> | |
15 | <section><title>Subsubsection 1</title> | |
16 | <para>Suspendisse sagittis metus nec leo. Suspendisse velit. Phasellus ipsum | |
17 | dolor, porttitor ut1, varius id, scelerisque vel, ligula. Aliquam tempor sem | |
18 | in pede tincidunt nonummy. Vestibulum et nulla. Nunc et dolor a risus | |
19 | porttitor tem pus. Sed felis arcu, consectetuer non, imperdiet sollicitudin, | |
20 | ullamcorper vitae, nulla. Vestibulum ante ipsum primis in faucibus.</para> | |
21 | </section> | |
22 | </section> | |
23 | <section><title>Subsection 2</title> | |
24 | <para>Duis eget libero aliquet quam ultrices malesuada. Donec molestie | |
25 | dignissim nunc. Curabitur turpis. Suspendisse a nibh ut elit vulputate | |
26 | ultrices. Etiam nulla erat, nonummy vel, fringilla at, scelerisque non, ante. | |
27 | Suspendisse adipiscing rhoncus purus. Nulla in augue. Ut ac nisi eu nisi | |
28 | cursus elementum. Pellentesque habitant morbi tristique senectus et netus et | |
29 | malesuada fames ac turpis egestas. Donec et turpis. Donec nec mi. Mauris | |
30 | malesuada congue sem. Maecenas et urna in nisi sagittis facilisis. Cras nibh. | |
31 | Aliquam purus. Donec convallis congue libero. Nulla feugiat. Nulla massa | |
32 | libero, consectetuer ac, aliquet ac, consequat eu, purus. Pellentesque | |
33 | eleifend pretium augue.</para> | |
34 | </section> | |
35 | <section><title>Subsection 3</title> | |
36 | <para>Integer auctor, nisi ut convallis imperdiet, ligula diam sollicitudin | |
37 | dolor, porttitor mattis urna sapien at velit. Fusce vestibulum, neque nec | |
38 | malesuada tempor, tortor nisi accumsan purus, quis faucibus metus elit ac | |
39 | urna. Aliquam commodo velit vel ipsum. Donec blandit diam blandit eros. | |
40 | Aliquam pretium fermentum neque. Sed nec tellus eu orci ullamcorper facilisis. | |
41 | Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac | |
42 | turpis egestas. Nulla sed leo. Class aptent taciti sociosqu ad litora torquent | |
43 | per conubia nostra, per inceptos hymenaeos. Fusce suscipit. Sed sit amet diam | |
44 | ac ante tincidunt ornare. Sed sodales vestibulum quam. Fusce accumsan. Ut ut | |
45 | mi.</para> | |
46 | </section> | |
47 | <section><title>Subsection 4</title> | |
48 | <para>Maecenas tincidunt lobortis nunc. Phasellus euismod diam sit amet felis. | |
49 | Donec lorem metus, vulputate vitae, ornare vel, molestie sit amet, pede. In | |
50 | erat velit, adipiscing sed, varius in, interdum cursus, enim. Quisque dolor | |
51 | ante, tincidunt vel, congue eget, consectetuer id, nunc. Suspendisse | |
52 | hendrerit. Proin egestas, massa eget egestas ullamcorper, nisl elit gravida | |
53 | magna, vitae dignissim odio velit ut tortor. Fusce lobortis consequat nulla. | |
54 | Vestibulum pretium justo at metus. Sed lorem velit, elementum eget, | |
55 | pellentesque ac, ornare id, mi. Pellentesque vel ligula et erat dictum | |
56 | commodo. Integer malesuada lacus nec metus. Aliquam id purus ac neque mattis | |
57 | venenatis. Aenean lobortis accumsan massa. Donec dui ante, facilisis vel, | |
58 | hendrerit ut, vehicula in, eros. Suspendisse potenti. Sed fringilla. | |
59 | Suspendisse vel nibh. Sed sit amet lacus quis massa tincidunt elementum. Ut ut | |
60 | augue vitae ligula dapibus aliquam.</para> | |
61 | </section> | |
62 | <section><title>Subsection 5</title> | |
63 | <para>Fusce non eros non lectus venenatis bibendum. Nullam pharetra. Nunc | |
64 | commodo pede et metus. Pellentesque habitant morbi tristique senectus et netus | |
65 | et malesuada fames ac turpis egestas. Vestibulum imperdiet nisl nec nulla. | |
66 | Morbi congue dictum pede. Aliquam ligula. In pede nulla, varius a, blandit ut, | |
67 | pulvinar vitae, mauris. Suspendisse sit amet magna. Curabitur cursus placerat | |
68 | justo. Vivamus imperdiet magna commodo mi. Vestibulum eget metus quis sem | |
69 | sollicitudin consectetuer. Morbi metus augue, elementum rutrum, luctus quis, | |
70 | porttitor a, est. Phasellus quis sapien et augue adipiscing fermentum. Sed | |
71 | fermentum tristique dui. Vivamus aliquam, tortor at ultricies commodo, urna | |
72 | ipsum fringilla neque, sit amet congue purus enim a justo.</para> | |
73 | </section> | |
74 | <section><title>Section 1.10.32 of "de Finibus Bonorum et Malorum", | |
75 | written by Cicero in 45 BC</title> | |
76 | <para>Sed ut perspiciatis unde omnis iste natus error sit voluptatem | |
77 | accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo | |
78 | inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. | |
79 | Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, | |
80 | sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. | |
81 | Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, | |
82 | adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et | |
83 | dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis | |
84 | nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex | |
85 | ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea | |
86 | voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem | |
87 | eum fugiat quo voluptas nulla pariatur?</para> | |
88 | </section> | |
89 | </chapter> | |
90 | <chapter><title>Chapter 2</title> | |
91 | <section><title>1914 translation by H. Rackham</title> | |
92 | <para>But I must explain to you how all this mistaken idea of denouncing | |
93 | pleasure and praising pain was born and I will give you a complete account of | |
94 | the system, and expound the actual teachings of the great explorer of the | |
95 | truth, the master-builder of human happiness. No one rejects, dislikes, or | |
96 | avoids pleasure itself, because it is pleasure, but because those who do not | |
97 | know how to pursue pleasure rationally encounter consequences that are | |
98 | extremely painful. Nor again is there anyone who loves or pursues or desires | |
99 | to obtain pain of itself, because it is pain, but because occasionally | |
100 | circumstances occur in which toil and pain can procure him some great | |
101 | pleasure. To take a trivial example, which of us ever undertakes laborious | |
102 | physical exercise, except to obtain some advantage from it? But who has any | |
103 | right to find fault with a man who chooses to enjoy a pleasure that has no | |
104 | annoying consequences, or one who avoids a pain that produces no resultant | |
105 | pleasure?</para> | |
106 | </section> | |
107 | <section><title>Section 1.10.33 of "de Finibus Bonorum et Malorum", | |
108 | written by Cicero in 45 BC</title> | |
109 | <para>At vero eos et accusamus et iusto odio dignissimos ducimus qui | |
110 | blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas | |
111 | molestias excepturi sint occaecati cupiditate non provident, similique sunt in | |
112 | culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et | |
113 | harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum | |
114 | soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime | |
115 | placeat facere possimus, omnis voluptas assumenda est, omnis dolor | |
116 | repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum | |
117 | necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae | |
118 | non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut | |
119 | reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus | |
120 | asperiores repellat.</para> | |
121 | </section> | |
122 | </chapter> | |
123 | </book> |
24 | 24 | <parent> |
25 | 25 | <groupId>org.apache.maven.doxia</groupId> |
26 | 26 | <artifactId>doxia</artifactId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 | |
64 | 64 | <groupId>org.apache.httpcomponents</groupId> |
65 | 65 | <artifactId>httpclient</artifactId> |
66 | 66 | <version>4.0.2</version> |
67 | </dependency> | |
68 | <dependency> | |
69 | <groupId>org.apache.httpcomponents</groupId> | |
70 | <artifactId>httpcore</artifactId> | |
71 | <version>4.0.1</version> | |
67 | 72 | </dependency> |
68 | 73 | |
69 | 74 | <!-- test --> |
29 | 29 | * |
30 | 30 | * @author <a href="mailto:steve.motola@gmail.com">Steve Motola</a> |
31 | 31 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
32 | * @version $Id: SwfMacro.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
32 | * @version $Id: SwfMacro.java 1151002 2011-07-26 07:17:54Z ltheussl $ | |
33 | 33 | */ |
34 | 34 | public class SwfMacro |
35 | 35 | extends AbstractMacro |
148 | 148 | .append( "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" ) |
149 | 149 | .append( version ).append( "\" width=\"" ).append( width ).append( "\" height=\"" ).append( height ) |
150 | 150 | .append( "\" id=\"" ).append( id ).append( "\">" ).append( EOL ); |
151 | content.append( "<param name=\"movie\" value=\"" ).append( src ).append( "\">" ).append( EOL ); | |
152 | content.append( "<param name=\"quality\" value=\"" ).append( quality ).append( "\">" ).append( EOL ); | |
153 | content.append( "<param name=\"menu\" value=\"" ).append( menu ).append( "\">" ).append( EOL ); | |
154 | content.append( "<param name=\"loop\" value=\"" ).append( loop ).append( "\">" ).append( EOL ); | |
155 | content.append( "<param name=\"play\" value=\"" ).append( play ).append( "\">" ).append( EOL ); | |
156 | content.append( "<param name=\"allowScriptAccess\" value=\"" ).append( allowScript ).append( "\">" ); | |
151 | content.append( "<param name=\"movie\" value=\"" ).append( src ).append( "\" />" ).append( EOL ); | |
152 | content.append( "<param name=\"quality\" value=\"" ).append( quality ).append( "\" />" ).append( EOL ); | |
153 | content.append( "<param name=\"menu\" value=\"" ).append( menu ).append( "\" />" ).append( EOL ); | |
154 | content.append( "<param name=\"loop\" value=\"" ).append( loop ).append( "\" />" ).append( EOL ); | |
155 | content.append( "<param name=\"play\" value=\"" ).append( play ).append( "\" />" ).append( EOL ); | |
156 | content.append( "<param name=\"allowScriptAccess\" value=\"" ) | |
157 | .append( allowScript ).append( "\" />" ).append( EOL ); | |
157 | 158 | content.append( "<embed src=\"" ).append( src ).append( "\" width=\"" ).append( width ).append( "\" height=\"" ) |
158 | 159 | .append( height ).append( "\" loop=\"" ).append( loop ).append( "\" play=\"" ).append( play ) |
159 | 160 | .append( "\" quality=\"" ).append( quality ).append( "\" allowScriptAccess=\"" ).append( allowScript ) |
31 | 31 | /** |
32 | 32 | * Utility class for reading snippets. |
33 | 33 | * |
34 | * @version $Id: SnippetReader.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
34 | * @version $Id: SnippetReader.java 1172204 2011-09-18 06:46:17Z hboutemy $ | |
35 | 35 | */ |
36 | 36 | public class SnippetReader |
37 | 37 | { |
178 | 178 | protected boolean isDemarcator( String snippetId, String what, String line ) |
179 | 179 | { |
180 | 180 | String upper = line.toUpperCase( Locale.ENGLISH ); |
181 | return upper.indexOf( what.toUpperCase( Locale.ENGLISH ) ) != -1 | |
182 | && upper.indexOf( "SNIPPET" ) != -1 | |
183 | && line.indexOf( snippetId ) != -1; | |
181 | return upper.contains( what.toUpperCase( Locale.ENGLISH ) ) | |
182 | && upper.contains( "SNIPPET" ) | |
183 | && line.contains( snippetId ); | |
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
31 | 31 | * @see <a href="http://www.w3.org/TR/html401/index/elements.html">http://www.w3.org/TR/html401/index/elements.html</a> |
32 | 32 | * |
33 | 33 | * @author ltheussl |
34 | * @version $Id: HtmlMarkup.java 779585 2009-05-28 12:43:33Z ltheussl $ | |
34 | * @version $Id: HtmlMarkup.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
35 | 35 | * @since 1.0 |
36 | 36 | */ |
37 | 37 | public interface HtmlMarkup |
72 | 72 | Tag ABBR = new Tag() |
73 | 73 | { |
74 | 74 | /** {@inheritDoc} */ |
75 | @Override | |
75 | 76 | public String toString() |
76 | 77 | { |
77 | 78 | return "abbr"; |
82 | 83 | Tag ACRONYM = new Tag() |
83 | 84 | { |
84 | 85 | /** {@inheritDoc} */ |
86 | @Override | |
85 | 87 | public String toString() |
86 | 88 | { |
87 | 89 | return "acronym"; |
110 | 112 | Tag BDO = new Tag() |
111 | 113 | { |
112 | 114 | /** {@inheritDoc} */ |
115 | @Override | |
113 | 116 | public String toString() |
114 | 117 | { |
115 | 118 | return "bdo"; |
132 | 135 | Tag BUTTON = new Tag() |
133 | 136 | { |
134 | 137 | /** {@inheritDoc} */ |
138 | @Override | |
135 | 139 | public String toString() |
136 | 140 | { |
137 | 141 | return "button"; |
154 | 158 | Tag COL = new Tag() |
155 | 159 | { |
156 | 160 | /** {@inheritDoc} */ |
161 | @Override | |
157 | 162 | public String toString() |
158 | 163 | { |
159 | 164 | return "col"; |
164 | 169 | Tag COLGROUP = new Tag() |
165 | 170 | { |
166 | 171 | /** {@inheritDoc} */ |
172 | @Override | |
167 | 173 | public String toString() |
168 | 174 | { |
169 | 175 | return "colgroup"; |
177 | 183 | Tag DEL = new Tag() |
178 | 184 | { |
179 | 185 | /** {@inheritDoc} */ |
186 | @Override | |
180 | 187 | public String toString() |
181 | 188 | { |
182 | 189 | return "del"; |
205 | 212 | Tag FIELDSET = new Tag() |
206 | 213 | { |
207 | 214 | /** {@inheritDoc} */ |
215 | @Override | |
208 | 216 | public String toString() |
209 | 217 | { |
210 | 218 | return "fieldset"; |
257 | 265 | Tag IFRAME = new Tag() |
258 | 266 | { |
259 | 267 | /** {@inheritDoc} */ |
268 | @Override | |
260 | 269 | public String toString() |
261 | 270 | { |
262 | 271 | return "iframe"; |
273 | 282 | Tag INS = new Tag() |
274 | 283 | { |
275 | 284 | /** {@inheritDoc} */ |
285 | @Override | |
276 | 286 | public String toString() |
277 | 287 | { |
278 | 288 | return "ins"; |
289 | 299 | Tag LABEL = new Tag() |
290 | 300 | { |
291 | 301 | /** {@inheritDoc} */ |
302 | @Override | |
292 | 303 | public String toString() |
293 | 304 | { |
294 | 305 | return "label"; |
299 | 310 | Tag LEGEND = new Tag() |
300 | 311 | { |
301 | 312 | /** {@inheritDoc} */ |
313 | @Override | |
302 | 314 | public String toString() |
303 | 315 | { |
304 | 316 | return "legend"; |
327 | 339 | Tag NOSCRIPT = new Tag() |
328 | 340 | { |
329 | 341 | /** {@inheritDoc} */ |
342 | @Override | |
330 | 343 | public String toString() |
331 | 344 | { |
332 | 345 | return "noscript"; |
343 | 356 | Tag OPTGROUP = new Tag() |
344 | 357 | { |
345 | 358 | /** {@inheritDoc} */ |
359 | @Override | |
346 | 360 | public String toString() |
347 | 361 | { |
348 | 362 | return "optgroup"; |
365 | 379 | Tag Q = new Tag() |
366 | 380 | { |
367 | 381 | /** {@inheritDoc} */ |
382 | @Override | |
368 | 383 | public String toString() |
369 | 384 | { |
370 | 385 | return "q"; |
411 | 426 | Tag TBODY = new Tag() |
412 | 427 | { |
413 | 428 | /** {@inheritDoc} */ |
429 | @Override | |
414 | 430 | public String toString() |
415 | 431 | { |
416 | 432 | return "tbody"; |
427 | 443 | Tag TFOOT = new Tag() |
428 | 444 | { |
429 | 445 | /** {@inheritDoc} */ |
446 | @Override | |
430 | 447 | public String toString() |
431 | 448 | { |
432 | 449 | return "tfoot"; |
440 | 457 | Tag THEAD = new Tag() |
441 | 458 | { |
442 | 459 | /** {@inheritDoc} */ |
460 | @Override | |
443 | 461 | public String toString() |
444 | 462 | { |
445 | 463 | return "thead"; |
24 | 24 | * An abstract class that defines some convenience methods for <code>Text</code> parsers. |
25 | 25 | * |
26 | 26 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
27 | * @version $Id: AbstractTextParser.java 638290 2008-03-18 09:45:22Z bentmann $ | |
27 | * @version $Id: AbstractTextParser.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
28 | 28 | * @since 1.0 |
29 | 29 | */ |
30 | 30 | public abstract class AbstractTextParser |
32 | 32 | implements TextMarkup |
33 | 33 | { |
34 | 34 | /** {@inheritDoc} */ |
35 | @Override | |
35 | 36 | public final int getType() |
36 | 37 | { |
37 | 38 | return TXT_TYPE; |
67 | 67 | * An abstract class that defines some convenience methods for <code>XML</code> parsers. |
68 | 68 | * |
69 | 69 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
70 | * @version $Id: AbstractXmlParser.java 1094965 2011-04-19 09:30:13Z ltheussl $ | |
70 | * @version $Id: AbstractXmlParser.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
71 | 71 | * @since 1.0 |
72 | 72 | */ |
73 | 73 | public abstract class AbstractXmlParser |
108 | 108 | { |
109 | 109 | init(); |
110 | 110 | |
111 | Reader src = source; | |
112 | ||
111 | 113 | // 1 first parsing if validation is required |
112 | 114 | if ( isValidate() ) |
113 | 115 | { |
114 | 116 | String content; |
115 | 117 | try |
116 | 118 | { |
117 | content = IOUtil.toString( new BufferedReader( source ) ); | |
119 | content = IOUtil.toString( new BufferedReader( src ) ); | |
118 | 120 | } |
119 | 121 | catch ( IOException e ) |
120 | 122 | { |
123 | 125 | |
124 | 126 | new XmlValidator( getLog() ).validate( content ); |
125 | 127 | |
126 | source = new StringReader( content ); | |
128 | src = new StringReader( content ); | |
127 | 129 | } |
128 | 130 | |
129 | 131 | // 2 second parsing to process |
131 | 133 | { |
132 | 134 | XmlPullParser parser = new MXParser(); |
133 | 135 | |
134 | parser.setInput( source ); | |
136 | parser.setInput( src ); | |
135 | 137 | |
136 | 138 | sink.enableLogging( getLog() ); |
137 | 139 | |
156 | 158 | * |
157 | 159 | * Convenience method to parse an arbitrary string and emit any xml events into the given sink. |
158 | 160 | */ |
161 | @Override | |
159 | 162 | public void parse( String string, Sink sink ) |
160 | 163 | throws ParseException |
161 | 164 | { |
163 | 166 | } |
164 | 167 | |
165 | 168 | /** {@inheritDoc} */ |
169 | @Override | |
166 | 170 | public final int getType() |
167 | 171 | { |
168 | 172 | return XML_TYPE; |
223 | 227 | |
224 | 228 | if ( isIgnorableWhitespace() ) |
225 | 229 | { |
226 | if ( !text.trim().equals( "" ) ) | |
230 | if ( text.trim().length() != 0 ) | |
227 | 231 | { |
228 | 232 | handleText( parser, sink ); |
229 | 233 | } |
508 | 512 | |
509 | 513 | if ( isCollapsibleWhitespace() ) |
510 | 514 | { |
511 | StringBuffer newText = new StringBuffer(); | |
515 | StringBuilder newText = new StringBuilder(); | |
512 | 516 | String[] elts = StringUtils.split( text, " \r\n" ); |
513 | 517 | for ( int i = 0; i < elts.length; i++ ) |
514 | 518 | { |
617 | 621 | if ( entitiesCount > 0 ) |
618 | 622 | { |
619 | 623 | // text should be foo [...] |
620 | int start = text.indexOf( "[" ); | |
621 | int end = text.lastIndexOf( "]" ); | |
624 | int start = text.indexOf( '['); | |
625 | int end = text.lastIndexOf( ']'); | |
622 | 626 | if ( start != -1 && end != -1 ) |
623 | 627 | { |
624 | text = text.substring( start + 1, end ); | |
625 | addDTDEntities( parser, text ); | |
628 | addDTDEntities( parser, text.substring( start + 1, end ) ); | |
626 | 629 | } |
627 | 630 | } |
628 | 631 | } |
648 | 651 | int entitiesCount = StringUtils.countMatches( text, ENTITY_START ); |
649 | 652 | if ( entitiesCount > 0 ) |
650 | 653 | { |
651 | text = StringUtils.replace( text, ENTITY_START, "\n" + ENTITY_START ); | |
652 | BufferedReader reader = new BufferedReader( new StringReader( text ) ); | |
654 | final String txt = StringUtils.replace( text, ENTITY_START, "\n" + ENTITY_START ); | |
655 | BufferedReader reader = new BufferedReader( new StringReader( txt ) ); | |
653 | 656 | String line; |
654 | 657 | String tmpLine = ""; |
655 | 658 | try |
42 | 42 | * |
43 | 43 | * @author <a href="mailto:jason@maven.org">Jason van Zyl</a> |
44 | 44 | * @author ltheussl |
45 | * @version $Id: XhtmlBaseParser.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
45 | * @version $Id: XhtmlBaseParser.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
46 | 46 | * @since 1.1 |
47 | 47 | */ |
48 | 48 | public class XhtmlBaseParser |
78 | 78 | private Map<String, Set<String>> warnMessages; |
79 | 79 | |
80 | 80 | /** {@inheritDoc} */ |
81 | @Override | |
81 | 82 | public void parse( Reader source, Sink sink ) |
82 | 83 | throws ParseException |
83 | 84 | { |
461 | 462 | } |
462 | 463 | |
463 | 464 | /** {@inheritDoc} */ |
465 | @Override | |
464 | 466 | protected void handleText( XmlPullParser parser, Sink sink ) |
465 | 467 | throws XmlPullParserException |
466 | 468 | { |
479 | 481 | } |
480 | 482 | |
481 | 483 | /** {@inheritDoc} */ |
484 | @Override | |
482 | 485 | protected void handleComment( XmlPullParser parser, Sink sink ) |
483 | 486 | throws XmlPullParserException |
484 | 487 | { |
495 | 498 | } |
496 | 499 | |
497 | 500 | /** {@inheritDoc} */ |
501 | @Override | |
498 | 502 | protected void handleCdsect( XmlPullParser parser, Sink sink ) |
499 | 503 | throws XmlPullParserException |
500 | 504 | { |
697 | 701 | } |
698 | 702 | |
699 | 703 | /** {@inheritDoc} */ |
704 | @Override | |
700 | 705 | protected void init() |
701 | 706 | { |
702 | 707 | super.init(); |
735 | 740 | |
736 | 741 | if ( href != null ) |
737 | 742 | { |
738 | int hashIndex = href.indexOf( "#" ); | |
743 | int hashIndex = href.indexOf( '#'); | |
739 | 744 | if ( hashIndex != -1 && !DoxiaUtils.isExternalLink( href ) ) |
740 | 745 | { |
741 | 746 | String hash = href.substring( hashIndex + 1 ); |
953 | 958 | */ |
954 | 959 | private void logMessage( String key, String msg ) |
955 | 960 | { |
956 | msg = "[XHTML Parser] " + msg; | |
961 | final String log = "[XHTML Parser] " + msg; | |
957 | 962 | if ( getLog().isDebugEnabled() ) |
958 | 963 | { |
959 | getLog().debug( msg ); | |
964 | getLog().debug( log ); | |
960 | 965 | |
961 | 966 | return; |
962 | 967 | } |
971 | 976 | { |
972 | 977 | set = new TreeSet<String>(); |
973 | 978 | } |
974 | set.add( msg ); | |
979 | set.add( log ); | |
975 | 980 | warnMessages.put( key, set ); |
976 | 981 | } |
977 | 982 |
27 | 27 | * |
28 | 28 | * @author ltheussl |
29 | 29 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
30 | * @version $Id: AbstractSink.java 1088993 2011-04-05 11:54:42Z ltheussl $ | |
30 | * @version $Id: AbstractSink.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
31 | 31 | * @since 1.1 |
32 | 32 | */ |
33 | 33 | public abstract class AbstractSink |
76 | 76 | |
77 | 77 | int length = text.length(); |
78 | 78 | |
79 | StringBuffer buffer = new StringBuffer( length ); | |
79 | StringBuilder buffer = new StringBuilder( length ); | |
80 | 80 | |
81 | 81 | for ( int i = 0; i < length; i++ ) |
82 | 82 | { |
27 | 27 | * An abstract <code>Sink</code> for xml markup syntax. |
28 | 28 | * |
29 | 29 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
30 | * @version $Id: AbstractXmlSink.java 762690 2009-04-07 11:11:22Z ltheussl $ | |
30 | * @version $Id: AbstractXmlSink.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | 33 | public abstract class AbstractXmlSink |
105 | 105 | throw new IllegalArgumentException( "A tag is required" ); |
106 | 106 | } |
107 | 107 | |
108 | StringBuffer sb = new StringBuffer(); | |
108 | StringBuilder sb = new StringBuilder(); | |
109 | 109 | sb.append( LESS_THAN ); |
110 | 110 | |
111 | 111 | if ( nameSpace != null ) |
149 | 149 | throw new IllegalArgumentException( "A tag is required" ); |
150 | 150 | } |
151 | 151 | |
152 | StringBuffer sb = new StringBuffer(); | |
152 | StringBuilder sb = new StringBuilder(); | |
153 | 153 | sb.append( LESS_THAN ); |
154 | 154 | sb.append( SLASH ); |
155 | 155 |
29 | 29 | * May be used to invoke the same method on a List of Sinks. |
30 | 30 | * |
31 | 31 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> |
32 | * @version $Id: PipelineSink.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
32 | * @version $Id: PipelineSink.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
33 | 33 | */ |
34 | 34 | public class PipelineSink |
35 | 35 | implements InvocationHandler |
84 | 84 | public static Sink newInstance( List<Sink> pipeline ) |
85 | 85 | { |
86 | 86 | return (Sink) Proxy.newProxyInstance( PipelineSink.class.getClassLoader(), |
87 | new Class[]{Sink.class}, | |
87 | new Class<?>[]{Sink.class}, | |
88 | 88 | new PipelineSink( pipeline ) ); |
89 | 89 | } |
90 | 90 | } |
0 | package org.apache.maven.doxia.sink; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.ByteArrayOutputStream; | |
22 | import java.io.File; | |
23 | import java.io.FileOutputStream; | |
24 | import java.io.IOException; | |
25 | import java.io.OutputStream; | |
26 | import java.util.ArrayList; | |
27 | import java.util.List; | |
28 | ||
29 | import org.apache.maven.doxia.logging.Log; | |
30 | ||
31 | /** | |
32 | * The RandomAccessSink provides the ability to create a {@link Sink} with hooks. | |
33 | * A page can be prepared by first creating its structure and specifying the positions of these hooks. | |
34 | * After specifying the structure, the page can be filled with content from one or more models. | |
35 | * These hooks can prevent you to have to loop over the model multiple times to build the page as desired. | |
36 | * | |
37 | * @author Robert Scholte | |
38 | * @since 1.3 | |
39 | */ | |
40 | public class RandomAccessSink | |
41 | implements Sink | |
42 | { | |
43 | private SinkFactory sinkFactory; | |
44 | ||
45 | private String encoding; | |
46 | ||
47 | private OutputStream coreOutputStream; | |
48 | ||
49 | private Sink coreSink; | |
50 | ||
51 | private List<Sink> sinks = new ArrayList<Sink>(); | |
52 | ||
53 | private List<ByteArrayOutputStream> outputStreams = new ArrayList<ByteArrayOutputStream>(); | |
54 | ||
55 | private Sink currentSink; | |
56 | ||
57 | public RandomAccessSink( SinkFactory sinkFactory, OutputStream stream ) | |
58 | throws IOException | |
59 | { | |
60 | this.sinkFactory = sinkFactory; | |
61 | this.coreOutputStream = stream; | |
62 | this.coreSink = this.currentSink = sinkFactory.createSink( stream ); | |
63 | } | |
64 | ||
65 | public RandomAccessSink( SinkFactory sinkFactory, OutputStream stream, String encoding ) | |
66 | throws IOException | |
67 | { | |
68 | this.sinkFactory = sinkFactory; | |
69 | this.coreOutputStream = stream; | |
70 | this.encoding = encoding; | |
71 | this.coreSink = this.currentSink = sinkFactory.createSink( stream, encoding ); | |
72 | } | |
73 | ||
74 | public RandomAccessSink( SinkFactory sinkFactory, File outputDirectory, String outputName ) | |
75 | throws IOException | |
76 | { | |
77 | this.sinkFactory = sinkFactory; | |
78 | this.coreOutputStream = new FileOutputStream( new File( outputDirectory, outputName ) ); | |
79 | this.coreSink = this.currentSink = sinkFactory.createSink( coreOutputStream ); | |
80 | } | |
81 | ||
82 | public RandomAccessSink( SinkFactory sinkFactory, File outputDirectory, String outputName, String encoding ) | |
83 | throws IOException | |
84 | { | |
85 | this.sinkFactory = sinkFactory; | |
86 | this.coreOutputStream = new FileOutputStream( new File( outputDirectory, outputName ) ); | |
87 | this.encoding = encoding; | |
88 | this.coreSink = this.currentSink = sinkFactory.createSink( coreOutputStream, encoding ); | |
89 | } | |
90 | ||
91 | /** | |
92 | * By calling this method a sink reference is added at the current position. You can write to both the new sink | |
93 | * reference and the original sink. After flushing all sinks will be flushed in the right order. | |
94 | * | |
95 | * @return a subsink reference you can write to | |
96 | */ | |
97 | public Sink addSinkHook() | |
98 | { | |
99 | Sink subSink = null; | |
100 | try | |
101 | { | |
102 | ByteArrayOutputStream subOut = new ByteArrayOutputStream(); | |
103 | ByteArrayOutputStream newOut = new ByteArrayOutputStream(); | |
104 | ||
105 | outputStreams.add( subOut ); | |
106 | outputStreams.add( newOut ); | |
107 | ||
108 | if ( encoding != null ) | |
109 | { | |
110 | subSink = sinkFactory.createSink( subOut, encoding ); | |
111 | currentSink = sinkFactory.createSink( newOut, encoding ); | |
112 | } | |
113 | else | |
114 | { | |
115 | subSink = sinkFactory.createSink( subOut ); | |
116 | currentSink = sinkFactory.createSink( newOut ); | |
117 | } | |
118 | sinks.add( subSink ); | |
119 | sinks.add( currentSink ); | |
120 | } | |
121 | catch ( IOException e ) | |
122 | { | |
123 | // IOException can only be caused by our own ByteArrayOutputStream | |
124 | } | |
125 | return subSink; | |
126 | } | |
127 | ||
128 | /** {@inheritDoc} */ | |
129 | public void anchor( String name ) | |
130 | { | |
131 | currentSink.anchor( name ); | |
132 | } | |
133 | ||
134 | /** {@inheritDoc} */ | |
135 | public void anchor( String name, SinkEventAttributes attributes ) | |
136 | { | |
137 | currentSink.anchor( name, attributes ); | |
138 | } | |
139 | ||
140 | /** {@inheritDoc} */ | |
141 | public void anchor_() | |
142 | { | |
143 | currentSink.anchor_(); | |
144 | } | |
145 | ||
146 | /** {@inheritDoc} */ | |
147 | public void author() | |
148 | { | |
149 | currentSink.author(); | |
150 | } | |
151 | ||
152 | /** {@inheritDoc} */ | |
153 | public void author( SinkEventAttributes attributes ) | |
154 | { | |
155 | currentSink.author( attributes ); | |
156 | } | |
157 | ||
158 | /** {@inheritDoc} */ | |
159 | public void author_() | |
160 | { | |
161 | currentSink.author_(); | |
162 | } | |
163 | ||
164 | /** {@inheritDoc} */ | |
165 | public void body() | |
166 | { | |
167 | currentSink.body(); | |
168 | } | |
169 | ||
170 | /** {@inheritDoc} */ | |
171 | public void body( SinkEventAttributes attributes ) | |
172 | { | |
173 | currentSink.body( attributes ); | |
174 | } | |
175 | ||
176 | /** {@inheritDoc} */ | |
177 | public void body_() | |
178 | { | |
179 | currentSink.body_(); | |
180 | } | |
181 | ||
182 | /** {@inheritDoc} */ | |
183 | public void bold() | |
184 | { | |
185 | currentSink.bold(); | |
186 | } | |
187 | ||
188 | /** {@inheritDoc} */ | |
189 | public void bold_() | |
190 | { | |
191 | currentSink.bold_(); | |
192 | } | |
193 | ||
194 | /** | |
195 | * Close all sinks | |
196 | */ | |
197 | public void close() | |
198 | { | |
199 | for ( Sink sink : sinks ) | |
200 | { | |
201 | // sink is responsible for closing it's stream | |
202 | sink.close(); | |
203 | } | |
204 | coreSink.close(); | |
205 | } | |
206 | ||
207 | /** {@inheritDoc} */ | |
208 | public void comment( String comment ) | |
209 | { | |
210 | currentSink.comment( comment ); | |
211 | } | |
212 | ||
213 | /** {@inheritDoc} */ | |
214 | public void date() | |
215 | { | |
216 | currentSink.date(); | |
217 | } | |
218 | ||
219 | /** {@inheritDoc} */ | |
220 | public void date( SinkEventAttributes attributes ) | |
221 | { | |
222 | currentSink.date( attributes ); | |
223 | } | |
224 | ||
225 | /** {@inheritDoc} */ | |
226 | public void date_() | |
227 | { | |
228 | currentSink.date_(); | |
229 | } | |
230 | ||
231 | /** {@inheritDoc} */ | |
232 | public void definedTerm() | |
233 | { | |
234 | currentSink.definedTerm(); | |
235 | } | |
236 | ||
237 | /** {@inheritDoc} */ | |
238 | public void definedTerm( SinkEventAttributes attributes ) | |
239 | { | |
240 | currentSink.definedTerm( attributes ); | |
241 | } | |
242 | ||
243 | /** {@inheritDoc} */ | |
244 | public void definedTerm_() | |
245 | { | |
246 | currentSink.definedTerm_(); | |
247 | } | |
248 | ||
249 | /** {@inheritDoc} */ | |
250 | public void definition() | |
251 | { | |
252 | currentSink.definition(); | |
253 | } | |
254 | ||
255 | /** {@inheritDoc} */ | |
256 | public void definition( SinkEventAttributes attributes ) | |
257 | { | |
258 | currentSink.definition( attributes ); | |
259 | } | |
260 | ||
261 | /** {@inheritDoc} */ | |
262 | public void definitionList() | |
263 | { | |
264 | currentSink.definitionList(); | |
265 | } | |
266 | ||
267 | /** {@inheritDoc} */ | |
268 | public void definitionList( SinkEventAttributes attributes ) | |
269 | { | |
270 | currentSink.definitionList( attributes ); | |
271 | } | |
272 | ||
273 | /** {@inheritDoc} */ | |
274 | public void definitionListItem() | |
275 | { | |
276 | currentSink.definitionListItem(); | |
277 | } | |
278 | ||
279 | /** {@inheritDoc} */ | |
280 | public void definitionListItem( SinkEventAttributes attributes ) | |
281 | { | |
282 | currentSink.definitionListItem( attributes ); | |
283 | } | |
284 | ||
285 | /** {@inheritDoc} */ | |
286 | public void definitionListItem_() | |
287 | { | |
288 | currentSink.definitionListItem_(); | |
289 | } | |
290 | ||
291 | /** {@inheritDoc} */ | |
292 | public void definitionList_() | |
293 | { | |
294 | currentSink.definitionList_(); | |
295 | } | |
296 | ||
297 | /** {@inheritDoc} */ | |
298 | public void definition_() | |
299 | { | |
300 | currentSink.definition_(); | |
301 | } | |
302 | ||
303 | /** {@inheritDoc} */ | |
304 | public void figure() | |
305 | { | |
306 | currentSink.figure(); | |
307 | } | |
308 | ||
309 | /** {@inheritDoc} */ | |
310 | public void figure( SinkEventAttributes attributes ) | |
311 | { | |
312 | currentSink.figure( attributes ); | |
313 | } | |
314 | ||
315 | /** {@inheritDoc} */ | |
316 | public void figureCaption() | |
317 | { | |
318 | currentSink.figureCaption(); | |
319 | } | |
320 | ||
321 | /** {@inheritDoc} */ | |
322 | public void figureCaption( SinkEventAttributes attributes ) | |
323 | { | |
324 | currentSink.figureCaption( attributes ); | |
325 | } | |
326 | ||
327 | /** {@inheritDoc} */ | |
328 | public void figureCaption_() | |
329 | { | |
330 | currentSink.figureCaption_(); | |
331 | } | |
332 | ||
333 | /** {@inheritDoc} */ | |
334 | public void figureGraphics( String name ) | |
335 | { | |
336 | currentSink.figureGraphics( name ); | |
337 | } | |
338 | ||
339 | /** {@inheritDoc} */ | |
340 | public void figureGraphics( String src, SinkEventAttributes attributes ) | |
341 | { | |
342 | currentSink.figureGraphics( src, attributes ); | |
343 | } | |
344 | ||
345 | /** {@inheritDoc} */ | |
346 | public void figure_() | |
347 | { | |
348 | currentSink.figure_(); | |
349 | } | |
350 | ||
351 | /** | |
352 | * Flush all sinks | |
353 | */ | |
354 | public void flush() | |
355 | { | |
356 | for ( int i = 0; i < sinks.size(); i++ ) | |
357 | { | |
358 | // first flush to get complete buffer | |
359 | // sink is responsible for flushing it's stream | |
360 | Sink sink = sinks.get( i ); | |
361 | sink.flush(); | |
362 | ||
363 | ByteArrayOutputStream stream = outputStreams.get( i ); | |
364 | try | |
365 | { | |
366 | coreOutputStream.write( stream.toByteArray() ); | |
367 | } | |
368 | catch ( IOException e ) | |
369 | { | |
370 | // @todo | |
371 | } | |
372 | } | |
373 | coreSink.flush(); | |
374 | } | |
375 | ||
376 | /** {@inheritDoc} */ | |
377 | public void head() | |
378 | { | |
379 | currentSink.head(); | |
380 | } | |
381 | ||
382 | /** {@inheritDoc} */ | |
383 | public void head( SinkEventAttributes attributes ) | |
384 | { | |
385 | currentSink.head( attributes ); | |
386 | } | |
387 | ||
388 | /** {@inheritDoc} */ | |
389 | public void head_() | |
390 | { | |
391 | currentSink.head_(); | |
392 | } | |
393 | ||
394 | /** {@inheritDoc} */ | |
395 | public void horizontalRule() | |
396 | { | |
397 | currentSink.horizontalRule(); | |
398 | } | |
399 | ||
400 | /** {@inheritDoc} */ | |
401 | public void horizontalRule( SinkEventAttributes attributes ) | |
402 | { | |
403 | currentSink.horizontalRule( attributes ); | |
404 | } | |
405 | ||
406 | /** {@inheritDoc} */ | |
407 | public void italic() | |
408 | { | |
409 | currentSink.italic(); | |
410 | } | |
411 | ||
412 | /** {@inheritDoc} */ | |
413 | public void italic_() | |
414 | { | |
415 | currentSink.italic_(); | |
416 | } | |
417 | ||
418 | /** {@inheritDoc} */ | |
419 | public void lineBreak() | |
420 | { | |
421 | currentSink.lineBreak(); | |
422 | } | |
423 | ||
424 | /** {@inheritDoc} */ | |
425 | public void lineBreak( SinkEventAttributes attributes ) | |
426 | { | |
427 | currentSink.lineBreak( attributes ); | |
428 | } | |
429 | ||
430 | /** {@inheritDoc} */ | |
431 | public void link( String name ) | |
432 | { | |
433 | currentSink.link( name ); | |
434 | } | |
435 | ||
436 | /** {@inheritDoc} */ | |
437 | public void link( String name, SinkEventAttributes attributes ) | |
438 | { | |
439 | currentSink.link( name, attributes ); | |
440 | } | |
441 | ||
442 | /** {@inheritDoc} */ | |
443 | public void link_() | |
444 | { | |
445 | currentSink.link_(); | |
446 | } | |
447 | ||
448 | /** {@inheritDoc} */ | |
449 | public void list() | |
450 | { | |
451 | currentSink.list(); | |
452 | } | |
453 | ||
454 | /** {@inheritDoc} */ | |
455 | public void list( SinkEventAttributes attributes ) | |
456 | { | |
457 | currentSink.list( attributes ); | |
458 | } | |
459 | ||
460 | /** {@inheritDoc} */ | |
461 | public void listItem() | |
462 | { | |
463 | currentSink.listItem(); | |
464 | } | |
465 | ||
466 | /** {@inheritDoc} */ | |
467 | public void listItem( SinkEventAttributes attributes ) | |
468 | { | |
469 | currentSink.listItem( attributes ); | |
470 | } | |
471 | ||
472 | /** {@inheritDoc} */ | |
473 | public void listItem_() | |
474 | { | |
475 | currentSink.listItem_(); | |
476 | } | |
477 | ||
478 | /** {@inheritDoc} */ | |
479 | public void list_() | |
480 | { | |
481 | currentSink.list_(); | |
482 | } | |
483 | ||
484 | /** {@inheritDoc} */ | |
485 | public void monospaced() | |
486 | { | |
487 | currentSink.monospaced(); | |
488 | } | |
489 | ||
490 | /** {@inheritDoc} */ | |
491 | public void monospaced_() | |
492 | { | |
493 | currentSink.monospaced_(); | |
494 | } | |
495 | ||
496 | /** {@inheritDoc} */ | |
497 | public void nonBreakingSpace() | |
498 | { | |
499 | currentSink.nonBreakingSpace(); | |
500 | } | |
501 | ||
502 | /** {@inheritDoc} */ | |
503 | public void numberedList( int numbering ) | |
504 | { | |
505 | currentSink.numberedList( numbering ); | |
506 | } | |
507 | ||
508 | /** {@inheritDoc} */ | |
509 | public void numberedList( int numbering, SinkEventAttributes attributes ) | |
510 | { | |
511 | currentSink.numberedList( numbering, attributes ); | |
512 | } | |
513 | ||
514 | /** {@inheritDoc} */ | |
515 | public void numberedListItem() | |
516 | { | |
517 | currentSink.numberedListItem(); | |
518 | } | |
519 | ||
520 | /** {@inheritDoc} */ | |
521 | public void numberedListItem( SinkEventAttributes attributes ) | |
522 | { | |
523 | currentSink.numberedListItem( attributes ); | |
524 | } | |
525 | ||
526 | /** {@inheritDoc} */ | |
527 | public void numberedListItem_() | |
528 | { | |
529 | currentSink.numberedListItem_(); | |
530 | } | |
531 | ||
532 | /** {@inheritDoc} */ | |
533 | public void numberedList_() | |
534 | { | |
535 | currentSink.numberedList_(); | |
536 | } | |
537 | ||
538 | /** {@inheritDoc} */ | |
539 | public void pageBreak() | |
540 | { | |
541 | currentSink.pageBreak(); | |
542 | } | |
543 | ||
544 | /** {@inheritDoc} */ | |
545 | public void paragraph() | |
546 | { | |
547 | currentSink.paragraph(); | |
548 | } | |
549 | ||
550 | /** {@inheritDoc} */ | |
551 | public void paragraph( SinkEventAttributes attributes ) | |
552 | { | |
553 | currentSink.paragraph( attributes ); | |
554 | } | |
555 | ||
556 | /** {@inheritDoc} */ | |
557 | public void paragraph_() | |
558 | { | |
559 | currentSink.paragraph_(); | |
560 | } | |
561 | ||
562 | /** {@inheritDoc} */ | |
563 | public void rawText( String text ) | |
564 | { | |
565 | currentSink.rawText( text ); | |
566 | } | |
567 | ||
568 | /** {@inheritDoc} */ | |
569 | public void section( int level, SinkEventAttributes attributes ) | |
570 | { | |
571 | currentSink.section( level, attributes ); | |
572 | } | |
573 | ||
574 | /** {@inheritDoc} */ | |
575 | public void section1() | |
576 | { | |
577 | currentSink.section1(); | |
578 | } | |
579 | ||
580 | /** {@inheritDoc} */ | |
581 | public void section1_() | |
582 | { | |
583 | currentSink.section1_(); | |
584 | } | |
585 | ||
586 | /** {@inheritDoc} */ | |
587 | public void section2() | |
588 | { | |
589 | currentSink.section2(); | |
590 | } | |
591 | ||
592 | /** {@inheritDoc} */ | |
593 | public void section2_() | |
594 | { | |
595 | currentSink.section2_(); | |
596 | } | |
597 | ||
598 | /** {@inheritDoc} */ | |
599 | public void section3() | |
600 | { | |
601 | currentSink.section3(); | |
602 | } | |
603 | ||
604 | /** {@inheritDoc} */ | |
605 | public void section3_() | |
606 | { | |
607 | currentSink.section3_(); | |
608 | } | |
609 | ||
610 | /** {@inheritDoc} */ | |
611 | public void section4() | |
612 | { | |
613 | currentSink.section4(); | |
614 | } | |
615 | ||
616 | /** {@inheritDoc} */ | |
617 | public void section4_() | |
618 | { | |
619 | currentSink.section4_(); | |
620 | } | |
621 | ||
622 | /** {@inheritDoc} */ | |
623 | public void section5() | |
624 | { | |
625 | currentSink.section5(); | |
626 | } | |
627 | ||
628 | /** {@inheritDoc} */ | |
629 | public void section5_() | |
630 | { | |
631 | currentSink.section5_(); | |
632 | } | |
633 | ||
634 | /** {@inheritDoc} */ | |
635 | public void sectionTitle() | |
636 | { | |
637 | currentSink.sectionTitle(); | |
638 | } | |
639 | ||
640 | /** {@inheritDoc} */ | |
641 | public void sectionTitle( int level, SinkEventAttributes attributes ) | |
642 | { | |
643 | currentSink.sectionTitle( level, attributes ); | |
644 | } | |
645 | ||
646 | /** {@inheritDoc} */ | |
647 | public void sectionTitle1() | |
648 | { | |
649 | currentSink.sectionTitle1(); | |
650 | } | |
651 | ||
652 | /** {@inheritDoc} */ | |
653 | public void sectionTitle1_() | |
654 | { | |
655 | currentSink.sectionTitle1_(); | |
656 | } | |
657 | ||
658 | /** {@inheritDoc} */ | |
659 | public void sectionTitle2() | |
660 | { | |
661 | currentSink.sectionTitle2(); | |
662 | } | |
663 | ||
664 | /** {@inheritDoc} */ | |
665 | public void sectionTitle2_() | |
666 | { | |
667 | currentSink.sectionTitle2_(); | |
668 | } | |
669 | ||
670 | /** {@inheritDoc} */ | |
671 | public void sectionTitle3() | |
672 | { | |
673 | currentSink.sectionTitle3(); | |
674 | } | |
675 | ||
676 | /** {@inheritDoc} */ | |
677 | public void sectionTitle3_() | |
678 | { | |
679 | currentSink.sectionTitle3_(); | |
680 | } | |
681 | ||
682 | /** {@inheritDoc} */ | |
683 | public void sectionTitle4() | |
684 | { | |
685 | currentSink.sectionTitle4(); | |
686 | } | |
687 | ||
688 | /** {@inheritDoc} */ | |
689 | public void sectionTitle4_() | |
690 | { | |
691 | currentSink.sectionTitle4_(); | |
692 | } | |
693 | ||
694 | /** {@inheritDoc} */ | |
695 | public void sectionTitle5() | |
696 | { | |
697 | currentSink.sectionTitle5(); | |
698 | } | |
699 | ||
700 | /** {@inheritDoc} */ | |
701 | public void sectionTitle5_() | |
702 | { | |
703 | currentSink.sectionTitle5_(); | |
704 | } | |
705 | ||
706 | /** {@inheritDoc} */ | |
707 | public void sectionTitle_() | |
708 | { | |
709 | currentSink.sectionTitle_(); | |
710 | } | |
711 | ||
712 | /** {@inheritDoc} */ | |
713 | public void sectionTitle_( int level ) | |
714 | { | |
715 | currentSink.sectionTitle_( level ); | |
716 | } | |
717 | ||
718 | /** {@inheritDoc} */ | |
719 | public void section_( int level ) | |
720 | { | |
721 | currentSink.section_( level ); | |
722 | } | |
723 | ||
724 | /** {@inheritDoc} */ | |
725 | public void table() | |
726 | { | |
727 | currentSink.table(); | |
728 | } | |
729 | ||
730 | /** {@inheritDoc} */ | |
731 | public void table( SinkEventAttributes attributes ) | |
732 | { | |
733 | currentSink.table( attributes ); | |
734 | } | |
735 | ||
736 | /** {@inheritDoc} */ | |
737 | public void tableCaption() | |
738 | { | |
739 | currentSink.tableCaption(); | |
740 | } | |
741 | ||
742 | /** {@inheritDoc} */ | |
743 | public void tableCaption( SinkEventAttributes attributes ) | |
744 | { | |
745 | currentSink.tableCaption( attributes ); | |
746 | } | |
747 | ||
748 | /** {@inheritDoc} */ | |
749 | public void tableCaption_() | |
750 | { | |
751 | currentSink.tableCaption_(); | |
752 | } | |
753 | ||
754 | /** {@inheritDoc} */ | |
755 | public void tableCell() | |
756 | { | |
757 | currentSink.tableCell(); | |
758 | } | |
759 | ||
760 | /** {@inheritDoc} */ | |
761 | public void tableCell( String width ) | |
762 | { | |
763 | currentSink.tableCell( width ); | |
764 | } | |
765 | ||
766 | /** {@inheritDoc} */ | |
767 | public void tableCell( SinkEventAttributes attributes ) | |
768 | { | |
769 | currentSink.tableCell( attributes ); | |
770 | } | |
771 | ||
772 | /** {@inheritDoc} */ | |
773 | public void tableCell_() | |
774 | { | |
775 | currentSink.tableCell_(); | |
776 | } | |
777 | ||
778 | /** {@inheritDoc} */ | |
779 | public void tableHeaderCell() | |
780 | { | |
781 | currentSink.tableHeaderCell(); | |
782 | } | |
783 | ||
784 | /** {@inheritDoc} */ | |
785 | public void tableHeaderCell( String width ) | |
786 | { | |
787 | currentSink.tableHeaderCell( width ); | |
788 | } | |
789 | ||
790 | /** {@inheritDoc} */ | |
791 | public void tableHeaderCell( SinkEventAttributes attributes ) | |
792 | { | |
793 | currentSink.tableHeaderCell( attributes ); | |
794 | } | |
795 | ||
796 | /** {@inheritDoc} */ | |
797 | public void tableHeaderCell_() | |
798 | { | |
799 | currentSink.tableHeaderCell_(); | |
800 | } | |
801 | ||
802 | /** {@inheritDoc} */ | |
803 | public void tableRow() | |
804 | { | |
805 | currentSink.tableRow(); | |
806 | } | |
807 | ||
808 | /** {@inheritDoc} */ | |
809 | public void tableRow( SinkEventAttributes attributes ) | |
810 | { | |
811 | currentSink.tableRow( attributes ); | |
812 | } | |
813 | ||
814 | /** {@inheritDoc} */ | |
815 | public void tableRow_() | |
816 | { | |
817 | currentSink.tableRow_(); | |
818 | } | |
819 | ||
820 | /** {@inheritDoc} */ | |
821 | public void tableRows( int[] justification, boolean grid ) | |
822 | { | |
823 | currentSink.tableRows( justification, grid ); | |
824 | } | |
825 | ||
826 | /** {@inheritDoc} */ | |
827 | public void tableRows_() | |
828 | { | |
829 | currentSink.tableRows_(); | |
830 | } | |
831 | ||
832 | /** {@inheritDoc} */ | |
833 | public void table_() | |
834 | { | |
835 | currentSink.table_(); | |
836 | } | |
837 | ||
838 | /** {@inheritDoc} */ | |
839 | public void text( String text ) | |
840 | { | |
841 | currentSink.text( text ); | |
842 | } | |
843 | ||
844 | /** {@inheritDoc} */ | |
845 | public void text( String text, SinkEventAttributes attributes ) | |
846 | { | |
847 | currentSink.text( text, attributes ); | |
848 | } | |
849 | ||
850 | /** {@inheritDoc} */ | |
851 | public void title() | |
852 | { | |
853 | currentSink.title(); | |
854 | } | |
855 | ||
856 | /** {@inheritDoc} */ | |
857 | public void title( SinkEventAttributes attributes ) | |
858 | { | |
859 | currentSink.title( attributes ); | |
860 | } | |
861 | ||
862 | /** {@inheritDoc} */ | |
863 | public void title_() | |
864 | { | |
865 | currentSink.title_(); | |
866 | } | |
867 | ||
868 | /** {@inheritDoc} */ | |
869 | public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes ) | |
870 | { | |
871 | currentSink.unknown( name, requiredParams, attributes ); | |
872 | } | |
873 | ||
874 | /** {@inheritDoc} */ | |
875 | public void verbatim( boolean boxed ) | |
876 | { | |
877 | currentSink.verbatim( boxed ); | |
878 | } | |
879 | ||
880 | /** {@inheritDoc} */ | |
881 | public void verbatim( SinkEventAttributes attributes ) | |
882 | { | |
883 | currentSink.verbatim( attributes ); | |
884 | } | |
885 | ||
886 | /** {@inheritDoc} */ | |
887 | public void verbatim_() | |
888 | { | |
889 | currentSink.verbatim_(); | |
890 | } | |
891 | ||
892 | /** {@inheritDoc} */ | |
893 | public void enableLogging( Log log ) | |
894 | { | |
895 | currentSink.enableLogging( log ); | |
896 | } | |
897 | }⏎ |
29 | 29 | * Implementation of MutableAttributeSet using a LinkedHashMap. |
30 | 30 | * |
31 | 31 | * @author ltheussl |
32 | * @version $Id: SinkEventAttributeSet.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
32 | * @version $Id: SinkEventAttributeSet.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
33 | 33 | * @since 1.1 |
34 | 34 | */ |
35 | 35 | public class SinkEventAttributeSet |
148 | 148 | |
149 | 149 | attribs = new LinkedHashMap<String, Object>( n / 2 ); |
150 | 150 | |
151 | for ( int i = 0; i < n; i = i + 2 ) | |
151 | for ( int i = 0; i < n; i += 2 ) | |
152 | 152 | { |
153 | 153 | attribs.put( attributes[i], attributes[i + 1] ); |
154 | 154 | } |
355 | 355 | } |
356 | 356 | |
357 | 357 | /** {@inheritDoc} */ |
358 | @Override | |
358 | 359 | public Object clone() |
359 | 360 | { |
360 | 361 | SinkEventAttributeSet attr = new SinkEventAttributeSet( attribs.size() ); |
369 | 370 | } |
370 | 371 | |
371 | 372 | /** {@inheritDoc} */ |
373 | @Override | |
372 | 374 | public int hashCode() |
373 | 375 | { |
374 | 376 | final int parentHash = ( resolveParent == null ? 0 : resolveParent.hashCode() ); |
377 | 379 | } |
378 | 380 | |
379 | 381 | /** {@inheritDoc} */ |
382 | @Override | |
380 | 383 | public boolean equals( Object obj ) |
381 | 384 | { |
382 | 385 | if ( this == obj ) |
393 | 396 | } |
394 | 397 | |
395 | 398 | /** {@inheritDoc} */ |
399 | @Override | |
396 | 400 | public String toString() |
397 | 401 | { |
398 | StringBuffer s = new StringBuffer(); | |
402 | StringBuilder s = new StringBuilder(); | |
399 | 403 | Enumeration<String> names = getAttributeNames(); |
400 | 404 | |
401 | 405 | while ( names.hasMoreElements() ) |
30 | 30 | * Collection of common utility methods for sinks. |
31 | 31 | * |
32 | 32 | * @author ltheussl |
33 | * @version $Id: SinkUtils.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
33 | * @version $Id: SinkUtils.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
34 | 34 | * @since 1.1 |
35 | 35 | */ |
36 | 36 | public class SinkUtils |
183 | 183 | return ""; |
184 | 184 | } |
185 | 185 | |
186 | StringBuffer sb = new StringBuffer(); | |
186 | StringBuilder sb = new StringBuilder(); | |
187 | 187 | |
188 | 188 | Enumeration<?> names = att.getAttributeNames(); |
189 | 189 | |
214 | 214 | |
215 | 215 | private static String asCssString( AttributeSet att ) |
216 | 216 | { |
217 | StringBuffer sb = new StringBuffer(); | |
217 | StringBuilder sb = new StringBuilder(); | |
218 | 218 | |
219 | 219 | Enumeration<?> names = att.getAttributeNames(); |
220 | 220 |
45 | 45 | * |
46 | 46 | * @author Jason van Zyl |
47 | 47 | * @author ltheussl |
48 | * @version $Id: XhtmlBaseSink.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
48 | * @version $Id: XhtmlBaseSink.java 1185529 2011-10-18 08:27:44Z ltheussl $ | |
49 | 49 | * @since 1.1 |
50 | 50 | */ |
51 | 51 | public class XhtmlBaseSink |
223 | 223 | */ |
224 | 224 | protected int[] getCellJustif() |
225 | 225 | { |
226 | return (int[]) this.cellJustifStack.getLast(); | |
226 | return this.cellJustifStack.getLast(); | |
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
257 | 257 | } |
258 | 258 | |
259 | 259 | /** {@inheritDoc} */ |
260 | @Override | |
260 | 261 | protected void init() |
261 | 262 | { |
262 | 263 | super.init(); |
300 | 301 | // ---------------------------------------------------------------------- |
301 | 302 | |
302 | 303 | /** {@inheritDoc} */ |
304 | @Override | |
303 | 305 | public void section( int level, SinkEventAttributes attributes ) |
304 | 306 | { |
305 | 307 | onSection( level, attributes ); |
306 | 308 | } |
307 | 309 | |
308 | 310 | /** {@inheritDoc} */ |
311 | @Override | |
309 | 312 | public void sectionTitle( int level, SinkEventAttributes attributes ) |
310 | 313 | { |
311 | 314 | onSectionTitle( level, attributes ); |
312 | 315 | } |
313 | 316 | |
314 | 317 | /** {@inheritDoc} */ |
318 | @Override | |
315 | 319 | public void sectionTitle_( int level ) |
316 | 320 | { |
317 | 321 | onSectionTitle_( level ); |
318 | 322 | } |
319 | 323 | |
320 | 324 | /** {@inheritDoc} */ |
325 | @Override | |
321 | 326 | public void section_( int level ) |
322 | 327 | { |
323 | 328 | onSection_( level ); |
324 | 329 | } |
325 | 330 | |
326 | 331 | /** {@inheritDoc} */ |
332 | @Override | |
327 | 333 | public void section1() |
328 | 334 | { |
329 | 335 | onSection( SECTION_LEVEL_1, null ); |
330 | 336 | } |
331 | 337 | |
332 | 338 | /** {@inheritDoc} */ |
339 | @Override | |
333 | 340 | public void sectionTitle1() |
334 | 341 | { |
335 | 342 | onSectionTitle( SECTION_LEVEL_1, null ); |
336 | 343 | } |
337 | 344 | |
338 | 345 | /** {@inheritDoc} */ |
346 | @Override | |
339 | 347 | public void sectionTitle1_() |
340 | 348 | { |
341 | 349 | onSectionTitle_( SECTION_LEVEL_1 ); |
342 | 350 | } |
343 | 351 | |
344 | 352 | /** {@inheritDoc} */ |
353 | @Override | |
345 | 354 | public void section1_() |
346 | 355 | { |
347 | 356 | onSection_( SECTION_LEVEL_1 ); |
348 | 357 | } |
349 | 358 | |
350 | 359 | /** {@inheritDoc} */ |
360 | @Override | |
351 | 361 | public void section2() |
352 | 362 | { |
353 | 363 | onSection( SECTION_LEVEL_2, null ); |
354 | 364 | } |
355 | 365 | |
356 | 366 | /** {@inheritDoc} */ |
367 | @Override | |
357 | 368 | public void sectionTitle2() |
358 | 369 | { |
359 | 370 | onSectionTitle( SECTION_LEVEL_2, null ); |
360 | 371 | } |
361 | 372 | |
362 | 373 | /** {@inheritDoc} */ |
374 | @Override | |
363 | 375 | public void sectionTitle2_() |
364 | 376 | { |
365 | 377 | onSectionTitle_( SECTION_LEVEL_2 ); |
366 | 378 | } |
367 | 379 | |
368 | 380 | /** {@inheritDoc} */ |
381 | @Override | |
369 | 382 | public void section2_() |
370 | 383 | { |
371 | 384 | onSection_( SECTION_LEVEL_2 ); |
372 | 385 | } |
373 | 386 | |
374 | 387 | /** {@inheritDoc} */ |
388 | @Override | |
375 | 389 | public void section3() |
376 | 390 | { |
377 | 391 | onSection( SECTION_LEVEL_3, null ); |
378 | 392 | } |
379 | 393 | |
380 | 394 | /** {@inheritDoc} */ |
395 | @Override | |
381 | 396 | public void sectionTitle3() |
382 | 397 | { |
383 | 398 | onSectionTitle( SECTION_LEVEL_3, null ); |
384 | 399 | } |
385 | 400 | |
386 | 401 | /** {@inheritDoc} */ |
402 | @Override | |
387 | 403 | public void sectionTitle3_() |
388 | 404 | { |
389 | 405 | onSectionTitle_( SECTION_LEVEL_3 ); |
390 | 406 | } |
391 | 407 | |
392 | 408 | /** {@inheritDoc} */ |
409 | @Override | |
393 | 410 | public void section3_() |
394 | 411 | { |
395 | 412 | onSection_( SECTION_LEVEL_3 ); |
396 | 413 | } |
397 | 414 | |
398 | 415 | /** {@inheritDoc} */ |
416 | @Override | |
399 | 417 | public void section4() |
400 | 418 | { |
401 | 419 | onSection( SECTION_LEVEL_4, null ); |
402 | 420 | } |
403 | 421 | |
404 | 422 | /** {@inheritDoc} */ |
423 | @Override | |
405 | 424 | public void sectionTitle4() |
406 | 425 | { |
407 | 426 | onSectionTitle( SECTION_LEVEL_4, null ); |
408 | 427 | } |
409 | 428 | |
410 | 429 | /** {@inheritDoc} */ |
430 | @Override | |
411 | 431 | public void sectionTitle4_() |
412 | 432 | { |
413 | 433 | onSectionTitle_( SECTION_LEVEL_4 ); |
414 | 434 | } |
415 | 435 | |
416 | 436 | /** {@inheritDoc} */ |
437 | @Override | |
417 | 438 | public void section4_() |
418 | 439 | { |
419 | 440 | onSection_( SECTION_LEVEL_4 ); |
420 | 441 | } |
421 | 442 | |
422 | 443 | /** {@inheritDoc} */ |
444 | @Override | |
423 | 445 | public void section5() |
424 | 446 | { |
425 | 447 | onSection( SECTION_LEVEL_5, null ); |
426 | 448 | } |
427 | 449 | |
428 | 450 | /** {@inheritDoc} */ |
451 | @Override | |
429 | 452 | public void sectionTitle5() |
430 | 453 | { |
431 | 454 | onSectionTitle( SECTION_LEVEL_5, null ); |
432 | 455 | } |
433 | 456 | |
434 | 457 | /** {@inheritDoc} */ |
458 | @Override | |
435 | 459 | public void sectionTitle5_() |
436 | 460 | { |
437 | 461 | onSectionTitle_( SECTION_LEVEL_5 ); |
438 | 462 | } |
439 | 463 | |
440 | 464 | /** {@inheritDoc} */ |
465 | @Override | |
441 | 466 | public void section5_() |
442 | 467 | { |
443 | 468 | onSection_( SECTION_LEVEL_5 ); |
460 | 485 | att.addAttributes( SinkUtils.filterAttributes( |
461 | 486 | attributes, SinkUtils.SINK_BASE_ATTRIBUTES ) ); |
462 | 487 | |
463 | att.removeAttribute( Attribute.ID.toString() ); | |
464 | 488 | writeStartTag( HtmlMarkup.DIV, att ); |
465 | 489 | } |
466 | 490 | } |
559 | 583 | * {@inheritDoc} |
560 | 584 | * @see javax.swing.text.html.HTML.Tag#UL |
561 | 585 | */ |
586 | @Override | |
562 | 587 | public void list() |
563 | 588 | { |
564 | 589 | list( null ); |
568 | 593 | * {@inheritDoc} |
569 | 594 | * @see javax.swing.text.html.HTML.Tag#UL |
570 | 595 | */ |
596 | @Override | |
571 | 597 | public void list( SinkEventAttributes attributes ) |
572 | 598 | { |
573 | 599 | if ( paragraphFlag ) |
588 | 614 | * {@inheritDoc} |
589 | 615 | * @see javax.swing.text.html.HTML.Tag#UL |
590 | 616 | */ |
617 | @Override | |
591 | 618 | public void list_() |
592 | 619 | { |
593 | 620 | writeEndTag( HtmlMarkup.UL ); |
597 | 624 | * {@inheritDoc} |
598 | 625 | * @see javax.swing.text.html.HTML.Tag#LI |
599 | 626 | */ |
627 | @Override | |
600 | 628 | public void listItem() |
601 | 629 | { |
602 | 630 | listItem( null ); |
606 | 634 | * {@inheritDoc} |
607 | 635 | * @see javax.swing.text.html.HTML.Tag#LI |
608 | 636 | */ |
637 | @Override | |
609 | 638 | public void listItem( SinkEventAttributes attributes ) |
610 | 639 | { |
611 | 640 | MutableAttributeSet atts = SinkUtils.filterAttributes( |
618 | 647 | * {@inheritDoc} |
619 | 648 | * @see javax.swing.text.html.HTML.Tag#LI |
620 | 649 | */ |
650 | @Override | |
621 | 651 | public void listItem_() |
622 | 652 | { |
623 | 653 | writeEndTag( HtmlMarkup.LI ); |
629 | 659 | * {@inheritDoc} |
630 | 660 | * @see javax.swing.text.html.HTML.Tag#OL |
631 | 661 | */ |
662 | @Override | |
632 | 663 | public void numberedList( int numbering ) |
633 | 664 | { |
634 | 665 | numberedList( numbering, null ); |
640 | 671 | * {@inheritDoc} |
641 | 672 | * @see javax.swing.text.html.HTML.Tag#OL |
642 | 673 | */ |
674 | @Override | |
643 | 675 | public void numberedList( int numbering, SinkEventAttributes attributes ) |
644 | 676 | { |
645 | 677 | if ( paragraphFlag ) |
687 | 719 | * {@inheritDoc} |
688 | 720 | * @see javax.swing.text.html.HTML.Tag#OL |
689 | 721 | */ |
722 | @Override | |
690 | 723 | public void numberedList_() |
691 | 724 | { |
692 | 725 | writeEndTag( HtmlMarkup.OL ); |
696 | 729 | * {@inheritDoc} |
697 | 730 | * @see javax.swing.text.html.HTML.Tag#LI |
698 | 731 | */ |
732 | @Override | |
699 | 733 | public void numberedListItem() |
700 | 734 | { |
701 | 735 | numberedListItem( null ); |
705 | 739 | * {@inheritDoc} |
706 | 740 | * @see javax.swing.text.html.HTML.Tag#LI |
707 | 741 | */ |
742 | @Override | |
708 | 743 | public void numberedListItem( SinkEventAttributes attributes ) |
709 | 744 | { |
710 | 745 | MutableAttributeSet atts = SinkUtils.filterAttributes( |
717 | 752 | * {@inheritDoc} |
718 | 753 | * @see javax.swing.text.html.HTML.Tag#LI |
719 | 754 | */ |
755 | @Override | |
720 | 756 | public void numberedListItem_() |
721 | 757 | { |
722 | 758 | writeEndTag( HtmlMarkup.LI ); |
726 | 762 | * {@inheritDoc} |
727 | 763 | * @see javax.swing.text.html.HTML.Tag#DL |
728 | 764 | */ |
765 | @Override | |
729 | 766 | public void definitionList() |
730 | 767 | { |
731 | 768 | definitionList( null ); |
735 | 772 | * {@inheritDoc} |
736 | 773 | * @see javax.swing.text.html.HTML.Tag#DL |
737 | 774 | */ |
775 | @Override | |
738 | 776 | public void definitionList( SinkEventAttributes attributes ) |
739 | 777 | { |
740 | 778 | if ( paragraphFlag ) |
755 | 793 | * {@inheritDoc} |
756 | 794 | * @see javax.swing.text.html.HTML.Tag#DL |
757 | 795 | */ |
796 | @Override | |
758 | 797 | public void definitionList_() |
759 | 798 | { |
760 | 799 | writeEndTag( HtmlMarkup.DL ); |
764 | 803 | * {@inheritDoc} |
765 | 804 | * @see javax.swing.text.html.HTML.Tag#DT |
766 | 805 | */ |
806 | @Override | |
767 | 807 | public void definedTerm( SinkEventAttributes attributes ) |
768 | 808 | { |
769 | 809 | MutableAttributeSet atts = SinkUtils.filterAttributes( |
776 | 816 | * {@inheritDoc} |
777 | 817 | * @see javax.swing.text.html.HTML.Tag#DT |
778 | 818 | */ |
819 | @Override | |
779 | 820 | public void definedTerm() |
780 | 821 | { |
781 | 822 | definedTerm( null ); |
785 | 826 | * {@inheritDoc} |
786 | 827 | * @see javax.swing.text.html.HTML.Tag#DT |
787 | 828 | */ |
829 | @Override | |
788 | 830 | public void definedTerm_() |
789 | 831 | { |
790 | 832 | writeEndTag( HtmlMarkup.DT ); |
794 | 836 | * {@inheritDoc} |
795 | 837 | * @see javax.swing.text.html.HTML.Tag#DD |
796 | 838 | */ |
839 | @Override | |
797 | 840 | public void definition() |
798 | 841 | { |
799 | 842 | definition( null ); |
803 | 846 | * {@inheritDoc} |
804 | 847 | * @see javax.swing.text.html.HTML.Tag#DD |
805 | 848 | */ |
849 | @Override | |
806 | 850 | public void definition( SinkEventAttributes attributes ) |
807 | 851 | { |
808 | 852 | MutableAttributeSet atts = SinkUtils.filterAttributes( |
815 | 859 | * {@inheritDoc} |
816 | 860 | * @see javax.swing.text.html.HTML.Tag#DD |
817 | 861 | */ |
862 | @Override | |
818 | 863 | public void definition_() |
819 | 864 | { |
820 | 865 | writeEndTag( HtmlMarkup.DD ); |
827 | 872 | * backward compatibility. Note that the behavior is different though, as this method |
828 | 873 | * writes an img tag, while correctly the img tag should be written by figureGraphics(). |
829 | 874 | */ |
875 | @Override | |
830 | 876 | public void figure() |
831 | 877 | { |
832 | 878 | write( String.valueOf( LESS_THAN ) + HtmlMarkup.IMG ); |
837 | 883 | * {@inheritDoc} |
838 | 884 | * @see javax.swing.text.html.HTML.Tag#IMG |
839 | 885 | */ |
886 | @Override | |
840 | 887 | public void figure( SinkEventAttributes attributes ) |
841 | 888 | { |
842 | 889 | inFigure = true; |
858 | 905 | } |
859 | 906 | |
860 | 907 | /** {@inheritDoc} */ |
908 | @Override | |
861 | 909 | public void figure_() |
862 | 910 | { |
863 | 911 | if ( legacyFigure ) |
885 | 933 | * this method is only kept for backward compatibility. Note that the behavior is |
886 | 934 | * different though, as this method does not write the img tag, only the src attribute. |
887 | 935 | */ |
936 | @Override | |
888 | 937 | public void figureGraphics( String name ) |
889 | 938 | { |
890 | 939 | write( String.valueOf( SPACE ) + Attribute.SRC + EQUAL + QUOTE + escapeHTML( name ) + QUOTE ); |
891 | 940 | } |
892 | 941 | |
893 | 942 | /** {@inheritDoc} */ |
943 | @Override | |
894 | 944 | public void figureGraphics( String src, SinkEventAttributes attributes ) |
895 | 945 | { |
896 | 946 | if ( inFigure ) |
933 | 983 | * this method is only kept for backward compatibility. Note that the behavior is |
934 | 984 | * different though, as this method only writes an alt attribute. |
935 | 985 | */ |
986 | @Override | |
936 | 987 | public void figureCaption() |
937 | 988 | { |
938 | 989 | figureCaptionFlag = true; |
941 | 992 | } |
942 | 993 | |
943 | 994 | /** {@inheritDoc} */ |
995 | @Override | |
944 | 996 | public void figureCaption( SinkEventAttributes attributes ) |
945 | 997 | { |
946 | 998 | if ( legacyFigureCaption ) |
962 | 1014 | } |
963 | 1015 | |
964 | 1016 | /** {@inheritDoc} */ |
1017 | @Override | |
965 | 1018 | public void figureCaption_() |
966 | 1019 | { |
967 | 1020 | if ( legacyFigureCaption ) |
979 | 1032 | * {@inheritDoc} |
980 | 1033 | * @see javax.swing.text.html.HTML.Tag#P |
981 | 1034 | */ |
1035 | @Override | |
982 | 1036 | public void paragraph() |
983 | 1037 | { |
984 | 1038 | paragraph( null ); |
988 | 1042 | * {@inheritDoc} |
989 | 1043 | * @see javax.swing.text.html.HTML.Tag#P |
990 | 1044 | */ |
1045 | @Override | |
991 | 1046 | public void paragraph( SinkEventAttributes attributes ) |
992 | 1047 | { |
993 | 1048 | paragraphFlag = true; |
1002 | 1057 | * {@inheritDoc} |
1003 | 1058 | * @see javax.swing.text.html.HTML.Tag#P |
1004 | 1059 | */ |
1060 | @Override | |
1005 | 1061 | public void paragraph_() |
1006 | 1062 | { |
1007 | 1063 | if ( paragraphFlag ) |
1018 | 1074 | * @see javax.swing.text.html.HTML.Tag#DIV |
1019 | 1075 | * @see javax.swing.text.html.HTML.Tag#PRE |
1020 | 1076 | */ |
1077 | @Override | |
1021 | 1078 | public void verbatim( boolean boxed ) |
1022 | 1079 | { |
1023 | 1080 | if ( boxed ) |
1037 | 1094 | * @see javax.swing.text.html.HTML.Tag#DIV |
1038 | 1095 | * @see javax.swing.text.html.HTML.Tag#PRE |
1039 | 1096 | */ |
1097 | @Override | |
1040 | 1098 | public void verbatim( SinkEventAttributes attributes ) |
1041 | 1099 | { |
1042 | 1100 | if ( paragraphFlag ) |
1065 | 1123 | "boxed".equals( atts.getAttribute( SinkEventAttributes.DECORATION ).toString() ); |
1066 | 1124 | } |
1067 | 1125 | |
1126 | SinkEventAttributes divAtts = null; | |
1127 | ||
1068 | 1128 | if ( boxed ) |
1069 | 1129 | { |
1070 | atts.addAttribute( Attribute.CLASS, "source" ); | |
1130 | divAtts = new SinkEventAttributeSet( new String[] { Attribute.CLASS.toString(), "source" } ); | |
1071 | 1131 | } |
1072 | 1132 | |
1073 | 1133 | atts.removeAttribute( SinkEventAttributes.DECORATION ); |
1074 | 1134 | |
1075 | String width = (String) atts.getAttribute( Attribute.WIDTH.toString() ); | |
1076 | atts.removeAttribute( Attribute.WIDTH.toString() ); | |
1077 | ||
1078 | writeStartTag( HtmlMarkup.DIV, atts ); | |
1079 | ||
1080 | if ( width != null ) | |
1081 | { | |
1082 | atts.addAttribute( Attribute.WIDTH.toString(), width ); | |
1083 | } | |
1084 | ||
1085 | atts.removeAttribute( Attribute.ALIGN.toString() ); | |
1086 | atts.removeAttribute( Attribute.CLASS.toString() ); | |
1087 | ||
1135 | writeStartTag( HtmlMarkup.DIV, divAtts ); | |
1088 | 1136 | writeStartTag( HtmlMarkup.PRE, atts ); |
1089 | 1137 | } |
1090 | 1138 | |
1093 | 1141 | * @see javax.swing.text.html.HTML.Tag#DIV |
1094 | 1142 | * @see javax.swing.text.html.HTML.Tag#PRE |
1095 | 1143 | */ |
1144 | @Override | |
1096 | 1145 | public void verbatim_() |
1097 | 1146 | { |
1098 | 1147 | writeEndTag( HtmlMarkup.PRE ); |
1106 | 1155 | * {@inheritDoc} |
1107 | 1156 | * @see javax.swing.text.html.HTML.Tag#HR |
1108 | 1157 | */ |
1158 | @Override | |
1109 | 1159 | public void horizontalRule() |
1110 | 1160 | { |
1111 | 1161 | horizontalRule( null ); |
1115 | 1165 | * {@inheritDoc} |
1116 | 1166 | * @see javax.swing.text.html.HTML.Tag#HR |
1117 | 1167 | */ |
1168 | @Override | |
1118 | 1169 | public void horizontalRule( SinkEventAttributes attributes ) |
1119 | 1170 | { |
1120 | 1171 | MutableAttributeSet atts = SinkUtils.filterAttributes( |
1124 | 1175 | } |
1125 | 1176 | |
1126 | 1177 | /** {@inheritDoc} */ |
1178 | @Override | |
1127 | 1179 | public void table() |
1128 | 1180 | { |
1129 | 1181 | // start table with tableRows |
1131 | 1183 | } |
1132 | 1184 | |
1133 | 1185 | /** {@inheritDoc} */ |
1186 | @Override | |
1134 | 1187 | public void table( SinkEventAttributes attributes ) |
1135 | 1188 | { |
1136 | 1189 | this.tableContentWriterStack.addLast( new StringWriter() ); |
1160 | 1213 | * {@inheritDoc} |
1161 | 1214 | * @see javax.swing.text.html.HTML.Tag#TABLE |
1162 | 1215 | */ |
1216 | @Override | |
1163 | 1217 | public void table_() |
1164 | 1218 | { |
1165 | 1219 | this.tableRows = false; |
1191 | 1245 | if ( tableCaption != null ) |
1192 | 1246 | { |
1193 | 1247 | // DOXIA-177 |
1194 | StringBuffer sb = new StringBuffer(); | |
1248 | StringBuilder sb = new StringBuilder(); | |
1195 | 1249 | sb.append( tableContent.substring( 0, tableContent.indexOf( Markup.GREATER_THAN ) + 1 ) ); |
1196 | 1250 | sb.append( tableCaption ); |
1197 | 1251 | sb.append( tableContent.substring( tableContent.indexOf( Markup.GREATER_THAN ) + 1 ) ); |
1211 | 1265 | * {@inheritDoc} |
1212 | 1266 | * @see javax.swing.text.html.HTML.Tag#TABLE |
1213 | 1267 | */ |
1268 | @Override | |
1214 | 1269 | public void tableRows( int[] justification, boolean grid ) |
1215 | 1270 | { |
1216 | 1271 | this.tableRows = true; |
1242 | 1297 | } |
1243 | 1298 | |
1244 | 1299 | /** {@inheritDoc} */ |
1300 | @Override | |
1245 | 1301 | public void tableRows_() |
1246 | 1302 | { |
1247 | 1303 | this.tableRows = false; |
1263 | 1319 | * {@inheritDoc} |
1264 | 1320 | * @see javax.swing.text.html.HTML.Tag#TR |
1265 | 1321 | */ |
1322 | @Override | |
1266 | 1323 | public void tableRow() |
1267 | 1324 | { |
1268 | 1325 | // To be backward compatible |
1279 | 1336 | * {@inheritDoc} |
1280 | 1337 | * @see javax.swing.text.html.HTML.Tag#TR |
1281 | 1338 | */ |
1339 | @Override | |
1282 | 1340 | public void tableRow( SinkEventAttributes attributes ) |
1283 | 1341 | { |
1284 | 1342 | MutableAttributeSet att = new SinkEventAttributeSet(); |
1310 | 1368 | * {@inheritDoc} |
1311 | 1369 | * @see javax.swing.text.html.HTML.Tag#TR |
1312 | 1370 | */ |
1371 | @Override | |
1313 | 1372 | public void tableRow_() |
1314 | 1373 | { |
1315 | 1374 | writeEndTag( HtmlMarkup.TR ); |
1316 | 1375 | } |
1317 | 1376 | |
1318 | 1377 | /** {@inheritDoc} */ |
1378 | @Override | |
1319 | 1379 | public void tableCell() |
1320 | 1380 | { |
1321 | 1381 | tableCell( (SinkEventAttributeSet) null ); |
1322 | 1382 | } |
1323 | 1383 | |
1324 | 1384 | /** {@inheritDoc} */ |
1385 | @Override | |
1325 | 1386 | public void tableHeaderCell() |
1326 | 1387 | { |
1327 | 1388 | tableHeaderCell( (SinkEventAttributeSet) null ); |
1328 | 1389 | } |
1329 | 1390 | |
1330 | 1391 | /** {@inheritDoc} */ |
1392 | @Override | |
1331 | 1393 | public void tableCell( String width ) |
1332 | 1394 | { |
1333 | 1395 | MutableAttributeSet att = new SinkEventAttributeSet(); |
1337 | 1399 | } |
1338 | 1400 | |
1339 | 1401 | /** {@inheritDoc} */ |
1402 | @Override | |
1340 | 1403 | public void tableHeaderCell( String width ) |
1341 | 1404 | { |
1342 | 1405 | MutableAttributeSet att = new SinkEventAttributeSet(); |
1346 | 1409 | } |
1347 | 1410 | |
1348 | 1411 | /** {@inheritDoc} */ |
1412 | @Override | |
1349 | 1413 | public void tableCell( SinkEventAttributes attributes ) |
1350 | 1414 | { |
1351 | 1415 | tableCell( false, attributes ); |
1352 | 1416 | } |
1353 | 1417 | |
1354 | 1418 | /** {@inheritDoc} */ |
1419 | @Override | |
1355 | 1420 | public void tableHeaderCell( SinkEventAttributes attributes ) |
1356 | 1421 | { |
1357 | 1422 | tableCell( true, attributes ); |
1367 | 1432 | { |
1368 | 1433 | Tag t = ( headerRow ? HtmlMarkup.TH : HtmlMarkup.TD ); |
1369 | 1434 | |
1370 | MutableAttributeSet att = new SinkEventAttributeSet(); | |
1371 | ||
1372 | 1435 | if ( attributes == null ) |
1373 | 1436 | { |
1374 | attributes = new SinkEventAttributeSet( 0 ); | |
1375 | } | |
1376 | ||
1377 | att.addAttributes( SinkUtils.filterAttributes( | |
1378 | attributes, SinkUtils.SINK_TD_ATTRIBUTES ) ); | |
1379 | ||
1380 | writeStartTag( t, att ); | |
1381 | } | |
1382 | ||
1383 | /** {@inheritDoc} */ | |
1437 | writeStartTag( t, null ); | |
1438 | } | |
1439 | else | |
1440 | { | |
1441 | writeStartTag( t, | |
1442 | SinkUtils.filterAttributes( attributes, SinkUtils.SINK_TD_ATTRIBUTES ) ); | |
1443 | } | |
1444 | } | |
1445 | ||
1446 | /** {@inheritDoc} */ | |
1447 | @Override | |
1384 | 1448 | public void tableCell_() |
1385 | 1449 | { |
1386 | 1450 | tableCell_( false ); |
1387 | 1451 | } |
1388 | 1452 | |
1389 | 1453 | /** {@inheritDoc} */ |
1454 | @Override | |
1390 | 1455 | public void tableHeaderCell_() |
1391 | 1456 | { |
1392 | 1457 | tableCell_( true ); |
1417 | 1482 | * {@inheritDoc} |
1418 | 1483 | * @see javax.swing.text.html.HTML.Tag#CAPTION |
1419 | 1484 | */ |
1485 | @Override | |
1420 | 1486 | public void tableCaption() |
1421 | 1487 | { |
1422 | 1488 | tableCaption( null ); |
1426 | 1492 | * {@inheritDoc} |
1427 | 1493 | * @see javax.swing.text.html.HTML.Tag#CAPTION |
1428 | 1494 | */ |
1495 | @Override | |
1429 | 1496 | public void tableCaption( SinkEventAttributes attributes ) |
1430 | 1497 | { |
1431 | 1498 | StringWriter sw = new StringWriter(); |
1443 | 1510 | * {@inheritDoc} |
1444 | 1511 | * @see javax.swing.text.html.HTML.Tag#CAPTION |
1445 | 1512 | */ |
1513 | @Override | |
1446 | 1514 | public void tableCaption_() |
1447 | 1515 | { |
1448 | 1516 | writeEndTag( HtmlMarkup.CAPTION ); |
1458 | 1526 | * {@inheritDoc} |
1459 | 1527 | * @see javax.swing.text.html.HTML.Tag#A |
1460 | 1528 | */ |
1529 | @Override | |
1461 | 1530 | public void anchor( String name ) |
1462 | 1531 | { |
1463 | 1532 | anchor( name, null ); |
1467 | 1536 | * {@inheritDoc} |
1468 | 1537 | * @see javax.swing.text.html.HTML.Tag#A |
1469 | 1538 | */ |
1539 | @Override | |
1470 | 1540 | public void anchor( String name, SinkEventAttributes attributes ) |
1471 | 1541 | { |
1472 | 1542 | if ( name == null ) |
1503 | 1573 | * {@inheritDoc} |
1504 | 1574 | * @see javax.swing.text.html.HTML.Tag#A |
1505 | 1575 | */ |
1576 | @Override | |
1506 | 1577 | public void anchor_() |
1507 | 1578 | { |
1508 | 1579 | if ( !headFlag ) |
1512 | 1583 | } |
1513 | 1584 | |
1514 | 1585 | /** {@inheritDoc} */ |
1586 | @Override | |
1515 | 1587 | public void link( String name ) |
1516 | 1588 | { |
1517 | 1589 | link( name, null ); |
1518 | 1590 | } |
1519 | 1591 | |
1520 | 1592 | /** {@inheritDoc} */ |
1593 | @Override | |
1521 | 1594 | public void link( String name, SinkEventAttributes attributes ) |
1522 | 1595 | { |
1523 | 1596 | if ( attributes == null ) |
1584 | 1657 | * {@inheritDoc} |
1585 | 1658 | * @see javax.swing.text.html.HTML.Tag#A |
1586 | 1659 | */ |
1660 | @Override | |
1587 | 1661 | public void link_() |
1588 | 1662 | { |
1589 | 1663 | if ( !headFlag ) |
1596 | 1670 | * {@inheritDoc} |
1597 | 1671 | * @see javax.swing.text.html.HTML.Tag#I |
1598 | 1672 | */ |
1673 | @Override | |
1599 | 1674 | public void italic() |
1600 | 1675 | { |
1601 | 1676 | if ( !headFlag ) |
1608 | 1683 | * {@inheritDoc} |
1609 | 1684 | * @see javax.swing.text.html.HTML.Tag#I |
1610 | 1685 | */ |
1686 | @Override | |
1611 | 1687 | public void italic_() |
1612 | 1688 | { |
1613 | 1689 | if ( !headFlag ) |
1620 | 1696 | * {@inheritDoc} |
1621 | 1697 | * @see javax.swing.text.html.HTML.Tag#B |
1622 | 1698 | */ |
1699 | @Override | |
1623 | 1700 | public void bold() |
1624 | 1701 | { |
1625 | 1702 | if ( !headFlag ) |
1632 | 1709 | * {@inheritDoc} |
1633 | 1710 | * @see javax.swing.text.html.HTML.Tag#B |
1634 | 1711 | */ |
1712 | @Override | |
1635 | 1713 | public void bold_() |
1636 | 1714 | { |
1637 | 1715 | if ( !headFlag ) |
1644 | 1722 | * {@inheritDoc} |
1645 | 1723 | * @see javax.swing.text.html.HTML.Tag#TT |
1646 | 1724 | */ |
1725 | @Override | |
1647 | 1726 | public void monospaced() |
1648 | 1727 | { |
1649 | 1728 | if ( !headFlag ) |
1656 | 1735 | * {@inheritDoc} |
1657 | 1736 | * @see javax.swing.text.html.HTML.Tag#TT |
1658 | 1737 | */ |
1738 | @Override | |
1659 | 1739 | public void monospaced_() |
1660 | 1740 | { |
1661 | 1741 | if ( !headFlag ) |
1668 | 1748 | * {@inheritDoc} |
1669 | 1749 | * @see javax.swing.text.html.HTML.Tag#BR |
1670 | 1750 | */ |
1751 | @Override | |
1671 | 1752 | public void lineBreak() |
1672 | 1753 | { |
1673 | 1754 | lineBreak( null ); |
1677 | 1758 | * {@inheritDoc} |
1678 | 1759 | * @see javax.swing.text.html.HTML.Tag#BR |
1679 | 1760 | */ |
1761 | @Override | |
1680 | 1762 | public void lineBreak( SinkEventAttributes attributes ) |
1681 | 1763 | { |
1682 | 1764 | if ( headFlag || isVerbatimFlag() ) |
1693 | 1775 | } |
1694 | 1776 | |
1695 | 1777 | /** {@inheritDoc} */ |
1778 | @Override | |
1696 | 1779 | public void pageBreak() |
1697 | 1780 | { |
1698 | 1781 | comment( "PB" ); |
1699 | 1782 | } |
1700 | 1783 | |
1701 | 1784 | /** {@inheritDoc} */ |
1785 | @Override | |
1702 | 1786 | public void nonBreakingSpace() |
1703 | 1787 | { |
1704 | 1788 | if ( headFlag ) |
1712 | 1796 | } |
1713 | 1797 | |
1714 | 1798 | /** {@inheritDoc} */ |
1799 | @Override | |
1715 | 1800 | public void text( String text ) |
1716 | 1801 | { |
1717 | 1802 | if ( headFlag ) |
1729 | 1814 | } |
1730 | 1815 | |
1731 | 1816 | /** {@inheritDoc} */ |
1817 | @Override | |
1732 | 1818 | public void text( String text, SinkEventAttributes attributes ) |
1733 | 1819 | { |
1734 | 1820 | if ( attributes == null ) |
1776 | 1862 | } |
1777 | 1863 | |
1778 | 1864 | /** {@inheritDoc} */ |
1865 | @Override | |
1779 | 1866 | public void rawText( String text ) |
1780 | 1867 | { |
1781 | 1868 | if ( headFlag ) |
1789 | 1876 | } |
1790 | 1877 | |
1791 | 1878 | /** {@inheritDoc} */ |
1879 | @Override | |
1792 | 1880 | public void comment( String comment ) |
1793 | 1881 | { |
1794 | if ( StringUtils.isNotEmpty( comment ) && comment.indexOf( "--" ) != -1 ) | |
1795 | { | |
1796 | String originalComment = comment; | |
1882 | String cmt = comment; | |
1883 | ||
1884 | if ( StringUtils.isNotEmpty( cmt ) && cmt.contains( "--" ) ) | |
1885 | { | |
1886 | String originalComment = cmt; | |
1797 | 1887 | // http://www.w3.org/TR/2000/REC-xml-20001006#sec-comments |
1798 | while ( comment.indexOf( "--" ) != -1 ) | |
1888 | while ( cmt.contains( "--" ) ) | |
1799 | 1889 | { |
1800 | comment = StringUtils.replace( comment, "--", "- -" ); | |
1890 | cmt = StringUtils.replace( cmt, "--", "- -" ); | |
1801 | 1891 | } |
1802 | 1892 | |
1803 | getLog() | |
1804 | .warn( "[Xhtml Sink] Modified invalid comment: '" + originalComment + "' to '" + comment + "'" ); | |
1805 | } | |
1806 | ||
1807 | StringBuffer buf = new StringBuffer( comment.length() + 9 ); | |
1893 | getLog().warn( "[Xhtml Sink] Modified invalid comment: '" + originalComment + "' to '" + cmt + "'" ); | |
1894 | } | |
1895 | ||
1896 | StringBuilder buf = new StringBuilder( cmt.length() + 9 ); | |
1808 | 1897 | |
1809 | 1898 | buf.append( LESS_THAN ).append( BANG ).append( MINUS ).append( MINUS ).append( SPACE ); |
1810 | buf.append( comment ); | |
1899 | buf.append( cmt ); | |
1811 | 1900 | buf.append( SPACE ).append( MINUS ).append( MINUS ).append( GREATER_THAN ); |
1812 | 1901 | |
1813 | 1902 | write( buf.toString() ); |
1852 | 1941 | * @param attributes a set of attributes for the event. May be null. |
1853 | 1942 | * The attributes will always be written, no validity check is performed. |
1854 | 1943 | */ |
1944 | @Override | |
1855 | 1945 | public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes ) |
1856 | 1946 | { |
1857 | 1947 | if ( requiredParams == null || !( requiredParams[0] instanceof Integer ) ) |
1924 | 2014 | } |
1925 | 2015 | |
1926 | 2016 | /** {@inheritDoc} */ |
2017 | @Override | |
1927 | 2018 | public void flush() |
1928 | 2019 | { |
1929 | 2020 | writer.flush(); |
1930 | 2021 | } |
1931 | 2022 | |
1932 | 2023 | /** {@inheritDoc} */ |
2024 | @Override | |
1933 | 2025 | public void close() |
1934 | 2026 | { |
1935 | 2027 | writer.close(); |
1962 | 2054 | protected void content( String text ) |
1963 | 2055 | { |
1964 | 2056 | // small hack due to DOXIA-314 |
1965 | text = escapeHTML( text ); | |
1966 | text = StringUtils.replace( text, "&#", "&#" ); | |
1967 | write( text ); | |
2057 | String txt = escapeHTML( text ); | |
2058 | txt = StringUtils.replace( txt, "&#", "&#" ); | |
2059 | write( txt ); | |
1968 | 2060 | } |
1969 | 2061 | |
1970 | 2062 | /** |
2019 | 2111 | } |
2020 | 2112 | |
2021 | 2113 | /** {@inheritDoc} */ |
2114 | @Override | |
2022 | 2115 | protected void writeStartTag( Tag t, MutableAttributeSet att, boolean isSimpleTag ) |
2023 | 2116 | { |
2024 | 2117 | if ( this.tableCaptionXMLWriterStack.isEmpty() ) |
2050 | 2143 | } |
2051 | 2144 | |
2052 | 2145 | /** {@inheritDoc} */ |
2146 | @Override | |
2053 | 2147 | protected void writeEndTag( Tag t ) |
2054 | 2148 | { |
2055 | 2149 | if ( this.tableCaptionXMLWriterStack.isEmpty() ) |
2072 | 2166 | */ |
2073 | 2167 | private void logMessage( String key, String msg ) |
2074 | 2168 | { |
2075 | msg = "[XHTML Sink] " + msg; | |
2169 | final String mesg = "[XHTML Sink] " + msg; | |
2076 | 2170 | if ( getLog().isDebugEnabled() ) |
2077 | 2171 | { |
2078 | getLog().debug( msg ); | |
2172 | getLog().debug( mesg ); | |
2079 | 2173 | |
2080 | 2174 | return; |
2081 | 2175 | } |
2090 | 2184 | { |
2091 | 2185 | set = new TreeSet<String>(); |
2092 | 2186 | } |
2093 | set.add( msg ); | |
2187 | set.add( mesg ); | |
2094 | 2188 | warnMessages.put( key, set ); |
2095 | 2189 | } |
2096 | 2190 | } |
45 | 45 | * |
46 | 46 | * @author ltheussl |
47 | 47 | * @since 1.1 |
48 | * @version $Id: DoxiaUtils.java 1088993 2011-04-05 11:54:42Z ltheussl $ | |
48 | * @version $Id: DoxiaUtils.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
49 | 49 | */ |
50 | 50 | public class DoxiaUtils |
51 | 51 | { |
97 | 97 | |
98 | 98 | return ( text.startsWith( "http:/" ) || text.startsWith( "https:/" ) |
99 | 99 | || text.startsWith( "ftp:/" ) || text.startsWith( "mailto:" ) |
100 | || text.startsWith( "file:/" ) || text.indexOf( "://" ) != -1 ); | |
100 | || text.startsWith( "file:/" ) || text.contains( "://" ) ); | |
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
223 | 223 | return "a"; |
224 | 224 | } |
225 | 225 | |
226 | StringBuffer buffer = new StringBuffer( length ); | |
226 | StringBuilder buffer = new StringBuilder( length ); | |
227 | 227 | |
228 | 228 | for ( int i = 0; i < length; ++i ) |
229 | 229 | { |
361 | 361 | public static Date parseDate( final String str ) |
362 | 362 | throws ParseException |
363 | 363 | { |
364 | if ( "today".equals( str.toLowerCase( Locale.ENGLISH ) ) | |
365 | || "now".equals( str.toLowerCase( Locale.ENGLISH ) ) ) | |
364 | if ( "today".equalsIgnoreCase( str ) || "now".equalsIgnoreCase( str ) ) | |
366 | 365 | { |
367 | 366 | return new Date(); |
368 | 367 | } |
34 | 34 | * The <code>HtmlTools</code> class defines methods to HTML handling. |
35 | 35 | * |
36 | 36 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
37 | * @version $Id: HtmlTools.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
37 | * @version $Id: HtmlTools.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
38 | 38 | * @since 1.0 |
39 | 39 | */ |
40 | 40 | public class HtmlTools |
142 | 142 | } |
143 | 143 | |
144 | 144 | int length = text.length(); |
145 | StringBuffer buffer = new StringBuffer( length ); | |
145 | StringBuilder buffer = new StringBuilder( length ); | |
146 | 146 | |
147 | 147 | for ( int i = 0; i < length; ++i ) |
148 | 148 | { |
300 | 300 | return null; |
301 | 301 | } |
302 | 302 | |
303 | StringBuffer encoded = new StringBuffer(); | |
303 | StringBuilder encoded = new StringBuilder(); | |
304 | 304 | int length = url.length(); |
305 | 305 | |
306 | 306 | char[] unicode = new char[1]; |
96 | 96 | { |
97 | 97 | String value = matcher.group( 2 ); |
98 | 98 | |
99 | if ( value.indexOf( XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI ) != -1 ) | |
99 | if ( value.contains( XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI ) ) | |
100 | 100 | { |
101 | 101 | hasXsd = true; |
102 | 102 | } |
183 | 183 | } |
184 | 184 | |
185 | 185 | /** {@inheritDoc} */ |
186 | @Override | |
186 | 187 | public void warning( SAXParseException e ) |
187 | 188 | throws SAXException |
188 | 189 | { |
190 | 191 | } |
191 | 192 | |
192 | 193 | /** {@inheritDoc} */ |
194 | @Override | |
193 | 195 | public void error( SAXParseException e ) |
194 | 196 | throws SAXException |
195 | 197 | { |
210 | 212 | } |
211 | 213 | |
212 | 214 | /** {@inheritDoc} */ |
215 | @Override | |
213 | 216 | public void fatalError( SAXParseException e ) |
214 | 217 | throws SAXException |
215 | 218 | { |
219 | 222 | private void processException( int type, SAXParseException e ) |
220 | 223 | throws SAXException |
221 | 224 | { |
222 | StringBuffer message = new StringBuffer(); | |
225 | StringBuilder message = new StringBuilder(); | |
223 | 226 | |
224 | 227 | switch ( type ) |
225 | 228 | { |
0 | ----- | |
1 | Using RandomAccessSink | |
2 | ----- | |
3 | Robert Scholte | |
4 | ------ | |
5 | 2011-01-07 | |
6 | ------ | |
7 | ||
8 | ~~ Licensed to the Apache Software Foundation (ASF) under one | |
9 | ~~ or more contributor license agreements. See the NOTICE file | |
10 | ~~ distributed with this work for additional information | |
11 | ~~ regarding copyright ownership. The ASF licenses this file | |
12 | ~~ to you under the Apache License, Version 2.0 (the | |
13 | ~~ "License"); you may not use this file except in compliance | |
14 | ~~ with the License. You may obtain a copy of the License at | |
15 | ~~ | |
16 | ~~ http://www.apache.org/licenses/LICENSE-2.0 | |
17 | ~~ | |
18 | ~~ Unless required by applicable law or agreed to in writing, | |
19 | ~~ software distributed under the License is distributed on an | |
20 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
21 | ~~ KIND, either express or implied. See the License for the | |
22 | ~~ specific language governing permissions and limitations | |
23 | ~~ under the License. | |
24 | ||
25 | ~~ NOTE: For help with the syntax of this file, see: | |
26 | ~~ http://maven.apache.org/doxia/references/apt-format.html | |
27 | ||
28 | Using the RandomAccessSink | |
29 | ||
30 | The RandomAccessSink is a Sink with the ability to add hooks. | |
31 | To demonstrate its usage we can have a look at a FML (FAQ Markup Language)-page. | |
32 | The simple structure of such a page can be like: | |
33 | ||
34 | +----------------+ | |
35 | <faq id="1"> | |
36 | <question/> | |
37 | <answer/> | |
38 | </faq> | |
39 | <faq id="2"> | |
40 | <question/> | |
41 | <answer/> | |
42 | </faq> | |
43 | +----------------+ | |
44 | ||
45 | Such structure would be parsed to the following page: | |
46 | ||
47 | *-------------------------------+ | |
48 | | faq\["1"\].question \+ link \ | |
49 | | faq\["2"\].question \+ link \ | |
50 | *-------------------------------+ | |
51 | | faq\["1"\].question \+ anchor \ | |
52 | | faq\["1"\].answer \ | |
53 | | faq\["2"\].question \+ anchor \ | |
54 | | faq\["2"\].answer \ | |
55 | *-------------------------------+ | |
56 | ||
57 | With a Sink you can only append and there's no option to buffer. | |
58 | This would mean that you have to go twice over the structure: once for only the questions and once for the question + answer. | |
59 | ||
60 | When using the RandomAccesSink we can prepare the structure of the page | |
61 | ||
62 | +--------------------------------------------------------------------------------------------------* | |
63 | RandomAccessSink randomAccessSink = new RandomAccessSink( sinkFactory, outputStream, encoding ); | |
64 | Sink questions = randomAccessSink.addSinkHook(); | |
65 | Sink qAndA = randomAccessSink.addSinkHook(); | |
66 | +--------------------------------------------------------------------------------------------------* | |
67 | ||
68 | Now you can append the first question to both sinks, and append the answer to the second one. | |
69 | The same can be done with the second faq-entry. |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.0.0" | |
24 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
25 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 ../../../../doxia-sitetools/doxia-decoration-model/target/generated-site/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"> | |
26 | 25 | |
27 | 26 | <body> |
28 | 27 | |
29 | 28 | <menu ref="parent"/> |
30 | 29 | |
31 | <menu name="Schema Document 1.0"> | |
32 | <item name="Reference of Schema Document" href="document.html"/> | |
33 | <item name="Using Schema Document" href="using-document-xsd.html"/> | |
30 | <menu name="Overview"> | |
31 | <item name="Introduction" href="index.html"/> | |
32 | <item name="JavaDocs" href="apidocs/index.html"/> | |
33 | <item name="Source Xref" href="xref/index.html"/> | |
34 | <!--item name="FAQ" href="faq.html"/--> | |
35 | </menu> | |
36 | ||
37 | <menu name="Document Schema"> | |
38 | <item name="Reference" href="document.html"/> | |
39 | <item name="Using Document Schema" href="using-document-xsd.html"/> | |
40 | <item name="Using RandomAccessSink" href="using-randomaccesssink.html"/> | |
34 | 41 | </menu> |
35 | 42 | |
36 | 43 | <menu ref="reports"/> |
77 | 77 | |
78 | 78 | private void verifyModel( DocumentModel model ) |
79 | 79 | { |
80 | assertNotNull( model ); | |
80 | 81 | assertTrue( model.equals( model ) ); |
81 | assertFalse( model.equals( null ) ); | |
82 | 82 | assertTrue ( model.hashCode() != 0 ); |
83 | 83 | assertTrue( model.toString().length() > 0 ); |
84 | 84 |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugstøl</a> |
25 | * @version $Id: IndexEntryTest.java 762694 2009-04-07 11:16:56Z ltheussl $ | |
25 | * @version $Id: IndexEntryTest.java 1172204 2011-09-18 06:46:17Z hboutemy $ | |
26 | 26 | */ |
27 | 27 | public class IndexEntryTest |
28 | 28 | extends TestCase |
58 | 58 | assertIndexEntry( chapter2, root, 0, chapter1, null ); |
59 | 59 | |
60 | 60 | chapter2.setTitle( "Title 2" ); |
61 | assertTrue( chapter2.toString().indexOf( "Title 2" ) != -1 ); | |
61 | assertTrue( chapter2.toString().contains( "Title 2" ) ); | |
62 | 62 | } |
63 | 63 | |
64 | 64 | private void assertIndexEntry( IndexEntry entry, IndexEntry parent, int childCount, |
43 | 43 | */ |
44 | 44 | public void testExecute() |
45 | 45 | { |
46 | Map macroParameters = new HashMap(); | |
46 | final Map<String,Object> macroParameters = new HashMap<String,Object>(); | |
47 | 47 | macroParameters.put( "paramName", "paramValue" ); |
48 | 48 | macroParameters.put( "parser", "parserValue" ); |
49 | 49 | macroParameters.put( "sourceContent", "sourceContentValue" ); |
53 | 53 | |
54 | 54 | new EchoMacro().execute( sink, request ); |
55 | 55 | |
56 | Iterator it = sink.getEventList().iterator(); | |
57 | SinkEventElement event = (SinkEventElement) it.next(); | |
56 | Iterator<SinkEventElement> it = sink.getEventList().iterator(); | |
57 | SinkEventElement event = it.next(); | |
58 | 58 | assertEquals( "verbatim", event.getName() ); |
59 | event = (SinkEventElement) it.next(); | |
59 | event = it.next(); | |
60 | 60 | assertEquals( "text", event.getName() ); |
61 | 61 | assertEquals( "echo" + Macro.EOL, (String) event.getArgs()[0] ); |
62 | event = (SinkEventElement) it.next(); | |
62 | event = it.next(); | |
63 | 63 | assertEquals( "text", event.getName() ); |
64 | 64 | assertEquals( "paramName ---> paramValue" + Macro.EOL, (String) event.getArgs()[0] ); |
65 | event = (SinkEventElement) it.next(); | |
65 | event = it.next(); | |
66 | 66 | assertEquals( "verbatim_", event.getName() ); |
67 | 67 | assertFalse( it.hasNext() ); |
68 | 68 | } |
+15
-15
65 | 65 | assertEquals( "verbatim_", ( it.next() ).getName() ); |
66 | 66 | assertFalse( it.hasNext() ); |
67 | 67 | |
68 | assertTrue( snippet.indexOf( "preamble" ) != -1 ); | |
69 | assertTrue( snippet.indexOf( "first snippet" ) != -1 ); | |
70 | assertTrue( snippet.indexOf( "interlude" ) != -1 ); | |
71 | assertTrue( snippet.indexOf( "second snippet" ) != -1 ); | |
72 | assertTrue( snippet.indexOf( "conclusion" ) != -1 ); | |
68 | assertTrue( snippet.contains( "preamble" ) ); | |
69 | assertTrue( snippet.contains( "first snippet" ) ); | |
70 | assertTrue( snippet.contains( "interlude" ) ); | |
71 | assertTrue( snippet.contains( "second snippet" ) ); | |
72 | assertTrue( snippet.contains( "conclusion" ) ); | |
73 | 73 | |
74 | 74 | // again |
75 | 75 | |
87 | 87 | assertEquals( "verbatim_", ( it.next() ).getName() ); |
88 | 88 | assertFalse( it.hasNext() ); |
89 | 89 | |
90 | assertTrue( snippet.indexOf( "preamble" ) == -1 ); | |
91 | assertTrue( snippet.indexOf( "first snippet" ) != -1 ); | |
92 | assertTrue( snippet.indexOf( "interlude" ) == -1 ); | |
93 | assertTrue( snippet.indexOf( "second snippet" ) == -1 ); | |
94 | assertTrue( snippet.indexOf( "conclusion" ) == -1 ); | |
90 | assertFalse( snippet.contains( "preamble" ) ); | |
91 | assertTrue( snippet.contains( "first snippet" ) ); | |
92 | assertFalse( snippet.contains( "interlude" ) ); | |
93 | assertFalse( snippet.contains( "second snippet" ) ); | |
94 | assertFalse( snippet.contains( "conclusion" ) ); | |
95 | 95 | |
96 | 96 | // again |
97 | 97 | |
107 | 107 | snippet = (String) event.getArgs()[0]; |
108 | 108 | assertFalse( it.hasNext() ); |
109 | 109 | |
110 | assertTrue( snippet.indexOf( "preamble" ) == -1 ); | |
111 | assertTrue( snippet.indexOf( "first snippet" ) == -1 ); | |
112 | assertTrue( snippet.indexOf( "interlude" ) == -1 ); | |
113 | assertTrue( snippet.indexOf( "second snippet" ) != -1 ); | |
114 | assertTrue( snippet.indexOf( "conclusion" ) == -1 ); | |
110 | assertFalse( snippet.contains( "preamble" ) ); | |
111 | assertFalse( snippet.contains( "first snippet" ) ); | |
112 | assertFalse( snippet.contains( "interlude" ) ); | |
113 | assertTrue( snippet.contains( "second snippet" ) ); | |
114 | assertFalse( snippet.contains( "conclusion" ) ); | |
115 | 115 | } |
116 | 116 | } |
39 | 39 | * Test toc macro. |
40 | 40 | * |
41 | 41 | * @author ltheussl |
42 | * @version $Id: TocMacroTest.java 1091043 2011-04-11 11:44:39Z ltheussl $ | |
42 | * @version $Id: TocMacroTest.java 1172204 2011-09-18 06:46:17Z hboutemy $ | |
43 | 43 | */ |
44 | 44 | public class TocMacroTest |
45 | 45 | extends TestCase |
171 | 171 | TocMacro macro = new TocMacro(); |
172 | 172 | macro.execute( sink, request ); |
173 | 173 | |
174 | assertTrue( out.toString().indexOf( "<a href=\"#h21\">h21</a>" ) != -1 ); | |
175 | assertTrue( out.toString().indexOf( "<a href=\"#h22\">h22</a>" ) != -1 ); | |
176 | assertTrue( out.toString().indexOf( "<a href=\"#h3\">h3</a>" ) != -1 ); | |
174 | assertTrue( out.toString().contains( "<a href=\"#h21\">h21</a>" ) ); | |
175 | assertTrue( out.toString().contains( "<a href=\"#h22\">h22</a>" ) ); | |
176 | assertTrue( out.toString().contains( "<a href=\"#h3\">h3</a>" ) ); | |
177 | 177 | } |
178 | 178 | } |
31 | 31 | * Test for XhtmlBaseParser. |
32 | 32 | * |
33 | 33 | * @author ltheussl |
34 | * @version $Id: XhtmlBaseParserTest.java 1094965 2011-04-19 09:30:13Z ltheussl $ | |
34 | * @version $Id: XhtmlBaseParserTest.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
35 | 35 | * @since 1.1 |
36 | 36 | */ |
37 | 37 | public class XhtmlBaseParserTest |
50 | 50 | sink.reset(); |
51 | 51 | } |
52 | 52 | |
53 | /** Test Doxia version. */ | |
53 | 54 | public void testDoxiaVersion() |
54 | 55 | { |
55 | 56 | assertNotNull( XhtmlBaseParser.doxiaVersion() ); |
318 | 319 | public void testDoxia250() |
319 | 320 | throws Exception |
320 | 321 | { |
321 | StringBuffer sb = new StringBuffer(); | |
322 | StringBuilder sb = new StringBuilder(); | |
322 | 323 | sb.append( "<!DOCTYPE test [" ).append( XhtmlBaseParser.EOL ); |
323 | 324 | sb.append( "<!ENTITY foo \"ř\">" ).append( XhtmlBaseParser.EOL ); |
324 | 325 | sb.append( "<!ENTITY foo1 \" \">" ).append( XhtmlBaseParser.EOL ); |
0 | package org.apache.maven.doxia.sink; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | /** | |
22 | * @author Robert Scholte | |
23 | */ | |
24 | import java.io.ByteArrayOutputStream; | |
25 | import java.io.Writer; | |
26 | ||
27 | import junit.framework.TestCase; | |
28 | ||
29 | public class RandomAccessSinkTest | |
30 | extends TestCase | |
31 | { | |
32 | private SinkFactory factory = new AbstractXmlSinkFactory() | |
33 | { | |
34 | ||
35 | protected Sink createSink( Writer writer, String encoding, String languageId ) | |
36 | { | |
37 | return new TextSink( writer ); | |
38 | } | |
39 | ||
40 | protected Sink createSink( Writer writer, String encoding ) | |
41 | { | |
42 | return new TextSink( writer ); | |
43 | } | |
44 | }; | |
45 | ||
46 | private void buildSimple( Sink sink, String text ) | |
47 | throws Exception | |
48 | { | |
49 | sink.anchor( "foobar" ); | |
50 | sink.text( text ); | |
51 | sink.anchor_(); | |
52 | } | |
53 | ||
54 | public void testSimple() | |
55 | throws Exception | |
56 | { | |
57 | String encoding = "UTF-8"; | |
58 | String text = "Hello World"; | |
59 | ByteArrayOutputStream outFlatSink = new ByteArrayOutputStream(); | |
60 | Sink flatSink = factory.createSink( outFlatSink, encoding ); | |
61 | buildSimple( flatSink, text ); | |
62 | flatSink.flush(); | |
63 | flatSink.close(); | |
64 | ||
65 | ByteArrayOutputStream outRandomAccessSink = new ByteArrayOutputStream(); | |
66 | RandomAccessSink randomAccessSink = new RandomAccessSink( factory, outRandomAccessSink, encoding ); | |
67 | buildSimple( randomAccessSink, text ); | |
68 | randomAccessSink.flush(); | |
69 | randomAccessSink.close(); | |
70 | ||
71 | assertEquals( outFlatSink.toString( encoding ), outRandomAccessSink.toString( encoding ) ); | |
72 | } | |
73 | ||
74 | public void testComplex() | |
75 | throws Exception | |
76 | { | |
77 | String encoding = "UTF-8"; | |
78 | String summaryText = "Summary text"; | |
79 | String detailText = "Detail text"; | |
80 | ByteArrayOutputStream outFlatSink = new ByteArrayOutputStream(); | |
81 | Sink flatSink = factory.createSink( outFlatSink, encoding ); | |
82 | buildSimple( flatSink, summaryText ); | |
83 | flatSink.horizontalRule(); | |
84 | buildSimple( flatSink, detailText ); | |
85 | flatSink.flush(); | |
86 | flatSink.close(); | |
87 | ||
88 | ByteArrayOutputStream outRandomAccessSink = new ByteArrayOutputStream(); | |
89 | RandomAccessSink randomAccessSink = new RandomAccessSink( factory, outRandomAccessSink, encoding ); | |
90 | Sink summarySink = randomAccessSink.addSinkHook(); | |
91 | randomAccessSink.horizontalRule(); | |
92 | Sink detailSink = randomAccessSink.addSinkHook(); | |
93 | ||
94 | // here's an example of the strength of randomAccessSink. Summary and detail are built in reverse order | |
95 | buildSimple( detailSink, detailText ); | |
96 | buildSimple( summarySink, summaryText ); | |
97 | ||
98 | randomAccessSink.flush(); | |
99 | randomAccessSink.close(); | |
100 | ||
101 | assertEquals( outFlatSink.toString( encoding ), outRandomAccessSink.toString( encoding ) ); | |
102 | } | |
103 | }⏎ |
+2
-2
28 | 28 | * the input of some parser is well-formed. |
29 | 29 | * |
30 | 30 | * @author <a href="mailto:lars@trieloff.net">Lars Trieloff</a> |
31 | * @version $Id: WellformednessCheckingSink.java 1091043 2011-04-11 11:44:39Z ltheussl $ | |
31 | * @version $Id: WellformednessCheckingSink.java 1185112 2011-10-17 11:33:00Z ltheussl $ | |
32 | 32 | */ |
33 | 33 | public class WellformednessCheckingSink |
34 | 34 | extends AbstractSink |
586 | 586 | */ |
587 | 587 | public boolean isWellformed() |
588 | 588 | { |
589 | return errors.size() == 0; | |
589 | return errors.isEmpty(); | |
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
21 | 21 | import java.io.StringWriter; |
22 | 22 | import java.io.Writer; |
23 | 23 | |
24 | import javax.swing.text.html.HTML.Attribute; | |
25 | ||
24 | 26 | import org.codehaus.plexus.PlexusTestCase; |
25 | 27 | |
26 | 28 | /** |
27 | 29 | * Test for XhtmlBaseSink. |
28 | 30 | * |
29 | 31 | * @author ltheussl |
30 | * @version $Id: XhtmlBaseSinkTest.java 1091043 2011-04-11 11:44:39Z ltheussl $ | |
32 | * @version $Id: XhtmlBaseSinkTest.java 1185529 2011-10-18 08:27:44Z ltheussl $ | |
31 | 33 | * @since 1.1 |
32 | 34 | */ |
33 | 35 | public class XhtmlBaseSinkTest |
34 | 36 | extends PlexusTestCase |
35 | 37 | { |
36 | private final SinkEventAttributes attributes = | |
37 | new SinkEventAttributeSet( new String[] {SinkEventAttributes.STYLE, "bold"} ); | |
38 | private final SinkEventAttributes attributes = SinkEventAttributeSet.BOLD; | |
38 | 39 | private XhtmlBaseSink sink; |
39 | 40 | private Writer writer; |
40 | 41 | |
210 | 211 | } |
211 | 212 | |
212 | 213 | /** |
214 | * Test of section method, of class XhtmlBaseSink. | |
215 | */ | |
216 | public void testSectionAttributes() | |
217 | { | |
218 | final int level = XhtmlBaseSink.SECTION_LEVEL_1; | |
219 | final SinkEventAttributeSet set = new SinkEventAttributeSet( | |
220 | new String[] {"name", "section name", "class", "foo", "id", "bar"} ); | |
221 | ||
222 | try | |
223 | { | |
224 | sink = new XhtmlBaseSink( writer ); | |
225 | ||
226 | sink.section( level, set ); | |
227 | sink.sectionTitle( level, null ); | |
228 | sink.sectionTitle_( level ); | |
229 | sink.section_( level ); | |
230 | } | |
231 | finally | |
232 | { | |
233 | sink.close(); | |
234 | } | |
235 | ||
236 | assertEquals( "<div class=\"foo\" id=\"bar\"><h2></h2></div>", writer.toString() ); | |
237 | } | |
238 | ||
239 | /** | |
213 | 240 | * Test of section1 method, of class XhtmlBaseSink. |
214 | 241 | */ |
215 | 242 | public void testSection1() |
552 | 579 | |
553 | 580 | assertEquals( "<div class=\"source\"><pre></pre></div>", writer.toString() ); |
554 | 581 | |
582 | checkVerbatimAttributes( attributes, "<div><pre style=\"bold\"></pre></div>" ); | |
583 | ||
584 | final SinkEventAttributes att = | |
585 | new SinkEventAttributeSet( new String[] {SinkEventAttributes.ID, "id"} ); | |
586 | checkVerbatimAttributes( att, "<div><pre id=\"id\"></pre></div>" ); | |
587 | ||
588 | att.addAttribute( Attribute.CLASS, "class" ); | |
589 | checkVerbatimAttributes( att, "<div><pre id=\"id\" class=\"class\"></pre></div>" ); | |
590 | ||
591 | att.addAttribute( SinkEventAttributes.DECORATION, "boxed" ); | |
592 | checkVerbatimAttributes( att, "<div class=\"source\"><pre id=\"id\" class=\"class\"></pre></div>" ); | |
593 | ||
594 | att.removeAttribute( Attribute.CLASS.toString() ); | |
595 | checkVerbatimAttributes( att, "<div class=\"source\"><pre id=\"id\"></pre></div>" ); | |
596 | } | |
597 | ||
598 | private void checkVerbatimAttributes( final SinkEventAttributes att, final String expected ) | |
599 | { | |
600 | ||
555 | 601 | writer = new StringWriter(); |
556 | 602 | |
557 | 603 | try |
558 | 604 | { |
559 | 605 | sink = new XhtmlBaseSink( writer ); |
560 | 606 | |
561 | sink.verbatim( attributes ); | |
607 | sink.verbatim( att ); | |
562 | 608 | sink.verbatim_(); |
563 | 609 | } |
564 | 610 | finally |
566 | 612 | sink.close(); |
567 | 613 | } |
568 | 614 | |
569 | assertEquals( "<div style=\"bold\"><pre style=\"bold\"></pre></div>", writer.toString() ); | |
615 | assertEquals( expected, writer.toString() ); | |
570 | 616 | } |
571 | 617 | |
572 | 618 | /** |
923 | 969 | |
924 | 970 | String result = writer.toString(); |
925 | 971 | |
926 | assertTrue( result.indexOf( "ex.js?v=l&l=e" ) != -1 ); | |
927 | assertTrue( result.indexOf( "ex.jpg?v=l&l=e" ) != -1 ); | |
972 | assertTrue( result.contains( "ex.js?v=l&l=e" ) ); | |
973 | assertTrue( result.contains( "ex.jpg?v=l&l=e" ) ); | |
928 | 974 | } |
929 | 975 | |
930 | 976 | /** |
947 | 993 | |
948 | 994 | assertEquals( "a text '𝟭'", writer.toString() ); |
949 | 995 | } |
996 | ||
997 | /** | |
998 | * Test unicode chracters in tables. DOXIA-433. | |
999 | */ | |
1000 | public void testSpecialCharacters() | |
1001 | { | |
1002 | try | |
1003 | { | |
1004 | sink = new XhtmlBaseSink( writer ); | |
1005 | sink.table( null ); | |
1006 | sink.tableRows( null, true ); | |
1007 | sink.tableRow( null ); | |
1008 | sink.tableCell(); | |
1009 | sink.text( "\u2713", null ); | |
1010 | sink.tableCell_(); | |
1011 | sink.tableRow_(); | |
1012 | sink.tableRows_(); | |
1013 | sink.table_(); | |
1014 | } | |
1015 | finally | |
1016 | { | |
1017 | sink.close(); | |
1018 | } | |
1019 | ||
1020 | final String result = writer.toString(); | |
1021 | ||
1022 | assertTrue( result.contains( "✓" ) ); | |
1023 | } | |
950 | 1024 | } |
67 | 67 | */ |
68 | 68 | protected boolean isFailErrorMessage( String message ) |
69 | 69 | { |
70 | if ( message.indexOf( "schema_reference.4: Failed to read schema document 'http://www.w3.org/2001/xml.xsd'" ) == -1 | |
71 | && message.indexOf( "cvc-complex-type.4: Attribute 'alt' must appear on element 'img'." ) == -1 | |
72 | && message.indexOf( "cvc-complex-type.2.4.a: Invalid content starting with element" ) == -1 | |
73 | && message.indexOf( "cvc-complex-type.2.4.a: Invalid content was found starting with element" ) == -1 | |
74 | && message.indexOf( "cvc-datatype-valid.1.2.1:" ) == -1 // Doxia allow space | |
75 | && message.indexOf( "cvc-attribute.3:" ) == -1 ) // Doxia allow space | |
76 | { | |
77 | return true; | |
78 | } | |
79 | ||
80 | return false; | |
70 | return !( message.contains( "schema_reference.4: Failed to read schema document 'http://www.w3.org/2001/xml.xsd'" ) | |
71 | || message.contains( "cvc-complex-type.4: Attribute 'alt' must appear on element 'img'." ) | |
72 | || message.contains( "cvc-complex-type.2.4.a: Invalid content starting with element" ) | |
73 | || message.contains( "cvc-complex-type.2.4.a: Invalid content was found starting with element" ) | |
74 | || message.contains( "cvc-datatype-valid.1.2.1:" ) // Doxia allow space | |
75 | || message.contains( "cvc-attribute.3:" ) ); // Doxia allow space | |
81 | 76 | } |
82 | 77 | |
83 | 78 | @Override |
48 | 48 | * Abstract class to validate XML files with DTD or XSD mainly for Doxia namespaces. |
49 | 49 | * |
50 | 50 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
51 | * @version $Id: AbstractXmlValidatorTest.java 1091387 2011-04-12 12:46:05Z ltheussl $ | |
51 | * @version $Id: AbstractXmlValidatorTest.java 1172204 2011-09-18 06:46:17Z hboutemy $ | |
52 | 52 | * @since 1.0 |
53 | 53 | */ |
54 | 54 | public abstract class AbstractXmlValidatorTest |
190 | 190 | { |
191 | 191 | File file = new File( it.next().toString() ); |
192 | 192 | |
193 | if ( file.getAbsolutePath().indexOf( "META-INF" ) != -1 ) | |
193 | if ( file.getAbsolutePath().contains( "META-INF" ) ) | |
194 | 194 | { |
195 | 195 | continue; |
196 | 196 | } |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"> | |
24 | 25 | |
25 | 26 | <body> |
26 | 27 | |
27 | 28 | <menu ref="parent"/> |
29 | ||
30 | <menu name="Overview"> | |
31 | <item name="Introduction" href="index.html"/> | |
32 | <item name="JavaDocs" href="apidocs/index.html"/> | |
33 | <item name="Source Xref" href="xref/index.html"/> | |
34 | <!--item name="FAQ" href="faq.html"/--> | |
35 | </menu> | |
28 | 36 | |
29 | 37 | <menu ref="reports"/> |
30 | 38 |
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | ||
2 | <!-- | |
3 | Licensed to the Apache Software Foundation (ASF) under one | |
4 | or more contributor license agreements. See the NOTICE file | |
5 | distributed with this work for additional information | |
6 | regarding copyright ownership. The ASF licenses this file | |
7 | to you under the Apache License, Version 2.0 (the | |
8 | "License"); you may not use this file except in compliance | |
9 | with the License. You may obtain a copy of the License at | |
10 | ||
11 | http://www.apache.org/licenses/LICENSE-2.0 | |
12 | ||
13 | Unless required by applicable law or agreed to in writing, | |
14 | software distributed under the License is distributed on an | |
15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | KIND, either express or implied. See the License for the | |
17 | specific language governing permissions and limitations | |
18 | under the License. | |
19 | --> | |
20 | ||
21 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
22 | <modelVersion>4.0.0</modelVersion> | |
23 | ||
24 | <parent> | |
25 | <groupId>org.apache.maven.doxia</groupId> | |
26 | <artifactId>doxia</artifactId> | |
27 | <version>1.2</version> | |
28 | <relativePath>../pom.xml</relativePath> | |
29 | </parent> | |
30 | ||
31 | <artifactId>doxia-maven-plugin</artifactId> | |
32 | <packaging>maven-plugin</packaging> | |
33 | ||
34 | <name>Doxia :: Maven Plugin</name> | |
35 | <description>A Maven plugin for Doxia.</description> | |
36 | <url>http://maven.apache.org/doxia/doxia/doxia-maven-plugin/</url> | |
37 | ||
38 | <prerequisites> | |
39 | <maven>2.0.2</maven> | |
40 | </prerequisites> | |
41 | ||
42 | <dependencies> | |
43 | <dependency> | |
44 | <groupId>org.apache.maven</groupId> | |
45 | <artifactId>maven-plugin-api</artifactId> | |
46 | <version>2.0</version> | |
47 | </dependency> | |
48 | <dependency> | |
49 | <groupId>${project.groupId}</groupId> | |
50 | <artifactId>doxia-book</artifactId> | |
51 | <version>${projectVersion}</version> | |
52 | </dependency> | |
53 | <dependency> | |
54 | <groupId>${project.groupId}</groupId> | |
55 | <artifactId>doxia-core</artifactId> | |
56 | <version>${projectVersion}</version> | |
57 | </dependency> | |
58 | <dependency> | |
59 | <groupId>${project.groupId}</groupId> | |
60 | <artifactId>doxia-logging-api</artifactId> | |
61 | <version>${projectVersion}</version> | |
62 | </dependency> | |
63 | ||
64 | <!-- doxia modules ordered --> | |
65 | <dependency> | |
66 | <groupId>org.apache.maven.doxia</groupId> | |
67 | <artifactId>doxia-module-apt</artifactId> | |
68 | <version>${projectVersion}</version> | |
69 | </dependency> | |
70 | <dependency> | |
71 | <groupId>org.apache.maven.doxia</groupId> | |
72 | <artifactId>doxia-module-docbook-simple</artifactId> | |
73 | <version>${projectVersion}</version> | |
74 | </dependency> | |
75 | <dependency> | |
76 | <groupId>org.apache.maven.doxia</groupId> | |
77 | <artifactId>doxia-module-itext</artifactId> | |
78 | <version>${projectVersion}</version> | |
79 | </dependency> | |
80 | <dependency> | |
81 | <groupId>org.apache.maven.doxia</groupId> | |
82 | <artifactId>doxia-module-latex</artifactId> | |
83 | <version>${projectVersion}</version> | |
84 | </dependency> | |
85 | <dependency> | |
86 | <groupId>org.apache.maven.doxia</groupId> | |
87 | <artifactId>doxia-module-xdoc</artifactId> | |
88 | <version>${projectVersion}</version> | |
89 | </dependency> | |
90 | <dependency> | |
91 | <groupId>org.apache.maven.doxia</groupId> | |
92 | <artifactId>doxia-module-xhtml</artifactId> | |
93 | <version>${projectVersion}</version> | |
94 | </dependency> | |
95 | ||
96 | <dependency> | |
97 | <groupId>org.codehaus.plexus</groupId> | |
98 | <artifactId>plexus-utils</artifactId> | |
99 | </dependency> | |
100 | <dependency> | |
101 | <groupId>org.apache.maven.shared</groupId> | |
102 | <artifactId>maven-doxia-tools</artifactId> | |
103 | <version>1.0.1</version> | |
104 | <exclusions> | |
105 | <exclusion> | |
106 | <groupId>org.apache.maven.doxia</groupId> | |
107 | <artifactId>doxia-decoration-model</artifactId> | |
108 | </exclusion> | |
109 | </exclusions> | |
110 | </dependency> | |
111 | </dependencies> | |
112 | ||
113 | <build> | |
114 | <pluginManagement> | |
115 | <plugins> | |
116 | <plugin> | |
117 | <groupId>org.apache.maven.plugins</groupId> | |
118 | <artifactId>maven-plugin-plugin</artifactId> | |
119 | <version>2.5.1</version> | |
120 | </plugin> | |
121 | <plugin> | |
122 | <groupId>org.apache.maven.plugins</groupId> | |
123 | <artifactId>maven-shade-plugin</artifactId> | |
124 | <version>1.2.2</version> | |
125 | </plugin> | |
126 | </plugins> | |
127 | </pluginManagement> | |
128 | <plugins> | |
129 | <!-- Backward compatibility with Maven 2.0.x (MNG-3402) --> | |
130 | <plugin> | |
131 | <groupId>org.apache.maven.plugins</groupId> | |
132 | <artifactId>maven-shade-plugin</artifactId> | |
133 | <executions> | |
134 | <execution> | |
135 | <phase>package</phase> | |
136 | <goals> | |
137 | <goal>shade</goal> | |
138 | </goals> | |
139 | <configuration> | |
140 | <finalName>${project.build.finalName}</finalName> | |
141 | <createDependencyReducedPom>false</createDependencyReducedPom> | |
142 | <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope> | |
143 | <transformers> | |
144 | <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" /> | |
145 | </transformers> | |
146 | <artifactSet> | |
147 | <includes> | |
148 | <include>org.apache.maven.doxia:doxia-sink-api</include> | |
149 | <include>org.apache.maven.doxia:doxia-logging-api</include> | |
150 | </includes> | |
151 | </artifactSet> | |
152 | </configuration> | |
153 | </execution> | |
154 | </executions> | |
155 | </plugin> | |
156 | <plugin> | |
157 | <groupId>org.codehaus.mojo</groupId> | |
158 | <artifactId>clirr-maven-plugin</artifactId> | |
159 | <configuration> | |
160 | <comparisonVersion>1.1</comparisonVersion> | |
161 | <excludes> | |
162 | <!-- exclude shaded packages --> | |
163 | <exclude>org/apache/maven/doxia/logging/**</exclude> | |
164 | <exclude>org/apache/maven/doxia/sink/**</exclude> | |
165 | <exclude>org/codehaus/doxia/sink/**</exclude> | |
166 | </excludes> | |
167 | </configuration> | |
168 | </plugin> | |
169 | <plugin> | |
170 | <groupId>org.apache.maven.plugins</groupId> | |
171 | <artifactId>maven-plugin-plugin</artifactId> | |
172 | <executions> | |
173 | <execution> | |
174 | <id>generated-helpmojo</id> | |
175 | <goals> | |
176 | <goal>helpmojo</goal> | |
177 | </goals> | |
178 | </execution> | |
179 | </executions> | |
180 | </plugin> | |
181 | </plugins> | |
182 | </build> | |
183 | ||
184 | <reporting> | |
185 | <plugins> | |
186 | <plugin> | |
187 | <groupId>org.apache.maven.plugins</groupId> | |
188 | <artifactId>maven-plugin-plugin</artifactId> | |
189 | <version>2.5.1</version> | |
190 | </plugin> | |
191 | </plugins> | |
192 | </reporting> | |
193 | </project> |
0 | package org.apache.maven.doxia.plugin; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.util.List; | |
22 | ||
23 | /** | |
24 | * A model for a Book. | |
25 | * | |
26 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
27 | * @version $Id: Book.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
28 | * @since 1.0 | |
29 | */ | |
30 | public class Book | |
31 | { | |
32 | /** Path to the book descriptor file. */ | |
33 | private String descriptor; | |
34 | ||
35 | /** The list of formats to produce. */ | |
36 | private List<Format> formats; | |
37 | ||
38 | /** The base directory of source files. */ | |
39 | private String directory; | |
40 | ||
41 | /** Files to include. */ | |
42 | private List<String> includes; | |
43 | ||
44 | /** Files to exclude. */ | |
45 | private List<String> excludes; | |
46 | ||
47 | /** | |
48 | * Returns the path to the book descriptor file. | |
49 | * | |
50 | * @return the book descriptor file. | |
51 | */ | |
52 | public String getDescriptor() | |
53 | { | |
54 | return descriptor; | |
55 | } | |
56 | ||
57 | /** | |
58 | * Returns the list of {@link Format}s to produce. | |
59 | * | |
60 | * @return the list of formats. | |
61 | */ | |
62 | public List<Format> getFormats() | |
63 | { | |
64 | return formats; | |
65 | } | |
66 | ||
67 | /** | |
68 | * Returns the base directory of source files. | |
69 | * | |
70 | * @return the base directory. | |
71 | */ | |
72 | public String getDirectory() | |
73 | { | |
74 | return directory; | |
75 | } | |
76 | ||
77 | /** | |
78 | * Returns the list of files to include. | |
79 | * | |
80 | * @return the list of files to include. | |
81 | */ | |
82 | public List<String> getIncludes() | |
83 | { | |
84 | return includes; | |
85 | } | |
86 | ||
87 | /** | |
88 | * Returns the list of files to exclude. | |
89 | * | |
90 | * @return the list of files to exclude. | |
91 | */ | |
92 | public List<String> getExcludes() | |
93 | { | |
94 | return excludes; | |
95 | } | |
96 | } |
+0
-314
0 | package org.apache.maven.doxia.plugin; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.book.BookDoxia; | |
22 | import org.apache.maven.doxia.book.BookDoxiaException; | |
23 | import org.apache.maven.doxia.book.InvalidBookDescriptorException; | |
24 | import org.apache.maven.doxia.book.model.BookModel; | |
25 | import org.apache.maven.doxia.book.services.validation.ValidationResult; | |
26 | import org.apache.maven.doxia.tools.SiteTool; | |
27 | import org.apache.maven.plugin.AbstractMojo; | |
28 | import org.apache.maven.plugin.MojoExecutionException; | |
29 | import org.apache.maven.plugin.MojoFailureException; | |
30 | import org.codehaus.plexus.util.FileUtils; | |
31 | import org.codehaus.plexus.util.ReaderFactory; | |
32 | import org.codehaus.plexus.util.StringUtils; | |
33 | ||
34 | import java.io.File; | |
35 | import java.io.IOException; | |
36 | import java.util.List; | |
37 | import java.util.Locale; | |
38 | ||
39 | /** | |
40 | * A Mojo to create books in different output formats. | |
41 | * | |
42 | * @goal render-books | |
43 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
44 | * @version $Id: DoxiaRenderBooksMojo.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
45 | * @since 1.0 | |
46 | */ | |
47 | public class DoxiaRenderBooksMojo | |
48 | extends AbstractMojo | |
49 | { | |
50 | /** System EOL. */ | |
51 | private static final String LINE_SEPARATOR = System.getProperty( "line.separator" ); | |
52 | ||
53 | // ---------------------------------------------------------------------- | |
54 | // Mojo components | |
55 | // ---------------------------------------------------------------------- | |
56 | ||
57 | /** | |
58 | * BookDoxia component | |
59 | * | |
60 | * @component | |
61 | */ | |
62 | private BookDoxia bookDoxia; | |
63 | ||
64 | /** | |
65 | * SiteTool. | |
66 | * | |
67 | * @component | |
68 | */ | |
69 | protected SiteTool siteTool; | |
70 | ||
71 | // ---------------------------------------------------------------------- | |
72 | // Mojo parameters | |
73 | // ---------------------------------------------------------------------- | |
74 | ||
75 | /** | |
76 | * A list of books. | |
77 | * | |
78 | * @parameter | |
79 | * @required | |
80 | */ | |
81 | private List<Book> books; | |
82 | ||
83 | /** | |
84 | * Base directory of the project. | |
85 | * | |
86 | * @parameter default-value="${basedir}" | |
87 | */ | |
88 | private File basedir; | |
89 | ||
90 | /** | |
91 | * Directory containing the generated project docs. | |
92 | * | |
93 | * @parameter default-value="${project.build.directory}/generated-site" | |
94 | */ | |
95 | private File generatedDocs; | |
96 | ||
97 | /** | |
98 | * A comma separated list of locales supported by Maven. The first valid token will be the default Locale | |
99 | * for this instance of the Java Virtual Machine. | |
100 | * | |
101 | * @parameter default-value="${locales}" | |
102 | */ | |
103 | protected String locales; | |
104 | ||
105 | /** | |
106 | * Specifies the input encoding. | |
107 | * | |
108 | * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}" | |
109 | */ | |
110 | private String inputEncoding; | |
111 | ||
112 | /** | |
113 | * Specifies the output encoding. | |
114 | * | |
115 | * @parameter expression="${outputEncoding}" default-value="${project.reporting.outputEncoding}" | |
116 | */ | |
117 | private String outputEncoding; | |
118 | ||
119 | // ---------------------------------------------------------------------- | |
120 | // | |
121 | // ---------------------------------------------------------------------- | |
122 | ||
123 | /** | |
124 | * {@inheritDoc} | |
125 | * | |
126 | * Executes the Mojo. | |
127 | */ | |
128 | public void execute() | |
129 | throws MojoExecutionException, MojoFailureException | |
130 | { | |
131 | for ( Book book : books ) | |
132 | { | |
133 | // ---------------------------------------------------------------------- | |
134 | // Validate | |
135 | // ---------------------------------------------------------------------- | |
136 | ||
137 | if ( StringUtils.isEmpty( book.getDescriptor() ) ) | |
138 | { | |
139 | throw new MojoFailureException( "Invalid configuration: " | |
140 | + "The book is required to have a descriptor set." ); | |
141 | } | |
142 | ||
143 | if ( StringUtils.isEmpty( book.getDirectory() ) ) | |
144 | { | |
145 | throw new MojoFailureException( "Invalid configuration: " | |
146 | + "The book is required to have a directory set." ); | |
147 | } | |
148 | ||
149 | if ( book.getFormats() == null || book.getFormats().size() == 0 ) | |
150 | { | |
151 | throw new MojoFailureException( "Invalid configuration: " | |
152 | + "The book is required to have at least one format set." ); | |
153 | } | |
154 | ||
155 | // ---------------------------------------------------------------------- | |
156 | // | |
157 | // ---------------------------------------------------------------------- | |
158 | ||
159 | File descriptor = new File( basedir, book.getDescriptor() ); | |
160 | ||
161 | String includes; | |
162 | if ( book.getIncludes() != null ) | |
163 | { | |
164 | includes = StringUtils.join( book.getIncludes().iterator(), "," ); | |
165 | } | |
166 | else | |
167 | { | |
168 | includes = "**/*"; | |
169 | } | |
170 | ||
171 | String excludes = ""; | |
172 | ||
173 | if ( book.getExcludes() != null ) | |
174 | { | |
175 | excludes = StringUtils.join( book.getExcludes().iterator(), "," ); | |
176 | } | |
177 | ||
178 | // ---------------------------------------------------------------------- | |
179 | // Find all the files to pass to the renderer. | |
180 | // ---------------------------------------------------------------------- | |
181 | ||
182 | if ( getLog().isDebugEnabled() ) | |
183 | { | |
184 | getLog().debug( "Locating files to include in the book:" ); | |
185 | getLog().debug( "Basedir: " + basedir ); | |
186 | getLog().debug( "Includes: " + includes ); | |
187 | getLog().debug( "Excludes: " + excludes ); | |
188 | } | |
189 | ||
190 | List<File> files; | |
191 | ||
192 | try | |
193 | { | |
194 | files = FileUtils.getFiles( new File( basedir, book.getDirectory() ), includes, excludes ); | |
195 | } | |
196 | catch ( IOException e ) | |
197 | { | |
198 | throw new MojoExecutionException( "Error while looking for input files. " + "Basedir=" | |
199 | + basedir.getAbsolutePath() + ", " + "includes=" + includes + ", " + "excludes=" + excludes, e ); | |
200 | } | |
201 | ||
202 | // ----------------------------------------------------------------------- | |
203 | // Load the model | |
204 | // ----------------------------------------------------------------------- | |
205 | ||
206 | BookModel bookModel; | |
207 | ||
208 | try | |
209 | { | |
210 | bookModel = bookDoxia.loadBook( descriptor ); | |
211 | } | |
212 | catch ( InvalidBookDescriptorException e ) | |
213 | { | |
214 | throw new MojoFailureException( "Invalid book descriptor: " + LINE_SEPARATOR | |
215 | + formatResult( e.getValidationResult() ) ); | |
216 | } | |
217 | catch ( BookDoxiaException e ) | |
218 | { | |
219 | throw new MojoExecutionException( "Error while loading the book descriptor", e ); | |
220 | } | |
221 | ||
222 | // ----------------------------------------------------------------------- | |
223 | // Render the book in all the formats | |
224 | // ----------------------------------------------------------------------- | |
225 | ||
226 | List<Locale> localesList = siteTool.getAvailableLocales( locales ); | |
227 | ||
228 | // Default is first in the list | |
229 | Locale defaultLocale = localesList.get( 0 ); | |
230 | Locale.setDefault( defaultLocale ); | |
231 | ||
232 | for ( Locale locale : localesList ) | |
233 | { | |
234 | for ( Format format : book.getFormats() ) | |
235 | { | |
236 | File outputDirectory = new File( generatedDocs, format.getId() ); | |
237 | File directory = new File( outputDirectory + "/" + locale.toString(), bookModel.getId() ); | |
238 | ||
239 | if ( locale.equals( defaultLocale ) ) | |
240 | { | |
241 | directory = new File( outputDirectory, bookModel.getId() ); | |
242 | } | |
243 | ||
244 | try | |
245 | { | |
246 | bookDoxia.renderBook( bookModel, format.getId(), files, directory, locale, | |
247 | getInputEncoding(), getOutputEncoding() ); | |
248 | } | |
249 | catch ( BookDoxiaException e ) | |
250 | { | |
251 | throw new MojoExecutionException( "Error while generating book in format '" | |
252 | + format.getId() + "'.", e ); | |
253 | } | |
254 | } | |
255 | } | |
256 | } | |
257 | } | |
258 | ||
259 | /** | |
260 | * Gets the input files encoding. | |
261 | * | |
262 | * @return The input files encoding, never <code>null</code>. | |
263 | * @since 1.1 | |
264 | */ | |
265 | protected String getInputEncoding() | |
266 | { | |
267 | return ( inputEncoding == null ) ? ReaderFactory.ISO_8859_1 : inputEncoding; | |
268 | } | |
269 | ||
270 | /** | |
271 | * Gets the effective reporting output files encoding. | |
272 | * | |
273 | * @return The effective reporting output file encoding, never <code>null</code>. | |
274 | * @since 1.1 | |
275 | */ | |
276 | protected String getOutputEncoding() | |
277 | { | |
278 | return ( outputEncoding == null ) ? ReaderFactory.UTF_8 : outputEncoding; | |
279 | } | |
280 | ||
281 | /** | |
282 | * Returns a formatted message of a ValidationResult. | |
283 | * | |
284 | * @param result the ValidationResult to format. | |
285 | * @return the formatted result. | |
286 | */ | |
287 | private String formatResult( ValidationResult result ) | |
288 | { | |
289 | StringBuffer buffer = new StringBuffer(); | |
290 | ||
291 | if ( result.getErrors().size() > 0 ) | |
292 | { | |
293 | buffer.append( "Validation errors:" ); | |
294 | ||
295 | for ( String error : result.getErrors() ) | |
296 | { | |
297 | buffer.append( LINE_SEPARATOR ).append( " " ).append( error ); | |
298 | } | |
299 | } | |
300 | ||
301 | if ( result.getWarnings().size() > 0 ) | |
302 | { | |
303 | buffer.append( "Validation warnings:" ); | |
304 | ||
305 | for ( String error : result.getWarnings() ) | |
306 | { | |
307 | buffer.append( LINE_SEPARATOR ).append( " " ).append( error ); | |
308 | } | |
309 | } | |
310 | ||
311 | return buffer.toString(); | |
312 | } | |
313 | } |
0 | package org.apache.maven.doxia.plugin; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | /** | |
22 | * A model for a supported output format. | |
23 | * | |
24 | * @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugstøl</a> | |
25 | * @version $Id: Format.java 740545 2009-02-04 01:03:50Z vsiveton $ | |
26 | * @since 1.0 | |
27 | */ | |
28 | public class Format | |
29 | { | |
30 | /** A unique identifier for the format. */ | |
31 | private String id; | |
32 | ||
33 | /** | |
34 | * Returns the (unique) identifier of this format. | |
35 | * | |
36 | * @return the identifier. | |
37 | */ | |
38 | public String getId() | |
39 | { | |
40 | return id; | |
41 | } | |
42 | } |
0 | ----- | |
1 | Doxia Maven Plugin | |
2 | ----- | |
3 | Lukas Theussl | |
4 | ----- | |
5 | ||
6 | ~~ Licensed to the Apache Software Foundation (ASF) under one | |
7 | ~~ or more contributor license agreements. See the NOTICE file | |
8 | ~~ distributed with this work for additional information | |
9 | ~~ regarding copyright ownership. The ASF licenses this file | |
10 | ~~ to you under the Apache License, Version 2.0 (the | |
11 | ~~ "License"); you may not use this file except in compliance | |
12 | ~~ with the License. You may obtain a copy of the License at | |
13 | ~~ | |
14 | ~~ http://www.apache.org/licenses/LICENSE-2.0 | |
15 | ~~ | |
16 | ~~ Unless required by applicable law or agreed to in writing, | |
17 | ~~ software distributed under the License is distributed on an | |
18 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
19 | ~~ KIND, either express or implied. See the License for the | |
20 | ~~ specific language governing permissions and limitations | |
21 | ~~ under the License. | |
22 | ||
23 | ~~ NOTE: For help with the syntax of this file, see: | |
24 | ~~ http://maven.apache.org/doxia/references/apt-format.html | |
25 | ||
26 | Introduction | |
27 | ||
28 | Doxia allows you to write books like user manuals and guides in any format supported by Doxia. Combined with the | |
29 | Doxia Book Maven you are able to include the manuals directly in your generated site with links to the off-line | |
30 | friendly formats like XDoc, PDF, RTF and LaTeX. | |
31 | ||
32 | * Goals Overview | |
33 | ||
34 | The Doxia Maven Plugin has one goal: | |
35 | ||
36 | * {{{./render-books-mojo.html}doxia:render-books}} to create books in different output formats. | |
37 | ||
38 | First you need a simple book descriptor which is used to specify the layout of your book, i.e. | |
39 | the ordering of the sections and the names for the chapters. | |
40 | See {{{http://maven.apache.org/doxia/book/index.html}The Book Descriptor Reference}} | |
41 | for a reference to the descriptor. | |
42 | ||
43 | * Usage | |
44 | ||
45 | General instructions on how to use the Doxia Maven Plugin can be found on the {{{./usage.html}usage page}}. Some more | |
46 | specific use cases are described in the examples given below. Last but not least, users occasionally contribute | |
47 | additional examples, tips or errata to the | |
48 | {{{http://docs.codehaus.org/display/MAVENUSER/PDF+Plugin}plugin's wiki page}}. | |
49 | ||
50 | In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel | |
51 | free to contact the {{{./mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could | |
52 | already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching | |
53 | the {{{./mail-lists.html}mail archive}}. | |
54 | ||
55 | If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our | |
56 | {{{./issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your | |
57 | concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, | |
58 | entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. | |
59 | Of course, patches are welcome, too. Contributors can check out the project from our | |
60 | {{{./source-repository.html}source repository}} and will find supplementary information in the | |
61 | {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. | |
62 | ||
63 | * Examples | |
64 | ||
65 | An Xdoc output example which has been rendered into this site can be viewed {{{http://maven.apache.org/doxia/doxia-example-book/index.html}here}}. |
0 | ----- | |
1 | Usage | |
2 | ----- | |
3 | Lukas Theussl | |
4 | ----- | |
5 | ||
6 | Usage | |
7 | ||
8 | Below is a sample pom.xml illustrate how to use it. | |
9 | ||
10 | +------------------------------------------------------ | |
11 | <plugin> | |
12 | <groupId>org.apache.maven.doxia</groupId> | |
13 | <artifactId>doxia-maven-plugin</artifactId> | |
14 | <version>${project.version}</version> | |
15 | <executions> | |
16 | <execution> | |
17 | <phase>pre-site</phase> | |
18 | <goals> | |
19 | <goal>render-books</goal> | |
20 | </goals> | |
21 | </execution> | |
22 | </executions> | |
23 | <configuration> | |
24 | <books> | |
25 | <book> | |
26 | <directory>src/books/example-book</directory> | |
27 | <descriptor>src/books/example-book.xml</descriptor> | |
28 | <formats> | |
29 | <format> | |
30 | <id>latex</id> | |
31 | </format> | |
32 | <format> | |
33 | <id>xdoc</id> | |
34 | </format> | |
35 | <format> | |
36 | <id>pdf</id> | |
37 | </format> | |
38 | <format> | |
39 | <id>rtf</id> | |
40 | </format> | |
41 | </formats> | |
42 | </book> | |
43 | </books> | |
44 | </configuration> | |
45 | </plugin> | |
46 | +------------------------------------------------------ | |
47 | ||
48 | See also the sample given on the main Doxia {{{http://maven.apache.org/doxia/book/index.html}site}}. |
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | ||
2 | <!-- | |
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | --> | |
22 | ||
23 | <project xmlns="http://maven.apache.org/DECORATION/1.0.0" | |
24 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
25 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd" | |
26 | name="Doxia Maven plugin"> | |
27 | ||
28 | <body> | |
29 | ||
30 | <menu ref="parent"/> | |
31 | ||
32 | <menu name="Overview"> | |
33 | <item name="Introduction" href="index.html"/> | |
34 | <item name="Goals" href="plugin-info.html"/> | |
35 | <item name="Usage" href="usage.html"/> | |
36 | <!--<item name="FAQ" href="faq.html"/>--> | |
37 | </menu> | |
38 | ||
39 | <menu ref="reports"/> | |
40 | ||
41 | </body> | |
42 | ||
43 | </project> |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
+2
-1
47 | 47 | * <br/> |
48 | 48 | * Based on the <a href="http://www.xmlmind.com/aptconvert.html">APTconvert</a> project. |
49 | 49 | * |
50 | * @version $Id: AptParser.java 1096107 2011-04-23 06:22:09Z ltheussl $ | |
50 | * @version $Id: AptParser.java 1137879 2011-06-21 06:48:28Z ltheussl $ | |
51 | 51 | * @since 1.0 |
52 | 52 | * @plexus.component role="org.apache.maven.doxia.parser.Parser" role-hint="apt" |
53 | 53 | */ |
2481 | 2481 | cellLine = replaceAll( cellLine, "\\u00A0>", "\\>" ); |
2482 | 2482 | cellLine = replaceAll( cellLine, "\\u00A0{", "\\{" ); |
2483 | 2483 | cellLine = replaceAll( cellLine, "\\u00A0}", "\\}" ); |
2484 | cellLine = replaceAll( cellLine, "\\u00A0u", "\\u" ); | |
2484 | 2485 | cellLine = replaceAll( cellLine, "\\u00A0\\u00A0", "\\\\" ); |
2485 | 2486 | cellLine = cellLine.trim(); |
2486 | 2487 |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="APT" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="APT"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
29 | 37 | |
30 | 38 | <menu ref="reports"/> |
31 | 39 |
+17
-10
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
40 | * @version $Id: AptParserTest.java 1096107 2011-04-23 06:22:09Z ltheussl $ | |
40 | * @version $Id: AptParserTest.java 1137879 2011-06-21 06:48:28Z ltheussl $ | |
41 | 41 | */ |
42 | 42 | public class AptParserTest |
43 | 43 | extends AbstractParserTest |
568 | 568 | public void testSpecialCharactersInTables() |
569 | 569 | throws Exception |
570 | 570 | { |
571 | // DOXIA-323 | |
571 | // DOXIA-323, DOXIA-433 | |
572 | 572 | String text = |
573 | " \\~ \\= \\- \\+ \\* \\[ \\] \\< \\> \\{ \\} \\\\" + EOL | |
573 | " \\~ \\= \\- \\+ \\* \\[ \\] \\< \\> \\{ \\} \\\\ \\u2713" + EOL | |
574 | 574 | + EOL |
575 | 575 | + "*--------------------------------------------------+---------------+" + EOL |
576 | + "| \\~ \\= \\- \\+ \\* \\[ \\] \\< \\> \\{ \\} \\\\ | special chars |" + EOL | |
576 | + "| \\~ \\= \\- \\+ \\* \\[ \\] \\< \\> \\{ \\} \\\\ \\u2713 | special chars |" + EOL | |
577 | 577 | + "*--------------------------------------------------+---------------+"; |
578 | 578 | |
579 | 579 | SinkEventTestingSink sink = new SinkEventTestingSink(); |
588 | 588 | assertEquals( "paragraph", ( it.next() ).getName() ); |
589 | 589 | SinkEventElement event = it.next(); |
590 | 590 | assertEquals( "text", event.getName() ); |
591 | assertEquals( "~ = - + * [ ] < > { } \\", event.getArgs()[0] ); | |
591 | assertEquals( "~ = - + * [ ] < > { } \\ \u2713", event.getArgs()[0] ); | |
592 | 592 | assertEquals( "paragraph_", ( it.next() ).getName() ); |
593 | 593 | |
594 | 594 | assertEquals( "table", ( it.next() ).getName() ); |
598 | 598 | |
599 | 599 | event = it.next(); |
600 | 600 | assertEquals( "text", event.getName() ); |
601 | assertEquals( "~ = - + * [ ] < > { } \\", event.getArgs()[0] ); | |
602 | assertEquals( "tableCell_", ( it.next() ).getName() ); | |
603 | assertEquals( "tableCell", ( it.next() ).getName() ); | |
604 | assertEquals( "text", ( it.next() ).getName() ); | |
605 | assertEquals( "tableCell_", ( it.next() ).getName() ); | |
601 | assertEquals( "~ = - + * [ ] < > { } \\ \u2713", event.getArgs()[0] ); | |
602 | assertEquals( "tableCell_", ( it.next() ).getName() ); | |
603 | assertEquals( "tableCell", ( it.next() ).getName() ); | |
604 | assertEquals( "text", ( it.next() ).getName() ); | |
605 | assertEquals( "tableCell_", ( it.next() ).getName() ); | |
606 | assertEquals( "tableRow_", ( it.next() ).getName() ); | |
607 | ||
608 | assertEquals( "tableRows_", ( it.next() ).getName() ); | |
609 | assertEquals( "table_", ( it.next() ).getName() ); | |
610 | assertEquals( "body_", ( it.next() ).getName() ); | |
611 | ||
612 | assertFalse( it.hasNext() ); | |
606 | 613 | } |
607 | 614 | |
608 | 615 | /** @throws Exception */ |
22 | 22 | <parent> |
23 | 23 | <artifactId>doxia-modules</artifactId> |
24 | 24 | <groupId>org.apache.maven.doxia</groupId> |
25 | <version>1.2</version> | |
25 | <version>1.3</version> | |
26 | 26 | <relativePath>../pom.xml</relativePath> |
27 | 27 | </parent> |
28 | 28 |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="Confluence" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="Confluence"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
29 | 37 | |
30 | 38 | <menu ref="reports"/> |
31 | 39 |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
0 | ----- | |
1 | Doxia Docbook-Simple | |
2 | ----- | |
3 | Benson I. Margulies | |
4 | ------ | |
5 | 2011-09-13 | |
6 | ------ | |
7 | ||
8 | A Doxia module for Simplified DocBook documents. DocBook format is supported both as source and target formats. | |
9 | ||
10 | This module is not configured, by default, in the maven-site-plugin. To use this module in the | |
11 | site plugin, you must explicitly configure it as a dependency in your pom.xml, as in the following example: | |
12 | ||
13 | +--------------------------------- | |
14 | ||
15 | <plugin> | |
16 | <groupId>org.apache.maven.plugins</groupId> | |
17 | <artifactId>maven-site-plugin</artifactId> | |
18 | <version>3.0</version> | |
19 | <configuration> | |
20 | <chmod>true</chmod> | |
21 | <inputEncoding>UTF-8</inputEncoding> | |
22 | <outputEncoding>UTF-8</outputEncoding> | |
23 | </configuration> | |
24 | <dependencies> | |
25 | <dependency> | |
26 | <groupId>org.apache.maven.doxia</groupId> | |
27 | <artifactId>doxia-module-docbook-simple</artifactId> | |
28 | <version>${project.version}</version> | |
29 | </dependency> | |
30 | </dependencies> | |
31 | </plugin> | |
32 | +--------------------------------- |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="Simplified Docbook" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="Simplified Docbook"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
29 | 37 | |
30 | 38 | <menu ref="reports"/> |
31 | 39 |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="FML" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="FML"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
29 | 30 | |
30 | <menu name="Schema FML 1.0.1"> | |
31 | <item name="Reference of Schema FML" href="xsddoc/index.html"/> | |
32 | <item name="Using Schema FML" href="using-fml-xsd.html"/> | |
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
37 | ||
38 | <menu name="FML Schema"> | |
39 | <item name="Reference" href="xsddoc/index.html"/> | |
40 | <item name="Using FML Schema" href="using-fml-xsd.html"/> | |
33 | 41 | </menu> |
34 | 42 | |
35 | 43 | <menu ref="reports"/> |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
85 | 85 | </xsl:attribute-set> |
86 | 86 | <xsl:attribute-set name="base.pre.style"> |
87 | 87 | <xsl:attribute name="font-family">monospace</xsl:attribute> |
88 | <xsl:attribute name="linefeed-treatment">preserve</xsl:attribute> | |
89 | <xsl:attribute name="wrap-option">no-wrap</xsl:attribute> | |
90 | <xsl:attribute name="keep-together">always</xsl:attribute> | |
91 | <xsl:attribute name="white-space-collapse">false</xsl:attribute> | |
88 | 92 | </xsl:attribute-set> |
89 | 93 | |
90 | 94 | <xsl:attribute-set name="italic"> |
112 | 116 | <xsl:attribute name="end-indent">inherited-property-value(end-indent) + 1em</xsl:attribute> |
113 | 117 | </xsl:attribute-set> |
114 | 118 | <xsl:attribute-set name="body.source" use-attribute-sets="body.pre"> |
115 | <xsl:attribute name="wrap-option">no-wrap</xsl:attribute> | |
116 | <xsl:attribute name="keep-together">always</xsl:attribute> | |
117 | <xsl:attribute name="white-space-collapse">false</xsl:attribute> | |
118 | 119 | <xsl:attribute name="color">black</xsl:attribute> |
119 | 120 | <xsl:attribute name="border-style">solid</xsl:attribute> |
120 | 121 | <xsl:attribute name="border-width">0.5pt</xsl:attribute> |
325 | 326 | <xsl:attribute name="text-align">center</xsl:attribute> |
326 | 327 | </xsl:attribute-set> |
327 | 328 | <xsl:attribute-set name="figure.graphics"> |
328 | <xsl:attribute name="height">auto</xsl:attribute> | |
329 | <xsl:attribute name="width">auto</xsl:attribute> | |
330 | <xsl:attribute name="content-height">auto</xsl:attribute> | |
331 | <xsl:attribute name="content-width">auto</xsl:attribute> | |
329 | <xsl:attribute name="height">100%</xsl:attribute> | |
330 | <xsl:attribute name="width">100%</xsl:attribute> | |
331 | <xsl:attribute name="content-height">scale-down-to-fit</xsl:attribute> | |
332 | <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute> | |
332 | 333 | </xsl:attribute-set> |
333 | 334 | <xsl:attribute-set name="figure.caption" use-attribute-sets="base.body.style"> |
334 | 335 | <xsl:attribute name="keep-with-previous">always</xsl:attribute> |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="FO" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="FO"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
31 | 32 | <item name="Overview" href="index.html"/> |
32 | 33 | <item name="Usage" href="usage.html"/> |
33 | 34 | <item name="Links" href="links.html"/> |
35 | <item name="JavaDocs" href="apidocs/index.html"/> | |
36 | <item name="Source Xref" href="xref/index.html"/> | |
37 | <!--item name="FAQ" href="faq.html"/--> | |
34 | 38 | </menu> |
35 | 39 | |
36 | 40 | <menu ref="reports"/> |
+6
-7
26 | 26 | /** |
27 | 27 | * FoConfiguration tests. |
28 | 28 | * |
29 | * @version $Id: FoConfigurationTest.java 806502 2009-08-21 11:33:25Z vsiveton $ | |
29 | * @version $Id: FoConfigurationTest.java 1125262 2011-05-20 07:23:00Z ltheussl $ | |
30 | 30 | */ |
31 | 31 | public class FoConfigurationTest |
32 | 32 | extends TestCase |
42 | 42 | assertEquals( "Non existent attribute ID should return empty string!", "", |
43 | 43 | config.getAttributeString( "a.dummy.attribute" ) ); |
44 | 44 | |
45 | assertEquals( "Wrong attributes returned for body.pre!", " font-family=\"monospace\" font-size=\"10pt\"", | |
46 | config.getAttributeString( "body.pre" ) ); | |
45 | assertEquals( "Wrong attributes returned for italic!", " font-style=\"italic\"", | |
46 | config.getAttributeString( "italic" ) ); | |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** Tests the getAttributeSet( String ) method. */ |
59 | 59 | config.getAttributeSet( "a.dummy.attribute" ) ); |
60 | 60 | |
61 | 61 | MutableAttributeSet expected = new SimpleAttributeSet(); |
62 | expected.addAttribute( "font-size", "10pt" ); | |
63 | expected.addAttribute( "font-family", "monospace" ); | |
64 | MutableAttributeSet actual = config.getAttributeSet( "body.pre" ); | |
62 | expected.addAttribute( "font-style", "italic" ); | |
63 | MutableAttributeSet actual = config.getAttributeSet( "italic" ); | |
65 | 64 | |
66 | assertTrue( "Wrong AttributeSet returned for body.pre!", expected.isEqual( actual ) ); | |
65 | assertTrue( "Wrong AttributeSet returned for italic!", expected.isEqual( actual ) ); | |
67 | 66 | } |
68 | 67 | |
69 | 68 | } |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="iText" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="iText"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
29 | 37 | |
30 | 38 | <menu ref="reports"/> |
31 | 39 |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="Latex" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="Latex"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
29 | 37 | |
30 | 38 | <menu ref="reports"/> |
31 | 39 |
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | ||
2 | <!-- | |
3 | Licensed to the Apache Software Foundation (ASF) under one | |
4 | or more contributor license agreements. See the NOTICE file | |
5 | distributed with this work for additional information | |
6 | regarding copyright ownership. The ASF licenses this file | |
7 | to you under the Apache License, Version 2.0 (the | |
8 | "License"); you may not use this file except in compliance | |
9 | with the License. You may obtain a copy of the License at | |
10 | ||
11 | http://www.apache.org/licenses/LICENSE-2.0 | |
12 | ||
13 | Unless required by applicable law or agreed to in writing, | |
14 | software distributed under the License is distributed on an | |
15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | KIND, either express or implied. See the License for the | |
17 | specific language governing permissions and limitations | |
18 | under the License. | |
19 | --> | |
20 | ||
21 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
22 | <modelVersion>4.0.0</modelVersion> | |
23 | ||
24 | <parent> | |
25 | <groupId>org.apache.maven.doxia</groupId> | |
26 | <artifactId>doxia-modules</artifactId> | |
27 | <version>1.3</version> | |
28 | <relativePath>../pom.xml</relativePath> | |
29 | </parent> | |
30 | ||
31 | <artifactId>doxia-module-markdown</artifactId> | |
32 | ||
33 | <name>Doxia :: Markdown Module</name> | |
34 | <description> | |
35 | A Doxia module for Markdown source documents. | |
36 | </description> | |
37 | <url>http://maven.apache.org/doxia/doxia/doxia-modules/doxia-module-markdown/</url> | |
38 | ||
39 | <contributors> | |
40 | <contributor> | |
41 | <name>Julien Nicoulaud</name> | |
42 | <email>julien.nicoulaud@gmail.com</email> | |
43 | <timezone>+1</timezone> | |
44 | <url>http://www.twitter.com/nicoulaj</url> | |
45 | </contributor> | |
46 | </contributors> | |
47 | ||
48 | <dependencies> | |
49 | <dependency> | |
50 | <groupId>org.pegdown</groupId> | |
51 | <artifactId>pegdown</artifactId> | |
52 | <version>1.0.2</version> | |
53 | </dependency> | |
54 | <dependency> | |
55 | <groupId>org.apache.maven.doxia</groupId> | |
56 | <artifactId>doxia-module-xhtml</artifactId> | |
57 | </dependency> | |
58 | <dependency> | |
59 | <groupId>org.codehaus.plexus</groupId> | |
60 | <artifactId>plexus-utils</artifactId> | |
61 | </dependency> | |
62 | </dependencies> | |
63 | ||
64 | </project> |
+78
-0
0 | package org.apache.maven.doxia.module.markdown; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.IOException; | |
22 | import java.io.Reader; | |
23 | import java.io.StringReader; | |
24 | ||
25 | import org.apache.maven.doxia.module.xhtml.XhtmlParser; | |
26 | import org.apache.maven.doxia.parser.ParseException; | |
27 | import org.apache.maven.doxia.sink.Sink; | |
28 | ||
29 | import org.codehaus.plexus.util.IOUtil; | |
30 | ||
31 | import org.pegdown.Extensions; | |
32 | import org.pegdown.PegDownProcessor; | |
33 | import org.pegdown.ast.RootNode; | |
34 | ||
35 | /** | |
36 | * Implementation of {@link org.apache.maven.doxia.parser.Parser} for Markdown documents. | |
37 | * <p/> | |
38 | * Defers parsing to the <a href="http://pegdown.org">PegDown library</a>. | |
39 | * | |
40 | * @author Julien Nicoulaud <julien.nicoulaud@gmail.com> | |
41 | * @plexus.component role="org.apache.maven.doxia.parser.Parser" role-hint="markdown" | |
42 | * @since 1.3 | |
43 | */ | |
44 | public class MarkdownParser | |
45 | extends XhtmlParser | |
46 | { | |
47 | ||
48 | /** | |
49 | * The role hint for the {@link MarkdownParser} Plexus component. | |
50 | */ | |
51 | public static final String ROLE_HINT = "markdown"; | |
52 | ||
53 | /** | |
54 | * The {@link PegDownProcessor} used to convert Pegdown documents to HTML. | |
55 | */ | |
56 | protected static final PegDownProcessor PEGDOWN_PROCESSOR = | |
57 | new PegDownProcessor( Extensions.ALL & ~Extensions.HARDWRAPS ); | |
58 | ||
59 | /** | |
60 | * {@inheritDoc} | |
61 | */ | |
62 | @Override | |
63 | public void parse( Reader source, Sink sink ) | |
64 | throws ParseException | |
65 | { | |
66 | try | |
67 | { | |
68 | RootNode rootNode = PEGDOWN_PROCESSOR.parseMarkdown( IOUtil.toString( source ).toCharArray() ); | |
69 | String markdownAsHtml = new MarkdownToDoxiaHtmlSerializer().toHtml( rootNode ); | |
70 | super.parse( new StringReader( "<html><body>" + markdownAsHtml + "</body></html>" ), sink ); | |
71 | } | |
72 | catch ( IOException e ) | |
73 | { | |
74 | throw new ParseException( "Failed reading Markdown source document", e ); | |
75 | } | |
76 | } | |
77 | } |
+52
-0
0 | package org.apache.maven.doxia.module.markdown; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.apache.maven.doxia.module.site.AbstractSiteModule; | |
22 | ||
23 | /** | |
24 | * {@link org.apache.maven.doxia.module.site.SiteModule} for Markdown. | |
25 | * | |
26 | * @author Julien Nicoulaud <julien.nicoulaud@gmail.com> | |
27 | * @plexus.component role="org.apache.maven.doxia.module.site.SiteModule" role-hint="markdown" | |
28 | * @since 1.3 | |
29 | */ | |
30 | public class MarkdownSiteModule | |
31 | extends AbstractSiteModule | |
32 | { | |
33 | ||
34 | /** | |
35 | * The source directory for Markdown files. | |
36 | */ | |
37 | public static final String SOURCE_DIRECTORY = "markdown"; | |
38 | ||
39 | /** | |
40 | * The extension for Markdown files. | |
41 | */ | |
42 | public static final String FILE_EXTENSION = "md"; | |
43 | ||
44 | /** | |
45 | * Build a new instance of {@link MarkdownSiteModule}. | |
46 | */ | |
47 | public MarkdownSiteModule() | |
48 | { | |
49 | super( SOURCE_DIRECTORY, FILE_EXTENSION, MarkdownParser.ROLE_HINT ); | |
50 | } | |
51 | } |
+46
-0
0 | package org.apache.maven.doxia.module.markdown; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import org.pegdown.ToHtmlSerializer; | |
22 | import org.pegdown.ast.VerbatimNode; | |
23 | ||
24 | /** | |
25 | * Custom Markdown to HTML serialization strategy that better matches the | |
26 | * conventions of existing Doxia modules. | |
27 | * | |
28 | * @author Brian Ferris (bdferris@google.com) | |
29 | */ | |
30 | public class MarkdownToDoxiaHtmlSerializer | |
31 | extends ToHtmlSerializer | |
32 | { | |
33 | /** | |
34 | * {@inheritDoc} | |
35 | */ | |
36 | @Override | |
37 | public void visit( VerbatimNode node ) | |
38 | { | |
39 | printer.println().print( "<div class=\"source\"><pre>" ); | |
40 | String text = node.getText(); | |
41 | text = transformVerbatimText( text ); | |
42 | printer.printEncoded( text, this ); | |
43 | printer.print( "</pre></div>" ); | |
44 | } | |
45 | } |
0 | ----- | |
1 | doxia-module-markdown | |
2 | ----- | |
3 | Julien Nicoulaud <julien.nicoulaud@gmail.com> | |
4 | ------ | |
5 | 2011-05-28 | |
6 | ------ | |
7 | ||
8 | ~~ Licensed to the Apache Software Foundation (ASF) under one | |
9 | ~~ or more contributor license agreements. See the NOTICE file | |
10 | ~~ distributed with this work for additional information | |
11 | ~~ regarding copyright ownership. The ASF licenses this file | |
12 | ~~ to you under the Apache License, Version 2.0 (the | |
13 | ~~ "License"); you may not use this file except in compliance | |
14 | ~~ with the License. You may obtain a copy of the License at | |
15 | ~~ | |
16 | ~~ http://www.apache.org/licenses/LICENSE-2.0 | |
17 | ~~ | |
18 | ~~ Unless required by applicable law or agreed to in writing, | |
19 | ~~ software distributed under the License is distributed on an | |
20 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
21 | ~~ KIND, either express or implied. See the License for the | |
22 | ~~ specific language governing permissions and limitations | |
23 | ~~ under the License. | |
24 | ||
25 | ~~ NOTE: For help with the syntax of this file, see: | |
26 | ~~ http://maven.apache.org/doxia/references/apt-format.html | |
27 | ||
28 | doxia-module-markdown | |
29 | ||
30 | Markdown is a popular lightweight markup language, easy to read and easy to write. | |
31 | It is supported by a large panel of websites, text editors/IDEs and converter tools. | |
32 | ||
33 | <<References>> | |
34 | ||
35 | * {{{http://daringfireball.net/projects/markdown}Markdown project website}} | |
36 | ||
37 | * {{{http://en.wikipedia.org/wiki/Markdown}Markdown Wikipedia page}} | |
38 | ||
39 | * {{{http://xbeta.org/wiki/show/Markdown}Markdown wiki}} |
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | ||
2 | <!-- | |
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | --> | |
22 | ||
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="Markdown"> | |
26 | ||
27 | <body> | |
28 | ||
29 | <menu ref="parent"/> | |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
37 | ||
38 | <menu ref="reports"/> | |
39 | ||
40 | </body> | |
41 | ||
42 | </project>⏎ |
+275
-0
0 | package org.apache.maven.doxia.module.markdown; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.io.Reader; | |
22 | ||
23 | import java.util.Iterator; | |
24 | ||
25 | import org.apache.maven.doxia.parser.AbstractParserTest; | |
26 | import org.apache.maven.doxia.parser.ParseException; | |
27 | import org.apache.maven.doxia.parser.Parser; | |
28 | import org.apache.maven.doxia.sink.SinkEventElement; | |
29 | import org.apache.maven.doxia.sink.SinkEventTestingSink; | |
30 | ||
31 | import org.codehaus.plexus.util.IOUtil; | |
32 | ||
33 | /** | |
34 | * Tests for {@link MarkdownParser}. | |
35 | * | |
36 | * @author Julien Nicoulaud <julien.nicoulaud@gmail.com> | |
37 | * @since 1.3 | |
38 | */ | |
39 | public class MarkdownParserTest | |
40 | extends AbstractParserTest | |
41 | { | |
42 | ||
43 | /** | |
44 | * The {@link MarkdownParser} used for the tests. | |
45 | */ | |
46 | protected MarkdownParser parser; | |
47 | ||
48 | /** | |
49 | * {@inheritDoc} | |
50 | */ | |
51 | @Override | |
52 | protected void setUp() throws Exception | |
53 | { | |
54 | super.setUp(); | |
55 | parser = (MarkdownParser) lookup( Parser.ROLE, MarkdownParser.ROLE_HINT ); | |
56 | } | |
57 | ||
58 | /** | |
59 | * {@inheritDoc} | |
60 | */ | |
61 | @Override | |
62 | protected Parser createParser() | |
63 | { | |
64 | return parser; | |
65 | } | |
66 | ||
67 | /** | |
68 | * {@inheritDoc} | |
69 | */ | |
70 | @Override | |
71 | protected String outputExtension() | |
72 | { | |
73 | return MarkdownSiteModule.FILE_EXTENSION; | |
74 | } | |
75 | ||
76 | /** | |
77 | * Assert the paragraph sink event is fired when parsing "paragraph.md". | |
78 | * | |
79 | * @throws Exception if the event list is not correct when parsing the document. | |
80 | */ | |
81 | public void testParagraphSinkEvent() throws Exception | |
82 | { | |
83 | Iterator<SinkEventElement> it = parseFileToEventTestingSink( "paragraph" ).getEventList().iterator(); | |
84 | ||
85 | assertEquals( "body", it.next().getName() ); | |
86 | assertEquals( "paragraph", it.next().getName() ); | |
87 | assertEquals( "text", it.next().getName() ); | |
88 | assertEquals( "paragraph_", it.next().getName() ); | |
89 | assertEquals( "body_", it.next().getName() ); | |
90 | ||
91 | assertFalse( it.hasNext() ); | |
92 | } | |
93 | ||
94 | /** | |
95 | * Assert the bold sink event is fired when parsing "bold.md". | |
96 | * | |
97 | * @throws Exception if the event list is not correct when parsing the document. | |
98 | */ | |
99 | public void testBoldSinkEvent() throws Exception | |
100 | { | |
101 | Iterator<SinkEventElement> it = parseFileToEventTestingSink( "bold" ).getEventList().iterator(); | |
102 | ||
103 | assertEquals( "body", it.next().getName() ); | |
104 | assertEquals( "paragraph", it.next().getName() ); | |
105 | assertEquals( "bold", it.next().getName() ); | |
106 | assertEquals( "text", it.next().getName() ); | |
107 | assertEquals( "bold_", it.next().getName() ); | |
108 | assertEquals( "paragraph_", it.next().getName() ); | |
109 | assertEquals( "body_", it.next().getName() ); | |
110 | ||
111 | assertFalse( it.hasNext() ); | |
112 | } | |
113 | ||
114 | /** | |
115 | * Assert the italic sink event is fired when parsing "italic.md". | |
116 | * | |
117 | * @throws Exception if the event list is not correct when parsing the document. | |
118 | */ | |
119 | public void testItalicSinkEvent() throws Exception | |
120 | { | |
121 | Iterator<SinkEventElement> it = parseFileToEventTestingSink( "italic" ).getEventList().iterator(); | |
122 | ||
123 | assertEquals( "body", it.next().getName() ); | |
124 | assertEquals( "paragraph", it.next().getName() ); | |
125 | assertEquals( "italic", it.next().getName() ); | |
126 | assertEquals( "text", it.next().getName() ); | |
127 | assertEquals( "italic_", it.next().getName() ); | |
128 | assertEquals( "paragraph_", it.next().getName() ); | |
129 | assertEquals( "body_", it.next().getName() ); | |
130 | ||
131 | assertFalse( it.hasNext() ); | |
132 | } | |
133 | ||
134 | /** | |
135 | * Assert the code sink event is fired when parsing "code.md". | |
136 | * | |
137 | * @throws Exception if the event list is not correct when parsing the document. | |
138 | */ | |
139 | public void testCodeSinkEvent() throws Exception | |
140 | { | |
141 | Iterator<SinkEventElement> it = parseFileToEventTestingSink( "code" ).getEventList().iterator(); | |
142 | ||
143 | assertEquals( "body", it.next().getName() ); | |
144 | assertEquals( "paragraph", it.next().getName() ); | |
145 | assertEquals( "text", it.next().getName() ); | |
146 | assertEquals( "paragraph_", it.next().getName() ); | |
147 | assertEquals( "text", it.next().getName() ); | |
148 | assertEquals( "verbatim", it.next().getName() ); | |
149 | assertEquals( "text", it.next().getName() ); | |
150 | assertEquals( "verbatim_", it.next().getName() ); | |
151 | assertEquals( "body_", it.next().getName() ); | |
152 | ||
153 | assertFalse( it.hasNext() ); | |
154 | } | |
155 | ||
156 | /** | |
157 | * Assert the image sink event is fired when parsing "image.md". | |
158 | * | |
159 | * @throws Exception if the event list is not correct when parsing the document. | |
160 | */ | |
161 | public void testImageSinkEvent() throws Exception | |
162 | { | |
163 | Iterator<SinkEventElement> it = parseFileToEventTestingSink( "image" ).getEventList().iterator(); | |
164 | ||
165 | assertEquals( "body", it.next().getName() ); | |
166 | assertEquals( "paragraph", it.next().getName() ); | |
167 | assertEquals( "text", it.next().getName() ); | |
168 | assertEquals( "figureGraphics", it.next().getName() ); | |
169 | assertEquals( "text", it.next().getName() ); | |
170 | assertEquals( "paragraph_", it.next().getName() ); | |
171 | assertEquals( "body_", it.next().getName() ); | |
172 | ||
173 | assertFalse( it.hasNext() ); | |
174 | } | |
175 | ||
176 | /** | |
177 | * Assert the link sink event is fired when parsing "link.md". | |
178 | * | |
179 | * @throws Exception if the event list is not correct when parsing the document. | |
180 | */ | |
181 | public void testLinkSinkEvent() throws Exception | |
182 | { | |
183 | Iterator<SinkEventElement> it = parseFileToEventTestingSink( "link" ).getEventList().iterator(); | |
184 | ||
185 | assertEquals( "body", it.next().getName() ); | |
186 | assertEquals( "paragraph", it.next().getName() ); | |
187 | assertEquals( "text", it.next().getName() ); | |
188 | assertEquals( "link", it.next().getName() ); | |
189 | assertEquals( "text", it.next().getName() ); | |
190 | assertEquals( "link_", it.next().getName() ); | |
191 | assertEquals( "text", it.next().getName() ); | |
192 | assertEquals( "paragraph_", it.next().getName() ); | |
193 | assertEquals( "body_", it.next().getName() ); | |
194 | ||
195 | assertFalse( it.hasNext() ); | |
196 | } | |
197 | ||
198 | /** | |
199 | * Assert the list sink event is fired when parsing "list.md". | |
200 | * | |
201 | * @throws Exception if the event list is not correct when parsing the document. | |
202 | */ | |
203 | public void testListSinkEvent() throws Exception | |
204 | { | |
205 | Iterator<SinkEventElement> it = parseFileToEventTestingSink( "list" ).getEventList().iterator(); | |
206 | ||
207 | assertEquals( "body", it.next().getName() ); | |
208 | assertEquals( "list", it.next().getName() ); | |
209 | assertEquals( "text", it.next().getName() ); | |
210 | assertEquals( "listItem", it.next().getName() ); | |
211 | assertEquals( "text", it.next().getName() ); | |
212 | assertEquals( "listItem_", it.next().getName() ); | |
213 | assertEquals( "text", it.next().getName() ); | |
214 | assertEquals( "listItem", it.next().getName() ); | |
215 | assertEquals( "text", it.next().getName() ); | |
216 | assertEquals( "listItem_", it.next().getName() ); | |
217 | assertEquals( "text", it.next().getName() ); | |
218 | assertEquals( "list_", it.next().getName() ); | |
219 | assertEquals( "body_", it.next().getName() ); | |
220 | ||
221 | assertFalse( it.hasNext() ); | |
222 | } | |
223 | ||
224 | /** | |
225 | * Assert the numbered list sink event is fired when parsing "numbered-list.md". | |
226 | * | |
227 | * @throws Exception if the event list is not correct when parsing the document. | |
228 | */ | |
229 | public void testNumberedListSinkEvent() throws Exception | |
230 | { | |
231 | Iterator<SinkEventElement> it = parseFileToEventTestingSink( "numbered-list" ).getEventList().iterator(); | |
232 | ||
233 | assertEquals( "body", it.next().getName() ); | |
234 | assertEquals( "numberedList", it.next().getName() ); | |
235 | assertEquals( "text", it.next().getName() ); | |
236 | assertEquals( "numberedListItem", it.next().getName() ); | |
237 | assertEquals( "text", it.next().getName() ); | |
238 | assertEquals( "numberedListItem_", it.next().getName() ); | |
239 | assertEquals( "text", it.next().getName() ); | |
240 | assertEquals( "numberedListItem", it.next().getName() ); | |
241 | assertEquals( "text", it.next().getName() ); | |
242 | assertEquals( "numberedListItem_", it.next().getName() ); | |
243 | assertEquals( "text", it.next().getName() ); | |
244 | assertEquals( "numberedList_", it.next().getName() ); | |
245 | assertEquals( "body_", it.next().getName() ); | |
246 | ||
247 | assertFalse( it.hasNext() ); | |
248 | } | |
249 | ||
250 | /** | |
251 | * Parse the file and return a {@link SinkEventTestingSink}. | |
252 | * | |
253 | * @param file the file to parse with {@link #parser}. | |
254 | * @return a sink to test parsing events. | |
255 | * @throws ParseException if the document parsing failed. | |
256 | */ | |
257 | protected SinkEventTestingSink parseFileToEventTestingSink( String file ) throws ParseException | |
258 | { | |
259 | Reader reader = null; | |
260 | SinkEventTestingSink sink = null; | |
261 | try | |
262 | { | |
263 | reader = getTestReader( file ); | |
264 | sink = new SinkEventTestingSink(); | |
265 | parser.parse( reader, sink ); | |
266 | } | |
267 | finally | |
268 | { | |
269 | IOUtil.close( reader ); | |
270 | } | |
271 | ||
272 | return sink; | |
273 | } | |
274 | } |
0 | **This is italic text.** |
0 | This is an image: ![example](http://example). |
0 | *This is italic text.* |
0 | This is a [link](http://example). |
0 | This is a paragraph. |
0 | Markdown test document | |
1 | ====================== | |
2 | ||
3 | This document aggregates all test documents of the Pegdown library, it was generated this way: | |
4 | ||
5 | git clone git://github.com/sirthias/pegdown.git | |
6 | for doc in pegdown/src/test/resources/**/*.md; do | |
7 | echo -e "\n\n$doc\n---\n" >> test.md | |
8 | cat $doc >> test.md | |
9 | done | |
10 | ||
11 | ||
12 | pegdown/src/test/resources/docs-php-markdown-todo/Email_auto_links.md | |
13 | --- | |
14 | ||
15 | <michel.fortin@michelf.com> | |
16 | ||
17 | International domain names: <help@tūdaliņ.lv> | |
18 | ||
19 | pegdown/src/test/resources/docs-php-markdown-todo/Emphasis.md | |
20 | --- | |
21 | ||
22 | Combined emphasis: | |
23 | ||
24 | 1. ***test test*** | |
25 | 2. ___test test___ | |
26 | 3. *test **test*** | |
27 | 4. **test *test*** | |
28 | 5. ***test* test** | |
29 | 6. ***test** test* | |
30 | 7. ***test* test** | |
31 | 8. **test *test*** | |
32 | 9. *test **test*** | |
33 | 10. _test __test___ | |
34 | 11. __test _test___ | |
35 | 12. ___test_ test__ | |
36 | 13. ___test__ test_ | |
37 | 14. ___test_ test__ | |
38 | 15. __test _test___ | |
39 | 16. _test __test___ | |
40 | ||
41 | ||
42 | Incorrect nesting: | |
43 | ||
44 | 1. *test **test* test** | |
45 | 2. _test __test_ test__ | |
46 | 3. **test *test** test* | |
47 | 4. __test _test__ test_ | |
48 | 5. *test *test* test* | |
49 | 6. _test _test_ test_ | |
50 | 7. **test **test** test** | |
51 | 8. __test __test__ test__ | |
52 | ||
53 | ||
54 | ||
55 | No emphasis: | |
56 | ||
57 | 1. test* test *test | |
58 | 2. test** test **test | |
59 | 3. test_ test _test | |
60 | 4. test__ test __test | |
61 | ||
62 | ||
63 | ||
64 | Middle-word emphasis (asterisks): | |
65 | ||
66 | 1. *a*b | |
67 | 2. a*b* | |
68 | 3. a*b*c | |
69 | 4. **a**b | |
70 | 5. a**b** | |
71 | 6. a**b**c | |
72 | ||
73 | ||
74 | Middle-word emphasis (underscore): | |
75 | ||
76 | 1. _a_b | |
77 | 2. a_b_ | |
78 | 3. a_b_c | |
79 | 4. __a__b | |
80 | 5. a__b__ | |
81 | 6. a__b__c | |
82 | ||
83 | my_precious_file.txt | |
84 | ||
85 | ||
86 | ## Tricky Cases | |
87 | ||
88 | E**. **Test** TestTestTest | |
89 | ||
90 | E**. **Test** Test Test Test | |
91 | ||
92 | ||
93 | pegdown/src/test/resources/docs-php-markdown-todo/Inline_HTML_(Span).md | |
94 | --- | |
95 | ||
96 | <abbr title="` **Attribute Content Is Not A Code Span** `">ACINACS</abbr> | |
97 | ||
98 | <abbr title="`first backtick!">SB</abbr> | |
99 | <abbr title="`second backtick!">SB</abbr> | |
100 | ||
101 | pegdown/src/test/resources/docs-php-markdown-todo/Ins_and_del.md | |
102 | --- | |
103 | ||
104 | Here is a block tag ins: | |
105 | ||
106 | <ins> | |
107 | <p>Some text</p> | |
108 | </ins> | |
109 | ||
110 | <ins>And here it is inside a paragraph.</ins> | |
111 | ||
112 | And here it is <ins>in the middle of</ins> a paragraph. | |
113 | ||
114 | <del> | |
115 | <p>Some text</p> | |
116 | </del> | |
117 | ||
118 | <del>And here is ins as a paragraph.</del> | |
119 | ||
120 | And here it is <del>in the middle of</del> a paragraph. | |
121 | ||
122 | ||
123 | pegdown/src/test/resources/docs-php-markdown-todo/Links_inline_style.md | |
124 | --- | |
125 | ||
126 | [silly URL w/ angle brackets](<?}]*+|&)>). | |
127 | ||
128 | ||
129 | pegdown/src/test/resources/docs-php-markdown-todo/Nesting.md | |
130 | --- | |
131 | ||
132 | Valid nesting: | |
133 | ||
134 | **[Link](url)** | |
135 | ||
136 | [**Link**](url) | |
137 | ||
138 | **[**Link**](url)** | |
139 | ||
140 | ||
141 | pegdown/src/test/resources/docs-php-markdown-todo/Parens_in_URL.md | |
142 | --- | |
143 | ||
144 | [Inline link 1 with parens](/url\(test\) "title"). | |
145 | ||
146 | [Inline link 2 with parens](</url\(test\)> "title"). | |
147 | ||
148 | [Inline link 3 with non-escaped parens](/url(test) "title"). | |
149 | ||
150 | [Inline link 4 with non-escaped parens](</url(test)> "title"). | |
151 | ||
152 | [Reference link 1 with parens][1]. | |
153 | ||
154 | [Reference link 2 with parens][2]. | |
155 | ||
156 | [1]: /url(test) "title" | |
157 | [2]: </url(test)> "title" | |
158 | ||
159 | ||
160 | pegdown/src/test/resources/docs-pythonmarkdown2/auto_link.md | |
161 | --- | |
162 | ||
163 | I can has autolink? <http://icanhascheeseburger.com> | |
164 | ||
165 | Ask garfield: <garfield@example.com> | |
166 | ||
167 | ||
168 | pegdown/src/test/resources/docs-pythonmarkdown2/auto_link_safe_mode.md | |
169 | --- | |
170 | ||
171 | I can has autolink? <http://icanhascheeseburger.com> | |
172 | ||
173 | Ask garfield: <garfield@example.com> | |
174 | ||
175 | ||
176 | pegdown/src/test/resources/docs-pythonmarkdown2/basic_safe_mode_escape.md | |
177 | --- | |
178 | ||
179 | blah <img src="dangerous"/> blah | |
180 | ||
181 | <div>yowzer!</div> | |
182 | ||
183 | blah | |
184 | ||
185 | ||
186 | pegdown/src/test/resources/docs-pythonmarkdown2/basic_safe_mode.md | |
187 | --- | |
188 | ||
189 | blah <img src="dangerous"/> blah | |
190 | ||
191 | <div>yowzer!</div> | |
192 | ||
193 | blah | |
194 | ||
195 | ||
196 | pegdown/src/test/resources/docs-pythonmarkdown2/blockquote.md | |
197 | --- | |
198 | ||
199 | [Trent wrote] | |
200 | > no way | |
201 | ||
202 | [Jeff wrote] | |
203 | > way | |
204 | ||
205 | ||
206 | pegdown/src/test/resources/docs-pythonmarkdown2/blockquote_with_pre.md | |
207 | --- | |
208 | ||
209 | > Markdown indents blockquotes a couple of spaces | |
210 | > necessitating some tweaks for pre-blocks in that | |
211 | > blockquote: | |
212 | > | |
213 | > here is a check | |
214 | > for that | |
215 | ||
216 | ||
217 | pegdown/src/test/resources/docs-pythonmarkdown2/codeblock.md | |
218 | --- | |
219 | ||
220 | some code | |
221 | ||
222 | some 'splaining | |
223 | ||
224 | some more code | |
225 | 2 > 1 | |
226 | ||
227 | ||
228 | ||
229 | pegdown/src/test/resources/docs-pythonmarkdown2/code_block_with_tabs.md | |
230 | --- | |
231 | ||
232 | Test with tabs for `_Detab`: | |
233 | ||
234 | Code 'block' with some "tabs" and "quotes" | |
235 | ||
236 | ||
237 | pegdown/src/test/resources/docs-pythonmarkdown2/code_safe_emphasis.md | |
238 | --- | |
239 | ||
240 | This is *italic* and this is **bold**. | |
241 | This is NOT _italic_ and this is __bold__ because --code-safe is turned on. | |
242 | ||
243 | ||
244 | pegdown/src/test/resources/docs-pythonmarkdown2/codespans.md | |
245 | --- | |
246 | ||
247 | `This` is a code span. | |
248 | And ``This is one with an `embedded backtick` ``. | |
249 | ||
250 | ||
251 | pegdown/src/test/resources/docs-pythonmarkdown2/codespans_safe_mode.md | |
252 | --- | |
253 | ||
254 | `This` is a code span. | |
255 | And ``This is one with an `embedded backtick` ``. | |
256 | ||
257 | ||
258 | pegdown/src/test/resources/docs-pythonmarkdown2/emacs_head_vars.md | |
259 | --- | |
260 | ||
261 | <!-- -*- markdown-extras: code-friendly -*- --> | |
262 | ||
263 | This sentence talks about the Python __init__ method, which I'd rather not be | |
264 | interpreted as Markdown's strong. | |
265 | ||
266 | ||
267 | pegdown/src/test/resources/docs-pythonmarkdown2/emacs_tail_vars.md | |
268 | --- | |
269 | ||
270 | This sentence talks about the Python __init__ method, which I'd rather not be | |
271 | interpreted as Markdown's strong. | |
272 | ||
273 | <!-- | |
274 | Local Variables: | |
275 | markdown-extras: code-friendly | |
276 | End: | |
277 | --> | |
278 | ||
279 | ||
280 | pegdown/src/test/resources/docs-pythonmarkdown2/emphasis.md | |
281 | --- | |
282 | ||
283 | This is *italic* and this is **bold**. | |
284 | This is also _italic_ and this is __bold__. | |
285 | ||
286 | ||
287 | pegdown/src/test/resources/docs-pythonmarkdown2/escapes.md | |
288 | --- | |
289 | ||
290 | \*\*don't shout\*\* | |
291 | ||
292 | \*don't emphasize\* | |
293 | ||
294 | ||
295 | pegdown/src/test/resources/docs-pythonmarkdown2/footnotes_letters.md | |
296 | --- | |
297 | ||
298 | This is a para with a footnote.[^foo] | |
299 | ||
300 | This is another para with a footnote[^hyphen-ated] in it. Actually it has two[^Capital] of | |
301 | them. | |
302 | ||
303 | ||
304 | [^foo]: Here is the body of the first footnote. | |
305 | ||
306 | [^hyphen-ated]: And of the second footnote. | |
307 | ||
308 | This one has multiple paragraphs. | |
309 | ||
310 | [^Capital]: | |
311 | Here is a footnote body that starts on next line. | |
312 | ||
313 | ||
314 | ||
315 | pegdown/src/test/resources/docs-pythonmarkdown2/footnotes_markup.md | |
316 | --- | |
317 | ||
318 | This is a para with a footnote.[^1] | |
319 | ||
320 | This is another para with a footnote.[^2] | |
321 | ||
322 | [^1]: And the **body** of the footnote has `markup`. For example, | |
323 | a [link to digg](http://digg.com). And some code: | |
324 | ||
325 | print "Hello, World!" | |
326 | ||
327 | [^2]: This body has markup too, *but* doesn't end with a code block. | |
328 | ||
329 | ||
330 | pegdown/src/test/resources/docs-pythonmarkdown2/footnotes.md | |
331 | --- | |
332 | ||
333 | This is a para with a footnote.[^1] | |
334 | ||
335 | This is another para with a footnote[^2] in it. Actually it has two[^3] of | |
336 | them. No, three[^4]. | |
337 | ||
338 | ||
339 | [^1]: Here is the body of the first footnote. | |
340 | ||
341 | [^2]: And of the second footnote. | |
342 | ||
343 | This one has multiple paragraphs. | |
344 | ||
345 | [^3]: | |
346 | Here is a footnote body that starts on next line. | |
347 | ||
348 | [^4]: quickie "that looks like a link ref if not careful" | |
349 | ||
350 | ||
351 | ||
352 | ||
353 | pegdown/src/test/resources/docs-pythonmarkdown2/footnotes_safe_mode_escape.md | |
354 | --- | |
355 | ||
356 | This is a para with a footnote.[^1] | |
357 | ||
358 | [^1]: Here is the <em>body</em> of <span class="yo">the</span> footnote. | |
359 | ||
360 | <div class="blah">And here is the second para of the footnote.</div> | |
361 | ||
362 | ||
363 | pegdown/src/test/resources/docs-pythonmarkdown2/hr.md | |
364 | --- | |
365 | ||
366 | Dashes: | |
367 | ||
368 | --- | |
369 | ||
370 | --- | |
371 | ||
372 | --- | |
373 | ||
374 | --- | |
375 | ||
376 | --- | |
377 | ||
378 | ||
379 | ||
380 | pegdown/src/test/resources/docs-pythonmarkdown2/img_in_link.md | |
381 | --- | |
382 | ||
383 | This example from | |
384 | <http://orestis.gr/en/blog/2007/05/28/python-markdown-problems/>: | |
385 | ||
386 | [![the google logo][logo]][google] | |
387 | [logo]: http://www.google.com/images/logo.gif | |
388 | [google]: http://www.google.com/ "click to visit Google.com" | |
389 | ||
390 | ||
391 | ||
392 | pegdown/src/test/resources/docs-pythonmarkdown2/inline_links.md | |
393 | --- | |
394 | ||
395 | an inline [link](/url/) | |
396 | ||
397 | a [link "with" title](/url/ "title") | |
398 | ||
399 | an inline ![image link](/url/) | |
400 | ||
401 | an ![image "with" title](/url/ "title") | |
402 | ||
403 | ||
404 | pegdown/src/test/resources/docs-pythonmarkdown2/issue2_safe_mode_borks_markup.md | |
405 | --- | |
406 | ||
407 | ## Heading 2 | |
408 | ||
409 | blah <script>alert('this should be removed')</script> **blah** | |
410 | ||
411 | <script>alert('as should this')</script> | |
412 | ||
413 | ||
414 | ||
415 | pegdown/src/test/resources/docs-pythonmarkdown2/link_defn_alt_title_delims.md | |
416 | --- | |
417 | ||
418 | Alternative delimiters for [link definitions][link1] are allowed -- as of | |
419 | Markdown 1.0.2, I think. Hence, [this link][link2] and [this link][link3] work | |
420 | too. | |
421 | ||
422 | [link1]: http://daringfireball.net/projects/markdown/syntax#link "link syntax" | |
423 | [link2]: http://daringfireball.net/projects/markdown/syntax#link 'link syntax' | |
424 | [link3]: http://daringfireball.net/projects/markdown/syntax#link (link syntax) | |
425 | ||
426 | ||
427 | pegdown/src/test/resources/docs-pythonmarkdown2/link_patterns_double_hit.md | |
428 | --- | |
429 | ||
430 | There once was a Mozilla bug 123 and a Komodo bug 123. | |
431 | ||
432 | ||
433 | pegdown/src/test/resources/docs-pythonmarkdown2/link_patterns_edge_cases.md | |
434 | --- | |
435 | ||
436 | Blah 123 becomes a line with two underscores. | |
437 | ||
438 | ||
439 | pegdown/src/test/resources/docs-pythonmarkdown2/link_patterns.md | |
440 | --- | |
441 | ||
442 | Recipe 123 and Komodo bug 234 are related. | |
443 | ||
444 | ||
445 | pegdown/src/test/resources/docs-pythonmarkdown2/lists.md | |
446 | --- | |
447 | ||
448 | count: | |
449 | ||
450 | * one | |
451 | * two | |
452 | * three | |
453 | ||
454 | count in spanish: | |
455 | ||
456 | 1. uno | |
457 | 2. dos | |
458 | 3. tres | |
459 | ||
460 | ||
461 | pegdown/src/test/resources/docs-pythonmarkdown2/mismatched_footnotes.md | |
462 | --- | |
463 | ||
464 | This is sentence has a footnote foo[^foo] and whamo[^whamo]. | |
465 | ||
466 | This is another para with a numbered footnote[^6]. | |
467 | ||
468 | ||
469 | [^foo]: Here is the body of the footnote foo. | |
470 | [^bar]: Here is the body of the footnote bar. | |
471 | [^6]: Here is the body of the footnote 6. | |
472 | ||
473 | ||
474 | ||
475 | pegdown/src/test/resources/docs-pythonmarkdown2/missing_link_defn.md | |
476 | --- | |
477 | ||
478 | ||
479 | This is a [missing link][missing] and a [used link][used]. | |
480 | ||
481 | ||
482 | [used]: http://foo.com | |
483 | [unused]: http://foo.com | |
484 | ||
485 | ||
486 | ||
487 | pegdown/src/test/resources/docs-pythonmarkdown2/nested_list.md | |
488 | --- | |
489 | ||
490 | shopping list: | |
491 | ||
492 | - veggies | |
493 | + carrots | |
494 | + lettuce | |
495 | - fruits | |
496 | + oranges | |
497 | + apples | |
498 | + *peaches* | |
499 | ||
500 | ||
501 | pegdown/src/test/resources/docs-pythonmarkdown2/nested_list_safe_mode.md | |
502 | --- | |
503 | ||
504 | shopping list: | |
505 | ||
506 | - veggies | |
507 | + carrots | |
508 | + lettuce | |
509 | - fruits | |
510 | + oranges | |
511 | + apples | |
512 | + *peaches* | |
513 | ||
514 | ||
515 | pegdown/src/test/resources/docs-pythonmarkdown2/parens_in_url_4.md | |
516 | --- | |
517 | ||
518 | [Inline link 4 with non-escaped parens](</url(test)> "title"). | |
519 | ||
520 | ||
521 | pegdown/src/test/resources/docs-pythonmarkdown2/raw_html.md | |
522 | --- | |
523 | ||
524 | ||
525 | Hi, <span foo="*bar*">*there*</span>. <!-- *blah* --> blah | |
526 | ||
527 | <div> | |
528 | **ack** | |
529 | </div> | |
530 | ||
531 | ||
532 | pegdown/src/test/resources/docs-pythonmarkdown2/ref_links.md | |
533 | --- | |
534 | ||
535 | [Google][] is fast ![star][]. | |
536 | ||
537 | [google]: http://www.google.com/ | |
538 | [star]: /img/star.png | |
539 | ||
540 | ||
541 | ||
542 | ||
543 | pegdown/src/test/resources/docs-pythonmarkdown2/sublist-para.md | |
544 | --- | |
545 | ||
546 | Some quick thoughts from a coder's perspective: | |
547 | ||
548 | - The source will be available in a Mercurial ... | |
549 | ||
550 | - Komodo is a Mozilla-based application... | |
551 | ||
552 | - Get a slightly tweaked mozilla build (C++, JavaScript, XUL). | |
553 | - Get a slightly tweaks Python build (C). | |
554 | - Add a bunch of core logic (Python)... | |
555 | - Add Komodo chrome (XUL, JavaScript, CSS, DTDs). | |
556 | ||
557 | What this means is that work on and add significant functionality... | |
558 | ||
559 | - Komodo uses the same extension mechanisms as Firefox... | |
560 | ||
561 | - Komodo builds and runs on Windows, Linux and ... | |
562 | ||
563 | ||
564 | pegdown/src/test/resources/docs-pythonmarkdown2/syntax_color.md | |
565 | --- | |
566 | ||
567 | Here is some sample code: | |
568 | ||
569 | :::python | |
570 | import sys | |
571 | def main(argv=sys.argv): | |
572 | logging.basicConfig() | |
573 | log.info('hi') | |
574 | ||
575 | and: | |
576 | ||
577 | :::ruby | |
578 | use 'zlib' | |
579 | sub main(argv) | |
580 | puts 'hi' | |
581 | end | |
582 | ||
583 | ||
584 | pegdown/src/test/resources/docs-pythonmarkdown2/underline_in_autolink.md | |
585 | --- | |
586 | ||
587 | Eric wrote up a (long) intro to writing UDL definitions a while back on | |
588 | his blog: <http://blogs.activestate.com/ericp/2007/01/kid_adding_a_ne.html> | |
589 | ||
590 | ||
591 | pegdown/src/test/resources/MarkdownTest103/Amps and angle encoding.md | |
592 | --- | |
593 | ||
594 | AT&T has an ampersand in their name. | |
595 | ||
596 | AT&T is another way to write it. | |
597 | ||
598 | This & that. | |
599 | ||
600 | 4 < 5. | |
601 | ||
602 | 6 > 5. | |
603 | ||
604 | Here's a [link] [1] with an ampersand in the URL. | |
605 | ||
606 | Here's a link with an amersand in the link text: [AT&T] [2]. | |
607 | ||
608 | Here's an inline [link](/script?foo=1&bar=2). | |
609 | ||
610 | Here's an inline [link](</script?foo=1&bar=2>). | |
611 | ||
612 | ||
613 | [1]: http://example.com/?foo=1&bar=2 | |
614 | [2]: http://att.com/ "AT&T" | |
615 | ||
616 | ||
617 | pegdown/src/test/resources/MarkdownTest103/Auto links.md | |
618 | --- | |
619 | ||
620 | Link: <http://example.com/>. | |
621 | ||
622 | With an ampersand: <http://example.com/?foo=1&bar=2> | |
623 | ||
624 | * In a list? | |
625 | * <http://example.com/> | |
626 | * It should. | |
627 | ||
628 | > Blockquoted: <http://example.com/> | |
629 | ||
630 | Auto-links should not occur here: `<http://example.com/>` | |
631 | ||
632 | or here: <http://example.com/> | |
633 | ||
634 | pegdown/src/test/resources/MarkdownTest103/Backslash escapes.md | |
635 | --- | |
636 | ||
637 | These should all get escaped: | |
638 | ||
639 | Backslash: \\ | |
640 | ||
641 | Backtick: \` | |
642 | ||
643 | Asterisk: \* | |
644 | ||
645 | Underscore: \_ | |
646 | ||
647 | Left brace: \{ | |
648 | ||
649 | Right brace: \} | |
650 | ||
651 | Left bracket: \[ | |
652 | ||
653 | Right bracket: \] | |
654 | ||
655 | Left paren: \( | |
656 | ||
657 | Right paren: \) | |
658 | ||
659 | Greater-than: \> | |
660 | ||
661 | Hash: \# | |
662 | ||
663 | Period: \. | |
664 | ||
665 | Bang: \! | |
666 | ||
667 | Plus: \+ | |
668 | ||
669 | Minus: \- | |
670 | ||
671 | ||
672 | ||
673 | These should not, because they occur within a code block: | |
674 | ||
675 | Backslash: \\ | |
676 | ||
677 | Backtick: \` | |
678 | ||
679 | Asterisk: \* | |
680 | ||
681 | Underscore: \_ | |
682 | ||
683 | Left brace: \{ | |
684 | ||
685 | Right brace: \} | |
686 | ||
687 | Left bracket: \[ | |
688 | ||
689 | Right bracket: \] | |
690 | ||
691 | Left paren: \( | |
692 | ||
693 | Right paren: \) | |
694 | ||
695 | Greater-than: \> | |
696 | ||
697 | Hash: \# | |
698 | ||
699 | Period: \. | |
700 | ||
701 | Bang: \! | |
702 | ||
703 | Plus: \+ | |
704 | ||
705 | Minus: \- | |
706 | ||
707 | ||
708 | Nor should these, which occur in code spans: | |
709 | ||
710 | Backslash: `\\` | |
711 | ||
712 | Backtick: `` \` `` | |
713 | ||
714 | Asterisk: `\*` | |
715 | ||
716 | Underscore: `\_` | |
717 | ||
718 | Left brace: `\{` | |
719 | ||
720 | Right brace: `\}` | |
721 | ||
722 | Left bracket: `\[` | |
723 | ||
724 | Right bracket: `\]` | |
725 | ||
726 | Left paren: `\(` | |
727 | ||
728 | Right paren: `\)` | |
729 | ||
730 | Greater-than: `\>` | |
731 | ||
732 | Hash: `\#` | |
733 | ||
734 | Period: `\.` | |
735 | ||
736 | Bang: `\!` | |
737 | ||
738 | Plus: `\+` | |
739 | ||
740 | Minus: `\-` | |
741 | ||
742 | ||
743 | These should get escaped, even though they're matching pairs for | |
744 | other Markdown constructs: | |
745 | ||
746 | \*asterisks\* | |
747 | ||
748 | \_underscores\_ | |
749 | ||
750 | \`backticks\` | |
751 | ||
752 | This is a code span with a literal backslash-backtick sequence: `` \` `` | |
753 | ||
754 | This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>. | |
755 | ||
756 | This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>. | |
757 | ||
758 | ||
759 | pegdown/src/test/resources/MarkdownTest103/Blockquotes with code blocks.md | |
760 | --- | |
761 | ||
762 | > Example: | |
763 | > | |
764 | > sub status { | |
765 | > print "working"; | |
766 | > } | |
767 | > | |
768 | > Or: | |
769 | > | |
770 | > sub status { | |
771 | > return "working"; | |
772 | > } | |
773 | ||
774 | ||
775 | pegdown/src/test/resources/MarkdownTest103/Code Blocks.md | |
776 | --- | |
777 | ||
778 | code block on the first line | |
779 | ||
780 | Regular text. | |
781 | ||
782 | code block indented by spaces | |
783 | ||
784 | Regular text. | |
785 | ||
786 | the lines in this block | |
787 | all contain trailing spaces | |
788 | ||
789 | Regular Text. | |
790 | ||
791 | code block on the last line | |
792 | ||
793 | pegdown/src/test/resources/MarkdownTest103/Code Spans.md | |
794 | --- | |
795 | ||
796 | `<test a="` content of attribute `">` | |
797 | ||
798 | Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span> | |
799 | ||
800 | Here's how you put `` `backticks` `` in a code span. | |
801 | ||
802 | ||
803 | ||
804 | pegdown/src/test/resources/MarkdownTest103/Hard-wrapped paragraphs with list-like lines.md | |
805 | --- | |
806 | ||
807 | In Markdown 1.0.0 and earlier. Version | |
808 | 8. This line turns into a list item. | |
809 | Because a hard-wrapped line in the | |
810 | middle of a paragraph looked like a | |
811 | list item. | |
812 | ||
813 | Here's one with a bullet. | |
814 | * criminey. | |
815 | ||
816 | ||
817 | pegdown/src/test/resources/MarkdownTest103/Horizontal rules.md | |
818 | --- | |
819 | ||
820 | Dashes: | |
821 | ||
822 | --- | |
823 | ||
824 | --- | |
825 | ||
826 | --- | |
827 | ||
828 | --- | |
829 | ||
830 | --- | |
831 | ||
832 | - - - | |
833 | ||
834 | - - - | |
835 | ||
836 | - - - | |
837 | ||
838 | - - - | |
839 | ||
840 | - - - | |
841 | ||
842 | ||
843 | Asterisks: | |
844 | ||
845 | *** | |
846 | ||
847 | *** | |
848 | ||
849 | *** | |
850 | ||
851 | *** | |
852 | ||
853 | *** | |
854 | ||
855 | * * * | |
856 | ||
857 | * * * | |
858 | ||
859 | * * * | |
860 | ||
861 | * * * | |
862 | ||
863 | * * * | |
864 | ||
865 | ||
866 | Underscores: | |
867 | ||
868 | ___ | |
869 | ||
870 | ___ | |
871 | ||
872 | ___ | |
873 | ||
874 | ___ | |
875 | ||
876 | ___ | |
877 | ||
878 | _ _ _ | |
879 | ||
880 | _ _ _ | |
881 | ||
882 | _ _ _ | |
883 | ||
884 | _ _ _ | |
885 | ||
886 | _ _ _ | |
887 | ||
888 | ||
889 | pegdown/src/test/resources/MarkdownTest103/Inline HTML (Advanced).md | |
890 | --- | |
891 | ||
892 | Simple block on one line: | |
893 | ||
894 | <div>foo</div> | |
895 | ||
896 | And nested without indentation: | |
897 | ||
898 | <div> | |
899 | <div> | |
900 | <div> | |
901 | foo | |
902 | </div> | |
903 | <div style=">"/> | |
904 | </div> | |
905 | <div>bar</div> | |
906 | </div> | |
907 | ||
908 | ||
909 | pegdown/src/test/resources/MarkdownTest103/Inline HTML comments.md | |
910 | --- | |
911 | ||
912 | Paragraph one. | |
913 | ||
914 | <!-- This is a simple comment --> | |
915 | ||
916 | <!-- | |
917 | This is another comment. | |
918 | --> | |
919 | ||
920 | Paragraph two. | |
921 | ||
922 | The end. | |
923 | ||
924 | ||
925 | pegdown/src/test/resources/MarkdownTest103/Inline HTML (Simple).md | |
926 | --- | |
927 | ||
928 | Here's a simple block: | |
929 | ||
930 | <div> | |
931 | foo | |
932 | </div> | |
933 | ||
934 | This should be a code block, though: | |
935 | ||
936 | <div> | |
937 | foo | |
938 | </div> | |
939 | ||
940 | As should this: | |
941 | ||
942 | <div>foo</div> | |
943 | ||
944 | Now, nested: | |
945 | ||
946 | <div> | |
947 | <div> | |
948 | <div> | |
949 | foo | |
950 | </div> | |
951 | </div> | |
952 | </div> | |
953 | ||
954 | This should just be an HTML comment: | |
955 | ||
956 | <!-- Comment --> | |
957 | ||
958 | Multiline: | |
959 | ||
960 | <!-- | |
961 | Blah | |
962 | Blah | |
963 | --> | |
964 | ||
965 | Code block: | |
966 | ||
967 | <!-- Comment --> | |
968 | ||
969 | Just plain comment, with trailing spaces on the line: | |
970 | ||
971 | <!-- foo --> | |
972 | ||
973 | Code: | |
974 | ||
975 | <hr /> | |
976 | ||
977 | Hr's: | |
978 | ||
979 | <hr/> | |
980 | ||
981 | <hr /> | |
982 | ||
983 | <hr/> | |
984 | ||
985 | <hr /> | |
986 | ||
987 | <hr class="foo" id="bar" /> | |
988 | ||
989 | <hr class="foo" id="bar"/> | |
990 | ||
991 | ||
992 | pegdown/src/test/resources/MarkdownTest103/Links, inline style.md | |
993 | --- | |
994 | ||
995 | Just a [URL](/url/). | |
996 | ||
997 | [URL and title](/url/ "title"). | |
998 | ||
999 | [URL and title](/url/ "title preceded by two spaces"). | |
1000 | ||
1001 | [URL and title](/url/ "title preceded by a tab"). | |
1002 | ||
1003 | [URL and title](/url/ "title has spaces afterward" ). | |
1004 | ||
1005 | ||
1006 | [Empty](). | |
1007 | ||
1008 | ||
1009 | pegdown/src/test/resources/MarkdownTest103/Links, reference style.md | |
1010 | --- | |
1011 | ||
1012 | Foo [bar] [1]. | |
1013 | ||
1014 | Foo [bar][1]. | |
1015 | ||
1016 | Foo [bar] | |
1017 | [1]. | |
1018 | ||
1019 | [1]: /url/ "Title" | |
1020 | ||
1021 | ||
1022 | With [embedded [brackets]] [b]. | |
1023 | ||
1024 | ||
1025 | Indented [once][]. | |
1026 | ||
1027 | Indented [twice][]. | |
1028 | ||
1029 | Indented [thrice][]. | |
1030 | ||
1031 | Indented [four][] times. | |
1032 | ||
1033 | [once]: /url | |
1034 | ||
1035 | [twice]: /url | |
1036 | ||
1037 | [thrice]: /url | |
1038 | ||
1039 | [four]: /url | |
1040 | ||
1041 | ||
1042 | [b]: /url/ | |
1043 | ||
1044 | * * * | |
1045 | ||
1046 | [this] [this] should work | |
1047 | ||
1048 | So should [this][this]. | |
1049 | ||
1050 | And [this] []. | |
1051 | ||
1052 | And [this][]. | |
1053 | ||
1054 | And [this]. | |
1055 | ||
1056 | But not [that] []. | |
1057 | ||
1058 | Nor [that][]. | |
1059 | ||
1060 | Nor [that]. | |
1061 | ||
1062 | [Something in brackets like [this][] should work] | |
1063 | ||
1064 | [Same with [this].] | |
1065 | ||
1066 | In this case, [this](/somethingelse/) points to something else. | |
1067 | ||
1068 | Backslashing should suppress \[this] and [this\]. | |
1069 | ||
1070 | [this]: foo | |
1071 | ||
1072 | ||
1073 | * * * | |
1074 | ||
1075 | Here's one where the [link | |
1076 | breaks] across lines. | |
1077 | ||
1078 | Here's another where the [link | |
1079 | breaks] across lines, but with a line-ending space. | |
1080 | ||
1081 | ||
1082 | [link breaks]: /url/ | |
1083 | ||
1084 | ||
1085 | pegdown/src/test/resources/MarkdownTest103/Links, shortcut references.md | |
1086 | --- | |
1087 | ||
1088 | This is the [simple case]. | |
1089 | ||
1090 | [simple case]: /simple | |
1091 | ||
1092 | ||
1093 | ||
1094 | This one has a [line | |
1095 | break]. | |
1096 | ||
1097 | This one has a [line | |
1098 | break] with a line-ending space. | |
1099 | ||
1100 | [line break]: /foo | |
1101 | ||
1102 | ||
1103 | [this] [that] and the [other] | |
1104 | ||
1105 | [this]: /this | |
1106 | [that]: /that | |
1107 | [other]: /other | |
1108 | ||
1109 | ||
1110 | pegdown/src/test/resources/MarkdownTest103/Literal quotes in titles.md | |
1111 | --- | |
1112 | ||
1113 | Foo [bar][]. | |
1114 | ||
1115 | Foo [bar](/url/ "Title with "quotes" inside"). | |
1116 | ||
1117 | ||
1118 | [bar]: /url/ "Title with "quotes" inside" | |
1119 | ||
1120 | ||
1121 | ||
1122 | pegdown/src/test/resources/MarkdownTest103/Markdown Documentation - Basics.md | |
1123 | --- | |
1124 | ||
1125 | Markdown: Basics | |
1126 | ================ | |
1127 | ||
1128 | <ul id="ProjectSubmenu"> | |
1129 | <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li> | |
1130 | <li><a class="selected" title="Markdown Basics">Basics</a></li> | |
1131 | <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li> | |
1132 | <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li> | |
1133 | <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li> | |
1134 | </ul> | |
1135 | ||
1136 | ||
1137 | Getting the Gist of Markdown's Formatting Syntax | |
1138 | ------------------------------------------------ | |
1139 | ||
1140 | This page offers a brief overview of what it's like to use Markdown. | |
1141 | The [syntax page] [s] provides complete, detailed documentation for | |
1142 | every feature, but Markdown should be very easy to pick up simply by | |
1143 | looking at a few examples of it in action. The examples on this page | |
1144 | are written in a before/after style, showing example syntax and the | |
1145 | HTML output produced by Markdown. | |
1146 | ||
1147 | It's also helpful to simply try Markdown out; the [Dingus] [d] is a | |
1148 | web application that allows you type your own Markdown-formatted text | |
1149 | and translate it to XHTML. | |
1150 | ||
1151 | **Note:** This document is itself written using Markdown; you | |
1152 | can [see the source for it by adding '.text' to the URL] [src]. | |
1153 | ||
1154 | [s]: /projects/markdown/syntax "Markdown Syntax" | |
1155 | [d]: /projects/markdown/dingus "Markdown Dingus" | |
1156 | [src]: /projects/markdown/basics.text | |
1157 | ||
1158 | ||
1159 | ## Paragraphs, Headers, Blockquotes ## | |
1160 | ||
1161 | A paragraph is simply one or more consecutive lines of text, separated | |
1162 | by one or more blank lines. (A blank line is any line that looks like a | |
1163 | blank line -- a line containing nothing spaces or tabs is considered | |
1164 | blank.) Normal paragraphs should not be intended with spaces or tabs. | |
1165 | ||
1166 | Markdown offers two styles of headers: *Setext* and *atx*. | |
1167 | Setext-style headers for `<h1>` and `<h2>` are created by | |
1168 | "underlining" with equal signs (`=`) and hyphens (`-`), respectively. | |
1169 | To create an atx-style header, you put 1-6 hash marks (`#`) at the | |
1170 | beginning of the line -- the number of hashes equals the resulting | |
1171 | HTML header level. | |
1172 | ||
1173 | Blockquotes are indicated using email-style '`>`' angle brackets. | |
1174 | ||
1175 | Markdown: | |
1176 | ||
1177 | A First Level Header | |
1178 | ==================== | |
1179 | ||
1180 | A Second Level Header | |
1181 | --------------------- | |
1182 | ||
1183 | Now is the time for all good men to come to | |
1184 | the aid of their country. This is just a | |
1185 | regular paragraph. | |
1186 | ||
1187 | The quick brown fox jumped over the lazy | |
1188 | dog's back. | |
1189 | ||
1190 | ### Header 3 | |
1191 | ||
1192 | > This is a blockquote. | |
1193 | > | |
1194 | > This is the second paragraph in the blockquote. | |
1195 | > | |
1196 | > ## This is an H2 in a blockquote | |
1197 | ||
1198 | ||
1199 | Output: | |
1200 | ||
1201 | <h1>A First Level Header</h1> | |
1202 | ||
1203 | <h2>A Second Level Header</h2> | |
1204 | ||
1205 | <p>Now is the time for all good men to come to | |
1206 | the aid of their country. This is just a | |
1207 | regular paragraph.</p> | |
1208 | ||
1209 | <p>The quick brown fox jumped over the lazy | |
1210 | dog's back.</p> | |
1211 | ||
1212 | <h3>Header 3</h3> | |
1213 | ||
1214 | <blockquote> | |
1215 | <p>This is a blockquote.</p> | |
1216 | ||
1217 | <p>This is the second paragraph in the blockquote.</p> | |
1218 | ||
1219 | <h2>This is an H2 in a blockquote</h2> | |
1220 | </blockquote> | |
1221 | ||
1222 | ||
1223 | ||
1224 | ### Phrase Emphasis ### | |
1225 | ||
1226 | Markdown uses asterisks and underscores to indicate spans of emphasis. | |
1227 | ||
1228 | Markdown: | |
1229 | ||
1230 | Some of these words *are emphasized*. | |
1231 | Some of these words _are emphasized also_. | |
1232 | ||
1233 | Use two asterisks for **strong emphasis**. | |
1234 | Or, if you prefer, __use two underscores instead__. | |
1235 | ||
1236 | Output: | |
1237 | ||
1238 | <p>Some of these words <em>are emphasized</em>. | |
1239 | Some of these words <em>are emphasized also</em>.</p> | |
1240 | ||
1241 | <p>Use two asterisks for <strong>strong emphasis</strong>. | |
1242 | Or, if you prefer, <strong>use two underscores instead</strong>.</p> | |
1243 | ||
1244 | ||
1245 | ||
1246 | ## Lists ## | |
1247 | ||
1248 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, | |
1249 | `+`, and `-`) as list markers. These three markers are | |
1250 | interchangable; this: | |
1251 | ||
1252 | * Candy. | |
1253 | * Gum. | |
1254 | * Booze. | |
1255 | ||
1256 | this: | |
1257 | ||
1258 | + Candy. | |
1259 | + Gum. | |
1260 | + Booze. | |
1261 | ||
1262 | and this: | |
1263 | ||
1264 | - Candy. | |
1265 | - Gum. | |
1266 | - Booze. | |
1267 | ||
1268 | all produce the same output: | |
1269 | ||
1270 | <ul> | |
1271 | <li>Candy.</li> | |
1272 | <li>Gum.</li> | |
1273 | <li>Booze.</li> | |
1274 | </ul> | |
1275 | ||
1276 | Ordered (numbered) lists use regular numbers, followed by periods, as | |
1277 | list markers: | |
1278 | ||
1279 | 1. Red | |
1280 | 2. Green | |
1281 | 3. Blue | |
1282 | ||
1283 | Output: | |
1284 | ||
1285 | <ol> | |
1286 | <li>Red</li> | |
1287 | <li>Green</li> | |
1288 | <li>Blue</li> | |
1289 | </ol> | |
1290 | ||
1291 | If you put blank lines between items, you'll get `<p>` tags for the | |
1292 | list item text. You can create multi-paragraph list items by indenting | |
1293 | the paragraphs by 4 spaces or 1 tab: | |
1294 | ||
1295 | * A list item. | |
1296 | ||
1297 | With multiple paragraphs. | |
1298 | ||
1299 | * Another item in the list. | |
1300 | ||
1301 | Output: | |
1302 | ||
1303 | <ul> | |
1304 | <li><p>A list item.</p> | |
1305 | <p>With multiple paragraphs.</p></li> | |
1306 | <li><p>Another item in the list.</p></li> | |
1307 | </ul> | |
1308 | ||
1309 | ||
1310 | ||
1311 | ### Links ### | |
1312 | ||
1313 | Markdown supports two styles for creating links: *inline* and | |
1314 | *reference*. With both styles, you use square brackets to delimit the | |
1315 | text you want to turn into a link. | |
1316 | ||
1317 | Inline-style links use parentheses immediately after the link text. | |
1318 | For example: | |
1319 | ||
1320 | This is an [example link](http://example.com/). | |
1321 | ||
1322 | Output: | |
1323 | ||
1324 | <p>This is an <a href="http://example.com/"> | |
1325 | example link</a>.</p> | |
1326 | ||
1327 | Optionally, you may include a title attribute in the parentheses: | |
1328 | ||
1329 | This is an [example link](http://example.com/ "With a Title"). | |
1330 | ||
1331 | Output: | |
1332 | ||
1333 | <p>This is an <a href="http://example.com/" title="With a Title"> | |
1334 | example link</a>.</p> | |
1335 | ||
1336 | Reference-style links allow you to refer to your links by names, which | |
1337 | you define elsewhere in your document: | |
1338 | ||
1339 | I get 10 times more traffic from [Google][1] than from | |
1340 | [Yahoo][2] or [MSN][3]. | |
1341 | ||
1342 | [1]: http://google.com/ "Google" | |
1343 | [2]: http://search.yahoo.com/ "Yahoo Search" | |
1344 | [3]: http://search.msn.com/ "MSN Search" | |
1345 | ||
1346 | Output: | |
1347 | ||
1348 | <p>I get 10 times more traffic from <a href="http://google.com/" | |
1349 | title="Google">Google</a> than from <a href="http://search.yahoo.com/" | |
1350 | title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" | |
1351 | title="MSN Search">MSN</a>.</p> | |
1352 | ||
1353 | The title attribute is optional. Link names may contain letters, | |
1354 | numbers and spaces, but are *not* case sensitive: | |
1355 | ||
1356 | I start my morning with a cup of coffee and | |
1357 | [The New York Times][NY Times]. | |
1358 | ||
1359 | [ny times]: http://www.nytimes.com/ | |
1360 | ||
1361 | Output: | |
1362 | ||
1363 | <p>I start my morning with a cup of coffee and | |
1364 | <a href="http://www.nytimes.com/">The New York Times</a>.</p> | |
1365 | ||
1366 | ||
1367 | ### Images ### | |
1368 | ||
1369 | Image syntax is very much like link syntax. | |
1370 | ||
1371 | Inline (titles are optional): | |
1372 | ||
1373 | ![alt text](/path/to/img.jpg "Title") | |
1374 | ||
1375 | Reference-style: | |
1376 | ||
1377 | ![alt text][id] | |
1378 | ||
1379 | [id]: /path/to/img.jpg "Title" | |
1380 | ||
1381 | Both of the above examples produce the same output: | |
1382 | ||
1383 | <img src="/path/to/img.jpg" alt="alt text" title="Title" /> | |
1384 | ||
1385 | ||
1386 | ||
1387 | ### Code ### | |
1388 | ||
1389 | In a regular paragraph, you can create code span by wrapping text in | |
1390 | backtick quotes. Any ampersands (`&`) and angle brackets (`<` or | |
1391 | `>`) will automatically be translated into HTML entities. This makes | |
1392 | it easy to use Markdown to write about HTML example code: | |
1393 | ||
1394 | I strongly recommend against using any `<blink>` tags. | |
1395 | ||
1396 | I wish SmartyPants used named entities like `—` | |
1397 | instead of decimal-encoded entites like `—`. | |
1398 | ||
1399 | Output: | |
1400 | ||
1401 | <p>I strongly recommend against using any | |
1402 | <code><blink></code> tags.</p> | |
1403 | ||
1404 | <p>I wish SmartyPants used named entities like | |
1405 | <code>&mdash;</code> instead of decimal-encoded | |
1406 | entites like <code>&#8212;</code>.</p> | |
1407 | ||
1408 | ||
1409 | To specify an entire block of pre-formatted code, indent every line of | |
1410 | the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`, | |
1411 | and `>` characters will be escaped automatically. | |
1412 | ||
1413 | Markdown: | |
1414 | ||
1415 | If you want your page to validate under XHTML 1.0 Strict, | |
1416 | you've got to put paragraph tags in your blockquotes: | |
1417 | ||
1418 | <blockquote> | |
1419 | <p>For example.</p> | |
1420 | </blockquote> | |
1421 | ||
1422 | Output: | |
1423 | ||
1424 | <p>If you want your page to validate under XHTML 1.0 Strict, | |
1425 | you've got to put paragraph tags in your blockquotes:</p> | |
1426 | ||
1427 | <pre><code><blockquote> | |
1428 | <p>For example.</p> | |
1429 | </blockquote> | |
1430 | </code></pre> | |
1431 | ||
1432 | ||
1433 | pegdown/src/test/resources/MarkdownTest103/Markdown Documentation - Syntax.md | |
1434 | --- | |
1435 | ||
1436 | Markdown: Syntax | |
1437 | ================ | |
1438 | ||
1439 | <ul id="ProjectSubmenu"> | |
1440 | <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li> | |
1441 | <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li> | |
1442 | <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li> | |
1443 | <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li> | |
1444 | <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li> | |
1445 | </ul> | |
1446 | ||
1447 | ||
1448 | * [Overview](#overview) | |
1449 | * [Philosophy](#philosophy) | |
1450 | * [Inline HTML](#html) | |
1451 | * [Automatic Escaping for Special Characters](#autoescape) | |
1452 | * [Block Elements](#block) | |
1453 | * [Paragraphs and Line Breaks](#p) | |
1454 | * [Headers](#header) | |
1455 | * [Blockquotes](#blockquote) | |
1456 | * [Lists](#list) | |
1457 | * [Code Blocks](#precode) | |
1458 | * [Horizontal Rules](#hr) | |
1459 | * [Span Elements](#span) | |
1460 | * [Links](#link) | |
1461 | * [Emphasis](#em) | |
1462 | * [Code](#code) | |
1463 | * [Images](#img) | |
1464 | * [Miscellaneous](#misc) | |
1465 | * [Backslash Escapes](#backslash) | |
1466 | * [Automatic Links](#autolink) | |
1467 | ||
1468 | ||
1469 | **Note:** This document is itself written using Markdown; you | |
1470 | can [see the source for it by adding '.text' to the URL][src]. | |
1471 | ||
1472 | [src]: /projects/markdown/syntax.text | |
1473 | ||
1474 | * * * | |
1475 | ||
1476 | <h2 id="overview">Overview</h2> | |
1477 | ||
1478 | <h3 id="philosophy">Philosophy</h3> | |
1479 | ||
1480 | Markdown is intended to be as easy-to-read and easy-to-write as is feasible. | |
1481 | ||
1482 | Readability, however, is emphasized above all else. A Markdown-formatted | |
1483 | document should be publishable as-is, as plain text, without looking | |
1484 | like it's been marked up with tags or formatting instructions. While | |
1485 | Markdown's syntax has been influenced by several existing text-to-HTML | |
1486 | filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4], | |
1487 | [Grutatext] [5], and [EtText] [6] -- the single biggest source of | |
1488 | inspiration for Markdown's syntax is the format of plain text email. | |
1489 | ||
1490 | [1]: http://docutils.sourceforge.net/mirror/setext.html | |
1491 | [2]: http://www.aaronsw.com/2002/atx/ | |
1492 | [3]: http://textism.com/tools/textile/ | |
1493 | [4]: http://docutils.sourceforge.net/rst.html | |
1494 | [5]: http://www.triptico.com/software/grutatxt.html | |
1495 | [6]: http://ettext.taint.org/doc/ | |
1496 | ||
1497 | To this end, Markdown's syntax is comprised entirely of punctuation | |
1498 | characters, which punctuation characters have been carefully chosen so | |
1499 | as to look like what they mean. E.g., asterisks around a word actually | |
1500 | look like \*emphasis\*. Markdown lists look like, well, lists. Even | |
1501 | blockquotes look like quoted passages of text, assuming you've ever | |
1502 | used email. | |
1503 | ||
1504 | ||
1505 | ||
1506 | <h3 id="html">Inline HTML</h3> | |
1507 | ||
1508 | Markdown's syntax is intended for one purpose: to be used as a | |
1509 | format for *writing* for the web. | |
1510 | ||
1511 | Markdown is not a replacement for HTML, or even close to it. Its | |
1512 | syntax is very small, corresponding only to a very small subset of | |
1513 | HTML tags. The idea is *not* to create a syntax that makes it easier | |
1514 | to insert HTML tags. In my opinion, HTML tags are already easy to | |
1515 | insert. The idea for Markdown is to make it easy to read, write, and | |
1516 | edit prose. HTML is a *publishing* format; Markdown is a *writing* | |
1517 | format. Thus, Markdown's formatting syntax only addresses issues that | |
1518 | can be conveyed in plain text. | |
1519 | ||
1520 | For any markup that is not covered by Markdown's syntax, you simply | |
1521 | use HTML itself. There's no need to preface it or delimit it to | |
1522 | indicate that you're switching from Markdown to HTML; you just use | |
1523 | the tags. | |
1524 | ||
1525 | The only restrictions are that block-level HTML elements -- e.g. `<div>`, | |
1526 | `<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding | |
1527 | content by blank lines, and the start and end tags of the block should | |
1528 | not be indented with tabs or spaces. Markdown is smart enough not | |
1529 | to add extra (unwanted) `<p>` tags around HTML block-level tags. | |
1530 | ||
1531 | For example, to add an HTML table to a Markdown article: | |
1532 | ||
1533 | This is a regular paragraph. | |
1534 | ||
1535 | <table> | |
1536 | <tr> | |
1537 | <td>Foo</td> | |
1538 | </tr> | |
1539 | </table> | |
1540 | ||
1541 | This is another regular paragraph. | |
1542 | ||
1543 | Note that Markdown formatting syntax is not processed within block-level | |
1544 | HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an | |
1545 | HTML block. | |
1546 | ||
1547 | Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be | |
1548 | used anywhere in a Markdown paragraph, list item, or header. If you | |
1549 | want, you can even use HTML tags instead of Markdown formatting; e.g. if | |
1550 | you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's | |
1551 | link or image syntax, go right ahead. | |
1552 | ||
1553 | Unlike block-level HTML tags, Markdown syntax *is* processed within | |
1554 | span-level tags. | |
1555 | ||
1556 | ||
1557 | <h3 id="autoescape">Automatic Escaping for Special Characters</h3> | |
1558 | ||
1559 | In HTML, there are two characters that demand special treatment: `<` | |
1560 | and `&`. Left angle brackets are used to start tags; ampersands are | |
1561 | used to denote HTML entities. If you want to use them as literal | |
1562 | characters, you must escape them as entities, e.g. `<`, and | |
1563 | `&`. | |
1564 | ||
1565 | Ampersands in particular are bedeviling for web writers. If you want to | |
1566 | write about 'AT&T', you need to write '`AT&T`'. You even need to | |
1567 | escape ampersands within URLs. Thus, if you want to link to: | |
1568 | ||
1569 | http://images.google.com/images?num=30&q=larry+bird | |
1570 | ||
1571 | you need to encode the URL as: | |
1572 | ||
1573 | http://images.google.com/images?num=30&q=larry+bird | |
1574 | ||
1575 | in your anchor tag `href` attribute. Needless to say, this is easy to | |
1576 | forget, and is probably the single most common source of HTML validation | |
1577 | errors in otherwise well-marked-up web sites. | |
1578 | ||
1579 | Markdown allows you to use these characters naturally, taking care of | |
1580 | all the necessary escaping for you. If you use an ampersand as part of | |
1581 | an HTML entity, it remains unchanged; otherwise it will be translated | |
1582 | into `&`. | |
1583 | ||
1584 | So, if you want to include a copyright symbol in your article, you can write: | |
1585 | ||
1586 | © | |
1587 | ||
1588 | and Markdown will leave it alone. But if you write: | |
1589 | ||
1590 | AT&T | |
1591 | ||
1592 | Markdown will translate it to: | |
1593 | ||
1594 | AT&T | |
1595 | ||
1596 | Similarly, because Markdown supports [inline HTML](#html), if you use | |
1597 | angle brackets as delimiters for HTML tags, Markdown will treat them as | |
1598 | such. But if you write: | |
1599 | ||
1600 | 4 < 5 | |
1601 | ||
1602 | Markdown will translate it to: | |
1603 | ||
1604 | 4 < 5 | |
1605 | ||
1606 | However, inside Markdown code spans and blocks, angle brackets and | |
1607 | ampersands are *always* encoded automatically. This makes it easy to use | |
1608 | Markdown to write about HTML code. (As opposed to raw HTML, which is a | |
1609 | terrible format for writing about HTML syntax, because every single `<` | |
1610 | and `&` in your example code needs to be escaped.) | |
1611 | ||
1612 | ||
1613 | * * * | |
1614 | ||
1615 | ||
1616 | <h2 id="block">Block Elements</h2> | |
1617 | ||
1618 | ||
1619 | <h3 id="p">Paragraphs and Line Breaks</h3> | |
1620 | ||
1621 | A paragraph is simply one or more consecutive lines of text, separated | |
1622 | by one or more blank lines. (A blank line is any line that looks like a | |
1623 | blank line -- a line containing nothing but spaces or tabs is considered | |
1624 | blank.) Normal paragraphs should not be intended with spaces or tabs. | |
1625 | ||
1626 | The implication of the "one or more consecutive lines of text" rule is | |
1627 | that Markdown supports "hard-wrapped" text paragraphs. This differs | |
1628 | significantly from most other text-to-HTML formatters (including Movable | |
1629 | Type's "Convert Line Breaks" option) which translate every line break | |
1630 | character in a paragraph into a `<br />` tag. | |
1631 | ||
1632 | When you *do* want to insert a `<br />` break tag using Markdown, you | |
1633 | end a line with two or more spaces, then type return. | |
1634 | ||
1635 | Yes, this takes a tad more effort to create a `<br />`, but a simplistic | |
1636 | "every line break is a `<br />`" rule wouldn't work for Markdown. | |
1637 | Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l] | |
1638 | work best -- and look better -- when you format them with hard breaks. | |
1639 | ||
1640 | [bq]: #blockquote | |
1641 | [l]: #list | |
1642 | ||
1643 | ||
1644 | ||
1645 | <h3 id="header">Headers</h3> | |
1646 | ||
1647 | Markdown supports two styles of headers, [Setext] [1] and [atx] [2]. | |
1648 | ||
1649 | Setext-style headers are "underlined" using equal signs (for first-level | |
1650 | headers) and dashes (for second-level headers). For example: | |
1651 | ||
1652 | This is an H1 | |
1653 | ============= | |
1654 | ||
1655 | This is an H2 | |
1656 | ------------- | |
1657 | ||
1658 | Any number of underlining `=`'s or `-`'s will work. | |
1659 | ||
1660 | Atx-style headers use 1-6 hash characters at the start of the line, | |
1661 | corresponding to header levels 1-6. For example: | |
1662 | ||
1663 | # This is an H1 | |
1664 | ||
1665 | ## This is an H2 | |
1666 | ||
1667 | ###### This is an H6 | |
1668 | ||
1669 | Optionally, you may "close" atx-style headers. This is purely | |
1670 | cosmetic -- you can use this if you think it looks better. The | |
1671 | closing hashes don't even need to match the number of hashes | |
1672 | used to open the header. (The number of opening hashes | |
1673 | determines the header level.) : | |
1674 | ||
1675 | # This is an H1 # | |
1676 | ||
1677 | ## This is an H2 ## | |
1678 | ||
1679 | ### This is an H3 ###### | |
1680 | ||
1681 | ||
1682 | <h3 id="blockquote">Blockquotes</h3> | |
1683 | ||
1684 | Markdown uses email-style `>` characters for blockquoting. If you're | |
1685 | familiar with quoting passages of text in an email message, then you | |
1686 | know how to create a blockquote in Markdown. It looks best if you hard | |
1687 | wrap the text and put a `>` before every line: | |
1688 | ||
1689 | > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, | |
1690 | > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. | |
1691 | > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. | |
1692 | > | |
1693 | > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse | |
1694 | > id sem consectetuer libero luctus adipiscing. | |
1695 | ||
1696 | Markdown allows you to be lazy and only put the `>` before the first | |
1697 | line of a hard-wrapped paragraph: | |
1698 | ||
1699 | > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, | |
1700 | consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. | |
1701 | Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. | |
1702 | ||
1703 | > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse | |
1704 | id sem consectetuer libero luctus adipiscing. | |
1705 | ||
1706 | Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by | |
1707 | adding additional levels of `>`: | |
1708 | ||
1709 | > This is the first level of quoting. | |
1710 | > | |
1711 | > > This is nested blockquote. | |
1712 | > | |
1713 | > Back to the first level. | |
1714 | ||
1715 | Blockquotes can contain other Markdown elements, including headers, lists, | |
1716 | and code blocks: | |
1717 | ||
1718 | > ## This is a header. | |
1719 | > | |
1720 | > 1. This is the first list item. | |
1721 | > 2. This is the second list item. | |
1722 | > | |
1723 | > Here's some example code: | |
1724 | > | |
1725 | > return shell_exec("echo $input | $markdown_script"); | |
1726 | ||
1727 | Any decent text editor should make email-style quoting easy. For | |
1728 | example, with BBEdit, you can make a selection and choose Increase | |
1729 | Quote Level from the Text menu. | |
1730 | ||
1731 | ||
1732 | <h3 id="list">Lists</h3> | |
1733 | ||
1734 | Markdown supports ordered (numbered) and unordered (bulleted) lists. | |
1735 | ||
1736 | Unordered lists use asterisks, pluses, and hyphens -- interchangably | |
1737 | -- as list markers: | |
1738 | ||
1739 | * Red | |
1740 | * Green | |
1741 | * Blue | |
1742 | ||
1743 | is equivalent to: | |
1744 | ||
1745 | + Red | |
1746 | + Green | |
1747 | + Blue | |
1748 | ||
1749 | and: | |
1750 | ||
1751 | - Red | |
1752 | - Green | |
1753 | - Blue | |
1754 | ||
1755 | Ordered lists use numbers followed by periods: | |
1756 | ||
1757 | 1. Bird | |
1758 | 2. McHale | |
1759 | 3. Parish | |
1760 | ||
1761 | It's important to note that the actual numbers you use to mark the | |
1762 | list have no effect on the HTML output Markdown produces. The HTML | |
1763 | Markdown produces from the above list is: | |
1764 | ||
1765 | <ol> | |
1766 | <li>Bird</li> | |
1767 | <li>McHale</li> | |
1768 | <li>Parish</li> | |
1769 | </ol> | |
1770 | ||
1771 | If you instead wrote the list in Markdown like this: | |
1772 | ||
1773 | 1. Bird | |
1774 | 1. McHale | |
1775 | 1. Parish | |
1776 | ||
1777 | or even: | |
1778 | ||
1779 | 3. Bird | |
1780 | 1. McHale | |
1781 | 8. Parish | |
1782 | ||
1783 | you'd get the exact same HTML output. The point is, if you want to, | |
1784 | you can use ordinal numbers in your ordered Markdown lists, so that | |
1785 | the numbers in your source match the numbers in your published HTML. | |
1786 | But if you want to be lazy, you don't have to. | |
1787 | ||
1788 | If you do use lazy list numbering, however, you should still start the | |
1789 | list with the number 1. At some point in the future, Markdown may support | |
1790 | starting ordered lists at an arbitrary number. | |
1791 | ||
1792 | List markers typically start at the left margin, but may be indented by | |
1793 | up to three spaces. List markers must be followed by one or more spaces | |
1794 | or a tab. | |
1795 | ||
1796 | To make lists look nice, you can wrap items with hanging indents: | |
1797 | ||
1798 | * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. | |
1799 | Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, | |
1800 | viverra nec, fringilla in, laoreet vitae, risus. | |
1801 | * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
1802 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
1803 | ||
1804 | But if you want to be lazy, you don't have to: | |
1805 | ||
1806 | * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. | |
1807 | Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, | |
1808 | viverra nec, fringilla in, laoreet vitae, risus. | |
1809 | * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
1810 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
1811 | ||
1812 | If list items are separated by blank lines, Markdown will wrap the | |
1813 | items in `<p>` tags in the HTML output. For example, this input: | |
1814 | ||
1815 | * Bird | |
1816 | * Magic | |
1817 | ||
1818 | will turn into: | |
1819 | ||
1820 | <ul> | |
1821 | <li>Bird</li> | |
1822 | <li>Magic</li> | |
1823 | </ul> | |
1824 | ||
1825 | But this: | |
1826 | ||
1827 | * Bird | |
1828 | ||
1829 | * Magic | |
1830 | ||
1831 | will turn into: | |
1832 | ||
1833 | <ul> | |
1834 | <li><p>Bird</p></li> | |
1835 | <li><p>Magic</p></li> | |
1836 | </ul> | |
1837 | ||
1838 | List items may consist of multiple paragraphs. Each subsequent | |
1839 | paragraph in a list item must be intended by either 4 spaces | |
1840 | or one tab: | |
1841 | ||
1842 | 1. This is a list item with two paragraphs. Lorem ipsum dolor | |
1843 | sit amet, consectetuer adipiscing elit. Aliquam hendrerit | |
1844 | mi posuere lectus. | |
1845 | ||
1846 | Vestibulum enim wisi, viverra nec, fringilla in, laoreet | |
1847 | vitae, risus. Donec sit amet nisl. Aliquam semper ipsum | |
1848 | sit amet velit. | |
1849 | ||
1850 | 2. Suspendisse id sem consectetuer libero luctus adipiscing. | |
1851 | ||
1852 | It looks nice if you indent every line of the subsequent | |
1853 | paragraphs, but here again, Markdown will allow you to be | |
1854 | lazy: | |
1855 | ||
1856 | * This is a list item with two paragraphs. | |
1857 | ||
1858 | This is the second paragraph in the list item. You're | |
1859 | only required to indent the first line. Lorem ipsum dolor | |
1860 | sit amet, consectetuer adipiscing elit. | |
1861 | ||
1862 | * Another item in the same list. | |
1863 | ||
1864 | To put a blockquote within a list item, the blockquote's `>` | |
1865 | delimiters need to be indented: | |
1866 | ||
1867 | * A list item with a blockquote: | |
1868 | ||
1869 | > This is a blockquote | |
1870 | > inside a list item. | |
1871 | ||
1872 | To put a code block within a list item, the code block needs | |
1873 | to be indented *twice* -- 8 spaces or two tabs: | |
1874 | ||
1875 | * A list item with a code block: | |
1876 | ||
1877 | <code goes here> | |
1878 | ||
1879 | ||
1880 | It's worth noting that it's possible to trigger an ordered list by | |
1881 | accident, by writing something like this: | |
1882 | ||
1883 | 1986. What a great season. | |
1884 | ||
1885 | In other words, a *number-period-space* sequence at the beginning of a | |
1886 | line. To avoid this, you can backslash-escape the period: | |
1887 | ||
1888 | 1986\. What a great season. | |
1889 | ||
1890 | ||
1891 | ||
1892 | <h3 id="precode">Code Blocks</h3> | |
1893 | ||
1894 | Pre-formatted code blocks are used for writing about programming or | |
1895 | markup source code. Rather than forming normal paragraphs, the lines | |
1896 | of a code block are interpreted literally. Markdown wraps a code block | |
1897 | in both `<pre>` and `<code>` tags. | |
1898 | ||
1899 | To produce a code block in Markdown, simply indent every line of the | |
1900 | block by at least 4 spaces or 1 tab. For example, given this input: | |
1901 | ||
1902 | This is a normal paragraph: | |
1903 | ||
1904 | This is a code block. | |
1905 | ||
1906 | Markdown will generate: | |
1907 | ||
1908 | <p>This is a normal paragraph:</p> | |
1909 | ||
1910 | <pre><code>This is a code block. | |
1911 | </code></pre> | |
1912 | ||
1913 | One level of indentation -- 4 spaces or 1 tab -- is removed from each | |
1914 | line of the code block. For example, this: | |
1915 | ||
1916 | Here is an example of AppleScript: | |
1917 | ||
1918 | tell application "Foo" | |
1919 | beep | |
1920 | end tell | |
1921 | ||
1922 | will turn into: | |
1923 | ||
1924 | <p>Here is an example of AppleScript:</p> | |
1925 | ||
1926 | <pre><code>tell application "Foo" | |
1927 | beep | |
1928 | end tell | |
1929 | </code></pre> | |
1930 | ||
1931 | A code block continues until it reaches a line that is not indented | |
1932 | (or the end of the article). | |
1933 | ||
1934 | Within a code block, ampersands (`&`) and angle brackets (`<` and `>`) | |
1935 | are automatically converted into HTML entities. This makes it very | |
1936 | easy to include example HTML source code using Markdown -- just paste | |
1937 | it and indent it, and Markdown will handle the hassle of encoding the | |
1938 | ampersands and angle brackets. For example, this: | |
1939 | ||
1940 | <div class="footer"> | |
1941 | © 2004 Foo Corporation | |
1942 | </div> | |
1943 | ||
1944 | will turn into: | |
1945 | ||
1946 | <pre><code><div class="footer"> | |
1947 | &copy; 2004 Foo Corporation | |
1948 | </div> | |
1949 | </code></pre> | |
1950 | ||
1951 | Regular Markdown syntax is not processed within code blocks. E.g., | |
1952 | asterisks are just literal asterisks within a code block. This means | |
1953 | it's also easy to use Markdown to write about Markdown's own syntax. | |
1954 | ||
1955 | ||
1956 | ||
1957 | <h3 id="hr">Horizontal Rules</h3> | |
1958 | ||
1959 | You can produce a horizontal rule tag (`<hr />`) by placing three or | |
1960 | more hyphens, asterisks, or underscores on a line by themselves. If you | |
1961 | wish, you may use spaces between the hyphens or asterisks. Each of the | |
1962 | following lines will produce a horizontal rule: | |
1963 | ||
1964 | * * * | |
1965 | ||
1966 | *** | |
1967 | ||
1968 | ***** | |
1969 | ||
1970 | - - - | |
1971 | ||
1972 | --------------------------------------- | |
1973 | ||
1974 | _ _ _ | |
1975 | ||
1976 | ||
1977 | * * * | |
1978 | ||
1979 | <h2 id="span">Span Elements</h2> | |
1980 | ||
1981 | <h3 id="link">Links</h3> | |
1982 | ||
1983 | Markdown supports two style of links: *inline* and *reference*. | |
1984 | ||
1985 | In both styles, the link text is delimited by [square brackets]. | |
1986 | ||
1987 | To create an inline link, use a set of regular parentheses immediately | |
1988 | after the link text's closing square bracket. Inside the parentheses, | |
1989 | put the URL where you want the link to point, along with an *optional* | |
1990 | title for the link, surrounded in quotes. For example: | |
1991 | ||
1992 | This is [an example](http://example.com/ "Title") inline link. | |
1993 | ||
1994 | [This link](http://example.net/) has no title attribute. | |
1995 | ||
1996 | Will produce: | |
1997 | ||
1998 | <p>This is <a href="http://example.com/" title="Title"> | |
1999 | an example</a> inline link.</p> | |
2000 | ||
2001 | <p><a href="http://example.net/">This link</a> has no | |
2002 | title attribute.</p> | |
2003 | ||
2004 | If you're referring to a local resource on the same server, you can | |
2005 | use relative paths: | |
2006 | ||
2007 | See my [About](/about/) page for details. | |
2008 | ||
2009 | Reference-style links use a second set of square brackets, inside | |
2010 | which you place a label of your choosing to identify the link: | |
2011 | ||
2012 | This is [an example][id] reference-style link. | |
2013 | ||
2014 | You can optionally use a space to separate the sets of brackets: | |
2015 | ||
2016 | This is [an example] [id] reference-style link. | |
2017 | ||
2018 | Then, anywhere in the document, you define your link label like this, | |
2019 | on a line by itself: | |
2020 | ||
2021 | [id]: http://example.com/ "Optional Title Here" | |
2022 | ||
2023 | That is: | |
2024 | ||
2025 | * Square brackets containing the link identifier (optionally | |
2026 | indented from the left margin using up to three spaces); | |
2027 | * followed by a colon; | |
2028 | * followed by one or more spaces (or tabs); | |
2029 | * followed by the URL for the link; | |
2030 | * optionally followed by a title attribute for the link, enclosed | |
2031 | in double or single quotes. | |
2032 | ||
2033 | The link URL may, optionally, be surrounded by angle brackets: | |
2034 | ||
2035 | [id]: <http://example.com/> "Optional Title Here" | |
2036 | ||
2037 | You can put the title attribute on the next line and use extra spaces | |
2038 | or tabs for padding, which tends to look better with longer URLs: | |
2039 | ||
2040 | [id]: http://example.com/longish/path/to/resource/here | |
2041 | "Optional Title Here" | |
2042 | ||
2043 | Link definitions are only used for creating links during Markdown | |
2044 | processing, and are stripped from your document in the HTML output. | |
2045 | ||
2046 | Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links: | |
2047 | ||
2048 | [link text][a] | |
2049 | [link text][A] | |
2050 | ||
2051 | are equivalent. | |
2052 | ||
2053 | The *implicit link name* shortcut allows you to omit the name of the | |
2054 | link, in which case the link text itself is used as the name. | |
2055 | Just use an empty set of square brackets -- e.g., to link the word | |
2056 | "Google" to the google.com web site, you could simply write: | |
2057 | ||
2058 | [Google][] | |
2059 | ||
2060 | And then define the link: | |
2061 | ||
2062 | [Google]: http://google.com/ | |
2063 | ||
2064 | Because link names may contain spaces, this shortcut even works for | |
2065 | multiple words in the link text: | |
2066 | ||
2067 | Visit [Daring Fireball][] for more information. | |
2068 | ||
2069 | And then define the link: | |
2070 | ||
2071 | [Daring Fireball]: http://daringfireball.net/ | |
2072 | ||
2073 | Link definitions can be placed anywhere in your Markdown document. I | |
2074 | tend to put them immediately after each paragraph in which they're | |
2075 | used, but if you want, you can put them all at the end of your | |
2076 | document, sort of like footnotes. | |
2077 | ||
2078 | Here's an example of reference links in action: | |
2079 | ||
2080 | I get 10 times more traffic from [Google] [1] than from | |
2081 | [Yahoo] [2] or [MSN] [3]. | |
2082 | ||
2083 | [1]: http://google.com/ "Google" | |
2084 | [2]: http://search.yahoo.com/ "Yahoo Search" | |
2085 | [3]: http://search.msn.com/ "MSN Search" | |
2086 | ||
2087 | Using the implicit link name shortcut, you could instead write: | |
2088 | ||
2089 | I get 10 times more traffic from [Google][] than from | |
2090 | [Yahoo][] or [MSN][]. | |
2091 | ||
2092 | [google]: http://google.com/ "Google" | |
2093 | [yahoo]: http://search.yahoo.com/ "Yahoo Search" | |
2094 | [msn]: http://search.msn.com/ "MSN Search" | |
2095 | ||
2096 | Both of the above examples will produce the following HTML output: | |
2097 | ||
2098 | <p>I get 10 times more traffic from <a href="http://google.com/" | |
2099 | title="Google">Google</a> than from | |
2100 | <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> | |
2101 | or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p> | |
2102 | ||
2103 | For comparison, here is the same paragraph written using | |
2104 | Markdown's inline link style: | |
2105 | ||
2106 | I get 10 times more traffic from [Google](http://google.com/ "Google") | |
2107 | than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or | |
2108 | [MSN](http://search.msn.com/ "MSN Search"). | |
2109 | ||
2110 | The point of reference-style links is not that they're easier to | |
2111 | write. The point is that with reference-style links, your document | |
2112 | source is vastly more readable. Compare the above examples: using | |
2113 | reference-style links, the paragraph itself is only 81 characters | |
2114 | long; with inline-style links, it's 176 characters; and as raw HTML, | |
2115 | it's 234 characters. In the raw HTML, there's more markup than there | |
2116 | is text. | |
2117 | ||
2118 | With Markdown's reference-style links, a source document much more | |
2119 | closely resembles the final output, as rendered in a browser. By | |
2120 | allowing you to move the markup-related metadata out of the paragraph, | |
2121 | you can add links without interrupting the narrative flow of your | |
2122 | prose. | |
2123 | ||
2124 | ||
2125 | <h3 id="em">Emphasis</h3> | |
2126 | ||
2127 | Markdown treats asterisks (`*`) and underscores (`_`) as indicators of | |
2128 | emphasis. Text wrapped with one `*` or `_` will be wrapped with an | |
2129 | HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML | |
2130 | `<strong>` tag. E.g., this input: | |
2131 | ||
2132 | *single asterisks* | |
2133 | ||
2134 | _single underscores_ | |
2135 | ||
2136 | **double asterisks** | |
2137 | ||
2138 | __double underscores__ | |
2139 | ||
2140 | will produce: | |
2141 | ||
2142 | <em>single asterisks</em> | |
2143 | ||
2144 | <em>single underscores</em> | |
2145 | ||
2146 | <strong>double asterisks</strong> | |
2147 | ||
2148 | <strong>double underscores</strong> | |
2149 | ||
2150 | You can use whichever style you prefer; the lone restriction is that | |
2151 | the same character must be used to open and close an emphasis span. | |
2152 | ||
2153 | Emphasis can be used in the middle of a word: | |
2154 | ||
2155 | un*fucking*believable | |
2156 | ||
2157 | But if you surround an `*` or `_` with spaces, it'll be treated as a | |
2158 | literal asterisk or underscore. | |
2159 | ||
2160 | To produce a literal asterisk or underscore at a position where it | |
2161 | would otherwise be used as an emphasis delimiter, you can backslash | |
2162 | escape it: | |
2163 | ||
2164 | \*this text is surrounded by literal asterisks\* | |
2165 | ||
2166 | ||
2167 | ||
2168 | <h3 id="code">Code</h3> | |
2169 | ||
2170 | To indicate a span of code, wrap it with backtick quotes (`` ` ``). | |
2171 | Unlike a pre-formatted code block, a code span indicates code within a | |
2172 | normal paragraph. For example: | |
2173 | ||
2174 | Use the `printf()` function. | |
2175 | ||
2176 | will produce: | |
2177 | ||
2178 | <p>Use the <code>printf()</code> function.</p> | |
2179 | ||
2180 | To include a literal backtick character within a code span, you can use | |
2181 | multiple backticks as the opening and closing delimiters: | |
2182 | ||
2183 | ``There is a literal backtick (`) here.`` | |
2184 | ||
2185 | which will produce this: | |
2186 | ||
2187 | <p><code>There is a literal backtick (`) here.</code></p> | |
2188 | ||
2189 | The backtick delimiters surrounding a code span may include spaces -- | |
2190 | one after the opening, one before the closing. This allows you to place | |
2191 | literal backtick characters at the beginning or end of a code span: | |
2192 | ||
2193 | A single backtick in a code span: `` ` `` | |
2194 | ||
2195 | A backtick-delimited string in a code span: `` `foo` `` | |
2196 | ||
2197 | will produce: | |
2198 | ||
2199 | <p>A single backtick in a code span: <code>`</code></p> | |
2200 | ||
2201 | <p>A backtick-delimited string in a code span: <code>`foo`</code></p> | |
2202 | ||
2203 | With a code span, ampersands and angle brackets are encoded as HTML | |
2204 | entities automatically, which makes it easy to include example HTML | |
2205 | tags. Markdown will turn this: | |
2206 | ||
2207 | Please don't use any `<blink>` tags. | |
2208 | ||
2209 | into: | |
2210 | ||
2211 | <p>Please don't use any <code><blink></code> tags.</p> | |
2212 | ||
2213 | You can write this: | |
2214 | ||
2215 | `—` is the decimal-encoded equivalent of `—`. | |
2216 | ||
2217 | to produce: | |
2218 | ||
2219 | <p><code>&#8212;</code> is the decimal-encoded | |
2220 | equivalent of <code>&mdash;</code>.</p> | |
2221 | ||
2222 | ||
2223 | ||
2224 | <h3 id="img">Images</h3> | |
2225 | ||
2226 | Admittedly, it's fairly difficult to devise a "natural" syntax for | |
2227 | placing images into a plain text document format. | |
2228 | ||
2229 | Markdown uses an image syntax that is intended to resemble the syntax | |
2230 | for links, allowing for two styles: *inline* and *reference*. | |
2231 | ||
2232 | Inline image syntax looks like this: | |
2233 | ||
2234 | ![Alt text](/path/to/img.jpg) | |
2235 | ||
2236 | ![Alt text](/path/to/img.jpg "Optional title") | |
2237 | ||
2238 | That is: | |
2239 | ||
2240 | * An exclamation mark: `!`; | |
2241 | * followed by a set of square brackets, containing the `alt` | |
2242 | attribute text for the image; | |
2243 | * followed by a set of parentheses, containing the URL or path to | |
2244 | the image, and an optional `title` attribute enclosed in double | |
2245 | or single quotes. | |
2246 | ||
2247 | Reference-style image syntax looks like this: | |
2248 | ||
2249 | ![Alt text][id] | |
2250 | ||
2251 | Where "id" is the name of a defined image reference. Image references | |
2252 | are defined using syntax identical to link references: | |
2253 | ||
2254 | [id]: url/to/image "Optional title attribute" | |
2255 | ||
2256 | As of this writing, Markdown has no syntax for specifying the | |
2257 | dimensions of an image; if this is important to you, you can simply | |
2258 | use regular HTML `<img>` tags. | |
2259 | ||
2260 | ||
2261 | * * * | |
2262 | ||
2263 | ||
2264 | <h2 id="misc">Miscellaneous</h2> | |
2265 | ||
2266 | <h3 id="autolink">Automatic Links</h3> | |
2267 | ||
2268 | Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this: | |
2269 | ||
2270 | <http://example.com/> | |
2271 | ||
2272 | Markdown will turn this into: | |
2273 | ||
2274 | <a href="http://example.com/">http://example.com/</a> | |
2275 | ||
2276 | Automatic links for email addresses work similarly, except that | |
2277 | Markdown will also perform a bit of randomized decimal and hex | |
2278 | entity-encoding to help obscure your address from address-harvesting | |
2279 | spambots. For example, Markdown will turn this: | |
2280 | ||
2281 | <address@example.com> | |
2282 | ||
2283 | into something like this: | |
2284 | ||
2285 | <a href="mailto:addre | |
2286 | ss@example.co | |
2287 | m">address@exa | |
2288 | mple.com</a> | |
2289 | ||
2290 | which will render in a browser as a clickable link to "address@example.com". | |
2291 | ||
2292 | (This sort of entity-encoding trick will indeed fool many, if not | |
2293 | most, address-harvesting bots, but it definitely won't fool all of | |
2294 | them. It's better than nothing, but an address published in this way | |
2295 | will probably eventually start receiving spam.) | |
2296 | ||
2297 | ||
2298 | ||
2299 | <h3 id="backslash">Backslash Escapes</h3> | |
2300 | ||
2301 | Markdown allows you to use backslash escapes to generate literal | |
2302 | characters which would otherwise have special meaning in Markdown's | |
2303 | formatting syntax. For example, if you wanted to surround a word with | |
2304 | literal asterisks (instead of an HTML `<em>` tag), you can backslashes | |
2305 | before the asterisks, like this: | |
2306 | ||
2307 | \*literal asterisks\* | |
2308 | ||
2309 | Markdown provides backslash escapes for the following characters: | |
2310 | ||
2311 | \ backslash | |
2312 | ` backtick | |
2313 | * asterisk | |
2314 | _ underscore | |
2315 | {} curly braces | |
2316 | [] square brackets | |
2317 | () parentheses | |
2318 | # hash mark | |
2319 | + plus sign | |
2320 | - minus sign (hyphen) | |
2321 | . dot | |
2322 | ! exclamation mark | |
2323 | ||
2324 | ||
2325 | ||
2326 | pegdown/src/test/resources/MarkdownTest103/Nested blockquotes.md | |
2327 | --- | |
2328 | ||
2329 | > foo | |
2330 | > | |
2331 | > > bar | |
2332 | > | |
2333 | > foo | |
2334 | ||
2335 | ||
2336 | pegdown/src/test/resources/MarkdownTest103/Ordered and unordered lists.md | |
2337 | --- | |
2338 | ||
2339 | ## Unordered | |
2340 | ||
2341 | Asterisks tight: | |
2342 | ||
2343 | * asterisk 1 | |
2344 | * asterisk 2 | |
2345 | * asterisk 3 | |
2346 | ||
2347 | ||
2348 | Asterisks loose: | |
2349 | ||
2350 | * asterisk 1 | |
2351 | ||
2352 | * asterisk 2 | |
2353 | ||
2354 | * asterisk 3 | |
2355 | ||
2356 | * * * | |
2357 | ||
2358 | Pluses tight: | |
2359 | ||
2360 | + Plus 1 | |
2361 | + Plus 2 | |
2362 | + Plus 3 | |
2363 | ||
2364 | ||
2365 | Pluses loose: | |
2366 | ||
2367 | + Plus 1 | |
2368 | ||
2369 | + Plus 2 | |
2370 | ||
2371 | + Plus 3 | |
2372 | ||
2373 | * * * | |
2374 | ||
2375 | ||
2376 | Minuses tight: | |
2377 | ||
2378 | - Minus 1 | |
2379 | - Minus 2 | |
2380 | - Minus 3 | |
2381 | ||
2382 | ||
2383 | Minuses loose: | |
2384 | ||
2385 | - Minus 1 | |
2386 | ||
2387 | - Minus 2 | |
2388 | ||
2389 | - Minus 3 | |
2390 | ||
2391 | ||
2392 | ## Ordered | |
2393 | ||
2394 | Tight: | |
2395 | ||
2396 | 1. First | |
2397 | 2. Second | |
2398 | 3. Third | |
2399 | ||
2400 | and: | |
2401 | ||
2402 | 1. One | |
2403 | 2. Two | |
2404 | 3. Three | |
2405 | ||
2406 | ||
2407 | Loose using tabs: | |
2408 | ||
2409 | 1. First | |
2410 | ||
2411 | 2. Second | |
2412 | ||
2413 | 3. Third | |
2414 | ||
2415 | and using spaces: | |
2416 | ||
2417 | 1. One | |
2418 | ||
2419 | 2. Two | |
2420 | ||
2421 | 3. Three | |
2422 | ||
2423 | Multiple paragraphs: | |
2424 | ||
2425 | 1. Item 1, graf one. | |
2426 | ||
2427 | Item 2. graf two. The quick brown fox jumped over the lazy dog's | |
2428 | back. | |
2429 | ||
2430 | 2. Item 2. | |
2431 | ||
2432 | 3. Item 3. | |
2433 | ||
2434 | ||
2435 | ||
2436 | ## Nested | |
2437 | ||
2438 | * Tab | |
2439 | * Tab | |
2440 | * Tab | |
2441 | ||
2442 | Here's another: | |
2443 | ||
2444 | 1. First | |
2445 | 2. Second: | |
2446 | * Fee | |
2447 | * Fie | |
2448 | * Foe | |
2449 | 3. Third | |
2450 | ||
2451 | Same thing but with paragraphs: | |
2452 | ||
2453 | 1. First | |
2454 | ||
2455 | 2. Second: | |
2456 | * Fee | |
2457 | * Fie | |
2458 | * Foe | |
2459 | ||
2460 | 3. Third | |
2461 | ||
2462 | ||
2463 | This was an error in Markdown 1.0.1: | |
2464 | ||
2465 | * this | |
2466 | ||
2467 | * sub | |
2468 | ||
2469 | that | |
2470 | ||
2471 | ||
2472 | pegdown/src/test/resources/MarkdownTest103/Strong and em together.md | |
2473 | --- | |
2474 | ||
2475 | ***This is strong and em.*** | |
2476 | ||
2477 | So is ***this*** word. | |
2478 | ||
2479 | ___This is strong and em.___ | |
2480 | ||
2481 | So is ___this___ word. | |
2482 | ||
2483 | ||
2484 | pegdown/src/test/resources/MarkdownTest103/Tabs.md | |
2485 | --- | |
2486 | ||
2487 | + this is a list item | |
2488 | indented with tabs | |
2489 | ||
2490 | + this is a list item | |
2491 | indented with spaces | |
2492 | ||
2493 | Code: | |
2494 | ||
2495 | this code block is indented by one tab | |
2496 | ||
2497 | And: | |
2498 | ||
2499 | this code block is indented by two tabs | |
2500 | ||
2501 | And: | |
2502 | ||
2503 | + this is an example list item | |
2504 | indented with tabs | |
2505 | ||
2506 | + this is an example list item | |
2507 | indented with spaces | |
2508 | ||
2509 | ||
2510 | pegdown/src/test/resources/MarkdownTest103/Tidyness.md | |
2511 | --- | |
2512 | ||
2513 | > A list within a blockquote: | |
2514 | > | |
2515 | > * asterisk 1 | |
2516 | > * asterisk 2 | |
2517 | > * asterisk 3 | |
2518 | ||
2519 | ||
2520 | pegdown/src/test/resources/Maruku/abbreviations.md | |
2521 | --- | |
2522 | ||
2523 | ||
2524 | The HTML specification is maintained by the W3C. | |
2525 | ||
2526 | *[HTML]: Hyper Text Markup Language | |
2527 | *[W3C]: World Wide Web Consortium | |
2528 | ||
2529 | ||
2530 | ||
2531 | Operation Tigra Genesis is going well. | |
2532 | ||
2533 | *[Tigra Genesis]: | |
2534 | ||
2535 | ||
2536 | pegdown/src/test/resources/Maruku/alt.md | |
2537 | --- | |
2538 | ||
2539 | ![bar](/foo.jpg) | |
2540 | ||
2541 | ||
2542 | ||
2543 | ||
2544 | pegdown/src/test/resources/Maruku/blank.md | |
2545 | --- | |
2546 | ||
2547 | ||
2548 | Linea 1 | |
2549 | ||
2550 | Linea 2 | |
2551 | ||
2552 | ||
2553 | pegdown/src/test/resources/Maruku/blanks_in_code.md | |
2554 | --- | |
2555 | ||
2556 | This block is composed of three lines: | |
2557 | ||
2558 | one | |
2559 | ||
2560 | three | |
2561 | ||
2562 | This block is composed of 5 | |
2563 | ||
2564 | ||
2565 | one | |
2566 | ||
2567 | ||
2568 | four | |
2569 | ||
2570 | ||
2571 | This block is composed of 2 | |
2572 | ||
2573 | ||
2574 | two | |
2575 | ||
2576 | ||
2577 | ||
2578 | ||
2579 | ||
2580 | pegdown/src/test/resources/Maruku/bug_def.md | |
2581 | --- | |
2582 | ||
2583 | [test][]: | |
2584 | ||
2585 | ||
2586 | ||
2587 | pegdown/src/test/resources/Maruku/bug_table.md | |
2588 | --- | |
2589 | ||
2590 | ||
2591 | ||
2592 | hello | |
2593 | {: summary="Table summary" .class1 style="color:red"} | |
2594 | ||
2595 | h | h | |
2596 | ----------|-- | |
2597 | {:t} c1 | c2 | |
2598 | {: summary="Table summary" .class1 style="color:red"} | |
2599 | ||
2600 | ||
2601 | ||
2602 | {:t: scope="row"} | |
2603 | ||
2604 | ||
2605 | pegdown/src/test/resources/Maruku/code2.md | |
2606 | --- | |
2607 | ||
2608 | > Code | |
2609 | > | |
2610 | > Ciao | |
2611 | ||
2612 | ||
2613 | pegdown/src/test/resources/Maruku/code3.md | |
2614 | --- | |
2615 | ||
2616 | ||
2617 | This is code (4 spaces): | |
2618 | ||
2619 | Code | |
2620 | This is not code | |
2621 | ||
2622 | Code | |
2623 | ||
2624 | This is code (1 tab): | |
2625 | ||
2626 | Code | |
2627 | This is not code | |
2628 | ||
2629 | Code | |
2630 | ||
2631 | ||
2632 | ||
2633 | ||
2634 | ||
2635 | pegdown/src/test/resources/Maruku/code.md | |
2636 | --- | |
2637 | ||
2638 | Here is an example of AppleScript: | |
2639 | ||
2640 | tell application "Foo" | |
2641 | beep | |
2642 | end tell | |
2643 | tab | |
2644 | ||
2645 | ||
2646 | ||
2647 | pegdown/src/test/resources/Maruku/data_loss.md | |
2648 | --- | |
2649 | ||
2650 | 1. abcd | |
2651 | efgh | |
2652 | ijkl | |
2653 | ||
2654 | ||
2655 | ||
2656 | pegdown/src/test/resources/Maruku/easy.md | |
2657 | --- | |
2658 | ||
2659 | *Hello!* how are **you**? | |
2660 | ||
2661 | ||
2662 | pegdown/src/test/resources/Maruku/email.md | |
2663 | --- | |
2664 | ||
2665 | ||
2666 | ||
2667 | This is an email address: <andrea@invalid.it> | |
2668 | ||
2669 | ||
2670 | ||
2671 | pegdown/src/test/resources/Maruku/entities.md | |
2672 | --- | |
2673 | ||
2674 | Maruku translates HTML entities to the equivalent in LaTeX: | |
2675 | ||
2676 | Entity | Result | |
2677 | ------------|---------- | |
2678 | `©` | © | |
2679 | `£` | £ | |
2680 | `a b` | a b | |
2681 | `λ` | λ | |
2682 | `—` | — | |
2683 | ||
2684 | ||
2685 | Entity-substitution does not happen in code blocks or inline code. | |
2686 | ||
2687 | The following should not be translated: | |
2688 | ||
2689 | © | |
2690 | ||
2691 | It should read just like this: `©`. | |
2692 | ||
2693 | ||
2694 | ||
2695 | ||
2696 | pegdown/src/test/resources/Maruku/escaping.md | |
2697 | --- | |
2698 | ||
2699 | Hello: ! \! \` \{ \} \[ \] \( \) \# \. \! * \* * | |
2700 | ||
2701 | ||
2702 | Ora, *emphasis*, **bold**, * <- due asterischi-> * , un underscore-> _ , _emphasis_, | |
2703 | incre*dible*e! | |
2704 | ||
2705 | This is ``Code with a special: -> ` <- ``(after) | |
2706 | ||
2707 | `Start ` of paragraph | |
2708 | ||
2709 | End of `paragraph ` | |
2710 | ||
2711 | ||
2712 | pegdown/src/test/resources/Maruku/extra_dl.md | |
2713 | --- | |
2714 | ||
2715 | CSS: style.css | |
2716 | ||
2717 | ||
2718 | Apple | |
2719 | : Pomaceous fruit of plants of the genus Malus in | |
2720 | the family Rosaceae. | |
2721 | ||
2722 | Orange | |
2723 | : The fruit of an evergreen tree of the genus Citrus. | |
2724 | ||
2725 | ||
2726 | ||
2727 | pegdown/src/test/resources/Maruku/extra_header_id.md | |
2728 | --- | |
2729 | ||
2730 | Header 1 {#header1} | |
2731 | ======== | |
2732 | ||
2733 | Header 2 {#header2} | |
2734 | -------- | |
2735 | ||
2736 | ### Header 3 ### {#header3} | |
2737 | ||
2738 | Then you can create links to different parts of the same document like this: | |
2739 | ||
2740 | [Link back to header 1](#header1), | |
2741 | [Link back to header 2](#header2), | |
2742 | [Link back to header 3](#header3) | |
2743 | ||
2744 | ||
2745 | ||
2746 | pegdown/src/test/resources/Maruku/extra_table1.md | |
2747 | --- | |
2748 | ||
2749 | ||
2750 | First Header | Second Header | |
2751 | ------------- | ------------- | |
2752 | Content Cell | Content Cell | |
2753 | Content Cell | Content Cell | |
2754 | ||
2755 | ||
2756 | ||
2757 | pegdown/src/test/resources/Maruku/footnotes.md | |
2758 | --- | |
2759 | ||
2760 | That's some text with a footnote [^b] and another [^c] and another [^a]. | |
2761 | ||
2762 | [^a]: And that's the footnote. | |
2763 | ||
2764 | That's the second paragraph of the footnote. | |
2765 | ||
2766 | ||
2767 | [^b]: And that's the footnote. | |
2768 | This is second sentence (same paragraph). | |
2769 | ||
2770 | [^c]: | |
2771 | This is the very long one. | |
2772 | ||
2773 | That's the second paragraph. | |
2774 | ||
2775 | ||
2776 | This is not a footnote. | |
2777 | ||
2778 | ||
2779 | pegdown/src/test/resources/Maruku/headers.md | |
2780 | --- | |
2781 | ||
2782 | A title with *emphasis* | |
2783 | ======================= | |
2784 | ||
2785 | A title with *emphasis* | |
2786 | ----------------------- | |
2787 | ||
2788 | ||
2789 | #### A title with *emphasis* #### | |
2790 | ||
2791 | ||
2792 | ||
2793 | ||
2794 | ||
2795 | pegdown/src/test/resources/Maruku/hex_entities.md | |
2796 | --- | |
2797 | ||
2798 | Examples of numeric character references include © or © for the copyright symbol, Α or Α for the Greek capital letter alpha, and ا or ا for the Arabic letter alef. | |
2799 | ||
2800 | ||
2801 | ||
2802 | ||
2803 | pegdown/src/test/resources/Maruku/hrule.md | |
2804 | --- | |
2805 | ||
2806 | * * * | |
2807 | ||
2808 | ||
2809 | ||
2810 | pegdown/src/test/resources/Maruku/html2.md | |
2811 | --- | |
2812 | ||
2813 | One | |
2814 | <div></div>123 | |
2815 | ||
2816 | <div></div>123 | |
2817 | ||
2818 | ||
2819 | pegdown/src/test/resources/Maruku/html3.md | |
2820 | --- | |
2821 | ||
2822 | taking part in <a href="http://sied.dis.uniroma1.it/">some arcane conspirations</a> which | |
2823 | involve <b href="http://www.flickr.com/photos/censi/70893277/">coffee</b>, | |
2824 | <a href="http://flickr.com/photos/censi/42775664/in/set-936677/">robots</a>, | |
2825 | <a href="http://www.flickr.com/photos/censi/42775888/in/set-936677/">sushi</a>, | |
2826 | ||
2827 | ||
2828 | ||
2829 | pegdown/src/test/resources/Maruku/html4.md | |
2830 | --- | |
2831 | ||
2832 | <div class="frame"> | |
2833 | <a class="photo" href="http://www.flickr.com/photos/censi/54757256/"><img alt="" | |
2834 | moz-do-not-send="true" | |
2835 | src="http://static.flickr.com/27/54757256_1a2c1d2a95_m.jpg" /></a> | |
2836 | </div> | |
2837 | ||
2838 | ||
2839 | ||
2840 | ||
2841 | pegdown/src/test/resources/Maruku/html5.md | |
2842 | --- | |
2843 | ||
2844 | <div class="frame"> | |
2845 | <a class="photo" href="http://www.flickr.com/photos/censi/88561568/" ><img moz-do-not-send="true" src="http://static.flickr.com/28/88561568_ab84d28245_m.jpg" width="240" height="180" alt="Aperitif" /></a> | |
2846 | </div> | |
2847 | ||
2848 | ||
2849 | ||
2850 | ||
2851 | pegdown/src/test/resources/Maruku/ie.md | |
2852 | --- | |
2853 | ||
2854 | `<p>here's an apostrophe & a quote "</p>` | |
2855 | ||
2856 | <p>here's an apostrophe & a quote "</p> | |
2857 | {:} | |
2858 | ||
2859 | <p>here's an apostrophe & a quote "</p> | |
2860 | {:lang=xml} | |
2861 | ||
2862 | <p>here's an apostrophe & a quote "</p> | |
2863 | {:html_use_syntax=true lang=not_supported} | |
2864 | ||
2865 | <p>here's an apostrophe & a quote "</p> | |
2866 | {:html_use_syntax=true lang=xml} | |
2867 | ||
2868 | ||
2869 | ||
2870 | ||
2871 | pegdown/src/test/resources/Maruku/images2.md | |
2872 | --- | |
2873 | ||
2874 | ||
2875 | This is an ![image][]. | |
2876 | ||
2877 | This is an ![image]. | |
2878 | ||
2879 | [image]: image.jpg | |
2880 | ||
2881 | ||
2882 | ||
2883 | pegdown/src/test/resources/Maruku/images.md | |
2884 | --- | |
2885 | ||
2886 | ||
2887 | This page does not uilizes ![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss) | |
2888 | ||
2889 | ||
2890 | Please mouseover to see the title: ![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss "Title ok!") | |
2891 | ||
2892 | Please mouseover to see the title: ![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss 'Title ok!') | |
2893 | ||
2894 | ||
2895 | I'll say it one more time: this page does not use ![Cascading Style Sheets] [css] | |
2896 | ||
2897 | This is double size: ![Cascading Style Sheets] [css2] | |
2898 | ||
2899 | ||
2900 | ||
2901 | [css]: http://jigsaw.w3.org/css-validator/images/vcss "Optional title attribute" | |
2902 | ||
2903 | [css2]: http://jigsaw.w3.org/css-validator/images/vcss "Optional title attribute" | |
2904 | ||
2905 | pegdown/src/test/resources/Maruku/inline_html2.md | |
2906 | --- | |
2907 | ||
2908 | <div markdown="1">Test **bold**</div> | |
2909 | <p markdown="1">Test **bold**</p> | |
2910 | ||
2911 | ||
2912 | pegdown/src/test/resources/Maruku/inline_html.md | |
2913 | --- | |
2914 | ||
2915 | CSS: style.css | |
2916 | ||
2917 | Input: | |
2918 | ||
2919 | <em>Emphasis</em> | |
2920 | ||
2921 | Result: <em>Emphasis</em> | |
2922 | ||
2923 | Input: | |
2924 | ||
2925 | <img src="http://jigsaw.w3.org/css-validator/images/vcss"/> | |
2926 | ||
2927 | Result on span: <img src="http://jigsaw.w3.org/css-validator/images/vcss"/> | |
2928 | ||
2929 | Result alone: | |
2930 | ||
2931 | <img src="http://jigsaw.w3.org/css-validator/images/vcss"/> | |
2932 | ||
2933 | <div markdown="1"> | |
2934 | This is *true* markdown text (paragraph) | |
2935 | ||
2936 | <p markdown="1"> | |
2937 | This is *true* markdown text (no paragraph) | |
2938 | </p> | |
2939 | <p markdown="block"> | |
2940 | This is *true* markdown text (block paragraph) | |
2941 | </p> | |
2942 | </div> | |
2943 | ||
2944 | <table> | |
2945 | <tr> | |
2946 | <td markdown="1">This is *true* markdown text. (no par)</td> | |
2947 | <td markdown="block">This is *true* markdown text. (par)</td> | |
2948 | </tr> | |
2949 | </table> | |
2950 | ||
2951 | ||
2952 | ||
2953 | ||
2954 | pegdown/src/test/resources/Maruku/links.md | |
2955 | --- | |
2956 | ||
2957 | ||
2958 | Search on [Google][] | |
2959 | ||
2960 | Search on [Google] [] | |
2961 | ||
2962 | Search on [Google] [google] | |
2963 | ||
2964 | Search on [Google] [Google] | |
2965 | ||
2966 | Search on [Google images][] | |
2967 | ||
2968 | Inline: [Google images](http://google.com) | |
2969 | ||
2970 | Inline with title: [Google images](http://google.com "Title") | |
2971 | ||
2972 | Inline with title: [Google images]( http://google.com "Title" ) | |
2973 | ||
2974 | ||
2975 | Search on <http://www.gogole.com> or <http://Here.com> or ask <bill@google.com> | |
2976 | or you might ask bill@google.com. | |
2977 | ||
2978 | If all else fails, ask [Google](http://www.google.com) | |
2979 | ||
2980 | [google]: http://www.google.com | |
2981 | ||
2982 | [google2]: http://www.google.com 'Single quotes' | |
2983 | ||
2984 | [google3]: http://www.google.com "Double quotes" | |
2985 | ||
2986 | [google4]: http://www.google.com (Parenthesis) | |
2987 | ||
2988 | [Google Search]: | |
2989 | http://www.google.com "Google search" | |
2990 | ||
2991 | [Google Images]: | |
2992 | http://images.google.com (Google images) | |
2993 | ||
2994 | ||
2995 | pegdown/src/test/resources/Maruku/list1.md | |
2996 | --- | |
2997 | ||
2998 | * A list item with a blockquote: | |
2999 | ||
3000 | > This is a blockquote | |
3001 | > inside a list item. | |
3002 | ||
3003 | ||
3004 | ||
3005 | pegdown/src/test/resources/Maruku/list2.md | |
3006 | --- | |
3007 | ||
3008 | * This is a list item with two paragraphs. | |
3009 | ||
3010 | This is the second paragraph in the list item. You're | |
3011 | only required to indent the first line. Lorem ipsum dolor | |
3012 | sit amet, consectetuer adipiscing elit. | |
3013 | ||
3014 | * other | |
3015 | ||
3016 | ||
3017 | ||
3018 | pegdown/src/test/resources/Maruku/list3.md | |
3019 | --- | |
3020 | ||
3021 | * A list item with a blockquote: | |
3022 | ||
3023 | > This is a blockquote | |
3024 | > inside a list item. | |
3025 | ||
3026 | * A list item with a code block: | |
3027 | ||
3028 | <code goes here> | |
3029 | ||
3030 | ||
3031 | pegdown/src/test/resources/Maruku/list4.md | |
3032 | --- | |
3033 | ||
3034 | This is a list: | |
3035 | * one | |
3036 | * two | |
3037 | ||
3038 | This is not a list: | |
3039 | * one | |
3040 | ciao | |
3041 | ||
3042 | This is a list: | |
3043 | 1. one | |
3044 | 1. two | |
3045 | ||
3046 | This is not a list: | |
3047 | 1987. one | |
3048 | ciao | |
3049 | ||
3050 | ||
3051 | ||
3052 | pegdown/src/test/resources/Maruku/lists11.md | |
3053 | --- | |
3054 | ||
3055 | - ένα | |
3056 | ||
3057 | ||
3058 | ||
3059 | pegdown/src/test/resources/Maruku/lists6.md | |
3060 | --- | |
3061 | ||
3062 | ||
3063 | ||
3064 | ||
3065 | pegdown/src/test/resources/Maruku/lists7b.md | |
3066 | --- | |
3067 | ||
3068 | * a | |
3069 | * a1 | |
3070 | * a2 | |
3071 | * b | |
3072 | ||
3073 | ||
3074 | ||
3075 | ||
3076 | pegdown/src/test/resources/Maruku/lists7.md | |
3077 | --- | |
3078 | ||
3079 | Ciao | |
3080 | ||
3081 | * Tab | |
3082 | * Tab | |
3083 | * Tab | |
3084 | ||
3085 | ||
3086 | ||
3087 | pegdown/src/test/resources/Maruku/lists8.md | |
3088 | --- | |
3089 | ||
3090 | Here is a paragraph. | |
3091 | ||
3092 | ||
3093 | * Item 1 | |
3094 | * Item 2 | |
3095 | * Item 3 | |
3096 | ||
3097 | ||
3098 | ||
3099 | pegdown/src/test/resources/Maruku/lists9.md | |
3100 | --- | |
3101 | ||
3102 | - Due | |
3103 | 1. tre | |
3104 | 1. tre | |
3105 | 1. tre | |
3106 | - Due | |
3107 | ||
3108 | ||
3109 | pegdown/src/test/resources/Maruku/lists_after_paragraph.md | |
3110 | --- | |
3111 | ||
3112 | Paragraph, list with no space: | |
3113 | * ciao | |
3114 | ||
3115 | Paragraph, list with 1 space: | |
3116 | * ciao | |
3117 | ||
3118 | Paragraph, list with 3 space: | |
3119 | * ciao | |
3120 | ||
3121 | Paragraph, list with 4 spaces: | |
3122 | * ciao | |
3123 | ||
3124 | Paragraph, list with 1 tab: | |
3125 | * ciao | |
3126 | ||
3127 | Paragraph (1 space after), list with no space: | |
3128 | * ciao | |
3129 | ||
3130 | Paragraph (2 spaces after), list with no space: | |
3131 | * ciao | |
3132 | ||
3133 | Paragraph (3 spaces after), list with no space: | |
3134 | * ciao | |
3135 | ||
3136 | Paragraph with block quote: | |
3137 | > Quoted | |
3138 | ||
3139 | Paragraph with header: | |
3140 | ### header ### | |
3141 | ||
3142 | Paragraph with header on two lines: | |
3143 | header | |
3144 | ------ | |
3145 | ||
3146 | ||
3147 | Paragraph with html after | |
3148 | <div></div> | |
3149 | ||
3150 | Paragraph with html after, indented: | |
3151 | <em>Emphasis</em> | |
3152 | ||
3153 | Paragraph with html after, indented: <em>Emphasis</em> *tralla* <em>Emph</em> | |
3154 | ||
3155 | Paragraph with html after, indented: <em>Emphasis *tralla* Emph</em> | |
3156 | ||
3157 | ||
3158 | ||
3159 | pegdown/src/test/resources/Maruku/lists.md | |
3160 | --- | |
3161 | ||
3162 | * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. | |
3163 | Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, | |
3164 | viverra nec, fringilla in, laoreet vitae, risus. | |
3165 | * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
3166 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
3167 | * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
3168 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
3169 | * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
3170 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
3171 | * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
3172 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
3173 | ||
3174 | Ancora | |
3175 | ||
3176 | * This is a list item with two paragraphs. Lorem ipsum dolor | |
3177 | sit amet, consectetuer adipiscing elit. Aliquam hendrerit | |
3178 | mi posuere lectus. | |
3179 | ||
3180 | ATTENZIONE! | |
3181 | ||
3182 | * Suspendisse id sem consectetuer libero luctus adipiscing. | |
3183 | ||
3184 | ||
3185 | Ancora | |
3186 | ||
3187 | * This is a list item with two paragraphs. | |
3188 | ||
3189 | This is the second paragraph in the list item. You're | |
3190 | only required to indent the first line. Lorem ipsum dolor | |
3191 | sit amet, consectetuer adipiscing elit. | |
3192 | ||
3193 | * Another item in the same list. | |
3194 | ||
3195 | ||
3196 | pegdown/src/test/resources/Maruku/lists_ol.md | |
3197 | --- | |
3198 | ||
3199 | 1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. | |
3200 | Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, | |
3201 | viverra nec, fringilla in, laoreet vitae, risus. | |
3202 | 2. Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
3203 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
3204 | 3. Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
3205 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
3206 | 3. Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
3207 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
3208 | 4. Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | |
3209 | Suspendisse id sem consectetuer libero luctus adipiscing. | |
3210 | ||
3211 | Ancora | |
3212 | ||
3213 | 1. This is a list item with two paragraphs. Lorem ipsum dolor | |
3214 | sit amet, consectetuer adipiscing elit. Aliquam hendrerit | |
3215 | mi posuere lectus. | |
3216 | ||
3217 | ATTENZIONE! | |
3218 | ||
3219 | - Uno | |
3220 | - Due | |
3221 | 1. tre | |
3222 | 1. tre | |
3223 | 1. tre | |
3224 | - Due | |
3225 | ||
3226 | 2. Suspendisse id sem consectetuer libero luctus adipiscing. | |
3227 | ||
3228 | ||
3229 | Ancora | |
3230 | ||
3231 | * This is a list item with two paragraphs. | |
3232 | ||
3233 | This is the second paragraph in the list item. You're | |
3234 | only required to indent the first line. Lorem ipsum dolor | |
3235 | sit amet, consectetuer adipiscing elit. | |
3236 | ||
3237 | * Another item in the same list. | |
3238 | ||
3239 | ||
3240 | pegdown/src/test/resources/Maruku/loss.md | |
3241 | --- | |
3242 | ||
3243 | <br/>123 | |
3244 | ||
3245 | ||
3246 | ||
3247 | pegdown/src/test/resources/Maruku/misc_sw.md | |
3248 | --- | |
3249 | ||
3250 | Subject: Software not painful to use | |
3251 | Subject_short: painless software | |
3252 | Topic: /misc/coolsw | |
3253 | Archive: no | |
3254 | Date: Nov 20 2006 | |
3255 | Order: -9.5 | |
3256 | inMenu: true | |
3257 | ||
3258 | ||
3259 | ### General ### | |
3260 | ||
3261 | * *Operating System* : [Mac OS X][switch]: heaven, after the purgatory of Linux | |
3262 | and the hell of Windows. | |
3263 | * *Browser*: [Firefox][firefox]. On a Mac, [Camino][camino]. | |
3264 | * *Email*: [GMail][gmail], "search, don't sort" really works. | |
3265 | * *Text Editor*: [TextMate][textmate], you have to buy it, but it's worth every | |
3266 | penny. There are rumours that it's been converting (recovering) Emacs | |
3267 | users (addicts). Unfortunately, it's Mac only. An alternative is | |
3268 | [jedit][jedit] (GPL, Java). | |
3269 | ||
3270 | ### Development ### | |
3271 | ||
3272 | * *Build system*: [cmake][cmake], throw the [autotools][autotools] away. | |
3273 | * *Source code control system*: ditch CVS for [subversion][subversion]. | |
3274 | * *Project management*: [Trac][trac] tracks everything. | |
3275 | * *Scripting language*: [Ruby][ruby] is Japanese pragmatism (and has a [poignant][poignant] guide). | |
3276 | Python, you say? Python is too academic and snob: | |
3277 | ||
3278 | $ python | |
3279 | Python 2.4.1 (\#1, Jun 4 2005, 00:54:33) | |
3280 | Type "help", "copyright", "credits" or "license" for more information. | |
3281 | >>> exit | |
3282 | 'Use Ctrl-D (i.e. EOF) to exit.' | |
3283 | >>> quit | |
3284 | 'Use Ctrl-D (i.e. EOF) to exit.' | |
3285 | ||
3286 | * *Java IDE*: [JBuilder][jbuilder] is great software and has a free version (IMHO better than Eclipse). Java | |
3287 | is not a pain anymore since it gained [generics][java-generics] and got opensourced. | |
3288 | * *Mark-up language*: HTML is so 2001, why don't you take at look at [Markdown][markdown]? [Look at the source of this page](data/misc_markdown.png). | |
3289 | * *C++ libraries*: | |
3290 | * [QT][qt] for GUIs. | |
3291 | * [GSL][gsl] for math. | |
3292 | * [Magick++][magick] for manipulating images. | |
3293 | * [Cairo][cairo] for creating PDFs. | |
3294 | * [Boost][boost] for just about everything else. | |
3295 | ||
3296 | ||
3297 | ### Research ### | |
3298 | ||
3299 | * *Writing papers*: [LaTeX][latex] | |
3300 | * *Writing papers & enjoying the process*: [LyX][lyx] | |
3301 | * *Handsome figures in your papers*: [xfig][xfig] or, better, [jfig][jfig]. | |
3302 | * *The occasional presentation with many graphical content*: | |
3303 | [OpenOffice Impress][impress] (using the [OOOlatex plugin][ooolatex]); | |
3304 | the alternative is PowerPoint with the [TexPoint][texpoint] plugin. | |
3305 | * *Managing BibTeX*: [jabref][jabref]: multi-platform, for all your bibtex needs. | |
3306 | * *IEEExplore and BibTeX*: convert citations using [BibConverter][bibconverter]. | |
3307 | ||
3308 | ### Cool websites ### | |
3309 | ||
3310 | * *Best site in the wwworld*: [Wikipedia][wikipedia] | |
3311 | * [Mutopia][mutopia] for sheet music; [the Gutenberg Project][gutenberg] for books; [LiberLiber][liberliber] for books in italian. | |
3312 | * *Blogs*: [Bloglines][bloglines] | |
3313 | * *Sharing photos*: [flickr][flickr] exposes an API you can use. | |
3314 | ||
3315 | ||
3316 | [firefox]: http://getfirefox.com/ | |
3317 | [gmail]: http://gmail.com/ | |
3318 | [bloglines]: http://bloglines.com/ | |
3319 | [wikipedia]: http://en.wikipedia.org/ | |
3320 | [ruby]: http://www.ruby-lang.org/ | |
3321 | [poignant]: http://poignantguide.net/ruby/ | |
3322 | [webgen]: http://webgen.rubyforge.org/ | |
3323 | [markdown]: http://daringfireball.net/projects/markdown/ | |
3324 | [latex]: http://en.wikipedia.org/wiki/LaTeX | |
3325 | [lyx]: http://www.lyx.org | |
3326 | [impress]: http://www.openoffice.org/product/impress.html | |
3327 | [ooolatex]: http://ooolatex.sourceforge.net/ | |
3328 | [texpoint]: http://texpoint.necula.org/ | |
3329 | [jabref]: http://jabref.sourceforge.net/ | |
3330 | [camino]: http://www.caminobrowser.org/ | |
3331 | [switch]: http://www.apple.com/getamac/ | |
3332 | [textmate]: http://www.apple.com/getamac/ | |
3333 | [cmake]: http://www.cmake.org/ | |
3334 | [xfig]: http://www.xfig.org/ | |
3335 | [jfig]: http://tams-www.informatik.uni-hamburg.de/applets/jfig/ | |
3336 | [subversion]: http://subversion.tigris.org | |
3337 | [jbuilder]: http://www.borland.com/us/products/jbuilder/index.html | |
3338 | [flickr]: http://www.flickr.com/ | |
3339 | [myflickr]: http://www.flickr.com/photos/censi | |
3340 | [bibconverter]: http://www.bibconverter.net/ieeexplore/ | |
3341 | [autotools]: http://sources.redhat.com/autobook/ | |
3342 | [jedit]: http://www.jedit.org/ | |
3343 | [qt]: http://www.trolltech.no/ | |
3344 | [gsl]: http://www.gnu.org/software/gsl/ | |
3345 | [magick]: http://www.imagemagick.org/Magick++/ | |
3346 | [cairo]: http://cairographics.org/ | |
3347 | [boost]: http://www.boost.org/ | |
3348 | [markdown]: http://en.wikipedia.org/wiki/Markdown | |
3349 | [trac]: http://trac.edgewall.org/ | |
3350 | [mutopia]: http://www.mutopiaproject.org/ | |
3351 | [liberliber]: http://www.liberliber.it/ | |
3352 | [gutenberg]: http://www.gutenberg.org/ | |
3353 | [java-generics]: http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html | |
3354 | ||
3355 | ||
3356 | ||
3357 | ||
3358 | pegdown/src/test/resources/Maruku/olist.md | |
3359 | --- | |
3360 | ||
3361 | This is a list: | |
3362 | ||
3363 | 2. one | |
3364 | 2. two | |
3365 | 3. three | |
3366 | ||
3367 | ||
3368 | pegdown/src/test/resources/Maruku/one.md | |
3369 | --- | |
3370 | ||
3371 | One line | |
3372 | ||
3373 | ||
3374 | pegdown/src/test/resources/Maruku/paragraph.md | |
3375 | --- | |
3376 | ||
3377 | Paragraph | |
3378 | ||
3379 | ||
3380 | ||
3381 | pegdown/src/test/resources/Maruku/paragraphs.md | |
3382 | --- | |
3383 | ||
3384 | Paragraph 1 | |
3385 | ||
3386 | Paragraph 2 | |
3387 | ||
3388 | ||
3389 | Paragraph 3 | |
3390 | Paragraph 4 | |
3391 | Paragraph Br-> | |
3392 | Paragraph 5 | |
3393 | ||
3394 | ||
3395 | ||
3396 | ||
3397 | pegdown/src/test/resources/Maruku/smartypants.md | |
3398 | --- | |
3399 | ||
3400 | 'Twas a "test" to 'remember' in the '90s. | |
3401 | 'Twas a "test" to 'remember' in the '90s. | |
3402 | ||
3403 | It was --- in a sense --- really... interesting. | |
3404 | It was --- in a sense --- really... interesting. | |
3405 | ||
3406 | I -- too -- met << some curly quotes >> there or <<here>>No space. | |
3407 | I -- too -- met << some curly quotes >> there or <<here>>No space. | |
3408 | ||
3409 | ||
3410 | She was 6\"12\'. | |
3411 | > She was 6\"12\'. | |
3412 | ||
3413 | ||
3414 | ||
3415 | pegdown/src/test/resources/Maruku/syntax_hl.md | |
3416 | --- | |
3417 | ||
3418 | This is ruby code: | |
3419 | ||
3420 | require 'maruku' | |
3421 | ||
3422 | puts Maruku.new($stdin).to_html | |
3423 | ||
3424 | This is ruby code: | |
3425 | ||
3426 | require 'maruku' | |
3427 | {: lang=ruby html_use_syntax} | |
3428 | ||
3429 | puts Maruku.new($stdin).to_html | |
3430 | ||
3431 | ||
3432 | pegdown/src/test/resources/Maruku/table_attributes.md | |
3433 | --- | |
3434 | ||
3435 | ||
3436 | h | h | |
3437 | ----------|-- | |
3438 | {:t} c1 | c2 | |
3439 | {: summary="Table summary" .class1 style="color:red" border=3 width="50%" frame=lhs rules=cols cellspacing=2em cellpadding=4px} | |
3440 | ||
3441 | {:t: scope="row"} | |
3442 | ||
3443 | ||
3444 | pegdown/src/test/resources/Maruku/test.md | |
3445 | --- | |
3446 | ||
3447 | ||
3448 | $ python | |
3449 | ||
3450 | ||
3451 | ||
3452 | ||
3453 | ||
3454 | pegdown/src/test/resources/Maruku/wrapping.md | |
3455 | --- | |
3456 | ||
3457 | Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Break: | |
3458 | Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. | |
3459 | ||
3460 | * Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet | |
3461 | Lorem ipsum Break: | |
3462 | Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet | |
3463 | * Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet | |
3464 | ||
3465 | ||
3466 | ||
3467 | pegdown/src/test/resources/Maruku/xml2.md | |
3468 | --- | |
3469 | ||
3470 | <!-- | |
3471 | < | |
3472 | --> | |
3473 | ||
3474 | ||
3475 | pegdown/src/test/resources/Maruku/xml3.md | |
3476 | --- | |
3477 | ||
3478 | <table markdown='1'> | |
3479 | Blah | |
3480 | <thead> | |
3481 | <td>*em*</td> | |
3482 | </thead> | |
3483 | </table> | |
3484 | ||
3485 | ||
3486 | ||
3487 | pegdown/src/test/resources/Maruku/xml_instruction.md | |
3488 | --- | |
3489 | ||
3490 | ||
3491 | <? noTarget?> | |
3492 | <?php ?> | |
3493 | <?xml ?> | |
3494 | <?mrk ?> | |
3495 | ||
3496 | Targets <? noTarget?> <?php ?> <?xml ?> <?mrk ?> | |
3497 | ||
3498 | Inside: <?mrk puts "Inside: Hello" ?> last | |
3499 | ||
3500 | ||
3501 | ||
3502 | ||
3503 | pegdown/src/test/resources/Maruku/xml.md | |
3504 | --- | |
3505 | ||
3506 | ||
3507 | <svg:svg/> | |
3508 | ||
3509 | <svg:svg | |
3510 | width="600px" height="400px"> | |
3511 | <svg:g id="group"> | |
3512 | <svg:circle id="circ1" r="1cm" cx="3cm" cy="3cm" style="fill:red;"></svg:circle> | |
3513 | <svg:circle id="circ2" r="1cm" cx="7cm" cy="3cm" style="fill:red;" /> | |
3514 | </svg:g> | |
3515 | </svg:svg> | |
3516 | ||
3517 | ||
3518 | ||
3519 | pegdown/src/test/resources/pegdown/Abbreviations.md | |
3520 | --- | |
3521 | ||
3522 | ||
3523 | The HTML specification is maintained by the W3C. | |
3524 | ||
3525 | *[HTML]: Hyper Text Markup Language | |
3526 | *[W3C]: World Wide Web Consortium | |
3527 | ||
3528 | ||
3529 | ||
3530 | Operation Tigra Genesis is going well. | |
3531 | ||
3532 | *[Tigra Genesis]: | |
3533 | ||
3534 | ||
3535 | pegdown/src/test/resources/pegdown/AstText.md | |
3536 | --- | |
3537 | ||
3538 | # Ast Test | |
3539 | ||
3540 | This _is_ a **simple** & small text to | |
3541 | ||
3542 | > test | |
3543 | > yes, test | |
3544 | ||
3545 | the functionality of | |
3546 | ||
3547 | * AST index creation | |
3548 | - one more level | |
3549 | ||
3550 | * nothing more | |
3551 | ||
3552 | Some code! | |
3553 | ||
3554 | * multi | |
3555 | paragraph | |
3556 | ||
3557 | list item! | |
3558 | ||
3559 | And: | |
3560 | ~ a definition! | |
3561 | ||
3562 | Another one | |
3563 | : With more | |
3564 | ||
3565 | than one paragraph! | |
3566 | ||
3567 | Everything | |
3568 | ||
3569 | is expected | |
3570 | to be fine | |
3571 | ||
3572 | A Blockquote | |
3573 | ||
3574 | > easy | |
3575 | > | |
3576 | > easy easy | |
3577 | ||
3578 | A code block starting with a tab: | |
3579 | ||
3580 | > bla bla | |
3581 | ||
3582 | And more text | |
3583 | ||
3584 | pegdown/src/test/resources/pegdown/Autolinks.md | |
3585 | --- | |
3586 | ||
3587 | # Autolinks | |
3588 | ||
3589 | Autolinks are simple URIs like http://www.parboiled.org, | |
3590 | which will be automatically "activated" by pegdown. | |
3591 | ||
3592 | pegdown tries to be smart and not include trailing | |
3593 | punctuation marks like commas and such in the email | |
3594 | and URI links (joe@somewhere.com is such an example). | |
3595 | ftp://somesite.org:1234: this would be another one! | |
3596 | ||
3597 | ||
3598 | pegdown/src/test/resources/pegdown/Bug_in_0.8.5.1.md | |
3599 | --- | |
3600 | ||
3601 | **A**ll**F**ather wo**R**ld **O**rder! | |
3602 | ||
3603 | pegdown/src/test/resources/pegdown/Bug_in_0.8.5.4.md | |
3604 | --- | |
3605 | ||
3606 | * Hello World | |
3607 | * Worwe qworijwetor | |
3608 | ||
3609 | pegdown/src/test/resources/pegdown/Bug_in_1.0.0.md | |
3610 | --- | |
3611 | ||
3612 | The following list contains items with code blocks: | |
3613 | ||
3614 | * List Item A | |
3615 | ||
3616 | This is a verbatim line | |
3617 | and another one | |
3618 | ||
3619 | all of these should become | |
3620 | part of the | |
3621 | ||
3622 | same verbatim block | |
3623 | ||
3624 | only these lines here | |
3625 | ||
3626 | should interrupt | |
3627 | the | |
3628 | ||
3629 | verbatims blocks | |
3630 | ||
3631 | * another List Items | |
3632 | ||
3633 | and something completely different here | |
3634 | ||
3635 | pegdown/src/test/resources/pegdown/HTML suppression.md | |
3636 | --- | |
3637 | ||
3638 | HTML <b>SUPPRESSION</b> | |
3639 | ======================= | |
3640 | ||
3641 | This is a paragraph containing a <strong>strong</strong> inline HTML element and: | |
3642 | ||
3643 | <div> | |
3644 | <p>an actual block of HTML!</p> | |
3645 | </div> | |
3646 | ||
3647 | ||
3648 | pegdown/src/test/resources/pegdown/Linebreaks.md | |
3649 | --- | |
3650 | ||
3651 | Linebreaks | |
3652 | ========== | |
3653 | ||
3654 | With the HARDWRAPS extension | |
3655 | enabled all these linebreaks | |
3656 | should be kept as is in the | |
3657 | created HTML | |
3658 | ||
3659 | These ones here | |
3660 | as | |
3661 | well! | |
3662 | ||
3663 | ||
3664 | pegdown/src/test/resources/pegdown/No Follow Links.md | |
3665 | --- | |
3666 | ||
3667 | # No Follow Links | |
3668 | ||
3669 | Autolinks are simple URIs like http://www.parboiled.org, | |
3670 | which will be automatically "activated" by pegdown. | |
3671 | ||
3672 | pegdown tries to be smart and not include trailing | |
3673 | punctuation marks like commas and such in the email | |
3674 | and URI links (joe@somewhere.com is such an example). | |
3675 | ftp://somesite.org:1234: this would be another one! | |
3676 | ||
3677 | This is a [regular](http://regular.com) link and | |
3678 | [this one here][] is a reference link. | |
3679 | ||
3680 | [this one here]: http://blabla.com | |
3681 | ||
3682 | pegdown/src/test/resources/pegdown/Parens_in_URL.md | |
3683 | --- | |
3684 | ||
3685 | [Inline link 1 with parens](/url\(test\) "title"). | |
3686 | ||
3687 | [Inline link 2 with parens](</url\(test\)> "title"). | |
3688 | ||
3689 | [Reference link 1 with parens][1]. | |
3690 | ||
3691 | [Reference link 2 with parens][2]. | |
3692 | ||
3693 | [1]: /url(test) "title" | |
3694 | [2]: </url(test)> "title" | |
3695 | ||
3696 | ||
3697 | pegdown/src/test/resources/pegdown/Quoted Blockquote.md | |
3698 | --- | |
3699 | ||
3700 | > Line A | |
3701 | > Line B | |
3702 | > | |
3703 | > Line after blank line. | |
3704 | ||
3705 | ||
3706 | pegdown/src/test/resources/pegdown/Smartypants.md | |
3707 | --- | |
3708 | ||
3709 | # Smart quotes, ellipses, dashes | |
3710 | ||
3711 | "Hello," said the spider. "'Shelob' is my name." | |
3712 | ||
3713 | 'A', 'B', and 'C' are letters. | |
3714 | ||
3715 | 'Oak,' 'elm,' and 'beech' are names of trees. | |
3716 | So is 'pine.' | |
3717 | ||
3718 | 'He said, "I want to go."' | |
3719 | Were you alive in the 70's? | |
3720 | ||
3721 | Here is some quoted '`code`' and a "[quoted link][1]". | |
3722 | ||
3723 | I've alwayed thought I'd rather not do it. But then we're all screwed, since I'm the only one! | |
3724 | ||
3725 | Some dashes: one---two --- three--four -- five. | |
3726 | ||
3727 | Dashes between numbers: 5-7, 255-66, 1987-1999. | |
3728 | ||
3729 | Ellipses...and. . .and . . . . | |
3730 | ||
3731 | pegdown/src/test/resources/pegdown/Special Chars.md | |
3732 | --- | |
3733 | ||
3734 | # Special character handling | |
3735 | ||
3736 | Quote from <http://henkelmann.eu/2011/01/06/actuarius_release_note> | |
3737 | ||
3738 | Better handling of escapes than PegDown: PegDown does not escape | |
3739 | special HTML characters like <, >, &, " and ' in normal text paragraphs, just in code blocks. | |
3740 | ||
3741 | Maybe if>they are¬ "stand-alone"? | |
3742 | ||
3743 | Well, I don't think so :) | |
3744 | (at least not as of **pegdown 0.9.2**!) | |
3745 | ||
3746 | pegdown/src/test/resources/pegdown/Tables.md | |
3747 | --- | |
3748 | ||
3749 | Tables | |
3750 | ------ | |
3751 | ||
3752 | Simple Table: | |
3753 | ||
3754 | First | Second | |
3755 | ------|------- | |
3756 | Cool | Shit | |
3757 | ||
3758 | Without header: | |
3759 | ||
3760 | |--------|-------| | |
3761 | |Cool | Shit | | |
3762 | |is this | really | |
3763 | ||
3764 | With some alignment: | |
3765 | ||
3766 | :-----|-----:|----|:---: | |
3767 | Cool | Shit | in | here | |
3768 | ||
3769 | And now to some colspan: | |
3770 | ||
3771 | Names || | |
3772 | Name | Firstname | Age | |
3773 | ------|-----------|----: | |
3774 | Fox | Peter | 42 | |
3775 | Guy | Ritchie | ca. 60 | |
3776 | ||
3777 | ||
3778 | Multimarkdown example: | |
3779 | ||
3780 | | | Grouping || | |
3781 | First Header | Second Header | Third Header | | |
3782 | ------------ | :-----------: | -----------: | | |
3783 | Content | *Long Cell* || | |
3784 | Content | **Cell** | Cell | | |
3785 | New section | More | Data | | |
3786 | And more | | And more | | |
3787 | ||
3788 | ||
3789 | ||
3790 | pegdown/src/test/resources/PhpMarkdown/Backslash_escapes.md | |
3791 | --- | |
3792 | ||
3793 | Tricky combinaisons: | |
3794 | ||
3795 | backslash with \-- two dashes | |
3796 | ||
3797 | backslash with \> greater than | |
3798 | ||
3799 | \[test](not a link) | |
3800 | ||
3801 | \*no emphasis* | |
3802 | ||
3803 | pegdown/src/test/resources/PhpMarkdown/Code_block_in_a_list_item.md | |
3804 | --- | |
3805 | ||
3806 | ||
3807 | * List Item: | |
3808 | ||
3809 | code block | |
3810 | ||
3811 | with a blank line | |
3812 | ||
3813 | within a list item. | |
3814 | ||
3815 | pegdown/src/test/resources/PhpMarkdown/Code_Spans.md | |
3816 | --- | |
3817 | ||
3818 | From `<!--` to `-->` | |
3819 | on two lines. | |
3820 | ||
3821 | From `<!--` | |
3822 | to `-->` | |
3823 | on three lines. | |
3824 | ||
3825 | ||
3826 | pegdown/src/test/resources/PhpMarkdown/Email_auto_links.md | |
3827 | --- | |
3828 | ||
3829 | <michel.fortin@michelf.com> | |
3830 | ||
3831 | International domain names: <help@tūdaliņ.lv> | |
3832 | ||
3833 | pegdown/src/test/resources/PhpMarkdown/Emphasis.md | |
3834 | --- | |
3835 | ||
3836 | Combined emphasis: | |
3837 | ||
3838 | 1. ***test test*** | |
3839 | 2. ___test test___ | |
3840 | 3. *test **test*** | |
3841 | 4. **test *test*** | |
3842 | 5. ***test* test** | |
3843 | 6. ***test** test* | |
3844 | 7. ***test* test** | |
3845 | 8. **test *test*** | |
3846 | 9. *test **test*** | |
3847 | 10. _test __test___ | |
3848 | 11. __test _test___ | |
3849 | 12. ___test_ test__ | |
3850 | 13. ___test__ test_ | |
3851 | 14. ___test_ test__ | |
3852 | 15. __test _test___ | |
3853 | 16. _test __test___ | |
3854 | ||
3855 | ||
3856 | Incorrect nesting: | |
3857 | ||
3858 | 1. *test **test* test** | |
3859 | 2. _test __test_ test__ | |
3860 | 3. **test *test** test* | |
3861 | 4. __test _test__ test_ | |
3862 | 5. *test *test* test* | |
3863 | 6. _test _test_ test_ | |
3864 | 7. **test **test** test** | |
3865 | 8. __test __test__ test__ | |
3866 | ||
3867 | ||
3868 | ||
3869 | No emphasis: | |
3870 | ||
3871 | 1. test* test *test | |
3872 | 2. test** test **test | |
3873 | 3. test_ test _test | |
3874 | 4. test__ test __test | |
3875 | ||
3876 | ||
3877 | ||
3878 | Middle-word emphasis (asterisks): | |
3879 | ||
3880 | 1. *a*b | |
3881 | 2. a*b* | |
3882 | 3. a*b*c | |
3883 | 4. **a**b | |
3884 | 5. a**b** | |
3885 | 6. a**b**c | |
3886 | ||
3887 | ||
3888 | Middle-word emphasis (underscore): | |
3889 | ||
3890 | 1. _a_b | |
3891 | 2. a_b_ | |
3892 | 3. a_b_c | |
3893 | 4. __a__b | |
3894 | 5. a__b__ | |
3895 | 6. a__b__c | |
3896 | ||
3897 | my_precious_file.txt | |
3898 | ||
3899 | ||
3900 | ## Tricky Cases | |
3901 | ||
3902 | E**. **Test** TestTestTest | |
3903 | ||
3904 | E**. **Test** Test Test Test | |
3905 | ||
3906 | ||
3907 | pegdown/src/test/resources/PhpMarkdownExtra/Abbr.md | |
3908 | --- | |
3909 | ||
3910 | Some text about HTML, SGML and HTML4. | |
3911 | ||
3912 | Let's talk about the U.S.A., (É.U. or É.-U. d'A. in French). | |
3913 | ||
3914 | *[HTML4]: Hyper Text Markup Language version 4 | |
3915 | *[HTML]: Hyper Text Markup Language | |
3916 | *[SGML]: Standard Generalized Markup Language | |
3917 | *[U.S.A.]: United States of America | |
3918 | *[É.U.] : États-Unis d'Amérique | |
3919 | *[É.-U. d'A.] : États-Unis d'Amérique | |
3920 | ||
3921 | And here we have a CD, some CDs, and some other CD's. | |
3922 | ||
3923 | *[CD]: Compact Disk | |
3924 | ||
3925 | Let's transfert documents through TCP/IP, using TCP packets. | |
3926 | ||
3927 | *[IP]: Internet Protocol | |
3928 | *[TCP]: Transmission Control Protocol | |
3929 | ||
3930 | --- | |
3931 | ||
3932 | Bienvenue sur [CMS](http://www.bidulecms.com "Bidule CMS"). | |
3933 | ||
3934 | *[CMS]: Content Management System | |
3935 | ||
3936 | pegdown/src/test/resources/PhpMarkdownExtra/Emphasis.md | |
3937 | --- | |
3938 | ||
3939 | Combined emphasis: | |
3940 | ||
3941 | 1. ***test test*** | |
3942 | 2. ___test test___ | |
3943 | 3. *test **test*** | |
3944 | 4. **test *test*** | |
3945 | 5. ***test* test** | |
3946 | 6. ***test** test* | |
3947 | 7. ***test* test** | |
3948 | 8. **test *test*** | |
3949 | 9. *test **test*** | |
3950 | 10. _test __test___ | |
3951 | 11. __test _test___ | |
3952 | 12. ___test_ test__ | |
3953 | 13. ___test__ test_ | |
3954 | 14. ___test_ test__ | |
3955 | 15. __test _test___ | |
3956 | 16. _test __test___ | |
3957 | ||
3958 | ||
3959 | Incorrect nesting: | |
3960 | ||
3961 | 1. *test **test* test** | |
3962 | 2. _test __test_ test__ | |
3963 | 3. **test *test** test* | |
3964 | 4. __test _test__ test_ | |
3965 | 5. *test *test* test* | |
3966 | 6. _test _test_ test_ | |
3967 | 7. **test **test** test** | |
3968 | 8. __test __test__ test__ | |
3969 | ||
3970 | ||
3971 | ||
3972 | No emphasis: | |
3973 | ||
3974 | 1. test* test *test | |
3975 | 2. test** test **test | |
3976 | 3. test_ test _test | |
3977 | 4. test__ test __test | |
3978 | ||
3979 | ||
3980 | ||
3981 | Middle-word emphasis (asterisks): | |
3982 | ||
3983 | 1. *a*b | |
3984 | 2. a*b* | |
3985 | 3. a*b*c | |
3986 | 4. **a**b | |
3987 | 5. a**b** | |
3988 | 6. a**b**c | |
3989 | ||
3990 | ||
3991 | Middle-word emphasis (underscore): | |
3992 | ||
3993 | 1. _a_b | |
3994 | 2. a_b_ | |
3995 | 3. a_b_c | |
3996 | 4. __a__b | |
3997 | 5. a__b__ | |
3998 | 6. a__b__c | |
3999 | ||
4000 | my_precious_file.txt | |
4001 | ||
4002 | ||
4003 | ## Tricky Cases | |
4004 | ||
4005 | E**. **Test** TestTestTest | |
4006 | ||
4007 | E**. **Test** Test Test Test | |
4008 | ||
4009 | ||
4010 | pegdown/src/test/resources/PhpMarkdownExtra/Fenced_Code_Blocks.md | |
4011 | --- | |
4012 | ||
4013 | ~~~ | |
4014 | Fenced | |
4015 | ~~~ | |
4016 | ||
4017 | Code block starting and ending with empty lines: | |
4018 | ||
4019 | ~~~ | |
4020 | ||
4021 | ||
4022 | Fenced | |
4023 | ||
4024 | ||
4025 | ~~~ | |
4026 | ||
4027 | Indented code block containing fenced code block sample: | |
4028 | ||
4029 | ~~~ | |
4030 | Fenced | |
4031 | ~~~ | |
4032 | ||
4033 | Fenced code block with indented code block sample: | |
4034 | ||
4035 | ~~~ | |
4036 | Some text | |
4037 | ||
4038 | Indented code block sample code | |
4039 | ~~~ | |
4040 | ||
4041 | Fenced code block with long markers: | |
4042 | ||
4043 | ~~~~~~~~~~~~~~~~~~ | |
4044 | Fenced | |
4045 | ~~~~~~~~~~~~~~~~~~ | |
4046 | ||
4047 | Empty Fenced code block: | |
4048 | ||
4049 | ~~~~~~~~~~~~~~~~~~ | |
4050 | ~~~~~~~~~~~~~~~~~~ | |
4051 | ||
4052 | Fenced code block with fenced code block markers of different length in it: | |
4053 | ||
4054 | ~~~~ | |
4055 | In code block | |
4056 | ~~~ | |
4057 | Still in code block | |
4058 | ~~~~~ | |
4059 | Still in code block | |
4060 | ~~~~ | |
4061 | ||
4062 | Fenced code block with Markdown header and horizontal rule: | |
4063 | ||
4064 | ~~~ | |
4065 | #test | |
4066 | --- | |
4067 | ~~~ | |
4068 | ||
4069 | Fenced code block with link definitions, footnote definition and | |
4070 | abbreviation definitions: | |
4071 | ||
4072 | ~~~ | |
4073 | [example]: http://example.com/ | |
4074 | ||
4075 | [^1]: Footnote def | |
4076 | ||
4077 | *[HTML]: HyperText Markup Language | |
4078 | ~~~ | |
4079 | ||
4080 | pegdown/src/test/resources/PhpMarkdownExtra/Footnotes.md | |
4081 | --- | |
4082 | ||
4083 | This is the first paragraph.[^first] | |
4084 | ||
4085 | [^first]: This is the first note. | |
4086 | ||
4087 | * List item one.[^second] | |
4088 | * List item two.[^third] | |
4089 | ||
4090 | [^third]: This is the third note, defined out of order. | |
4091 | [^second]: This is the second note. | |
4092 | [^fourth]: This is the fourth note. | |
4093 | ||
4094 | # Header[^fourth] | |
4095 | ||
4096 | Some paragraph with a footnote[^1], and another[^2]. | |
4097 | ||
4098 | [^1]: Content for fifth footnote. | |
4099 | [^2]: Content for sixth footnote spaning on | |
4100 | three lines, with some span-level markup like | |
4101 | _emphasis_, a [link][]. | |
4102 | ||
4103 | [link]: http://www.michelf.com/ | |
4104 | ||
4105 | Another paragraph with a named footnote[^fn-name]. | |
4106 | ||
4107 | [^fn-name]: | |
4108 | Footnote beginning on the line next to the marker. | |
4109 | ||
4110 | This paragraph should not have a footnote marker since | |
4111 | the footnote is undefined.[^3] | |
4112 | ||
4113 | This paragraph should not have a footnote marker since | |
4114 | the footnote has already been used before.[^1] | |
4115 | ||
4116 | This paragraph links to a footnote with plenty of | |
4117 | block-level content.[^block] | |
4118 | ||
4119 | [^block]: | |
4120 | Paragraph. | |
4121 | ||
4122 | * List item | |
4123 | ||
4124 | > Blockquote | |
4125 | ||
4126 | Code block | |
4127 | ||
4128 | This paragraph host the footnote reference within a | |
4129 | footnote test[^reference]. | |
4130 | ||
4131 | [^reference]: | |
4132 | This footnote attemps to refer to another footnote. This | |
4133 | should be impossible.[^impossible] | |
4134 | ||
4135 | [^impossible]: | |
4136 | This footnote should not appear, as it is refered from | |
4137 | another footnote, which is not allowed. | |
4138 | ||
4139 | ||
4140 | pegdown/src/test/resources/PhpMarkdownExtra/Inline_HTML_with_Markdown_content.md | |
4141 | --- | |
4142 | ||
4143 | # Markdown inside code blocks | |
4144 | ||
4145 | <div markdown="1"> | |
4146 | foo | |
4147 | </div> | |
4148 | ||
4149 | <table> | |
4150 | <tr><td markdown="1">test _emphasis_ (span)</td></tr> | |
4151 | </table> | |
4152 | ||
4153 | <table> | |
4154 | <tr><td markdown="span">test _emphasis_ (span)</td></tr> | |
4155 | </table> | |
4156 | ||
4157 | <table> | |
4158 | <tr><td markdown="block">test _emphasis_ (block)</td></tr> | |
4159 | </table> | |
4160 | ||
4161 | ## More complicated | |
4162 | ||
4163 | <table> | |
4164 | <tr><td markdown="1"> | |
4165 | * this is _not_ a list item</td></tr> | |
4166 | <tr><td markdown="span"> | |
4167 | * this is _not_ a list item</td></tr> | |
4168 | <tr><td markdown="block"> | |
4169 | * this _is_ a list item | |
4170 | </td></tr> | |
4171 | </table> | |
4172 | ||
4173 | ## With indent | |
4174 | ||
4175 | <div> | |
4176 | <div markdown="1"> | |
4177 | ||
4178 | Markdown content in HTML blocks is assumed to be | |
4179 | indented the same as the block opening tag. | |
4180 | ||
4181 | **This should be the third paragraph after the header.** | |
4182 | </div> | |
4183 | </div> | |
4184 | ||
4185 | ## Code block with rogue `</div>`s in Markdown code span and block | |
4186 | ||
4187 | <div> | |
4188 | <div markdown="1"> | |
4189 | * List item, not a code block | |
4190 | ||
4191 | Some text | |
4192 | ||
4193 | This is a code block. | |
4194 | </div> | |
4195 | </div> | |
4196 | ||
4197 | ## No code block in markdown span mode | |
4198 | ||
4199 | <p markdown="1"> | |
4200 | This is not a code block since Markdown parse paragraph | |
4201 | content as span. Code spans like `</p>` are allowed though. | |
4202 | </p> | |
4203 | ||
4204 | <p markdown="1">_Hello_ _world_</p> | |
4205 | ||
4206 | ## Preserving attributes and tags on more than one line: | |
4207 | ||
4208 | <p class="test" markdown="1" | |
4209 | id="12"> | |
4210 | Some _span_ content. | |
4211 | </p> | |
4212 | ||
4213 | ||
4214 | ## Header confusion bug | |
4215 | ||
4216 | <table class="canvas"> | |
4217 | <tr> | |
4218 | <td id="main" markdown="1">Hello World! | |
4219 | ============ | |
4220 | ||
4221 | Hello World!</td> | |
4222 | </tr> | |
4223 | </table> | |
4224 | ||
4225 | ||
4226 | pegdown/src/test/resources/PhpMarkdownExtra/Tables.md | |
4227 | --- | |
4228 | ||
4229 | # Simple tables | |
4230 | ||
4231 | Header 1 | Header 2 | |
4232 | --------- | --------- | |
4233 | Cell 1 | Cell 2 | |
4234 | Cell 3 | Cell 4 | |
4235 | ||
4236 | With leading pipes: | |
4237 | ||
4238 | | Header 1 | Header 2 | |
4239 | | --------- | --------- | |
4240 | | Cell 1 | Cell 2 | |
4241 | | Cell 3 | Cell 4 | |
4242 | ||
4243 | With tailing pipes: | |
4244 | ||
4245 | Header 1 | Header 2 | | |
4246 | --------- | --------- | | |
4247 | Cell 1 | Cell 2 | | |
4248 | Cell 3 | Cell 4 | | |
4249 | ||
4250 | With leading and tailing pipes: | |
4251 | ||
4252 | | Header 1 | Header 2 | | |
4253 | | --------- | --------- | | |
4254 | | Cell 1 | Cell 2 | | |
4255 | | Cell 3 | Cell 4 | | |
4256 | ||
4257 | * * * | |
4258 | ||
4259 | # One-column one-row table | |
4260 | ||
4261 | With leading pipes: | |
4262 | ||
4263 | | Header | |
4264 | | ------- | |
4265 | | Cell | |
4266 | ||
4267 | With tailing pipes: | |
4268 | ||
4269 | Header | | |
4270 | ------- | | |
4271 | Cell | | |
4272 | ||
4273 | With leading and tailing pipes: | |
4274 | ||
4275 | | Header | | |
4276 | | ------- | | |
4277 | | Cell | | |
4278 | ||
4279 | * * * | |
4280 | ||
4281 | Table alignement: | |
4282 | ||
4283 | | Default | Right | Center | Left | | |
4284 | | --------- |:--------- |:---------:| ---------:| | |
4285 | | Long Cell | Long Cell | Long Cell | Long Cell | | |
4286 | | Cell | Cell | Cell | Cell | | |
4287 | ||
4288 | Table alignement (alternate spacing): | |
4289 | ||
4290 | | Default | Right | Center | Left | | |
4291 | | --------- | :-------- | :-------: | --------: | | |
4292 | | Long Cell | Long Cell | Long Cell | Long Cell | | |
4293 | | Cell | Cell | Cell | Cell | | |
4294 | ||
4295 | * * * | |
4296 | ||
4297 | # Empty cells | |
4298 | ||
4299 | | Header 1 | Header 2 | | |
4300 | | --------- | --------- | | |
4301 | | A | B | | |
4302 | | C | | | |
4303 | ||
4304 | Header 1 | Header 2 | |
4305 | --------- | --------- | |
4306 | A | B | |
4307 | | D | |
4308 | ||
4309 | * * * | |
4310 | ||
4311 | # Missing tailing pipe | |
4312 | ||
4313 | Header 1 | Header 2 | |
4314 | --------- | --------- | | |
4315 | Cell | Cell | | |
4316 | Cell | Cell | | |
4317 | ||
4318 | Header 1 | Header 2 | | |
4319 | --------- | --------- | |
4320 | Cell | Cell | | |
4321 | Cell | Cell | | |
4322 | ||
4323 | Header 1 | Header 2 | | |
4324 | --------- | --------- | | |
4325 | Cell | Cell | |
4326 | Cell | Cell | | |
4327 | ||
4328 | Header 1 | Header 2 | | |
4329 | --------- | --------- | | |
4330 | Cell | Cell | | |
4331 | Cell | Cell | |
4332 | ||
4333 | ||
4334 | ||
4335 | pegdown/src/test/resources/PhpMarkdown/Headers.md | |
4336 | --- | |
4337 | ||
4338 | Header | |
4339 | ====== | |
4340 | ||
4341 | Header | |
4342 | ------ | |
4343 | ||
4344 | ### Header | |
4345 | ||
4346 | - - - | |
4347 | ||
4348 | Header | |
4349 | ====== | |
4350 | Paragraph | |
4351 | ||
4352 | Header | |
4353 | ------ | |
4354 | Paragraph | |
4355 | ||
4356 | ### Header | |
4357 | Paragraph | |
4358 | ||
4359 | - - - | |
4360 | ||
4361 | Paragraph | |
4362 | Header | |
4363 | ====== | |
4364 | Paragraph | |
4365 | ||
4366 | Paragraph | |
4367 | Header | |
4368 | ------ | |
4369 | Paragraph | |
4370 | ||
4371 | Paragraph | |
4372 | ### Header | |
4373 | Paragraph | |
4374 | ||
4375 | pegdown/src/test/resources/PhpMarkdown/Horizontal_Rules.md | |
4376 | --- | |
4377 | ||
4378 | Horizontal rules: | |
4379 | ||
4380 | - - - | |
4381 | ||
4382 | * * * | |
4383 | ||
4384 | *** | |
4385 | ||
4386 | --- | |
4387 | ||
4388 | ___ | |
4389 | ||
4390 | Not horizontal rules (testing for a bug in 1.0.1j): | |
4391 | ||
4392 | +++ | |
4393 | ||
4394 | ,,, | |
4395 | ||
4396 | === | |
4397 | ||
4398 | ??? | |
4399 | ||
4400 | AAA | |
4401 | ||
4402 | jjj | |
4403 | ||
4404 | j j j | |
4405 | ||
4406 | n n n | |
4407 | ||
4408 | ||
4409 | pegdown/src/test/resources/PhpMarkdown/Inline_HTML_comments.md | |
4410 | --- | |
4411 | ||
4412 | Paragraph one. | |
4413 | ||
4414 | Paragraph two. | |
4415 | ||
4416 | <!-- enclosed tag </div> --> | |
4417 | ||
4418 | The end. | |
4419 | ||
4420 | ||
4421 | pegdown/src/test/resources/PhpMarkdown/Inline_HTML_(Simple).md | |
4422 | --- | |
4423 | ||
4424 | With some attributes: | |
4425 | ||
4426 | <div id="test"> | |
4427 | foo | |
4428 | </div> | |
4429 | ||
4430 | <div id="test" | |
4431 | class="nono"> | |
4432 | foo | |
4433 | </div> | |
4434 | ||
4435 | ||
4436 | pegdown/src/test/resources/PhpMarkdown/Inline_HTML_(Span).md | |
4437 | --- | |
4438 | ||
4439 | <abbr title="` **Attribute Content Is Not A Code Span** `">ACINACS</abbr> | |
4440 | ||
4441 | <abbr title="`first backtick!">SB</abbr> | |
4442 | <abbr title="`second backtick!">SB</abbr> | |
4443 | ||
4444 | pegdown/src/test/resources/PhpMarkdown/Ins_and_del.md | |
4445 | --- | |
4446 | ||
4447 | Here is a block tag ins: | |
4448 | ||
4449 | <ins> | |
4450 | <p>Some text</p> | |
4451 | </ins> | |
4452 | ||
4453 | <ins>And here it is inside a paragraph.</ins> | |
4454 | ||
4455 | And here it is <ins>in the middle of</ins> a paragraph. | |
4456 | ||
4457 | <del> | |
4458 | <p>Some text</p> | |
4459 | </del> | |
4460 | ||
4461 | <del>And here is ins as a paragraph.</del> | |
4462 | ||
4463 | And here it is <del>in the middle of</del> a paragraph. | |
4464 | ||
4465 | ||
4466 | pegdown/src/test/resources/PhpMarkdown/Links_inline_style.md | |
4467 | --- | |
4468 | ||
4469 | [silly URL w/ angle brackets](<?}]*+|&)>). | |
4470 | ||
4471 | ||
4472 | pegdown/src/test/resources/PhpMarkdown/MD5_Hashes.md | |
4473 | --- | |
4474 | ||
4475 | # Character Escapes | |
4476 | ||
4477 | The MD5 value for `+` is "26b17225b626fb9238849fd60eabdf60". | |
4478 | ||
4479 | # HTML Blocks | |
4480 | ||
4481 | <p>test</p> | |
4482 | ||
4483 | The MD5 value for `<p>test</p>` is: | |
4484 | ||
4485 | 6205333b793f34273d75379350b36826 | |
4486 | ||
4487 | pegdown/src/test/resources/PhpMarkdown/Nesting.md | |
4488 | --- | |
4489 | ||
4490 | Valid nesting: | |
4491 | ||
4492 | **[Link](url)** | |
4493 | ||
4494 | [**Link**](url) | |
4495 | ||
4496 | **[**Link**](url)** | |
4497 | ||
4498 | pegdown/src/test/resources/PhpMarkdown/Parens_in_URL.md | |
4499 | --- | |
4500 | ||
4501 | [Inline link 1 with parens](/url\(test\) "title"). | |
4502 | ||
4503 | [Inline link 2 with parens](</url\(test\)> "title"). | |
4504 | ||
4505 | [Inline link 3 with non-escaped parens](/url(test) "title"). | |
4506 | ||
4507 | [Inline link 4 with non-escaped parens](</url(test)> "title"). | |
4508 | ||
4509 | [Reference link 1 with parens][1]. | |
4510 | ||
4511 | [Reference link 2 with parens][2]. | |
4512 | ||
4513 | [1]: /url(test) "title" | |
4514 | [2]: </url(test)> "title" | |
4515 | ||
4516 | ||
4517 | pegdown/src/test/resources/PhpMarkdown/PHP-Specific_Bugs.md | |
4518 | --- | |
4519 | ||
4520 | This tests for a bug where quotes escaped by PHP when using | |
4521 | `preg_replace` with the `/e` modifier must be correctly unescaped | |
4522 | (hence the `_UnslashQuotes` function found only in PHP Markdown). | |
4523 | ||
4524 | ||
4525 | ||
4526 | Headers below should appear exactly as they are typed (no backslash | |
4527 | added or removed). | |
4528 | ||
4529 | Header "quoted\" again \\"" | |
4530 | =========================== | |
4531 | ||
4532 | Header "quoted\" again \\"" | |
4533 | --------------------------- | |
4534 | ||
4535 | ### Header "quoted\" again \\"" ### | |
4536 | ||
4537 | ||
4538 | ||
4539 | Test with tabs for `_Detab`: | |
4540 | ||
4541 | Code 'block' with some "tabs" and "quotes" | |
4542 | ||
4543 | ||
4544 | pegdown/src/test/resources/PhpMarkdown/Tight_blocks.md | |
4545 | --- | |
4546 | ||
4547 | Paragraph and no space: | |
4548 | * ciao | |
4549 | ||
4550 | Paragraph and 1 space: | |
4551 | * ciao | |
4552 | ||
4553 | Paragraph and 3 spaces: | |
4554 | * ciao | |
4555 | ||
4556 | Paragraph and 4 spaces: | |
4557 | * ciao | |
4558 | ||
4559 | Paragraph before header: | |
4560 | #Header | |
4561 | ||
4562 | Paragraph before blockquote: | |
4563 | >Some quote. | |
4564 | ||
4565 | pegdown/src/test/resources/textmarkdown/CoreDumps5.8.md | |
4566 | --- | |
4567 | ||
4568 | * Unordered | |
4569 | 1. Ordered | |
4570 | ||
4571 | Text | |
4572 | ||
4573 | * Unordered | |
4574 | 1. Ordered | |
4575 | ||
4576 | ||
4577 | pegdown/src/test/resources/textmarkdown/Emphasis.md | |
4578 | --- | |
4579 | ||
4580 | _M*A*S*H_ here I am going with original Markdown.. | |
4581 | ||
4582 | foo_bar_bas I am going with PHP Markdown Extra here (by default, there is an option for original style behavior - see | |
4583 | docs).. | |
4584 | ||
4585 | ||
4586 | pegdown/src/test/resources/textmarkdown/HTML-Comment-encoding.md | |
4587 | --- | |
4588 | ||
4589 | A markdown paragraph with a comment that *will* be processed by original Markdown. However MultiMarkdown and Pandoc do not convert the & sigil in the comment.. | |
4590 | ||
4591 | A paragraph <!-- This & *will* be converted by original Markdown --> | |
4592 | ||
4593 | <p><!-- This & will *not* be converted --></p> | |
4594 | ||
4595 | ||
4596 | pegdown/src/test/resources/textmarkdown/Links_brackets.md | |
4597 | --- | |
4598 | ||
4599 | [ZIP archives](http://en.wikipedia.org/wiki/ZIP_(file_format) "ZIP (file format) - Wikipedia, the free encyclopedia") | |
4600 | ||
4601 | ||
4602 | ||
4603 | pegdown/src/test/resources/textmarkdown/Links_multiline_bugs_1.md | |
4604 | --- | |
4605 | ||
4606 | <http://bugs.debian.org/459885> | |
4607 | ||
4608 | [link | |
4609 | text] [link | |
4610 | id] | |
4611 | ||
4612 | [link id]: /someurl/ | |
4613 | ||
4614 | ||
4615 | pegdown/src/test/resources/textmarkdown/Links_multiline_bugs_2.md | |
4616 | --- | |
4617 | ||
4618 | <http://bugs.debian.org/459885> | |
4619 | ||
4620 | Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla bla. This is [my | |
4621 | University][]. | |
4622 | ||
4623 | [my university]: http://www.ua.es | |
4624 | ||
4625 | ||
4626 | pegdown/src/test/resources/textmarkdown/Links_reference_style.md | |
4627 | --- | |
4628 | ||
4629 | Foo [bar] [1]. | |
4630 | ||
4631 | Foo [bar][1]. | |
4632 | ||
4633 | Foo [bar] | |
4634 | [1]. | |
4635 | ||
4636 | [1]: /url/ "Title" | |
4637 | ||
4638 | ||
4639 | With [embedded [brackets]] [b]. | |
4640 | ||
4641 | ||
4642 | Indented [once][]. | |
4643 | ||
4644 | Indented [twice][]. | |
4645 | ||
4646 | Indented [thrice][]. | |
4647 | ||
4648 | Indented [four][] times. | |
4649 | ||
4650 | [once]: /url | |
4651 | ||
4652 | [twice]: /url | |
4653 | ||
4654 | [thrice]: /url | |
4655 | ||
4656 | [four]: /url | |
4657 | ||
4658 | ||
4659 | [b]: /url/ | |
4660 | ||
4661 | * * * | |
4662 | ||
4663 | [this] [this] should work | |
4664 | ||
4665 | So should [this][this]. | |
4666 | ||
4667 | And [this] []. | |
4668 | ||
4669 | And [this][]. | |
4670 | ||
4671 | And [this]. | |
4672 | ||
4673 | But not [that] []. | |
4674 | ||
4675 | Nor [that][]. | |
4676 | ||
4677 | Nor [that]. | |
4678 | ||
4679 | [Something in brackets like [this][] should work] | |
4680 | ||
4681 | [Same with [this].] | |
4682 | ||
4683 | In this case, [this](/somethingelse/) points to something else. | |
4684 | ||
4685 | Backslashing should suppress \[this] and [this\]. | |
4686 | ||
4687 | [this]: foo | |
4688 | ||
4689 | ||
4690 | * * * | |
4691 | ||
4692 | Here's one where the [link | |
4693 | breaks] across lines. | |
4694 | ||
4695 | Here's another where the [link | |
4696 | breaks] across lines, but with a line-ending space. | |
4697 | ||
4698 | ||
4699 | [link breaks]: /url/ | |
4700 | ||
4701 | More multi line edge cases. First a broken link id | |
4702 | ||
4703 | [link | |
4704 | text] [link | |
4705 | id] | |
4706 | ||
4707 | [link id]: /someurl/ | |
4708 | ||
4709 | Then a line with 2 chars of trailing whitespace and a line break [my | |
4710 | University][]. | |
4711 | ||
4712 | The a shortcut reference link with 2 chars of trailing whitespace and a line break [my | |
4713 | University]. | |
4714 | ||
4715 | [my university]: http://www.ua.es | |
4716 | ||
4717 | pegdown/src/test/resources/textmarkdown/Lists-multilevel-md5-edgecase.md | |
4718 | --- | |
4719 | ||
4720 | # text1 | |
4721 | ||
4722 | * text2 | |
4723 | ||
4724 | * text3 | |
4725 | ||
4726 | text4 | |
4727 | ||
4728 | ## text5 | |
4729 | ||
4730 | * text6 | |
4731 | ||
4732 | * text7 | |
4733 | ||
4734 | text8 | |
4735 | ||
4736 | ## text9 | |
4737 | ||
4738 | * text10 | |
4739 | ||
4740 | * text11 | |
4741 | ||
4742 | text12 | |
4743 | ||
4744 | text13 |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 | |
45 | 45 | <version>${projectVersion}</version> |
46 | 46 | <scope>test</scope> |
47 | 47 | </dependency> |
48 | <dependency> | |
49 | <groupId>org.codehaus.plexus</groupId> | |
50 | <artifactId>plexus-utils</artifactId> | |
51 | <scope>test</scope> | |
52 | </dependency> | |
48 | 53 | </dependencies> |
49 | 54 | </project>⏎ |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="RTF" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="RTF"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
29 | 37 | |
30 | 38 | <menu ref="reports"/> |
31 | 39 |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 | |
56 | 56 | </roles> |
57 | 57 | </contributor> |
58 | 58 | </contributors> |
59 | ||
60 | <dependencies> | |
61 | <dependency> | |
62 | <groupId>org.codehaus.plexus</groupId> | |
63 | <artifactId>plexus-utils</artifactId> | |
64 | </dependency> | |
65 | </dependencies> | |
59 | 66 | </project> |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="Twiki" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="Twiki"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
29 | 37 | |
30 | 38 | <menu ref="reports"/> |
31 | 39 |
+117
-0
0 | package org.apache.maven.doxia.module.twiki.parser; | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.util.Iterator; | |
22 | import org.apache.maven.doxia.module.twiki.TWikiParser; | |
23 | import org.apache.maven.doxia.parser.AbstractParserTest; | |
24 | import org.apache.maven.doxia.parser.Parser; | |
25 | import org.apache.maven.doxia.sink.SinkEventElement; | |
26 | import org.apache.maven.doxia.sink.SinkEventTestingSink; | |
27 | ||
28 | /** | |
29 | * | |
30 | * @author ltheussl | |
31 | */ | |
32 | public class TwikiParserTest | |
33 | extends AbstractParserTest | |
34 | { | |
35 | private TWikiParser parser; | |
36 | private static final String id = "twiki"; | |
37 | ||
38 | @Override | |
39 | protected void setUp() | |
40 | throws Exception | |
41 | { | |
42 | super.setUp(); | |
43 | ||
44 | this.parser = (TWikiParser) lookup( Parser.ROLE, id ); | |
45 | } | |
46 | ||
47 | @Override | |
48 | protected Parser createParser() | |
49 | { | |
50 | return parser; | |
51 | } | |
52 | ||
53 | @Override | |
54 | protected String outputExtension() | |
55 | { | |
56 | return id; | |
57 | } | |
58 | ||
59 | /** @throws Exception */ | |
60 | public void testHtml() | |
61 | throws Exception | |
62 | { | |
63 | // DOXIA-441 | |
64 | final String text = "_ita_, *b* and a bit of <font color=\"red\">red</font>"; | |
65 | ||
66 | SinkEventTestingSink sink = new SinkEventTestingSink(); | |
67 | ||
68 | parser.parse( text, sink ); | |
69 | ||
70 | Iterator<SinkEventElement> it = sink.getEventList().iterator(); | |
71 | ||
72 | assertEquals( "head", ( it.next() ).getName() ); | |
73 | assertEquals( "head_", ( it.next() ).getName() ); | |
74 | assertEquals( "body", ( it.next() ).getName() ); | |
75 | assertEquals( "paragraph", ( it.next() ).getName() ); | |
76 | ||
77 | assertEquals( "italic", ( it.next() ).getName() ); | |
78 | SinkEventElement textElement = it.next(); | |
79 | assertEquals( "text", textElement.getName() ); | |
80 | assertEquals( "ita", textElement.getArgs()[0] ); | |
81 | assertEquals( "italic_", ( it.next() ).getName() ); | |
82 | ||
83 | textElement = it.next(); | |
84 | assertEquals( "text", textElement.getName() ); | |
85 | assertEquals( ", ", textElement.getArgs()[0] ); | |
86 | ||
87 | assertEquals( "bold", ( it.next() ).getName() ); | |
88 | textElement = it.next(); | |
89 | assertEquals( "text", textElement.getName() ); | |
90 | assertEquals( "b", textElement.getArgs()[0] ); | |
91 | assertEquals( "bold_", ( it.next() ).getName() ); | |
92 | ||
93 | // FIXME! | |
94 | //textElement = it.next(); | |
95 | //assertEquals( "text", textElement.getName() ); | |
96 | //assertEquals( "and a bit of", textElement.getArgs()[0] ); | |
97 | ||
98 | textElement = it.next(); | |
99 | assertEquals( "rawText", textElement.getName() ); | |
100 | assertEquals( "<font color=\"red\">", textElement.getArgs()[0] ); | |
101 | ||
102 | textElement = it.next(); | |
103 | assertEquals( "text", textElement.getName() ); | |
104 | assertEquals( "red", textElement.getArgs()[0] ); | |
105 | ||
106 | textElement = it.next(); | |
107 | assertEquals( "rawText", textElement.getName() ); | |
108 | assertEquals( "</font>", textElement.getArgs()[0] ); | |
109 | ||
110 | assertEquals( "paragraph_", ( it.next() ).getName() ); | |
111 | assertEquals( "body_", ( it.next() ).getName() ); | |
112 | assertEquals( "flush", ( it.next() ).getName() ); | |
113 | assertEquals( "close", ( it.next() ).getName() ); | |
114 | assertFalse( it.hasNext() ); | |
115 | } | |
116 | }⏎ |
0 | ---+ Twiki Java Parser | |
1 | ||
2 | ---++ Features | |
3 | ||
4 | This parser of the [[http://www.twiki.org][TWiki]] text format supports most | |
5 | of http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules formatting commands. | |
6 | ||
7 | ---+++ General | |
8 | ||
9 | * Paragraps, | |
10 | * Wiki Words | |
11 | * WikiWord | |
12 | * Web.WikiWord#anchor, | |
13 | * escaped: !WikiWord | |
14 | * Forced Links: | |
15 | * [[wiki word]] | |
16 | * escaped ![[wiki word]] | |
17 | * Specific links: | |
18 | * [[http://www.zauber.com.ar][Zauber]], | |
19 | * prevention: ![[http://www.zauber.com.ar][Forced links]] | |
20 | * Anchors: [[#AnchorEnd][End]] | |
21 | * inline urls: | |
22 | * http://twiki.org/ | |
23 | * mailto link: | |
24 | * [[mailto:a@z.com Mail]] | |
25 | * [[mailto:?subject=Hi Hi]] | |
26 | ||
27 | ---+++ Text Format: | |
28 | ||
29 | * *bold* | |
30 | * _italic_ | |
31 | * __bold italic__ | |
32 | * =Fixedfont= | |
33 | * ==Bold fixed== | |
34 | ||
35 | And nested formats like: | |
36 | * *bold with _italic_ and some =fixed= and bold* | |
37 | Make sure there is no space between the text and the bold, italic, or other | |
38 | indicators (* _ __ = ==). | |
39 | ||
40 | ---+++ Lists | |
41 | ||
42 | * items | |
43 | * nested items | |
44 | * ordered list | |
45 | * arabic numerals | |
46 | 1. item | |
47 | 1. item | |
48 | 1. ... | |
49 | * uppercase letters | |
50 | A. item | |
51 | A. item | |
52 | A. ... | |
53 | * lowercase letters | |
54 | a. item | |
55 | a. item | |
56 | a. ... | |
57 | * uppercase roman numerals | |
58 | A. item | |
59 | A. item | |
60 | A. .... | |
61 | * Uppercase Roman Numerals | |
62 | I. item | |
63 | I. item | |
64 | I. ... | |
65 | * Lowercase Roman Numerals | |
66 | i. item | |
67 | i. item | |
68 | i. .... | |
69 | ||
70 | ---+++ Separators | |
71 | ||
72 | Up | |
73 | --------------------------- | |
74 | Down | |
75 | ||
76 | ---+++ Table | |
77 | ||
78 | | *A* | *B* | *C* | | |
79 | | Foo | bar | Foo | | |
80 | | Bar | Foo | bar | | |
81 | | Foo | bar | Foo | | |
82 | ||
83 | ---++ Missing things | |
84 | ---+++ Verbating Mode | |
85 | <verbatim> | |
86 | class CatAnimal { | |
87 | void purr() { | |
88 | <code here> | |
89 | } | |
90 | </verbatim> | |
91 | ||
92 | ---+++ Definition List | |
93 | (i don't use it) | |
94 | $ Sushi: Japan | |
95 | $ Dim Sum: S.F. | |
96 | $ Asado: Argentina | |
97 | ||
98 | ---+++ Diable Links | |
99 | ||
100 | <noautolink> | |
101 | RedHat & | |
102 | SuSE | |
103 | </noautolink> | |
104 | ||
105 | ---+++ Html | |
106 | * <pre>some text</pre> | |
107 | ||
108 | #EndAnchor |
0 | ---+ Twiki Java Parser | |
1 | ||
2 | ---++ Features | |
3 | ||
4 | This parser of the [[http://www.twiki.org][TWiki]] text format supports most | |
5 | of http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules formatting commands. | |
6 | ||
7 | ---+++ General | |
8 | ||
9 | * Paragraps, | |
10 | * Wiki Words | |
11 | * WikiWord | |
12 | * Web.WikiWord#anchor, | |
13 | * escaped: !WikiWord | |
14 | * Forced Links: | |
15 | * [[wiki word]] | |
16 | * escaped ![[wiki word]] | |
17 | * Specific links: | |
18 | * [[http://www.zauber.com.ar][Zauber]], | |
19 | * prevention: ![[http://www.zauber.com.ar][Forced links]] | |
20 | * Anchors: [[#AnchorEnd][End]] | |
21 | * inline urls: | |
22 | * http://twiki.org/ | |
23 | * mailto link: | |
24 | * [[mailto:a@z.com Mail]] | |
25 | * [[mailto:?subject=Hi Hi]] | |
26 | ||
27 | ---+++ Text Format: | |
28 | ||
29 | * *bold* | |
30 | * _italic_ | |
31 | * __bold italic__ | |
32 | * =Fixedfont= | |
33 | * ==Bold fixed== | |
34 | ||
35 | And nested formats like: | |
36 | * *bold with _italic_ and some =fixed= and bold* | |
37 | Make sure there is no space between the text and the bold, italic, or other | |
38 | indicators (* _ __ = ==). | |
39 | ||
40 | ---+++ Lists | |
41 | ||
42 | * items | |
43 | * nested items | |
44 | * ordered list | |
45 | * arabic numerals | |
46 | 1. item | |
47 | 1. item | |
48 | 1. ... | |
49 | * uppercase letters | |
50 | A. item | |
51 | A. item | |
52 | A. ... | |
53 | * lowercase letters | |
54 | a. item | |
55 | a. item | |
56 | a. ... | |
57 | * uppercase roman numerals | |
58 | A. item | |
59 | A. item | |
60 | A. .... | |
61 | * Uppercase Roman Numerals | |
62 | I. item | |
63 | I. item | |
64 | I. ... | |
65 | * Lowercase Roman Numerals | |
66 | i. item | |
67 | i. item | |
68 | i. .... | |
69 | ||
70 | ---+++ Separators | |
71 | ||
72 | Up | |
73 | --------------------------- | |
74 | Down | |
75 | ||
76 | ---+++ Table | |
77 | ||
78 | | *A* | *B* | *C* | | |
79 | | Foo | bar | Foo | | |
80 | | Bar | Foo | bar | | |
81 | | Foo | bar | Foo | | |
82 | ||
83 | ---++ Missing things | |
84 | ---+++ Verbating Mode | |
85 | <verbatim> | |
86 | class CatAnimal { | |
87 | void purr() { | |
88 | <code here> | |
89 | } | |
90 | </verbatim> | |
91 | ||
92 | ---+++ Definition List | |
93 | (i don't use it) | |
94 | $ Sushi: Japan | |
95 | $ Dim Sum: S.F. | |
96 | $ Asado: Argentina | |
97 | ||
98 | ---+++ Diable Links | |
99 | ||
100 | <noautolink> | |
101 | RedHat & | |
102 | SuSE | |
103 | </noautolink> | |
104 | ||
105 | ---+++ Html | |
106 | * <pre>some text</pre> | |
107 | ||
108 | #EndAnchor |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
+2
-2
45 | 45 | * Parse an xdoc model and emit events into the specified doxia Sink. |
46 | 46 | * |
47 | 47 | * @author <a href="mailto:jason@maven.org">Jason van Zyl</a> |
48 | * @version $Id: XdocParser.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
48 | * @version $Id: XdocParser.java 1185529 2011-10-18 08:27:44Z ltheussl $ | |
49 | 49 | * @since 1.0 |
50 | 50 | * @plexus.component role="org.apache.maven.doxia.parser.Parser" role-hint="xdoc" |
51 | 51 | */ |
475 | 475 | } |
476 | 476 | |
477 | 477 | sink.section( level, attribs ); |
478 | sink.sectionTitle( level, attribs ); | |
478 | sink.sectionTitle( level, null ); | |
479 | 479 | sink.text( HtmlTools.unescapeHTML( parser.getAttributeValue( null, Attribute.NAME.toString() ) ) ); |
480 | 480 | sink.sectionTitle_( level ); |
481 | 481 | } |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="Xdoc" xmlns="http://maven.apache.org/DECORATION/1.0.0" | |
24 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
25 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 file:../../../../../doxia-sitetools/doxia-decoration-model/target/generated-site/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="Xdoc"> | |
26 | 26 | |
27 | 27 | <body> |
28 | 28 | |
29 | 29 | <menu ref="parent"/> |
30 | 30 | |
31 | <menu name="Schema XDOC 2.0"> | |
32 | <item name="Reference of Schema XDOC" href="xsddoc/index.html"/> | |
33 | <item name="Using Schema XDOC" href="using-xdoc-xsd.html"/> | |
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
37 | ||
38 | <menu name="XDOC 2.0 Schema"> | |
39 | <item name="Reference" href="xsddoc/index.html"/> | |
40 | <item name="Using XDOC Schema" href="using-xdoc-xsd.html"/> | |
34 | 41 | </menu> |
35 | 42 | |
36 | 43 | <menu ref="reports"/> |
+36
-1
30 | 30 | import org.apache.maven.doxia.parser.ParseException; |
31 | 31 | import org.apache.maven.doxia.parser.Parser; |
32 | 32 | import org.apache.maven.doxia.sink.Sink; |
33 | import org.apache.maven.doxia.sink.SinkEventAttributeSet; | |
33 | 34 | import org.apache.maven.doxia.sink.SinkEventElement; |
34 | 35 | import org.apache.maven.doxia.sink.SinkEventTestingSink; |
35 | 36 | |
39 | 40 | /** |
40 | 41 | * @author <a href="mailto:jason@maven.org">Jason van Zyl</a> |
41 | 42 | * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a> |
42 | * @version $Id: XdocParserTest.java 1091053 2011-04-11 12:55:07Z ltheussl $ | |
43 | * @version $Id: XdocParserTest.java 1185529 2011-10-18 08:27:44Z ltheussl $ | |
43 | 44 | * @since 1.0 |
44 | 45 | */ |
45 | 46 | public class XdocParserTest |
252 | 253 | assertEquals( "text", ( it.next() ).getName() ); |
253 | 254 | assertEquals( "sectionTitle2_", ( it.next() ).getName() ); |
254 | 255 | assertEquals( "section2_", ( it.next() ).getName() ); |
256 | assertEquals( "section1_", ( it.next() ).getName() ); | |
257 | assertFalse( it.hasNext() ); | |
258 | } | |
259 | ||
260 | /** @throws Exception */ | |
261 | public void testSectionAttributes() | |
262 | throws Exception | |
263 | { | |
264 | // DOXIA-448 | |
265 | String text = "<section name=\"section name\" class=\"foo\" id=\"bar\"></section>"; | |
266 | ||
267 | SinkEventTestingSink sink = new SinkEventTestingSink(); | |
268 | ||
269 | parser.parse( text, sink ); | |
270 | ||
271 | Iterator<SinkEventElement> it = sink.getEventList().iterator(); | |
272 | ||
273 | assertEquals( "anchor", ( it.next() ).getName() ); | |
274 | assertEquals( "anchor_", ( it.next() ).getName() ); | |
275 | ||
276 | SinkEventElement next = it.next(); | |
277 | assertEquals( "section1", next.getName() ); | |
278 | SinkEventAttributeSet set = (SinkEventAttributeSet) next.getArgs()[0]; | |
279 | assertEquals( 3, set.getAttributeCount() ); | |
280 | assertTrue( set.containsAttribute( "name", "section name" ) ); | |
281 | assertTrue( set.containsAttribute( "class", "foo" ) ); | |
282 | assertTrue( set.containsAttribute( "id", "bar" ) ); | |
283 | ||
284 | next = it.next(); | |
285 | assertEquals( "sectionTitle1", next.getName() ); | |
286 | assertNull( (SinkEventAttributeSet) next.getArgs()[0] ); | |
287 | ||
288 | assertEquals( "text", ( it.next() ).getName() ); | |
289 | assertEquals( "sectionTitle1_", ( it.next() ).getName() ); | |
255 | 290 | assertEquals( "section1_", ( it.next() ).getName() ); |
256 | 291 | assertFalse( it.hasNext() ); |
257 | 292 | } |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia-modules</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="Xhtml" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="Xhtml"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 | |
28 | 29 | <menu ref="parent"/> |
30 | ||
31 | <menu name="Overview"> | |
32 | <item name="Introduction" href="index.html"/> | |
33 | <item name="JavaDocs" href="apidocs/index.html"/> | |
34 | <item name="Source Xref" href="xref/index.html"/> | |
35 | <!--item name="FAQ" href="faq.html"/--> | |
36 | </menu> | |
29 | 37 | |
30 | 38 | <menu ref="reports"/> |
31 | 39 |
+29
-29
28 | 28 | import org.apache.maven.doxia.sink.SinkEventTestingSink; |
29 | 29 | import org.codehaus.plexus.util.FileUtils; |
30 | 30 | |
31 | ||
32 | 31 | /** |
33 | 32 | * @author <a href="mailto:lars@trieloff.net">Lars Trieloff</a> |
34 | * @version $Id: XhtmlParserTest.java 784707 2009-06-15 09:53:12Z vsiveton $ | |
33 | * @version $Id: XhtmlParserTest.java 1196253 2011-11-01 20:13:24Z hboutemy $ | |
35 | 34 | */ |
36 | 35 | public class XhtmlParserTest |
37 | 36 | extends AbstractParserTest |
50 | 49 | // Be sure to delete them |
51 | 50 | String tmpDir = System.getProperty( "java.io.tmpdir" ); |
52 | 51 | String excludes = "xhtml-lat1.ent, xhtml1-transitional.dtd, xhtml-special.ent, xhtml-symbol.ent"; |
53 | List tmpFiles = FileUtils.getFileNames( new File( tmpDir ), excludes, null, true ); | |
54 | for ( Iterator it = tmpFiles.iterator(); it.hasNext(); ) | |
52 | @SuppressWarnings( "unchecked" ) | |
53 | List<String> tmpFiles = FileUtils.getFileNames( new File( tmpDir ), excludes, null, true ); | |
54 | for ( String filename : tmpFiles ) | |
55 | 55 | { |
56 | File tmpFile = new File( it.next().toString() ); | |
56 | File tmpFile = new File( filename ); | |
57 | 57 | tmpFile.delete(); |
58 | 58 | } |
59 | 59 | } |
80 | 80 | |
81 | 81 | ( (XhtmlParser) createParser() ).parse( text, sink ); |
82 | 82 | |
83 | Iterator it = sink.getEventList().iterator(); | |
83 | Iterator<SinkEventElement> it = sink.getEventList().iterator(); | |
84 | 84 | |
85 | assertEquals( "body", ( (SinkEventElement) it.next() ).getName() ); | |
86 | assertEquals( "body_", ( (SinkEventElement) it.next() ).getName() ); | |
85 | assertEquals( "body", it.next().getName() ); | |
86 | assertEquals( "body_", it.next().getName() ); | |
87 | 87 | assertFalse( it.hasNext() ); |
88 | 88 | } |
89 | 89 | |
98 | 98 | |
99 | 99 | ( (XhtmlParser) createParser() ).parse( text, sink ); |
100 | 100 | |
101 | Iterator it = sink.getEventList().iterator(); | |
101 | Iterator<SinkEventElement> it = sink.getEventList().iterator(); | |
102 | 102 | |
103 | assertEquals( "head", ( (SinkEventElement) it.next() ).getName() ); | |
104 | assertEquals( "title", ( (SinkEventElement) it.next() ).getName() ); | |
105 | assertEquals( "text", ( (SinkEventElement) it.next() ).getName() ); | |
106 | assertEquals( "title_", ( (SinkEventElement) it.next() ).getName() ); | |
107 | assertEquals( "author", ( (SinkEventElement) it.next() ).getName() ); | |
108 | assertEquals( "text", ( (SinkEventElement) it.next() ).getName() ); | |
109 | assertEquals( "author_", ( (SinkEventElement) it.next() ).getName() ); | |
110 | assertEquals( "date", ( (SinkEventElement) it.next() ).getName() ); | |
111 | assertEquals( "text", ( (SinkEventElement) it.next() ).getName() ); | |
112 | assertEquals( "date_", ( (SinkEventElement) it.next() ).getName() ); | |
113 | assertEquals( "unknown", ( (SinkEventElement) it.next() ).getName() ); | |
114 | assertEquals( "head_", ( (SinkEventElement) it.next() ).getName() ); | |
103 | assertEquals( "head", it.next().getName() ); | |
104 | assertEquals( "title", it.next().getName() ); | |
105 | assertEquals( "text", it.next().getName() ); | |
106 | assertEquals( "title_", it.next().getName() ); | |
107 | assertEquals( "author", it.next().getName() ); | |
108 | assertEquals( "text", it.next().getName() ); | |
109 | assertEquals( "author_", it.next().getName() ); | |
110 | assertEquals( "date", it.next().getName() ); | |
111 | assertEquals( "text", it.next().getName() ); | |
112 | assertEquals( "date_", it.next().getName() ); | |
113 | assertEquals( "unknown", it.next().getName() ); | |
114 | assertEquals( "head_", it.next().getName() ); | |
115 | 115 | assertFalse( it.hasNext() ); |
116 | 116 | } |
117 | 117 | |
125 | 125 | |
126 | 126 | ( (XhtmlParser) createParser() ).parse( text, sink ); |
127 | 127 | |
128 | Iterator it = sink.getEventList().iterator(); | |
128 | Iterator<SinkEventElement> it = sink.getEventList().iterator(); | |
129 | 129 | |
130 | assertEquals( "verbatim", ( (SinkEventElement) it.next() ).getName() ); | |
131 | assertEquals( "verbatim_", ( (SinkEventElement) it.next() ).getName() ); | |
130 | assertEquals( "verbatim", it.next().getName() ); | |
131 | assertEquals( "verbatim_", it.next().getName() ); | |
132 | 132 | assertFalse( it.hasNext() ); |
133 | 133 | } |
134 | 134 | |
146 | 146 | |
147 | 147 | ( (XhtmlParser) createParser() ).parse( text, sink ); |
148 | 148 | |
149 | Iterator it = sink.getEventList().iterator(); | |
150 | assertEquals( "unknown", ( (SinkEventElement) it.next() ).getName() ); | |
151 | assertEquals( "unknown", ( (SinkEventElement) it.next() ).getName() ); | |
152 | assertEquals( "unknown", ( (SinkEventElement) it.next() ).getName() ); | |
153 | assertEquals( "unknown", ( (SinkEventElement) it.next() ).getName() ); | |
149 | Iterator<SinkEventElement> it = sink.getEventList().iterator(); | |
150 | assertEquals( "unknown", it.next().getName() ); | |
151 | assertEquals( "unknown", it.next().getName() ); | |
152 | assertEquals( "unknown", it.next().getName() ); | |
153 | assertEquals( "unknown", it.next().getName() ); | |
154 | 154 | assertFalse( it.hasNext() ); |
155 | 155 | } |
156 | 156 | } |
21 | 21 | <parent> |
22 | 22 | <artifactId>doxia</artifactId> |
23 | 23 | <groupId>org.apache.maven.doxia</groupId> |
24 | <version>1.2</version> | |
24 | <version>1.3</version> | |
25 | 25 | <relativePath>../pom.xml</relativePath> |
26 | 26 | </parent> |
27 | 27 | |
45 | 45 | <module>doxia-module-twiki</module> |
46 | 46 | <module>doxia-module-xdoc</module> |
47 | 47 | <module>doxia-module-xhtml</module> |
48 | <!-- this has a dep on xhtml module, so needs to be built last! --> | |
49 | <module>doxia-module-markdown</module> | |
48 | 50 | </modules> |
49 | 51 | |
50 | 52 | <dependencies> |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project name="Modules" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd" | |
25 | name="Modules"> | |
25 | 26 | |
26 | 27 | <body> |
27 | 28 |
24 | 24 | <parent> |
25 | 25 | <artifactId>doxia</artifactId> |
26 | 26 | <groupId>org.apache.maven.doxia</groupId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
20 | 20 | */ |
21 | 21 | --> |
22 | 22 | |
23 | <project> | |
23 | <project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
24 | xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"> | |
24 | 25 | |
25 | 26 | <body> |
26 | 27 | |
27 | 28 | <menu ref="parent"/> |
29 | ||
30 | <menu name="Overview"> | |
31 | <item name="Introduction" href="index.html"/> | |
32 | <item name="JavaDocs" href="apidocs/index.html"/> | |
33 | <item name="Source Xref" href="xref/index.html"/> | |
34 | <!--item name="FAQ" href="faq.html"/--> | |
35 | </menu> | |
28 | 36 | |
29 | 37 | <menu ref="reports"/> |
30 | 38 |
24 | 24 | <parent> |
25 | 25 | <groupId>org.apache.maven.doxia</groupId> |
26 | 26 | <artifactId>doxia</artifactId> |
27 | <version>1.2</version> | |
27 | <version>1.3</version> | |
28 | 28 | <relativePath>../pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 |
54 | 54 | <p> |
55 | 55 | Doxia also has a fairly simple tool for writing books. It comes complete with a Maven plugin |
56 | 56 | to produce PDFs, LaTeX documents and Xdoc for direct integration in your Maven site. |
57 | The <a href="http://svn.apache.org/repos/asf/maven/doxia/doxia/trunk/doxia-book/">Doxia Book code</a> | |
57 | The <a href="http://svn.apache.org/repos/asf/maven/doxia/doxia-tools/trunk/doxia-book-renderer/">Doxia Book code</a> | |
58 | 58 | is still limited but fully functional. |
59 | </p> | |
60 | <p> | |
61 | See <a href="./book/index.html">Writing Books in Doxia</a> for more information. | |
62 | 59 | </p> |
63 | 60 | </answer> |
64 | 61 | </faq> |
24 | 24 | <parent> |
25 | 25 | <groupId>org.apache.maven</groupId> |
26 | 26 | <artifactId>maven-parent</artifactId> |
27 | <version>19</version> | |
27 | <version>21</version> | |
28 | 28 | <relativePath>../../pom/maven/pom.xml</relativePath> |
29 | 29 | </parent> |
30 | 30 | |
31 | 31 | <groupId>org.apache.maven.doxia</groupId> |
32 | 32 | <artifactId>doxia</artifactId> |
33 | <version>1.2</version> | |
33 | <version>1.3</version> | |
34 | 34 | <packaging>pom</packaging> |
35 | 35 | |
36 | 36 | <name>Doxia</name> |
40 | 40 | |
41 | 41 | <mailingLists> |
42 | 42 | <mailingList> |
43 | <name>Doxia Developer List</name> | |
44 | <post>doxia-dev@maven.apache.org</post> | |
45 | <subscribe>doxia-dev-subscribe@maven.apache.org</subscribe> | |
46 | <unsubscribe>doxia-dev-unsubscribe@maven.apache.org</unsubscribe> | |
47 | <archive>http://mail-archives.apache.org/mod_mbox/maven-doxia-dev/</archive> | |
48 | <otherArchives> | |
49 | <otherArchive>http://www.mail-archive.com/doxia-dev@maven.apache.org</otherArchive> | |
50 | <otherArchive>http://www.nabble.com/Doxia---dev-f11816.html</otherArchive> | |
51 | <otherArchive>http://markmail.org/list/org.apache.maven.doxia-dev</otherArchive> | |
52 | </otherArchives> | |
53 | </mailingList> | |
54 | <mailingList> | |
55 | <name>Doxia User List</name> | |
56 | <post>doxia-users@maven.apache.org</post> | |
57 | <subscribe>doxia-users-subscribe@maven.apache.org</subscribe> | |
58 | <unsubscribe>doxia-users-unsubscribe@maven.apache.org</unsubscribe> | |
59 | <archive>http://mail-archives.apache.org/mod_mbox/maven-doxia-users/</archive> | |
60 | <otherArchives> | |
61 | <otherArchive>http://www.mail-archive.com/doxia-users@maven.apache.org</otherArchive> | |
62 | <otherArchive>http://www.nabble.com/Doxia---Users-f14483.html</otherArchive> | |
63 | <otherArchive>http://markmail.org/list/org.apache.maven.doxia-users</otherArchive> | |
64 | </otherArchives> | |
65 | </mailingList> | |
66 | <mailingList> | |
67 | <name>Doxia Commits List</name> | |
68 | <subscribe>doxia-commits-subscribe@maven.apache.org</subscribe> | |
69 | <unsubscribe>doxia-commits-unsubscribe@maven.apache.org</unsubscribe> | |
70 | <archive>http://mail-archives.apache.org/mod_mbox/maven-doxia-commits/</archive> | |
71 | <otherArchives> | |
72 | <otherArchive>http://www.mail-archive.com/doxia-commits@maven.apache.org</otherArchive> | |
73 | <otherArchive>http://markmail.org/list/org.apache.maven.doxia-commits</otherArchive> | |
43 | <name>Maven User List</name> | |
44 | <subscribe>users-subscribe@maven.apache.org</subscribe> | |
45 | <unsubscribe>users-unsubscribe@maven.apache.org</unsubscribe> | |
46 | <post>users@maven.apache.org</post> | |
47 | <archive>http://mail-archives.apache.org/mod_mbox/maven-users</archive> | |
48 | <otherArchives> | |
49 | <otherArchive>http://www.mail-archive.com/users@maven.apache.org/</otherArchive> | |
50 | <otherArchive>http://oldnabble.com/Maven---Users-f178.html</otherArchive> | |
51 | <otherArchive>http://markmail.org/list/org.apache.maven.users</otherArchive> | |
52 | </otherArchives> | |
53 | </mailingList> | |
54 | <mailingList> | |
55 | <name>Maven Developer List</name> | |
56 | <subscribe>dev-subscribe@maven.apache.org</subscribe> | |
57 | <unsubscribe>dev-unsubscribe@maven.apache.org</unsubscribe> | |
58 | <post>dev@maven.apache.org</post> | |
59 | <archive>http://mail-archives.apache.org/mod_mbox/maven-dev</archive> | |
60 | <otherArchives> | |
61 | <otherArchive>http://www.mail-archive.com/dev@maven.apache.org/</otherArchive> | |
62 | <otherArchive>http://old.nabble.com/Maven-Developers-f179.html</otherArchive> | |
63 | <otherArchive>http://markmail.org/list/org.apache.maven.dev</otherArchive> | |
64 | </otherArchives> | |
65 | </mailingList> | |
66 | <mailingList> | |
67 | <name>Maven Commits List</name> | |
68 | <subscribe>commits-subscribe@maven.apache.org</subscribe> | |
69 | <unsubscribe>commits-unsubscribe@maven.apache.org</unsubscribe> | |
70 | <archive>http://mail-archives.apache.org/mod_mbox/maven-commits</archive> | |
71 | <otherArchives> | |
72 | <otherArchive>http://www.mail-archive.com/commits@maven.apache.org</otherArchive> | |
73 | <otherArchive>http://old.nabble.com/Maven---Commits-f15575.html</otherArchive> | |
74 | <otherArchive>http://markmail.org/list/org.apache.maven.commits</otherArchive> | |
74 | 75 | </otherArchives> |
75 | 76 | </mailingList> |
76 | 77 | <mailingList> |
80 | 81 | <archive>http://mail-archives.apache.org/mod_mbox/maven-issues/</archive> |
81 | 82 | <otherArchives> |
82 | 83 | <otherArchive>http://www.mail-archive.com/issues@maven.apache.org</otherArchive> |
84 | <otherArchive>http://old.nabble.com/Maven---Issues-f15573.html</otherArchive> | |
85 | <otherArchive>http://markmail.org/list/org.apache.maven.issues</otherArchive> | |
86 | </otherArchives> | |
87 | </mailingList> | |
88 | <mailingList> | |
89 | <name>Old Doxia Developer List (closed)</name> | |
90 | <archive>http://mail-archives.apache.org/mod_mbox/maven-doxia-dev/</archive> | |
91 | <otherArchives> | |
92 | <otherArchive>http://www.mail-archive.com/doxia-dev@maven.apache.org</otherArchive> | |
93 | <otherArchive>http://www.nabble.com/Doxia---dev-f11816.html</otherArchive> | |
94 | <otherArchive>http://markmail.org/list/org.apache.maven.doxia-dev</otherArchive> | |
95 | </otherArchives> | |
96 | </mailingList> | |
97 | <mailingList> | |
98 | <name>Old Doxia User List (closed)</name> | |
99 | <archive>http://mail-archives.apache.org/mod_mbox/maven-doxia-users/</archive> | |
100 | <otherArchives> | |
101 | <otherArchive>http://www.mail-archive.com/doxia-users@maven.apache.org</otherArchive> | |
102 | <otherArchive>http://www.nabble.com/Doxia---Users-f14483.html</otherArchive> | |
103 | <otherArchive>http://markmail.org/list/org.apache.maven.doxia-users</otherArchive> | |
104 | </otherArchives> | |
105 | </mailingList> | |
106 | <mailingList> | |
107 | <name>Old Doxia Commits List (closed)</name> | |
108 | <archive>http://mail-archives.apache.org/mod_mbox/maven-doxia-commits/</archive> | |
109 | <otherArchives> | |
110 | <otherArchive>http://www.mail-archive.com/doxia-commits@maven.apache.org</otherArchive> | |
111 | <otherArchive>http://markmail.org/list/org.apache.maven.doxia-commits</otherArchive> | |
112 | </otherArchives> | |
113 | </mailingList> | |
114 | <mailingList> | |
115 | <name>Maven Issues List</name> | |
116 | <subscribe>issues-subscribe@maven.apache.org</subscribe> | |
117 | <unsubscribe>issues-unsubscribe@maven.apache.org</unsubscribe> | |
118 | <archive>http://mail-archives.apache.org/mod_mbox/maven-issues/</archive> | |
119 | <otherArchives> | |
120 | <otherArchive>http://www.mail-archive.com/issues@maven.apache.org</otherArchive> | |
83 | 121 | <otherArchive>http://www.nabble.com/Maven---Issues-f15573.html</otherArchive> |
84 | 122 | <otherArchive>http://markmail.org/list/org.apache.maven.issues</otherArchive> |
85 | 123 | </otherArchives> |
86 | 124 | </mailingList> |
125 | ||
126 | <!-- duplication from parent pom - temporary until they inherit properly --> | |
127 | <mailingList> | |
128 | <name>Maven Announcements List</name> | |
129 | <post>announce@maven.apache.org</post> | |
130 | <subscribe>announce-subscribe@maven.apache.org</subscribe> | |
131 | <unsubscribe>announce-unsubscribe@maven.apache.org</unsubscribe> | |
132 | <archive>http://mail-archives.apache.org/mod_mbox/maven-announce/</archive> | |
133 | <otherArchives> | |
134 | <otherArchive>http://www.mail-archive.com/announce@maven.apache.org</otherArchive> | |
135 | <otherArchive>http://www.nabble.com/Maven-Announcements-f15617.html</otherArchive> | |
136 | <otherArchive>http://markmail.org/list/org.apache.maven.announces</otherArchive> | |
137 | </otherArchives> | |
138 | </mailingList> | |
139 | <mailingList> | |
140 | <name>Maven Notifications List</name> | |
141 | <subscribe>notifications-subscribe@maven.apache.org</subscribe> | |
142 | <unsubscribe>notifications-unsubscribe@maven.apache.org</unsubscribe> | |
143 | <archive>http://mail-archives.apache.org/mod_mbox/maven-notifications/</archive> | |
144 | <otherArchives> | |
145 | <otherArchive>http://www.mail-archive.com/notifications@maven.apache.org</otherArchive> | |
146 | <otherArchive>http://www.nabble.com/Maven---Notifications-f15574.html</otherArchive> | |
147 | <otherArchive>http://markmail.org/list/org.apache.maven.notifications</otherArchive> | |
148 | </otherArchives> | |
149 | </mailingList> | |
87 | 150 | </mailingLists> |
88 | 151 | |
89 | 152 | <prerequisites> |
90 | <maven>2.0.6</maven> | |
153 | <maven>${mavenVersion}</maven> | |
91 | 154 | </prerequisites> |
92 | 155 | |
93 | 156 | <modules> |
96 | 159 | <module>doxia-test-docs</module> |
97 | 160 | <module>doxia-core</module> |
98 | 161 | <module>doxia-modules</module> |
99 | <module>doxia-book</module> | |
100 | <module>doxia-maven-plugin</module> | |
101 | 162 | </modules> |
102 | 163 | |
103 | 164 | <scm> |
104 | <connection>scm:svn:http://svn.apache.org/repos/asf/maven/doxia/doxia/tags/doxia-1.2</connection> | |
105 | <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/doxia/doxia/tags/doxia-1.2</developerConnection> | |
106 | <url>http://svn.apache.org/viewcvs.cgi/maven/doxia/doxia/tags/doxia-1.2</url> | |
165 | <connection>scm:svn:http://svn.apache.org/repos/asf/maven/doxia/doxia/tags/doxia-1.3</connection> | |
166 | <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/doxia/doxia/tags/doxia-1.3</developerConnection> | |
167 | <url>http://svn.apache.org/viewcvs.cgi/maven/doxia/doxia/tags/doxia-1.3</url> | |
107 | 168 | </scm> |
108 | 169 | |
109 | 170 | <issueManagement> |
113 | 174 | |
114 | 175 | <ciManagement> |
115 | 176 | <system>Jenkins</system> |
116 | <url>https://builds.apache.org/hudson/job/doxia/</url> | |
177 | <url>https://builds.apache.org/job/doxia/</url> | |
117 | 178 | </ciManagement> |
118 | 179 | |
119 | 180 | <distributionManagement> |
124 | 185 | </distributionManagement> |
125 | 186 | |
126 | 187 | <properties> |
188 | <mavenVersion>2.0.6</mavenVersion> | |
127 | 189 | <projectVersion>${project.version}</projectVersion> |
128 | 190 | </properties> |
129 | 191 | |
211 | 273 | <dependency> |
212 | 274 | <groupId>org.apache.maven.doxia</groupId> |
213 | 275 | <artifactId>doxia-module-xhtml</artifactId> |
214 | <version>${projectVersion}</version> | |
215 | </dependency> | |
216 | ||
217 | <!-- Others --> | |
218 | <dependency> | |
219 | <groupId>org.apache.maven.doxia</groupId> | |
220 | <artifactId>doxia-book</artifactId> | |
221 | <version>${projectVersion}</version> | |
222 | </dependency> | |
223 | <dependency> | |
224 | <groupId>org.apache.maven.doxia</groupId> | |
225 | <artifactId>doxia-maven-plugin</artifactId> | |
226 | 276 | <version>${projectVersion}</version> |
227 | 277 | </dependency> |
228 | 278 | |
254 | 304 | <directory>src/main/resources</directory> |
255 | 305 | </resource> |
256 | 306 | <resource> |
257 | <directory>${build.directory}/generated-site/xsd</directory> | |
307 | <directory>${project.build.directory}/generated-site/xsd</directory> | |
258 | 308 | <includes> |
259 | 309 | <include>**/*.xsd</include> |
260 | 310 | </includes> |
262 | 312 | </resources> |
263 | 313 | <pluginManagement> |
264 | 314 | <plugins> |
265 | <plugin> | |
266 | <groupId>org.apache.maven.plugins</groupId> | |
267 | <artifactId>maven-compiler-plugin</artifactId> | |
268 | <configuration> | |
269 | <source>1.5</source> | |
270 | <target>1.5</target> | |
271 | </configuration> | |
272 | </plugin> | |
273 | <plugin> | |
274 | <groupId>org.apache.maven.plugins</groupId> | |
275 | <artifactId>maven-antrun-plugin</artifactId> | |
276 | <version>1.3</version> | |
277 | </plugin> | |
278 | 315 | <plugin> |
279 | 316 | <groupId>org.apache.maven.plugins</groupId> |
280 | 317 | <artifactId>maven-release-plugin</artifactId> |
289 | 326 | <version>1.3.5</version> |
290 | 327 | </plugin> |
291 | 328 | <plugin> |
292 | <groupId>org.codehaus.modello</groupId> | |
293 | <artifactId>modello-maven-plugin</artifactId> | |
294 | <configuration> | |
295 | <useJava5>true</useJava5> | |
296 | </configuration> | |
297 | </plugin> | |
298 | <plugin> | |
299 | 329 | <groupId>org.codehaus.mojo</groupId> |
300 | 330 | <artifactId>clirr-maven-plugin</artifactId> |
301 | <configuration> | |
302 | <comparisonVersion>1.1</comparisonVersion> | |
303 | </configuration> | |
304 | </plugin> | |
305 | <plugin> | |
306 | <groupId>org.apache.maven.plugins</groupId> | |
307 | <artifactId>maven-javadoc-plugin</artifactId> | |
308 | <configuration> | |
309 | <source>1.5</source> | |
310 | <links> | |
311 | <link>http://java.sun.com/j2se/1.4.2/docs/api/</link> | |
312 | <link>http://plexus.codehaus.org/plexus-utils/apidocs/</link> | |
313 | <link>http://junit.sourceforge.net/javadoc/</link> | |
314 | </links> | |
315 | <tagletArtifacts> | |
316 | <tagletArtifact> | |
317 | <groupId>org.codehaus.plexus</groupId> | |
318 | <artifactId>plexus-component-javadoc</artifactId> | |
319 | <version>1.5.5</version> | |
320 | </tagletArtifact> | |
321 | </tagletArtifacts> | |
322 | </configuration> | |
323 | 331 | </plugin> |
324 | 332 | <plugin> |
325 | 333 | <artifactId>maven-site-plugin</artifactId> |
395 | 403 | <plugins> |
396 | 404 | <plugin> |
397 | 405 | <groupId>org.apache.maven.plugins</groupId> |
398 | <artifactId>maven-javadoc-plugin</artifactId> | |
406 | <artifactId>maven-changes-plugin</artifactId> | |
407 | <version>2.6</version> | |
399 | 408 | <configuration> |
400 | <source>1.5</source> | |
401 | <links> | |
402 | <link>http://java.sun.com/j2se/1.4.2/docs/api/</link> | |
403 | <link>http://plexus.codehaus.org/plexus-utils/apidocs/</link> | |
404 | <link>http://junit.sourceforge.net/javadoc/</link> | |
405 | </links> | |
406 | <tagletArtifacts> | |
407 | <tagletArtifact> | |
408 | <groupId>org.codehaus.plexus</groupId> | |
409 | <artifactId>plexus-component-javadoc</artifactId> | |
410 | <version>1.5.5</version> | |
411 | </tagletArtifact> | |
412 | </tagletArtifacts> | |
409 | <columnNames>Type,Key,Summary,Resolution,Assignee</columnNames> | |
410 | <maxEntries>1000</maxEntries> | |
411 | <onlyCurrentVersion>true</onlyCurrentVersion> | |
412 | <sortColumnNames>Key</sortColumnNames> | |
413 | 413 | </configuration> |
414 | <reportSets> | |
415 | <reportSet> | |
416 | <reports> | |
417 | <report>jira-report</report> | |
418 | </reports> | |
419 | </reportSet> | |
420 | </reportSets> | |
414 | 421 | </plugin> |
415 | <plugin> | |
416 | <groupId>org.codehaus.mojo</groupId> | |
417 | <artifactId>cobertura-maven-plugin</artifactId> | |
418 | <version>2.4</version> | |
419 | </plugin> | |
420 | <plugin> | |
421 | <artifactId>maven-pmd-plugin</artifactId> | |
422 | <version>2.5</version> | |
423 | <configuration> | |
424 | <targetJdk>1.5</targetJdk> | |
425 | </configuration> | |
426 | </plugin> | |
427 | </plugins> | |
428 | </reporting> | |
429 | </profile> | |
430 | <profile> | |
431 | <id>reporting-aggregate</id> | |
432 | <!-- To generate aggregate reports --> | |
433 | <!-- To deploy both aggregate reports for top-level project and standalone reports for modules, call | |
434 | mvn site -Preporting | |
435 | mvn site:deploy | |
436 | mvn site -Preporting-aggregate | |
437 | mvn -N site:deploy | |
438 | --> | |
439 | <reporting> | |
440 | <plugins> | |
441 | 422 | <plugin> |
442 | 423 | <groupId>org.apache.maven.plugins</groupId> |
443 | 424 | <artifactId>maven-jxr-plugin</artifactId> |
444 | <configuration> | |
445 | <aggregate>true</aggregate> | |
446 | </configuration> | |
425 | <version>2.3</version> | |
426 | <reportSets> | |
427 | <reportSet> | |
428 | <id>non-aggregate</id> | |
429 | <reports> | |
430 | <report>jxr</report> | |
431 | </reports> | |
432 | </reportSet> | |
433 | <reportSet> | |
434 | <id>aggregate</id> | |
435 | <reports> | |
436 | <report>aggregate</report> | |
437 | </reports> | |
438 | </reportSet> | |
439 | </reportSets> | |
447 | 440 | </plugin> |
448 | 441 | <plugin> |
449 | 442 | <groupId>org.apache.maven.plugins</groupId> |
450 | 443 | <artifactId>maven-javadoc-plugin</artifactId> |
451 | <configuration> | |
452 | <aggregate>true</aggregate> | |
453 | <source>1.5</source> | |
454 | <links> | |
455 | <link>http://java.sun.com/j2se/1.4.2/docs/api/</link> | |
456 | <link>http://plexus.codehaus.org/plexus-utils/apidocs/</link> | |
457 | <link>http://junit.sourceforge.net/javadoc/</link> | |
458 | </links> | |
459 | <tagletArtifacts> | |
460 | <tagletArtifact> | |
461 | <groupId>org.codehaus.plexus</groupId> | |
462 | <artifactId>plexus-component-javadoc</artifactId> | |
463 | <version>1.5.5</version> | |
464 | </tagletArtifact> | |
465 | </tagletArtifacts> | |
466 | </configuration> | |
467 | 444 | <reportSets> |
468 | 445 | <reportSet> |
446 | <id>non-aggregate</id> | |
447 | <reports> | |
448 | <report>javadoc</report> | |
449 | </reports> | |
450 | </reportSet> | |
451 | <reportSet> | |
452 | <id>aggregate</id> | |
469 | 453 | <reports> |
470 | 454 | <report>aggregate</report> |
471 | <report>test-aggregate</report> | |
472 | 455 | </reports> |
473 | 456 | </reportSet> |
474 | 457 | </reportSets> |
476 | 459 | </plugins> |
477 | 460 | </reporting> |
478 | 461 | </profile> |
479 | <profile> | |
480 | <id>m2e</id> | |
481 | <properties> | |
482 | <m2BuildDirectory>target</m2BuildDirectory> | |
483 | </properties> | |
484 | <activation> | |
485 | <property> | |
486 | <name>m2e.version</name> | |
487 | </property> | |
488 | </activation> | |
489 | <build> | |
490 | <directory>${m2BuildDirectory}</directory> | |
491 | <plugins> | |
492 | <plugin> | |
493 | <groupId>org.maven.ide.eclipse</groupId> | |
494 | <artifactId>lifecycle-mapping</artifactId> | |
495 | <version>0.10.0</version> | |
496 | <configuration> | |
497 | <mappingId>customizable</mappingId> | |
498 | <configurators> | |
499 | <configurator id="org.maven.ide.eclipse.jdt.javaConfigurator" /> | |
500 | <configurator id="org.maven.ide.eclipse.modello.modelloConfigurator" /> | |
501 | <configurator id="org.maven.ide.eclipse.plexus.annotations.plexusConfigurator" /> | |
502 | </configurators> | |
503 | <mojoExecutions> | |
504 | <mojoExecution>org.apache.maven.plugins:maven-resources-plugin::</mojoExecution> | |
505 | </mojoExecutions> | |
506 | </configuration> | |
507 | </plugin> | |
508 | </plugins> | |
509 | </build> | |
510 | </profile> | |
511 | 462 | </profiles> |
512 | 463 | </project> |
27 | 27 | |
28 | 28 | <module name="Checker"> |
29 | 29 | |
30 | <!-- Checks that a package.html file exists for each package. --> | |
31 | <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml --> | |
32 | <!-- module name="PackageHtml"/ --> | |
30 | <!-- Checks that each Java package has a Javadoc file used for commenting. --> | |
31 | <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage --> | |
32 | <!-- module name="JavadocPackage"> | |
33 | <property name="allowLegacy" value="true"/> | |
34 | </module--> | |
33 | 35 | |
34 | 36 | <!-- Checks whether files end with a new line. --> |
35 | 37 | <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> |
38 | 40 | <!-- Checks that property files contain the same keys. --> |
39 | 41 | <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> |
40 | 42 | <!-- module name="Translation"/ --> |
43 | ||
44 | <module name="FileLength"/> | |
45 | ||
46 | <!-- Checks for Headers --> | |
47 | <!-- See http://checkstyle.sf.net/config_header.html --> | |
48 | <module name="RegexpHeader"> | |
49 | <property name="headerFile" value="${checkstyle.header.file}"/> | |
50 | </module> | |
51 | ||
52 | <module name="FileTabCharacter"> | |
53 | <property name="eachLine" value="true"/> | |
54 | </module> | |
55 | ||
56 | <!-- Line with trailing spaces --> | |
57 | <module name="RegexpSingleline"> | |
58 | <property name="format" value="\s+$"/> | |
59 | <property name="message" value="Line has trailing spaces."/> | |
60 | </module> | |
41 | 61 | |
42 | 62 | <module name="TreeWalker"> |
43 | 63 | |
66 | 86 | <property name="severity" value="warning"/> |
67 | 87 | <property name="scope" value="protected"/> |
68 | 88 | </module> |
69 | <module name="JavadocType"/> | |
89 | <module name="JavadocType"> | |
90 | <property name="scope" value="protected"/> | |
91 | <property name="allowUnknownTags" value="true" /> | |
92 | </module> | |
70 | 93 | <module name="JavadocVariable"> |
71 | 94 | <property name="severity" value="info"/> |
72 | 95 | <property name="scope" value="protected"/> |
78 | 101 | <module name="ConstantName"/> |
79 | 102 | <module name="LocalFinalVariableName"/> |
80 | 103 | <module name="LocalVariableName"/> |
81 | <!-- <module name="MethodName"/> --> | |
82 | 104 | <module name="MethodName"> |
83 | 105 | <property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> |
84 | 106 | </module> |
86 | 108 | <module name="ParameterName"/> |
87 | 109 | <module name="StaticVariableName"/> |
88 | 110 | <module name="TypeName"/> |
89 | ||
90 | ||
91 | <!-- Checks for Headers --> | |
92 | <!-- See http://checkstyle.sf.net/config_header.html --> | |
93 | <module name="RegexpHeader"> | |
94 | <property name="headerFile" value="${checkstyle.header.file}"/> | |
95 | </module> | |
96 | 111 | |
97 | 112 | <!-- Checks for imports --> |
98 | 113 | <!-- See http://checkstyle.sf.net/config_import.html --> |
104 | 119 | |
105 | 120 | <!-- Checks for Size Violations. --> |
106 | 121 | <!-- See http://checkstyle.sf.net/config_sizes.html --> |
107 | <module name="FileLength"/> | |
108 | 122 | <module name="MethodLength"/> |
109 | 123 | <module name="ParameterNumber"/> |
110 | 124 | |
120 | 134 | <module name="ParenPad"> |
121 | 135 | <property name="option" value="space" /> |
122 | 136 | </module> |
123 | <module name="TabCharacter"/> | |
124 | 137 | <module name="WhitespaceAfter"/> |
125 | 138 | <module name="WhitespaceAround"/> |
126 | 139 | <!-- module name="MethodParamPad"/ --> |
168 | 181 | <!-- module name="DesignForExtension"/ --> |
169 | 182 | <!-- module name="FinalClass"/ --> |
170 | 183 | <!-- module name="HideUtilityClassConstructor"/ --> |
171 | <!-- <module name="InterfaceIsType"/> --> | |
184 | <!-- module name="InterfaceIsType"/ --> | |
172 | 185 | <module name="VisibilityModifier"> |
173 | 186 | <property name="protectedAllowed" value="true"/> |
187 | <property name="packageAllowed" value="true"/> | |
174 | 188 | </module> |
175 | 189 | |
176 | 190 | <!-- Miscellaneous other checks. --> |
177 | 191 | <!-- See http://checkstyle.sf.net/config_misc.html --> |
178 | 192 | <!-- module name="ArrayTypeStyle"/ --> |
179 | 193 | <!-- module name="FinalParameters"/ --> |
180 | <!-- Line with Trailing Spaces --> | |
181 | <module name="GenericIllegalRegexp"> | |
182 | <property name="format" value="\s+$"/> | |
183 | <property name="message" value="Line has trailing spaces."/> | |
184 | </module> | |
185 | 194 | <!-- Let todo plugin handle this. |
186 | 195 | <module name="TodoComment"/> |
187 | 196 | --> |
Binary diff not shown
Binary diff not shown
21 | 21 | <document> |
22 | 22 | |
23 | 23 | <properties> |
24 | <title>Doxia</title> | |
24 | <title>Doxia (base)</title> | |
25 | 25 | <author email="hboutemy_AT_apache_DOT_org">Hervé Boutemy</author> |
26 | 26 | </properties> |
27 | 27 | |
29 | 29 | |
30 | 30 | <section name="Doxia"> |
31 | 31 | |
32 | <p>Doxia is a content generation framework that provides powerful techniques for generating static and dynamic content, supporting a variety of markup languages.</p> | |
32 | <p>Doxia is a content generation framework that provides powerful techniques for generating static and dynamic content, | |
33 | supporting <a href="/doxia/references/index.html">a variety of markup languages</a>.</p> | |
34 | ||
35 | <p>The actual component is the base component from the whole Doxia suite, used by the | |
36 | <a href="../doxia-sitetools">Doxia Sitetools</a> extension that adds site and documents support.</p> | |
33 | 37 | |
34 | 38 | <p> |
35 | <!-- workaround for DOXIA-227: usemap attribute is stripped (fixed in Doxia 1.1, was 1.0-beta-1) --> | |
36 | <script type="text/javascript"> | |
37 | tag='<img src="images/doxia-deps.png" width="647" height="414" border="0" usemap="#Doxia_dependencies" />'; | |
38 | tag=tag.substring(0,tag.length-2)+' usemap=\'#Doxia_dependencies\''+tag.substring(tag.length-2); | |
39 | document.write(tag); | |
40 | </script> | |
39 | <img src="images/doxia-deps.png" width="647" height="335" border="0" usemap="#Doxia_dependencies" /> | |
41 | 40 | <map name="Doxia_dependencies"> |
42 | <area shape="rect" coords="98,382,220,413" href="doxia-test-docs/" /> | |
43 | <area shape="rect" coords="262,382,385,413" href="doxia-logging-api/" /> | |
44 | <area shape="rect" coords="262,333,385,364" href="doxia-sink-api/" /> | |
45 | <area shape="rect" coords="262,280,385,313" href="doxia-core/" /> | |
46 | <area shape="rect" coords="41,117,167,149" href="doxia-modules/doxia-module-apt/" /> | |
47 | <area shape="rect" coords="190,116,315,149" href="doxia-modules/doxia-module-xdoc/" /> | |
48 | <area shape="rect" coords="339,117,462,149" href="doxia-modules/doxia-module-xhtml/" /> | |
49 | <area shape="rect" coords="486,117,609,149" href="doxia-modules/doxia-module-fml/" /> | |
50 | <area shape="rect" coords="68,159,243,190" href="doxia-modules/doxia-module-confluence/" /> | |
51 | <area shape="rect" coords="276,159,399,190" href="doxia-modules/doxia-module-twiki/" /> | |
52 | <area shape="rect" coords="431,158,554,190" href="doxia-modules/doxia-module-latex/" /> | |
53 | <area shape="rect" coords="14,201,232,232" href="doxia-modules/doxia-module-docbook-simple/" /> | |
54 | <area shape="rect" coords="242,201,365,232" href="doxia-modules/doxia-module-rtf/" /> | |
55 | <area shape="rect" coords="378,201,501,232" href="doxia-modules/doxia-module-itext" /> | |
56 | <area shape="rect" coords="512,201,636,232" href="doxia-modules/doxia-module-fo/" /> | |
57 | <area shape="rect" coords="0,106,646,260" href="doxia-modules/" /> | |
58 | <area shape="rect" coords="251,53,396,85" href="doxia-book/" /> | |
59 | <area shape="rect" coords="251,0,395,32" href="doxia-maven-plugin/" /> | |
60 | <area shape="rect" coords="71,34,232,66" href="http://maven.apache.org/shared/maven-doxia-tools/" /> | |
61 | <area shape="rect" coords="420,34,580,66" href="http://maven.apache.org/ref/current/maven-plugin-api/" /> | |
62 | <area shape="rect" coords="407,280,472,312" href="http://www.lowagie.com/iText/" /> | |
63 | <area shape="rect" coords="552,280,599,312" href="http://xmlgraphics.apache.org/fop/" /> | |
64 | <area shape="rect" coords="420,382,542,412" href="http://plexus.codehaus.org/" /> | |
41 | <area shape="rect" coords="98,303,220,335" href="./doxia-test-docs/" /> | |
42 | <area shape="rect" coords="262,303,385,335" href="./doxia-logging-api/" /> | |
43 | <area shape="rect" coords="262,254,385,285" href="./doxia-sink-api/" /> | |
44 | <area shape="rect" coords="262,201,385,234" href="./doxia-core/" /> | |
45 | <area shape="rect" coords="41,12,167,44" href="./doxia-modules/doxia-module-apt/" /> | |
46 | <area shape="rect" coords="190,11,315,44" href="./doxia-modules/doxia-module-xdoc/" /> | |
47 | <area shape="rect" coords="339,12,462,44" href="./doxia-modules/doxia-module-xhtml/" /> | |
48 | <area shape="rect" coords="486,12,609,44" href="./doxia-modules/doxia-module-fml/" /> | |
49 | <area shape="rect" coords="68,54,243,85" href="./doxia-modules/doxia-module-confluence/" /> | |
50 | <area shape="rect" coords="276,54,399,85" href="./doxia-modules/doxia-module-twiki/" /> | |
51 | <area shape="rect" coords="431,53,554,85" href="./doxia-modules/doxia-module-latex/" /> | |
52 | <area shape="rect" coords="14,96,232,127" href="./doxia-modules/doxia-module-docbook-simple/" /> | |
53 | <area shape="rect" coords="242,96,365,127" href="./doxia-modules/doxia-module-rtf/" /> | |
54 | <area shape="rect" coords="378,96,501,127" href="./doxia-modules/doxia-module-itext" /> | |
55 | <area shape="rect" coords="512,96,636,127" href="./doxia-modules/doxia-module-fo/" /> | |
56 | <area shape="rect" coords="91,136,272,168" href="./doxia-modules/doxia-module-markdown/" /> | |
57 | <area shape="rect" coords="0,0,646,175" href="./doxia-modules/" /> | |
58 | <area shape="rect" coords="136,200,228,233" href="http://www.pegdown.org/" /> | |
59 | <area shape="rect" coords="136,250,228,282" href="http://www.parboiled.org/" /> | |
60 | <area shape="rect" coords="407,201,472,233" href="http://www.lowagie.com/iText/" /> | |
61 | <area shape="rect" coords="551,199,600,232" href="http://xmlgraphics.apache.org/fop/" /> | |
62 | <area shape="rect" coords="420,303,542,334" href="http://plexus.codehaus.org/" /> | |
65 | 63 | </map> |
66 | 64 | </p> |
67 | 65 |