Skip to content
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

GRAILS-8809 fix for relative image URLs on windows #395

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions grails-docs/src/main/groovy/grails/doc/PdfBuilder.groovy
Expand Up @@ -47,7 +47,9 @@ class PdfBuilder {
File htmlFile = new File(guideDir, "single.html")
File outputFile = new File(guideDir, "single.pdf")

String xml = createXml(htmlFile, baseDir.absolutePath)
String base = baseDir.toPath().toUri().toString()
base += base.endsWith('/')?'':'/'
String xml = createXml(htmlFile, base)
createPdf xml, outputFile, guideDir
}

Expand All @@ -57,7 +59,7 @@ class PdfBuilder {
// fix inner anchors
xml = xml.replaceAll('<a href="\\.\\./guide/single\\.html', '<a href="')
// fix image refs to absolute paths
xml = xml.replaceAll('src="\\.\\./img/', "src=\"file://${base}/img/")
xml = xml.replaceAll('src="\\.\\./img/', "src=\"${base}img/")

// convert tabs to spaces otherwise they only take up one space
xml = xml.replaceAll('\t', ' ')
Expand Down