Skip to content

handling link in simple mark down handler #397 #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- [fj-doc-base] handling link in simple mark down handler <https://github.com/fugerit-org/fj-doc/pull/397>

## [8.13.1] - 2025-04-24

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Date;
import java.util.List;

import org.fugerit.java.core.lang.helpers.StringUtils;
import org.fugerit.java.doc.base.config.DocException;
import org.fugerit.java.doc.base.helper.DocTypeFacadeDefault;
import org.fugerit.java.doc.base.helper.DocTypeFacadeHelper;
Expand Down Expand Up @@ -110,6 +111,9 @@ public void handlePara(DocPara docPara, DocContainer parent, DocTypeFacadeHelper
}
// test
this.handleText(docPara.getText(), docPara.getStyle() );
for ( DocElement element : docPara.getElementList() ) {
handleElement( element, docPara, helper );
}
if ( body ) {
this.writer.println( " \n" ); // endline with two white spaces
} else {
Expand All @@ -119,7 +123,15 @@ public void handlePara(DocPara docPara, DocContainer parent, DocTypeFacadeHelper

@Override
public void handlePhrase(DocPhrase docPhrase, DocContainer parent, DocTypeFacadeHelper helper) throws DocException {
this.handleText(docPhrase.getText(), docPhrase.getStyle() );
if (StringUtils.isNotEmpty( docPhrase.getLink() ) ) {
if ( docPhrase.getLink().equals( docPhrase.getText() ) ) {
this.handleText( String.format( "<%s>", docPhrase.getText() ), docPhrase.getStyle() );
} else {
this.handleText( String.format( "[%s](%s)", docPhrase.getText(), docPhrase.getLink() ), docPhrase.getStyle() );
}
} else {
this.handleText(docPhrase.getText(), docPhrase.getStyle() );
}
this.writer.print( " " );
}

Expand Down
5 changes: 5 additions & 0 deletions fj-doc-base/src/test/resources/sample/default_doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
<para font-name="symbol" style="italic">Symbol</para>
<para font-name="helvetica" style="underline">Symbol</para>
<para size="3" fore-color="#dddddd">Test default font</para>


<para><phrase link="https://github.com/fugerit-org/fj-doc">https://github.com/fugerit-org/fj-doc</phrase></para>
<para><phrase link="https://venusdocs.fugerit.org/">Venus DOCS</phrase></para>

<table columns="3" colwidths="30;30;40" width="100" id="excel-table" padding="2">
<row>
<cell align="center" border-color="#000000" border-width="1"><para style="bold">Name</para></cell>
Expand Down