@@ -161,21 +161,27 @@ case class Settings(
161
161
def isFileWatching : Boolean = watch && ! check
162
162
163
163
def toInputFile (infile : AbsolutePath ): Option [InputFile ] = {
164
- val relpath = if (infile == in) {
164
+ val relativeIn = if (infile == in) {
165
165
RelativePath (in.toNIO.getFileName.toString)
166
166
} else {
167
167
infile.toRelative(in)
168
168
}
169
- if (isIncluded(relpath)) {
170
- val outfile = out.resolve(relpath)
171
- Some (InputFile (relpath, infile, outfile))
169
+ if (isIncluded(relativeIn)) {
170
+ val outfile = if (assumedRegularFile(out)) {
171
+ out
172
+ } else {
173
+ out.resolve(relativeIn)
174
+ }
175
+ Some (InputFile (relativeIn, infile, outfile))
172
176
} else {
173
177
None
174
178
}
175
179
}
180
+
176
181
def isExplicitlyExcluded (path : RelativePath ): Boolean = {
177
182
exclude.exists(_.matches(path.toNIO))
178
183
}
184
+
179
185
def isIncluded (path : RelativePath ): Boolean = {
180
186
(include.isEmpty || include.exists(_.matches(path.toNIO))) &&
181
187
! isExplicitlyExcluded(path)
@@ -185,10 +191,13 @@ case class Settings(
185
191
val ctx = new OnLoadContext (reporter, this )
186
192
preModifiers.foreach(_.onLoad(ctx))
187
193
}
194
+
188
195
def validate (logger : Reporter ): Configured [Context ] = {
189
196
if (Files .exists(in.toNIO)) {
190
- if (out.toNIO.startsWith(in.toNIO)) {
197
+ if (out.toNIO.startsWith(in.toNIO) && ! assumedRegularFile(out) ) {
191
198
Configured .error(Feedback .outSubdirectoryOfIn(in.toNIO, out.toNIO))
199
+ } else if (assumedRegularFile(out) && Files .isDirectory(in.toNIO)) {
200
+ Configured .error(" your 'in' must be a file if 'out' is a file" )
192
201
} else {
193
202
val compiler = MarkdownCompiler .fromClasspath(classpath, scalacOptions)
194
203
onLoad(logger)
@@ -202,13 +211,12 @@ case class Settings(
202
211
ConfError .fileDoesNotExist(in.toNIO).notOk
203
212
}
204
213
}
205
- def resolveIn (relpath : RelativePath ): AbsolutePath = {
206
- in.resolve(relpath)
207
- }
208
214
209
- def resolveOut (relpath : RelativePath ): AbsolutePath = {
210
- out.resolve(relpath)
215
+ private def assumedRegularFile (absPath : AbsolutePath ): Boolean = {
216
+ val extension = PathIO .extension(absPath.toNIO)
217
+ markdownExtensions.toSet.contains(extension)
211
218
}
219
+
212
220
def withWorkingDirectory (dir : AbsolutePath ): Settings = {
213
221
copy(
214
222
in = dir.resolve(" docs" ),
0 commit comments