[ https://issues.apache.org/jira/browse/DOXIA-569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17652558#comment-17652558 ]
ASF GitHub Bot commented on DOXIA-569: -------------------------------------- michael-o commented on code in PR #128: URL: https://github.com/apache/maven-doxia/pull/128#discussion_r1058507342 ########## doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTest.java: ########## @@ -492,7 +492,7 @@ public void testFooter() * the same result as {@link #getListBlock getListBlock}( item ). * */ - public void testList() + public void _testList() { Review Comment: Why this change? ########## doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownMarkup.java: ########## @@ -0,0 +1,147 @@ +package org.apache.maven.doxia.module.markdown; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.doxia.markup.TextMarkup; +import org.codehaus.plexus.util.StringUtils; + +/** + * This interface defines all markups and syntaxes used by the <b>Markdown</b> format. + */ +@SuppressWarnings( "checkstyle:interfaceistype" ) +public interface MarkdownMarkup + extends TextMarkup +{ + // ---------------------------------------------------------------------- + // Markup separators + // ---------------------------------------------------------------------- + + /** APT backslash markup char: '\\' */ Review Comment: Still should be fixed. ########## doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java: ########## @@ -0,0 +1,1163 @@ +package org.apache.maven.doxia.module.markdown; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.PrintWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +import org.apache.maven.doxia.sink.SinkEventAttributes; +import org.apache.maven.doxia.sink.impl.AbstractTextSink; +import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; +import org.codehaus.plexus.util.StringUtils; + +/** + * Markdown generator implementation. + * <br> + * <b>Note</b>: The encoding used is UTF-8. + */ +public class MarkdownSink + extends AbstractTextSink + implements MarkdownMarkup +{ + // ---------------------------------------------------------------------- + // Instance fields + // ---------------------------------------------------------------------- + + /** A buffer that holds the current text when headerFlag or bufferFlag set to <code>true</code>. */ + private StringBuffer buffer; + + /** A buffer that holds the table caption. */ + private StringBuilder tableCaptionBuffer; + + /** author. */ + private String author; + + /** title. */ + private String title; + + /** date. */ + private String date; + + /** linkName. */ + private String linkName; + + /** startFlag. */ + private boolean startFlag; + + /** tableCaptionFlag. */ + private boolean tableCaptionFlag; + + /** tableCellFlag. */ + private boolean tableCellFlag; + + /** headerFlag. */ + private boolean headerFlag; + + /** bufferFlag. */ + private boolean bufferFlag; + + /** itemFlag. */ + private boolean itemFlag; + + /** verbatimFlag. */ + private boolean verbatimFlag; + + /** gridFlag for tables. */ + private boolean gridFlag; + + /** number of cells in a table. */ + private int cellCount; + + /** The writer to use. */ + private final PrintWriter writer; + + /** justification of table cells. */ + private int[] cellJustif; + + /** a line of a row in a table. */ + private String rowLine; + + /** is header row */ + private boolean headerRow; + + /** listNestingIndent. */ + private String listNestingIndent; + + /** listStyles. */ + private final Stack<String> listStyles; + + /** Keep track of the closing tags for inline events. */ + protected Stack<List<String>> inlineStack = new Stack<>(); + + // ---------------------------------------------------------------------- + // Public protected methods + // ---------------------------------------------------------------------- + + /** + * Constructor, initialize the Writer and the variables. + * + * @param writer not null writer to write the result. <b>Should</b> be an UTF-8 Writer. + */ + protected MarkdownSink( Writer writer ) + { + this.writer = new PrintWriter( writer ); + this.listStyles = new Stack<>(); + + init(); + } + + /** + * Returns the buffer that holds the current text. + * + * @return A StringBuffer. + */ + protected StringBuffer getBuffer() + { + return buffer; + } + + /** + * Used to determine whether we are in head mode. + * + * @param headFlag True for head mode. + */ + protected void setHeadFlag( boolean headFlag ) + { + this.headerFlag = headFlag; + } + + /** + * {@inheritDoc} + */ + protected void init() + { + super.init(); + + resetBuffer(); + + this.tableCaptionBuffer = new StringBuilder(); + this.listNestingIndent = ""; + + this.author = null; + this.title = null; + this.date = null; + this.linkName = null; + this.startFlag = true; + this.tableCaptionFlag = false; + this.tableCellFlag = false; + this.headerFlag = false; + this.bufferFlag = false; + this.itemFlag = false; + this.verbatimFlag = false; + this.gridFlag = false; + this.cellCount = 0; + this.cellJustif = null; + this.rowLine = null; + this.listStyles.clear(); + this.inlineStack.clear(); + } + + /** + * Reset the StringBuilder. + */ + protected void resetBuffer() + { + buffer = new StringBuffer(); + } + + /** + * Reset the TableCaptionBuffer. + */ + protected void resetTableCaptionBuffer() + { + tableCaptionBuffer = new StringBuilder(); + } + + /** + * {@inheritDoc} + */ + public void head() + { + boolean startFlag = this.startFlag; + + init(); + + headerFlag = true; + this.startFlag = startFlag; + } + + /** + * {@inheritDoc} + */ + public void head_() + { + headerFlag = false; + + if ( ! startFlag ) + { + write( EOL ); + } + // TODO add - > Add Markdown Sink to be able to convert anything to Markdown > ------------------------------------------------------------ > > Key: DOXIA-569 > URL: https://issues.apache.org/jira/browse/DOXIA-569 > Project: Maven Doxia > Issue Type: New Feature > Components: Module - Markdown > Affects Versions: 1.8 > Reporter: Herve Boutemy > Priority: Major > Labels: intern > > Markdown is well known: having Markdown Sink would help people transform > existing content to Markdown -- This message was sent by Atlassian Jira (v8.20.10#820010)