• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021-2024 The Khronos Group Inc.
2#
3# SPDX-License-Identifier: Apache-2.0
4
5require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
6
7include Asciidoctor
8
9class ExistsIncludeProcessor < Extensions::IncludeProcessor
10  def handles? target
11    # Only handle files which do not exist
12    # This relies on the full absolute path to every include file being
13    # given, since relative directory information exists only in the
14    # process method.
15
16    not File.exist? target
17  end
18
19  def process doc, reader, target, attributes
20    # If we reach this point, we have been asked to include a file which
21    # does not exist. Do nothing, instead of raising an error.
22
23    reader
24  end
25end
26
27Extensions.register do
28  include_processor ExistsIncludeProcessor
29end
30
31