Skip to content

Commit e2c77f3

Browse files
authored
Merge pull request #398 from fugerit-org/397-chore-handling-link-in-simple-mark-down-handler
handling link in simple mark down handler #397
2 parents 300efce + 7f21375 commit e2c77f3

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- [fj-doc-base] handling link in simple mark down handler <https://github.com/fugerit-org/fj-doc/pull/397>
13+
1014
## [8.13.1] - 2025-04-24
1115

1216
### Added

fj-doc-base/src/main/java/org/fugerit/java/doc/base/typehandler/markdown/MarkdownBasicDocFacade.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Date;
55
import java.util.List;
66

7+
import org.fugerit.java.core.lang.helpers.StringUtils;
78
import org.fugerit.java.doc.base.config.DocException;
89
import org.fugerit.java.doc.base.helper.DocTypeFacadeDefault;
910
import org.fugerit.java.doc.base.helper.DocTypeFacadeHelper;
@@ -110,6 +111,9 @@ public void handlePara(DocPara docPara, DocContainer parent, DocTypeFacadeHelper
110111
}
111112
// test
112113
this.handleText(docPara.getText(), docPara.getStyle() );
114+
for ( DocElement element : docPara.getElementList() ) {
115+
handleElement( element, docPara, helper );
116+
}
113117
if ( body ) {
114118
this.writer.println( " \n" ); // endline with two white spaces
115119
} else {
@@ -119,7 +123,15 @@ public void handlePara(DocPara docPara, DocContainer parent, DocTypeFacadeHelper
119123

120124
@Override
121125
public void handlePhrase(DocPhrase docPhrase, DocContainer parent, DocTypeFacadeHelper helper) throws DocException {
122-
this.handleText(docPhrase.getText(), docPhrase.getStyle() );
126+
if (StringUtils.isNotEmpty( docPhrase.getLink() ) ) {
127+
if ( docPhrase.getLink().equals( docPhrase.getText() ) ) {
128+
this.handleText( String.format( "<%s>", docPhrase.getText() ), docPhrase.getStyle() );
129+
} else {
130+
this.handleText( String.format( "[%s](%s)", docPhrase.getText(), docPhrase.getLink() ), docPhrase.getStyle() );
131+
}
132+
} else {
133+
this.handleText(docPhrase.getText(), docPhrase.getStyle() );
134+
}
123135
this.writer.print( " " );
124136
}
125137

fj-doc-base/src/test/resources/sample/default_doc.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
<para font-name="symbol" style="italic">Symbol</para>
3636
<para font-name="helvetica" style="underline">Symbol</para>
3737
<para size="3" fore-color="#dddddd">Test default font</para>
38+
39+
40+
<para><phrase link="https://github.com/fugerit-org/fj-doc">https://github.com/fugerit-org/fj-doc</phrase></para>
41+
<para><phrase link="https://venusdocs.fugerit.org/">Venus DOCS</phrase></para>
42+
3843
<table columns="3" colwidths="30;30;40" width="100" id="excel-table" padding="2">
3944
<row>
4045
<cell align="center" border-color="#000000" border-width="1"><para style="bold">Name</para></cell>

0 commit comments

Comments
 (0)