Skip to content

Commit eca4489

Browse files
Fixed regex for CRLF line endings
1 parent c58e781 commit eca4489

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

build.gradle

+22-15
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import org.apache.commons.text.StringEscapeUtils
2929
import org.apache.tools.ant.filters.ReplaceTokens
3030

3131
import javax.swing.*
32+
import java.awt.*
3233

3334
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
3435

@@ -73,43 +74,49 @@ processResources {
7374
}
7475
}
7576

76-
ext.readInfoFile = { String name ->
77-
// @formatter:off
78-
return file(name).text
77+
ext {
78+
readInfoFile = { String name ->
79+
// @formatter:off
80+
return file(name).text
7981
// Remove unnecessary whitespace
8082
.trim()
8183

8284
// Replace headlines
83-
.replaceAll('(\\n|^)##(.*)(\\n|$)', { matcher -> "${matcher[1]}<b>${matcher[2]}</b>${matcher[3]}" })
85+
.replaceAll('(\r?\n|^)##(.*)(\r?\n|$)', { matcher -> "${matcher[1]}<b>${matcher[2]}</b>${matcher[3]}" })
8486

8587
// Replace issue links
8688
.replaceAll('\\[([^\\[]+)\\]\\(([^\\)]+)\\)', { matcher -> "<a href=\"${matcher[2]}\">${matcher[1]}</a>" })
8789
.replaceAll('\\(#([0-9]+)\\)', { matcher -> "(<a href=\"${github}/issues/${matcher[1]}\">#${matcher[1]}</a>)" })
8890

8991
// Replace inner lists
90-
.replaceAll("\n - (.*)", { matcher -> "<li>${matcher[1]}</li>" })
92+
.replaceAll("\r?\n - (.*)", { matcher -> "<li>${matcher[1]}</li>" })
9193
.replaceAll("((?:<li>.*</li>)+)", { matcher -> "<ul>${matcher[1]}</ul>" })
9294

9395
// Replace lists
94-
.replaceAll("\n- (.*)", { matcher -> "<li>${matcher[1]}</li>" })
96+
.replaceAll("\r?\n- (.*)", { matcher -> "<li>${matcher[1]}</li>" })
9597
.replaceAll("((?:<li>.*</li>)+)", { matcher -> "<ul>${matcher[1]}</ul>" })
9698
.replaceAll('\\s*<li>\\s*', '<li>')
9799
.replaceAll('\\s*</li>\\s*', '</li>')
98100
.replaceAll('\\s*<ul>\\s*', '<ul>')
99101
.replaceAll('\\s*</ul>\\s*', '</ul>')
100102

101103
// Replace newlines
102-
.replace('\n', '<br>')
104+
.replace('\r?\n', '<br>')
103105
// @formatter:on
104-
}
106+
}
107+
108+
showHtml = { String html ->
109+
JFrame frame = new JFrame("Changelog")
110+
frame.defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE
111+
frame.contentPane = new JScrollPane(new JLabel('<html>' + html))
112+
Dimension screenSize = Toolkit.defaultToolkit.screenSize
113+
frame.preferredSize = new Dimension((screenSize.width / 2).intValue(), (screenSize.height / 2).intValue())
114+
frame.location = new Point((screenSize.width / 4).intValue(), (screenSize.height / 4).intValue())
115+
frame.alwaysOnTop = true
116+
frame.pack()
117+
frame.visible = true
118+
}
105119

106-
project.ext.showHtml = { String html ->
107-
JFrame frame = new JFrame("Changelog")
108-
frame.defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE
109-
frame.contentPane.add(new JLabel('<html>' + html))
110-
frame.alwaysOnTop = true
111-
frame.pack()
112-
frame.visible = true
113120
}
114121

115122
tasks.create(name: 'showChangelog') {

0 commit comments

Comments
 (0)